babylon.module.d.ts 5.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122
  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/observable" {
  50. import { Nullable } from "babylonjs/types";
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * 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.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * 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).
  162. * 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.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @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.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module "babylonjs/Misc/domManagement" {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Extracts text content from a DOM element hierarchy
  284. * @param element defines the root element
  285. * @returns a string
  286. */
  287. static GetDOMTextContent(element: HTMLElement): string;
  288. }
  289. }
  290. declare module "babylonjs/Misc/logger" {
  291. /**
  292. * Logger used througouht the application to allow configuration of
  293. * the log level required for the messages.
  294. */
  295. export class Logger {
  296. /**
  297. * No log
  298. */
  299. static readonly NoneLogLevel: number;
  300. /**
  301. * Only message logs
  302. */
  303. static readonly MessageLogLevel: number;
  304. /**
  305. * Only warning logs
  306. */
  307. static readonly WarningLogLevel: number;
  308. /**
  309. * Only error logs
  310. */
  311. static readonly ErrorLogLevel: number;
  312. /**
  313. * All logs
  314. */
  315. static readonly AllLogLevel: number;
  316. private static _LogCache;
  317. /**
  318. * Gets a value indicating the number of loading errors
  319. * @ignorenaming
  320. */
  321. static errorsCount: number;
  322. /**
  323. * Callback called when a new log is added
  324. */
  325. static OnNewCacheEntry: (entry: string) => void;
  326. private static _AddLogEntry;
  327. private static _FormatMessage;
  328. private static _LogDisabled;
  329. private static _LogEnabled;
  330. private static _WarnDisabled;
  331. private static _WarnEnabled;
  332. private static _ErrorDisabled;
  333. private static _ErrorEnabled;
  334. /**
  335. * Log a message to the console
  336. */
  337. static Log: (message: string) => void;
  338. /**
  339. * Write a warning message to the console
  340. */
  341. static Warn: (message: string) => void;
  342. /**
  343. * Write an error message to the console
  344. */
  345. static Error: (message: string) => void;
  346. /**
  347. * Gets current log cache (list of logs)
  348. */
  349. static readonly LogCache: string;
  350. /**
  351. * Clears the log cache
  352. */
  353. static ClearLogCache(): void;
  354. /**
  355. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  356. */
  357. static LogLevels: number;
  358. }
  359. }
  360. declare module "babylonjs/Misc/typeStore" {
  361. /** @hidden */
  362. export class _TypeStore {
  363. /** @hidden */
  364. static RegisteredTypes: {
  365. [key: string]: Object;
  366. };
  367. /** @hidden */
  368. static GetClass(fqdn: string): any;
  369. }
  370. }
  371. declare module "babylonjs/Misc/deepCopier" {
  372. /**
  373. * Class containing a set of static utilities functions for deep copy.
  374. */
  375. export class DeepCopier {
  376. /**
  377. * Tries to copy an object by duplicating every property
  378. * @param source defines the source object
  379. * @param destination defines the target object
  380. * @param doNotCopyList defines a list of properties to avoid
  381. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  382. */
  383. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  384. }
  385. }
  386. declare module "babylonjs/Misc/precisionDate" {
  387. /**
  388. * Class containing a set of static utilities functions for precision date
  389. */
  390. export class PrecisionDate {
  391. /**
  392. * Gets either window.performance.now() if supported or Date.now() else
  393. */
  394. static readonly Now: number;
  395. }
  396. }
  397. declare module "babylonjs/Misc/devTools" {
  398. /** @hidden */
  399. export class _DevTools {
  400. static WarnImport(name: string): string;
  401. }
  402. }
  403. declare module "babylonjs/Misc/webRequest" {
  404. /**
  405. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  406. */
  407. export class WebRequest {
  408. private _xhr;
  409. /**
  410. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  411. * i.e. when loading files, where the server/service expects an Authorization header
  412. */
  413. static CustomRequestHeaders: {
  414. [key: string]: string;
  415. };
  416. /**
  417. * Add callback functions in this array to update all the requests before they get sent to the network
  418. */
  419. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  420. private _injectCustomRequestHeaders;
  421. /**
  422. * Gets or sets a function to be called when loading progress changes
  423. */
  424. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  425. /**
  426. * Returns client's state
  427. */
  428. readonly readyState: number;
  429. /**
  430. * Returns client's status
  431. */
  432. readonly status: number;
  433. /**
  434. * Returns client's status as a text
  435. */
  436. readonly statusText: string;
  437. /**
  438. * Returns client's response
  439. */
  440. readonly response: any;
  441. /**
  442. * Returns client's response url
  443. */
  444. readonly responseURL: string;
  445. /**
  446. * Returns client's response as text
  447. */
  448. readonly responseText: string;
  449. /**
  450. * Gets or sets the expected response type
  451. */
  452. responseType: XMLHttpRequestResponseType;
  453. /** @hidden */
  454. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  455. /** @hidden */
  456. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  457. /**
  458. * Cancels any network activity
  459. */
  460. abort(): void;
  461. /**
  462. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  463. * @param body defines an optional request body
  464. */
  465. send(body?: Document | BodyInit | null): void;
  466. /**
  467. * Sets the request method, request URL
  468. * @param method defines the method to use (GET, POST, etc..)
  469. * @param url defines the url to connect with
  470. */
  471. open(method: string, url: string): void;
  472. }
  473. }
  474. declare module "babylonjs/Misc/fileRequest" {
  475. import { Observable } from "babylonjs/Misc/observable";
  476. /**
  477. * File request interface
  478. */
  479. export interface IFileRequest {
  480. /**
  481. * Raised when the request is complete (success or error).
  482. */
  483. onCompleteObservable: Observable<IFileRequest>;
  484. /**
  485. * Aborts the request for a file.
  486. */
  487. abort: () => void;
  488. }
  489. }
  490. declare module "babylonjs/Misc/performanceMonitor" {
  491. /**
  492. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  493. */
  494. export class PerformanceMonitor {
  495. private _enabled;
  496. private _rollingFrameTime;
  497. private _lastFrameTimeMs;
  498. /**
  499. * constructor
  500. * @param frameSampleSize The number of samples required to saturate the sliding window
  501. */
  502. constructor(frameSampleSize?: number);
  503. /**
  504. * Samples current frame
  505. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  506. */
  507. sampleFrame(timeMs?: number): void;
  508. /**
  509. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  510. */
  511. readonly averageFrameTime: number;
  512. /**
  513. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  514. */
  515. readonly averageFrameTimeVariance: number;
  516. /**
  517. * Returns the frame time of the most recent frame
  518. */
  519. readonly instantaneousFrameTime: number;
  520. /**
  521. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  522. */
  523. readonly averageFPS: number;
  524. /**
  525. * Returns the average framerate in frames per second using the most recent frame time
  526. */
  527. readonly instantaneousFPS: number;
  528. /**
  529. * Returns true if enough samples have been taken to completely fill the sliding window
  530. */
  531. readonly isSaturated: boolean;
  532. /**
  533. * Enables contributions to the sliding window sample set
  534. */
  535. enable(): void;
  536. /**
  537. * Disables contributions to the sliding window sample set
  538. * Samples will not be interpolated over the disabled period
  539. */
  540. disable(): void;
  541. /**
  542. * Returns true if sampling is enabled
  543. */
  544. readonly isEnabled: boolean;
  545. /**
  546. * Resets performance monitor
  547. */
  548. reset(): void;
  549. }
  550. /**
  551. * RollingAverage
  552. *
  553. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  554. */
  555. export class RollingAverage {
  556. /**
  557. * Current average
  558. */
  559. average: number;
  560. /**
  561. * Current variance
  562. */
  563. variance: number;
  564. protected _samples: Array<number>;
  565. protected _sampleCount: number;
  566. protected _pos: number;
  567. protected _m2: number;
  568. /**
  569. * constructor
  570. * @param length The number of samples required to saturate the sliding window
  571. */
  572. constructor(length: number);
  573. /**
  574. * Adds a sample to the sample set
  575. * @param v The sample value
  576. */
  577. add(v: number): void;
  578. /**
  579. * Returns previously added values or null if outside of history or outside the sliding window domain
  580. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  581. * @return Value previously recorded with add() or null if outside of range
  582. */
  583. history(i: number): number;
  584. /**
  585. * Returns true if enough samples have been taken to completely fill the sliding window
  586. * @return true if sample-set saturated
  587. */
  588. isSaturated(): boolean;
  589. /**
  590. * Resets the rolling average (equivalent to 0 samples taken so far)
  591. */
  592. reset(): void;
  593. /**
  594. * Wraps a value around the sample range boundaries
  595. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  596. * @return Wrapped position in sample range
  597. */
  598. protected _wrapPosition(i: number): number;
  599. }
  600. }
  601. declare module "babylonjs/Misc/stringDictionary" {
  602. import { Nullable } from "babylonjs/types";
  603. /**
  604. * This class implement a typical dictionary using a string as key and the generic type T as value.
  605. * The underlying implementation relies on an associative array to ensure the best performances.
  606. * The value can be anything including 'null' but except 'undefined'
  607. */
  608. export class StringDictionary<T> {
  609. /**
  610. * This will clear this dictionary and copy the content from the 'source' one.
  611. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  612. * @param source the dictionary to take the content from and copy to this dictionary
  613. */
  614. copyFrom(source: StringDictionary<T>): void;
  615. /**
  616. * Get a value based from its key
  617. * @param key the given key to get the matching value from
  618. * @return the value if found, otherwise undefined is returned
  619. */
  620. get(key: string): T | undefined;
  621. /**
  622. * Get a value from its key or add it if it doesn't exist.
  623. * This method will ensure you that a given key/data will be present in the dictionary.
  624. * @param key the given key to get the matching value from
  625. * @param factory the factory that will create the value if the key is not present in the dictionary.
  626. * The factory will only be invoked if there's no data for the given key.
  627. * @return the value corresponding to the key.
  628. */
  629. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  630. /**
  631. * Get a value from its key if present in the dictionary otherwise add it
  632. * @param key the key to get the value from
  633. * @param val if there's no such key/value pair in the dictionary add it with this value
  634. * @return the value corresponding to the key
  635. */
  636. getOrAdd(key: string, val: T): T;
  637. /**
  638. * Check if there's a given key in the dictionary
  639. * @param key the key to check for
  640. * @return true if the key is present, false otherwise
  641. */
  642. contains(key: string): boolean;
  643. /**
  644. * Add a new key and its corresponding value
  645. * @param key the key to add
  646. * @param value the value corresponding to the key
  647. * @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
  648. */
  649. add(key: string, value: T): boolean;
  650. /**
  651. * Update a specific value associated to a key
  652. * @param key defines the key to use
  653. * @param value defines the value to store
  654. * @returns true if the value was updated (or false if the key was not found)
  655. */
  656. set(key: string, value: T): boolean;
  657. /**
  658. * Get the element of the given key and remove it from the dictionary
  659. * @param key defines the key to search
  660. * @returns the value associated with the key or null if not found
  661. */
  662. getAndRemove(key: string): Nullable<T>;
  663. /**
  664. * Remove a key/value from the dictionary.
  665. * @param key the key to remove
  666. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  667. */
  668. remove(key: string): boolean;
  669. /**
  670. * Clear the whole content of the dictionary
  671. */
  672. clear(): void;
  673. /**
  674. * Gets the current count
  675. */
  676. readonly count: number;
  677. /**
  678. * Execute a callback on each key/val of the dictionary.
  679. * Note that you can remove any element in this dictionary in the callback implementation
  680. * @param callback the callback to execute on a given key/value pair
  681. */
  682. forEach(callback: (key: string, val: T) => void): void;
  683. /**
  684. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  685. * If the callback returns null or undefined the method will iterate to the next key/value pair
  686. * Note that you can remove any element in this dictionary in the callback implementation
  687. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  688. * @returns the first item
  689. */
  690. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  691. private _count;
  692. private _data;
  693. }
  694. }
  695. declare module "babylonjs/Meshes/dataBuffer" {
  696. /**
  697. * Class used to store gfx data (like WebGLBuffer)
  698. */
  699. export class DataBuffer {
  700. /**
  701. * Gets or sets the number of objects referencing this buffer
  702. */
  703. references: number;
  704. /** Gets or sets the size of the underlying buffer */
  705. capacity: number;
  706. /**
  707. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  708. */
  709. is32Bits: boolean;
  710. /**
  711. * Gets the underlying buffer
  712. */
  713. readonly underlyingResource: any;
  714. }
  715. }
  716. declare module "babylonjs/Meshes/buffer" {
  717. import { Nullable, DataArray } from "babylonjs/types";
  718. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  719. /**
  720. * Class used to store data that will be store in GPU memory
  721. */
  722. export class Buffer {
  723. private _engine;
  724. private _buffer;
  725. /** @hidden */
  726. _data: Nullable<DataArray>;
  727. private _updatable;
  728. private _instanced;
  729. /**
  730. * Gets the byte stride.
  731. */
  732. readonly byteStride: number;
  733. /**
  734. * Constructor
  735. * @param engine the engine
  736. * @param data the data to use for this buffer
  737. * @param updatable whether the data is updatable
  738. * @param stride the stride (optional)
  739. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  740. * @param instanced whether the buffer is instanced (optional)
  741. * @param useBytes set to true if the stride in in bytes (optional)
  742. */
  743. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  744. /**
  745. * Create a new VertexBuffer based on the current buffer
  746. * @param kind defines the vertex buffer kind (position, normal, etc.)
  747. * @param offset defines offset in the buffer (0 by default)
  748. * @param size defines the size in floats of attributes (position is 3 for instance)
  749. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  750. * @param instanced defines if the vertex buffer contains indexed data
  751. * @param useBytes defines if the offset and stride are in bytes
  752. * @returns the new vertex buffer
  753. */
  754. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  755. /**
  756. * Gets a boolean indicating if the Buffer is updatable?
  757. * @returns true if the buffer is updatable
  758. */
  759. isUpdatable(): boolean;
  760. /**
  761. * Gets current buffer's data
  762. * @returns a DataArray or null
  763. */
  764. getData(): Nullable<DataArray>;
  765. /**
  766. * Gets underlying native buffer
  767. * @returns underlying native buffer
  768. */
  769. getBuffer(): Nullable<DataBuffer>;
  770. /**
  771. * Gets the stride in float32 units (i.e. byte stride / 4).
  772. * May not be an integer if the byte stride is not divisible by 4.
  773. * DEPRECATED. Use byteStride instead.
  774. * @returns the stride in float32 units
  775. */
  776. getStrideSize(): number;
  777. /**
  778. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  779. * @param data defines the data to store
  780. */
  781. create(data?: Nullable<DataArray>): void;
  782. /** @hidden */
  783. _rebuild(): void;
  784. /**
  785. * Update current buffer data
  786. * @param data defines the data to store
  787. */
  788. update(data: DataArray): void;
  789. /**
  790. * Updates the data directly.
  791. * @param data the new data
  792. * @param offset the new offset
  793. * @param vertexCount the vertex count (optional)
  794. * @param useBytes set to true if the offset is in bytes
  795. */
  796. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  797. /**
  798. * Release all resources
  799. */
  800. dispose(): void;
  801. }
  802. /**
  803. * Specialized buffer used to store vertex data
  804. */
  805. export class VertexBuffer {
  806. /** @hidden */
  807. _buffer: Buffer;
  808. private _kind;
  809. private _size;
  810. private _ownsBuffer;
  811. private _instanced;
  812. private _instanceDivisor;
  813. /**
  814. * The byte type.
  815. */
  816. static readonly BYTE: number;
  817. /**
  818. * The unsigned byte type.
  819. */
  820. static readonly UNSIGNED_BYTE: number;
  821. /**
  822. * The short type.
  823. */
  824. static readonly SHORT: number;
  825. /**
  826. * The unsigned short type.
  827. */
  828. static readonly UNSIGNED_SHORT: number;
  829. /**
  830. * The integer type.
  831. */
  832. static readonly INT: number;
  833. /**
  834. * The unsigned integer type.
  835. */
  836. static readonly UNSIGNED_INT: number;
  837. /**
  838. * The float type.
  839. */
  840. static readonly FLOAT: number;
  841. /**
  842. * Gets or sets the instance divisor when in instanced mode
  843. */
  844. instanceDivisor: number;
  845. /**
  846. * Gets the byte stride.
  847. */
  848. readonly byteStride: number;
  849. /**
  850. * Gets the byte offset.
  851. */
  852. readonly byteOffset: number;
  853. /**
  854. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  855. */
  856. readonly normalized: boolean;
  857. /**
  858. * Gets the data type of each component in the array.
  859. */
  860. readonly type: number;
  861. /**
  862. * Constructor
  863. * @param engine the engine
  864. * @param data the data to use for this vertex buffer
  865. * @param kind the vertex buffer kind
  866. * @param updatable whether the data is updatable
  867. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  868. * @param stride the stride (optional)
  869. * @param instanced whether the buffer is instanced (optional)
  870. * @param offset the offset of the data (optional)
  871. * @param size the number of components (optional)
  872. * @param type the type of the component (optional)
  873. * @param normalized whether the data contains normalized data (optional)
  874. * @param useBytes set to true if stride and offset are in bytes (optional)
  875. */
  876. 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);
  877. /** @hidden */
  878. _rebuild(): void;
  879. /**
  880. * Returns the kind of the VertexBuffer (string)
  881. * @returns a string
  882. */
  883. getKind(): string;
  884. /**
  885. * Gets a boolean indicating if the VertexBuffer is updatable?
  886. * @returns true if the buffer is updatable
  887. */
  888. isUpdatable(): boolean;
  889. /**
  890. * Gets current buffer's data
  891. * @returns a DataArray or null
  892. */
  893. getData(): Nullable<DataArray>;
  894. /**
  895. * Gets underlying native buffer
  896. * @returns underlying native buffer
  897. */
  898. getBuffer(): Nullable<DataBuffer>;
  899. /**
  900. * Gets the stride in float32 units (i.e. byte stride / 4).
  901. * May not be an integer if the byte stride is not divisible by 4.
  902. * DEPRECATED. Use byteStride instead.
  903. * @returns the stride in float32 units
  904. */
  905. getStrideSize(): number;
  906. /**
  907. * Returns the offset as a multiple of the type byte length.
  908. * DEPRECATED. Use byteOffset instead.
  909. * @returns the offset in bytes
  910. */
  911. getOffset(): number;
  912. /**
  913. * Returns the number of components per vertex attribute (integer)
  914. * @returns the size in float
  915. */
  916. getSize(): number;
  917. /**
  918. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  919. * @returns true if this buffer is instanced
  920. */
  921. getIsInstanced(): boolean;
  922. /**
  923. * Returns the instancing divisor, zero for non-instanced (integer).
  924. * @returns a number
  925. */
  926. getInstanceDivisor(): number;
  927. /**
  928. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  929. * @param data defines the data to store
  930. */
  931. create(data?: DataArray): void;
  932. /**
  933. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  934. * This function will create a new buffer if the current one is not updatable
  935. * @param data defines the data to store
  936. */
  937. update(data: DataArray): void;
  938. /**
  939. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  940. * Returns the directly updated WebGLBuffer.
  941. * @param data the new data
  942. * @param offset the new offset
  943. * @param useBytes set to true if the offset is in bytes
  944. */
  945. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  946. /**
  947. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  948. */
  949. dispose(): void;
  950. /**
  951. * Enumerates each value of this vertex buffer as numbers.
  952. * @param count the number of values to enumerate
  953. * @param callback the callback function called for each value
  954. */
  955. forEach(count: number, callback: (value: number, index: number) => void): void;
  956. /**
  957. * Positions
  958. */
  959. static readonly PositionKind: string;
  960. /**
  961. * Normals
  962. */
  963. static readonly NormalKind: string;
  964. /**
  965. * Tangents
  966. */
  967. static readonly TangentKind: string;
  968. /**
  969. * Texture coordinates
  970. */
  971. static readonly UVKind: string;
  972. /**
  973. * Texture coordinates 2
  974. */
  975. static readonly UV2Kind: string;
  976. /**
  977. * Texture coordinates 3
  978. */
  979. static readonly UV3Kind: string;
  980. /**
  981. * Texture coordinates 4
  982. */
  983. static readonly UV4Kind: string;
  984. /**
  985. * Texture coordinates 5
  986. */
  987. static readonly UV5Kind: string;
  988. /**
  989. * Texture coordinates 6
  990. */
  991. static readonly UV6Kind: string;
  992. /**
  993. * Colors
  994. */
  995. static readonly ColorKind: string;
  996. /**
  997. * Matrix indices (for bones)
  998. */
  999. static readonly MatricesIndicesKind: string;
  1000. /**
  1001. * Matrix weights (for bones)
  1002. */
  1003. static readonly MatricesWeightsKind: string;
  1004. /**
  1005. * Additional matrix indices (for bones)
  1006. */
  1007. static readonly MatricesIndicesExtraKind: string;
  1008. /**
  1009. * Additional matrix weights (for bones)
  1010. */
  1011. static readonly MatricesWeightsExtraKind: string;
  1012. /**
  1013. * Deduces the stride given a kind.
  1014. * @param kind The kind string to deduce
  1015. * @returns The deduced stride
  1016. */
  1017. static DeduceStride(kind: string): number;
  1018. /**
  1019. * Gets the byte length of the given type.
  1020. * @param type the type
  1021. * @returns the number of bytes
  1022. */
  1023. static GetTypeByteLength(type: number): number;
  1024. /**
  1025. * Enumerates each value of the given parameters as numbers.
  1026. * @param data the data to enumerate
  1027. * @param byteOffset the byte offset of the data
  1028. * @param byteStride the byte stride of the data
  1029. * @param componentCount the number of components per element
  1030. * @param componentType the type of the component
  1031. * @param count the number of values to enumerate
  1032. * @param normalized whether the data is normalized
  1033. * @param callback the callback function called for each value
  1034. */
  1035. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1036. private static _GetFloatValue;
  1037. }
  1038. }
  1039. declare module "babylonjs/Maths/math.scalar" {
  1040. /**
  1041. * Scalar computation library
  1042. */
  1043. export class Scalar {
  1044. /**
  1045. * Two pi constants convenient for computation.
  1046. */
  1047. static TwoPi: number;
  1048. /**
  1049. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1050. * @param a number
  1051. * @param b number
  1052. * @param epsilon (default = 1.401298E-45)
  1053. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1054. */
  1055. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1056. /**
  1057. * Returns a string : the upper case translation of the number i to hexadecimal.
  1058. * @param i number
  1059. * @returns the upper case translation of the number i to hexadecimal.
  1060. */
  1061. static ToHex(i: number): string;
  1062. /**
  1063. * Returns -1 if value is negative and +1 is value is positive.
  1064. * @param value the value
  1065. * @returns the value itself if it's equal to zero.
  1066. */
  1067. static Sign(value: number): number;
  1068. /**
  1069. * Returns the value itself if it's between min and max.
  1070. * Returns min if the value is lower than min.
  1071. * Returns max if the value is greater than max.
  1072. * @param value the value to clmap
  1073. * @param min the min value to clamp to (default: 0)
  1074. * @param max the max value to clamp to (default: 1)
  1075. * @returns the clamped value
  1076. */
  1077. static Clamp(value: number, min?: number, max?: number): number;
  1078. /**
  1079. * the log2 of value.
  1080. * @param value the value to compute log2 of
  1081. * @returns the log2 of value.
  1082. */
  1083. static Log2(value: number): number;
  1084. /**
  1085. * Loops the value, so that it is never larger than length and never smaller than 0.
  1086. *
  1087. * This is similar to the modulo operator but it works with floating point numbers.
  1088. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1089. * With t = 5 and length = 2.5, the result would be 0.0.
  1090. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1091. * @param value the value
  1092. * @param length the length
  1093. * @returns the looped value
  1094. */
  1095. static Repeat(value: number, length: number): number;
  1096. /**
  1097. * Normalize the value between 0.0 and 1.0 using min and max values
  1098. * @param value value to normalize
  1099. * @param min max to normalize between
  1100. * @param max min to normalize between
  1101. * @returns the normalized value
  1102. */
  1103. static Normalize(value: number, min: number, max: number): number;
  1104. /**
  1105. * Denormalize the value from 0.0 and 1.0 using min and max values
  1106. * @param normalized value to denormalize
  1107. * @param min max to denormalize between
  1108. * @param max min to denormalize between
  1109. * @returns the denormalized value
  1110. */
  1111. static Denormalize(normalized: number, min: number, max: number): number;
  1112. /**
  1113. * Calculates the shortest difference between two given angles given in degrees.
  1114. * @param current current angle in degrees
  1115. * @param target target angle in degrees
  1116. * @returns the delta
  1117. */
  1118. static DeltaAngle(current: number, target: number): number;
  1119. /**
  1120. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1121. * @param tx value
  1122. * @param length length
  1123. * @returns The returned value will move back and forth between 0 and length
  1124. */
  1125. static PingPong(tx: number, length: number): number;
  1126. /**
  1127. * Interpolates between min and max with smoothing at the limits.
  1128. *
  1129. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1130. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1131. * @param from from
  1132. * @param to to
  1133. * @param tx value
  1134. * @returns the smooth stepped value
  1135. */
  1136. static SmoothStep(from: number, to: number, tx: number): number;
  1137. /**
  1138. * Moves a value current towards target.
  1139. *
  1140. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1141. * Negative values of maxDelta pushes the value away from target.
  1142. * @param current current value
  1143. * @param target target value
  1144. * @param maxDelta max distance to move
  1145. * @returns resulting value
  1146. */
  1147. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1148. /**
  1149. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1150. *
  1151. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1152. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1153. * @param current current value
  1154. * @param target target value
  1155. * @param maxDelta max distance to move
  1156. * @returns resulting angle
  1157. */
  1158. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1159. /**
  1160. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1161. * @param start start value
  1162. * @param end target value
  1163. * @param amount amount to lerp between
  1164. * @returns the lerped value
  1165. */
  1166. static Lerp(start: number, end: number, amount: number): number;
  1167. /**
  1168. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1169. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1170. * @param start start value
  1171. * @param end target value
  1172. * @param amount amount to lerp between
  1173. * @returns the lerped value
  1174. */
  1175. static LerpAngle(start: number, end: number, amount: number): number;
  1176. /**
  1177. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1178. * @param a start value
  1179. * @param b target value
  1180. * @param value value between a and b
  1181. * @returns the inverseLerp value
  1182. */
  1183. static InverseLerp(a: number, b: number, value: number): number;
  1184. /**
  1185. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1186. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1187. * @param value1 spline value
  1188. * @param tangent1 spline value
  1189. * @param value2 spline value
  1190. * @param tangent2 spline value
  1191. * @param amount input value
  1192. * @returns hermite result
  1193. */
  1194. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1195. /**
  1196. * Returns a random float number between and min and max values
  1197. * @param min min value of random
  1198. * @param max max value of random
  1199. * @returns random value
  1200. */
  1201. static RandomRange(min: number, max: number): number;
  1202. /**
  1203. * This function returns percentage of a number in a given range.
  1204. *
  1205. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1206. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1207. * @param number to convert to percentage
  1208. * @param min min range
  1209. * @param max max range
  1210. * @returns the percentage
  1211. */
  1212. static RangeToPercent(number: number, min: number, max: number): number;
  1213. /**
  1214. * This function returns number that corresponds to the percentage in a given range.
  1215. *
  1216. * PercentToRange(0.34,0,100) will return 34.
  1217. * @param percent to convert to number
  1218. * @param min min range
  1219. * @param max max range
  1220. * @returns the number
  1221. */
  1222. static PercentToRange(percent: number, min: number, max: number): number;
  1223. /**
  1224. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1225. * @param angle The angle to normalize in radian.
  1226. * @return The converted angle.
  1227. */
  1228. static NormalizeRadians(angle: number): number;
  1229. }
  1230. }
  1231. declare module "babylonjs/Maths/math.constants" {
  1232. /**
  1233. * Constant used to convert a value to gamma space
  1234. * @ignorenaming
  1235. */
  1236. export const ToGammaSpace: number;
  1237. /**
  1238. * Constant used to convert a value to linear space
  1239. * @ignorenaming
  1240. */
  1241. export const ToLinearSpace = 2.2;
  1242. /**
  1243. * Constant used to define the minimal number value in Babylon.js
  1244. * @ignorenaming
  1245. */
  1246. let Epsilon: number;
  1247. export { Epsilon };
  1248. }
  1249. declare module "babylonjs/Maths/math.viewport" {
  1250. /**
  1251. * Class used to represent a viewport on screen
  1252. */
  1253. export class Viewport {
  1254. /** viewport left coordinate */
  1255. x: number;
  1256. /** viewport top coordinate */
  1257. y: number;
  1258. /**viewport width */
  1259. width: number;
  1260. /** viewport height */
  1261. height: number;
  1262. /**
  1263. * Creates a Viewport object located at (x, y) and sized (width, height)
  1264. * @param x defines viewport left coordinate
  1265. * @param y defines viewport top coordinate
  1266. * @param width defines the viewport width
  1267. * @param height defines the viewport height
  1268. */
  1269. constructor(
  1270. /** viewport left coordinate */
  1271. x: number,
  1272. /** viewport top coordinate */
  1273. y: number,
  1274. /**viewport width */
  1275. width: number,
  1276. /** viewport height */
  1277. height: number);
  1278. /**
  1279. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1280. * @param renderWidth defines the rendering width
  1281. * @param renderHeight defines the rendering height
  1282. * @returns a new Viewport
  1283. */
  1284. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1285. /**
  1286. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1287. * @param renderWidth defines the rendering width
  1288. * @param renderHeight defines the rendering height
  1289. * @param ref defines the target viewport
  1290. * @returns the current viewport
  1291. */
  1292. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1293. /**
  1294. * Returns a new Viewport copied from the current one
  1295. * @returns a new Viewport
  1296. */
  1297. clone(): Viewport;
  1298. }
  1299. }
  1300. declare module "babylonjs/Misc/arrayTools" {
  1301. /**
  1302. * Class containing a set of static utilities functions for arrays.
  1303. */
  1304. export class ArrayTools {
  1305. /**
  1306. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1307. * @param size the number of element to construct and put in the array
  1308. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1309. * @returns a new array filled with new objects
  1310. */
  1311. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1312. }
  1313. }
  1314. declare module "babylonjs/Maths/math.like" {
  1315. import { float, int, DeepImmutable } from "babylonjs/types";
  1316. /**
  1317. * @hidden
  1318. */
  1319. export interface IColor4Like {
  1320. r: float;
  1321. g: float;
  1322. b: float;
  1323. a: float;
  1324. }
  1325. /**
  1326. * @hidden
  1327. */
  1328. export interface IColor3Like {
  1329. r: float;
  1330. g: float;
  1331. b: float;
  1332. }
  1333. /**
  1334. * @hidden
  1335. */
  1336. export interface IVector4Like {
  1337. x: float;
  1338. y: float;
  1339. z: float;
  1340. w: float;
  1341. }
  1342. /**
  1343. * @hidden
  1344. */
  1345. export interface IVector3Like {
  1346. x: float;
  1347. y: float;
  1348. z: float;
  1349. }
  1350. /**
  1351. * @hidden
  1352. */
  1353. export interface IVector2Like {
  1354. x: float;
  1355. y: float;
  1356. }
  1357. /**
  1358. * @hidden
  1359. */
  1360. export interface IMatrixLike {
  1361. toArray(): DeepImmutable<Float32Array>;
  1362. updateFlag: int;
  1363. }
  1364. /**
  1365. * @hidden
  1366. */
  1367. export interface IViewportLike {
  1368. x: float;
  1369. y: float;
  1370. width: float;
  1371. height: float;
  1372. }
  1373. /**
  1374. * @hidden
  1375. */
  1376. export interface IPlaneLike {
  1377. normal: IVector3Like;
  1378. d: float;
  1379. normalize(): void;
  1380. }
  1381. }
  1382. declare module "babylonjs/Maths/math.vector" {
  1383. import { Viewport } from "babylonjs/Maths/math.viewport";
  1384. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1385. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1386. /**
  1387. * Class representing a vector containing 2 coordinates
  1388. */
  1389. export class Vector2 {
  1390. /** defines the first coordinate */
  1391. x: number;
  1392. /** defines the second coordinate */
  1393. y: number;
  1394. /**
  1395. * Creates a new Vector2 from the given x and y coordinates
  1396. * @param x defines the first coordinate
  1397. * @param y defines the second coordinate
  1398. */
  1399. constructor(
  1400. /** defines the first coordinate */
  1401. x?: number,
  1402. /** defines the second coordinate */
  1403. y?: number);
  1404. /**
  1405. * Gets a string with the Vector2 coordinates
  1406. * @returns a string with the Vector2 coordinates
  1407. */
  1408. toString(): string;
  1409. /**
  1410. * Gets class name
  1411. * @returns the string "Vector2"
  1412. */
  1413. getClassName(): string;
  1414. /**
  1415. * Gets current vector hash code
  1416. * @returns the Vector2 hash code as a number
  1417. */
  1418. getHashCode(): number;
  1419. /**
  1420. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1421. * @param array defines the source array
  1422. * @param index defines the offset in source array
  1423. * @returns the current Vector2
  1424. */
  1425. toArray(array: FloatArray, index?: number): Vector2;
  1426. /**
  1427. * Copy the current vector to an array
  1428. * @returns a new array with 2 elements: the Vector2 coordinates.
  1429. */
  1430. asArray(): number[];
  1431. /**
  1432. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1433. * @param source defines the source Vector2
  1434. * @returns the current updated Vector2
  1435. */
  1436. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1437. /**
  1438. * Sets the Vector2 coordinates with the given floats
  1439. * @param x defines the first coordinate
  1440. * @param y defines the second coordinate
  1441. * @returns the current updated Vector2
  1442. */
  1443. copyFromFloats(x: number, y: number): Vector2;
  1444. /**
  1445. * Sets the Vector2 coordinates with the given floats
  1446. * @param x defines the first coordinate
  1447. * @param y defines the second coordinate
  1448. * @returns the current updated Vector2
  1449. */
  1450. set(x: number, y: number): Vector2;
  1451. /**
  1452. * Add another vector with the current one
  1453. * @param otherVector defines the other vector
  1454. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1455. */
  1456. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1457. /**
  1458. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1459. * @param otherVector defines the other vector
  1460. * @param result defines the target vector
  1461. * @returns the unmodified current Vector2
  1462. */
  1463. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1464. /**
  1465. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1466. * @param otherVector defines the other vector
  1467. * @returns the current updated Vector2
  1468. */
  1469. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1470. /**
  1471. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1472. * @param otherVector defines the other vector
  1473. * @returns a new Vector2
  1474. */
  1475. addVector3(otherVector: Vector3): Vector2;
  1476. /**
  1477. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1478. * @param otherVector defines the other vector
  1479. * @returns a new Vector2
  1480. */
  1481. subtract(otherVector: Vector2): Vector2;
  1482. /**
  1483. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1484. * @param otherVector defines the other vector
  1485. * @param result defines the target vector
  1486. * @returns the unmodified current Vector2
  1487. */
  1488. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1489. /**
  1490. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1491. * @param otherVector defines the other vector
  1492. * @returns the current updated Vector2
  1493. */
  1494. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1495. /**
  1496. * Multiplies in place the current Vector2 coordinates by the given ones
  1497. * @param otherVector defines the other vector
  1498. * @returns the current updated Vector2
  1499. */
  1500. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1501. /**
  1502. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1503. * @param otherVector defines the other vector
  1504. * @returns a new Vector2
  1505. */
  1506. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1507. /**
  1508. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1509. * @param otherVector defines the other vector
  1510. * @param result defines the target vector
  1511. * @returns the unmodified current Vector2
  1512. */
  1513. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1514. /**
  1515. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1516. * @param x defines the first coordinate
  1517. * @param y defines the second coordinate
  1518. * @returns a new Vector2
  1519. */
  1520. multiplyByFloats(x: number, y: number): Vector2;
  1521. /**
  1522. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1523. * @param otherVector defines the other vector
  1524. * @returns a new Vector2
  1525. */
  1526. divide(otherVector: Vector2): Vector2;
  1527. /**
  1528. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1529. * @param otherVector defines the other vector
  1530. * @param result defines the target vector
  1531. * @returns the unmodified current Vector2
  1532. */
  1533. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1534. /**
  1535. * Divides the current Vector2 coordinates by the given ones
  1536. * @param otherVector defines the other vector
  1537. * @returns the current updated Vector2
  1538. */
  1539. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1540. /**
  1541. * Gets a new Vector2 with current Vector2 negated coordinates
  1542. * @returns a new Vector2
  1543. */
  1544. negate(): Vector2;
  1545. /**
  1546. * Multiply the Vector2 coordinates by scale
  1547. * @param scale defines the scaling factor
  1548. * @returns the current updated Vector2
  1549. */
  1550. scaleInPlace(scale: number): Vector2;
  1551. /**
  1552. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1553. * @param scale defines the scaling factor
  1554. * @returns a new Vector2
  1555. */
  1556. scale(scale: number): Vector2;
  1557. /**
  1558. * Scale the current Vector2 values by a factor to a given Vector2
  1559. * @param scale defines the scale factor
  1560. * @param result defines the Vector2 object where to store the result
  1561. * @returns the unmodified current Vector2
  1562. */
  1563. scaleToRef(scale: number, result: Vector2): Vector2;
  1564. /**
  1565. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1566. * @param scale defines the scale factor
  1567. * @param result defines the Vector2 object where to store the result
  1568. * @returns the unmodified current Vector2
  1569. */
  1570. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1571. /**
  1572. * Gets a boolean if two vectors are equals
  1573. * @param otherVector defines the other vector
  1574. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1575. */
  1576. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1577. /**
  1578. * Gets a boolean if two vectors are equals (using an epsilon value)
  1579. * @param otherVector defines the other vector
  1580. * @param epsilon defines the minimal distance to consider equality
  1581. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1582. */
  1583. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1584. /**
  1585. * Gets a new Vector2 from current Vector2 floored values
  1586. * @returns a new Vector2
  1587. */
  1588. floor(): Vector2;
  1589. /**
  1590. * Gets a new Vector2 from current Vector2 floored values
  1591. * @returns a new Vector2
  1592. */
  1593. fract(): Vector2;
  1594. /**
  1595. * Gets the length of the vector
  1596. * @returns the vector length (float)
  1597. */
  1598. length(): number;
  1599. /**
  1600. * Gets the vector squared length
  1601. * @returns the vector squared length (float)
  1602. */
  1603. lengthSquared(): number;
  1604. /**
  1605. * Normalize the vector
  1606. * @returns the current updated Vector2
  1607. */
  1608. normalize(): Vector2;
  1609. /**
  1610. * Gets a new Vector2 copied from the Vector2
  1611. * @returns a new Vector2
  1612. */
  1613. clone(): Vector2;
  1614. /**
  1615. * Gets a new Vector2(0, 0)
  1616. * @returns a new Vector2
  1617. */
  1618. static Zero(): Vector2;
  1619. /**
  1620. * Gets a new Vector2(1, 1)
  1621. * @returns a new Vector2
  1622. */
  1623. static One(): Vector2;
  1624. /**
  1625. * Gets a new Vector2 set from the given index element of the given array
  1626. * @param array defines the data source
  1627. * @param offset defines the offset in the data source
  1628. * @returns a new Vector2
  1629. */
  1630. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1631. /**
  1632. * Sets "result" from the given index element of the given array
  1633. * @param array defines the data source
  1634. * @param offset defines the offset in the data source
  1635. * @param result defines the target vector
  1636. */
  1637. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1638. /**
  1639. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1640. * @param value1 defines 1st point of control
  1641. * @param value2 defines 2nd point of control
  1642. * @param value3 defines 3rd point of control
  1643. * @param value4 defines 4th point of control
  1644. * @param amount defines the interpolation factor
  1645. * @returns a new Vector2
  1646. */
  1647. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1648. /**
  1649. * 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".
  1650. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1651. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1652. * @param value defines the value to clamp
  1653. * @param min defines the lower limit
  1654. * @param max defines the upper limit
  1655. * @returns a new Vector2
  1656. */
  1657. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1658. /**
  1659. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1660. * @param value1 defines the 1st control point
  1661. * @param tangent1 defines the outgoing tangent
  1662. * @param value2 defines the 2nd control point
  1663. * @param tangent2 defines the incoming tangent
  1664. * @param amount defines the interpolation factor
  1665. * @returns a new Vector2
  1666. */
  1667. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1668. /**
  1669. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1670. * @param start defines the start vector
  1671. * @param end defines the end vector
  1672. * @param amount defines the interpolation factor
  1673. * @returns a new Vector2
  1674. */
  1675. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1676. /**
  1677. * Gets the dot product of the vector "left" and the vector "right"
  1678. * @param left defines first vector
  1679. * @param right defines second vector
  1680. * @returns the dot product (float)
  1681. */
  1682. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1683. /**
  1684. * Returns a new Vector2 equal to the normalized given vector
  1685. * @param vector defines the vector to normalize
  1686. * @returns a new Vector2
  1687. */
  1688. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1689. /**
  1690. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1691. * @param left defines 1st vector
  1692. * @param right defines 2nd vector
  1693. * @returns a new Vector2
  1694. */
  1695. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1696. /**
  1697. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1698. * @param left defines 1st vector
  1699. * @param right defines 2nd vector
  1700. * @returns a new Vector2
  1701. */
  1702. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1703. /**
  1704. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1705. * @param vector defines the vector to transform
  1706. * @param transformation defines the matrix to apply
  1707. * @returns a new Vector2
  1708. */
  1709. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1710. /**
  1711. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1712. * @param vector defines the vector to transform
  1713. * @param transformation defines the matrix to apply
  1714. * @param result defines the target vector
  1715. */
  1716. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1717. /**
  1718. * Determines if a given vector is included in a triangle
  1719. * @param p defines the vector to test
  1720. * @param p0 defines 1st triangle point
  1721. * @param p1 defines 2nd triangle point
  1722. * @param p2 defines 3rd triangle point
  1723. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1724. */
  1725. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1726. /**
  1727. * Gets the distance between the vectors "value1" and "value2"
  1728. * @param value1 defines first vector
  1729. * @param value2 defines second vector
  1730. * @returns the distance between vectors
  1731. */
  1732. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1733. /**
  1734. * Returns the squared distance between the vectors "value1" and "value2"
  1735. * @param value1 defines first vector
  1736. * @param value2 defines second vector
  1737. * @returns the squared distance between vectors
  1738. */
  1739. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1740. /**
  1741. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1742. * @param value1 defines first vector
  1743. * @param value2 defines second vector
  1744. * @returns a new Vector2
  1745. */
  1746. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1747. /**
  1748. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1749. * @param p defines the middle point
  1750. * @param segA defines one point of the segment
  1751. * @param segB defines the other point of the segment
  1752. * @returns the shortest distance
  1753. */
  1754. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1755. }
  1756. /**
  1757. * Classed used to store (x,y,z) vector representation
  1758. * A Vector3 is the main object used in 3D geometry
  1759. * It can represent etiher the coordinates of a point the space, either a direction
  1760. * Reminder: js uses a left handed forward facing system
  1761. */
  1762. export class Vector3 {
  1763. /**
  1764. * Defines the first coordinates (on X axis)
  1765. */
  1766. x: number;
  1767. /**
  1768. * Defines the second coordinates (on Y axis)
  1769. */
  1770. y: number;
  1771. /**
  1772. * Defines the third coordinates (on Z axis)
  1773. */
  1774. z: number;
  1775. private static _UpReadOnly;
  1776. private static _ZeroReadOnly;
  1777. /**
  1778. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1779. * @param x defines the first coordinates (on X axis)
  1780. * @param y defines the second coordinates (on Y axis)
  1781. * @param z defines the third coordinates (on Z axis)
  1782. */
  1783. constructor(
  1784. /**
  1785. * Defines the first coordinates (on X axis)
  1786. */
  1787. x?: number,
  1788. /**
  1789. * Defines the second coordinates (on Y axis)
  1790. */
  1791. y?: number,
  1792. /**
  1793. * Defines the third coordinates (on Z axis)
  1794. */
  1795. z?: number);
  1796. /**
  1797. * Creates a string representation of the Vector3
  1798. * @returns a string with the Vector3 coordinates.
  1799. */
  1800. toString(): string;
  1801. /**
  1802. * Gets the class name
  1803. * @returns the string "Vector3"
  1804. */
  1805. getClassName(): string;
  1806. /**
  1807. * Creates the Vector3 hash code
  1808. * @returns a number which tends to be unique between Vector3 instances
  1809. */
  1810. getHashCode(): number;
  1811. /**
  1812. * Creates an array containing three elements : the coordinates of the Vector3
  1813. * @returns a new array of numbers
  1814. */
  1815. asArray(): number[];
  1816. /**
  1817. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1818. * @param array defines the destination array
  1819. * @param index defines the offset in the destination array
  1820. * @returns the current Vector3
  1821. */
  1822. toArray(array: FloatArray, index?: number): Vector3;
  1823. /**
  1824. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1825. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1826. */
  1827. toQuaternion(): Quaternion;
  1828. /**
  1829. * Adds the given vector to the current Vector3
  1830. * @param otherVector defines the second operand
  1831. * @returns the current updated Vector3
  1832. */
  1833. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1834. /**
  1835. * Adds the given coordinates to the current Vector3
  1836. * @param x defines the x coordinate of the operand
  1837. * @param y defines the y coordinate of the operand
  1838. * @param z defines the z coordinate of the operand
  1839. * @returns the current updated Vector3
  1840. */
  1841. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1842. /**
  1843. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1844. * @param otherVector defines the second operand
  1845. * @returns the resulting Vector3
  1846. */
  1847. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1848. /**
  1849. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1850. * @param otherVector defines the second operand
  1851. * @param result defines the Vector3 object where to store the result
  1852. * @returns the current Vector3
  1853. */
  1854. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1855. /**
  1856. * Subtract the given vector from the current Vector3
  1857. * @param otherVector defines the second operand
  1858. * @returns the current updated Vector3
  1859. */
  1860. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1861. /**
  1862. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1863. * @param otherVector defines the second operand
  1864. * @returns the resulting Vector3
  1865. */
  1866. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1867. /**
  1868. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1869. * @param otherVector defines the second operand
  1870. * @param result defines the Vector3 object where to store the result
  1871. * @returns the current Vector3
  1872. */
  1873. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1874. /**
  1875. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1876. * @param x defines the x coordinate of the operand
  1877. * @param y defines the y coordinate of the operand
  1878. * @param z defines the z coordinate of the operand
  1879. * @returns the resulting Vector3
  1880. */
  1881. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1882. /**
  1883. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1884. * @param x defines the x coordinate of the operand
  1885. * @param y defines the y coordinate of the operand
  1886. * @param z defines the z coordinate of the operand
  1887. * @param result defines the Vector3 object where to store the result
  1888. * @returns the current Vector3
  1889. */
  1890. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1891. /**
  1892. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1893. * @returns a new Vector3
  1894. */
  1895. negate(): Vector3;
  1896. /**
  1897. * Multiplies the Vector3 coordinates by the float "scale"
  1898. * @param scale defines the multiplier factor
  1899. * @returns the current updated Vector3
  1900. */
  1901. scaleInPlace(scale: number): Vector3;
  1902. /**
  1903. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1904. * @param scale defines the multiplier factor
  1905. * @returns a new Vector3
  1906. */
  1907. scale(scale: number): Vector3;
  1908. /**
  1909. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1910. * @param scale defines the multiplier factor
  1911. * @param result defines the Vector3 object where to store the result
  1912. * @returns the current Vector3
  1913. */
  1914. scaleToRef(scale: number, result: Vector3): Vector3;
  1915. /**
  1916. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1917. * @param scale defines the scale factor
  1918. * @param result defines the Vector3 object where to store the result
  1919. * @returns the unmodified current Vector3
  1920. */
  1921. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1922. /**
  1923. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1924. * @param otherVector defines the second operand
  1925. * @returns true if both vectors are equals
  1926. */
  1927. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1928. /**
  1929. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1930. * @param otherVector defines the second operand
  1931. * @param epsilon defines the minimal distance to define values as equals
  1932. * @returns true if both vectors are distant less than epsilon
  1933. */
  1934. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1935. /**
  1936. * Returns true if the current Vector3 coordinates equals the given floats
  1937. * @param x defines the x coordinate of the operand
  1938. * @param y defines the y coordinate of the operand
  1939. * @param z defines the z coordinate of the operand
  1940. * @returns true if both vectors are equals
  1941. */
  1942. equalsToFloats(x: number, y: number, z: number): boolean;
  1943. /**
  1944. * Multiplies the current Vector3 coordinates by the given ones
  1945. * @param otherVector defines the second operand
  1946. * @returns the current updated Vector3
  1947. */
  1948. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1949. /**
  1950. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1951. * @param otherVector defines the second operand
  1952. * @returns the new Vector3
  1953. */
  1954. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1955. /**
  1956. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1957. * @param otherVector defines the second operand
  1958. * @param result defines the Vector3 object where to store the result
  1959. * @returns the current Vector3
  1960. */
  1961. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1962. /**
  1963. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1964. * @param x defines the x coordinate of the operand
  1965. * @param y defines the y coordinate of the operand
  1966. * @param z defines the z coordinate of the operand
  1967. * @returns the new Vector3
  1968. */
  1969. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1970. /**
  1971. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1972. * @param otherVector defines the second operand
  1973. * @returns the new Vector3
  1974. */
  1975. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1976. /**
  1977. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1978. * @param otherVector defines the second operand
  1979. * @param result defines the Vector3 object where to store the result
  1980. * @returns the current Vector3
  1981. */
  1982. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1983. /**
  1984. * Divides the current Vector3 coordinates by the given ones.
  1985. * @param otherVector defines the second operand
  1986. * @returns the current updated Vector3
  1987. */
  1988. divideInPlace(otherVector: Vector3): Vector3;
  1989. /**
  1990. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1991. * @param other defines the second operand
  1992. * @returns the current updated Vector3
  1993. */
  1994. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1995. /**
  1996. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1997. * @param other defines the second operand
  1998. * @returns the current updated Vector3
  1999. */
  2000. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2001. /**
  2002. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2003. * @param x defines the x coordinate of the operand
  2004. * @param y defines the y coordinate of the operand
  2005. * @param z defines the z coordinate of the operand
  2006. * @returns the current updated Vector3
  2007. */
  2008. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2009. /**
  2010. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2011. * @param x defines the x coordinate of the operand
  2012. * @param y defines the y coordinate of the operand
  2013. * @param z defines the z coordinate of the operand
  2014. * @returns the current updated Vector3
  2015. */
  2016. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2017. /**
  2018. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2019. * Check if is non uniform within a certain amount of decimal places to account for this
  2020. * @param epsilon the amount the values can differ
  2021. * @returns if the the vector is non uniform to a certain number of decimal places
  2022. */
  2023. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2024. /**
  2025. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2026. */
  2027. readonly isNonUniform: boolean;
  2028. /**
  2029. * Gets a new Vector3 from current Vector3 floored values
  2030. * @returns a new Vector3
  2031. */
  2032. floor(): Vector3;
  2033. /**
  2034. * Gets a new Vector3 from current Vector3 floored values
  2035. * @returns a new Vector3
  2036. */
  2037. fract(): Vector3;
  2038. /**
  2039. * Gets the length of the Vector3
  2040. * @returns the length of the Vector3
  2041. */
  2042. length(): number;
  2043. /**
  2044. * Gets the squared length of the Vector3
  2045. * @returns squared length of the Vector3
  2046. */
  2047. lengthSquared(): number;
  2048. /**
  2049. * Normalize the current Vector3.
  2050. * Please note that this is an in place operation.
  2051. * @returns the current updated Vector3
  2052. */
  2053. normalize(): Vector3;
  2054. /**
  2055. * Reorders the x y z properties of the vector in place
  2056. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2057. * @returns the current updated vector
  2058. */
  2059. reorderInPlace(order: string): this;
  2060. /**
  2061. * Rotates the vector around 0,0,0 by a quaternion
  2062. * @param quaternion the rotation quaternion
  2063. * @param result vector to store the result
  2064. * @returns the resulting vector
  2065. */
  2066. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2067. /**
  2068. * Rotates a vector around a given point
  2069. * @param quaternion the rotation quaternion
  2070. * @param point the point to rotate around
  2071. * @param result vector to store the result
  2072. * @returns the resulting vector
  2073. */
  2074. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2075. /**
  2076. * Normalize the current Vector3 with the given input length.
  2077. * Please note that this is an in place operation.
  2078. * @param len the length of the vector
  2079. * @returns the current updated Vector3
  2080. */
  2081. normalizeFromLength(len: number): Vector3;
  2082. /**
  2083. * Normalize the current Vector3 to a new vector
  2084. * @returns the new Vector3
  2085. */
  2086. normalizeToNew(): Vector3;
  2087. /**
  2088. * Normalize the current Vector3 to the reference
  2089. * @param reference define the Vector3 to update
  2090. * @returns the updated Vector3
  2091. */
  2092. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2093. /**
  2094. * Creates a new Vector3 copied from the current Vector3
  2095. * @returns the new Vector3
  2096. */
  2097. clone(): Vector3;
  2098. /**
  2099. * Copies the given vector coordinates to the current Vector3 ones
  2100. * @param source defines the source Vector3
  2101. * @returns the current updated Vector3
  2102. */
  2103. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2104. /**
  2105. * Copies the given floats to the current Vector3 coordinates
  2106. * @param x defines the x coordinate of the operand
  2107. * @param y defines the y coordinate of the operand
  2108. * @param z defines the z coordinate of the operand
  2109. * @returns the current updated Vector3
  2110. */
  2111. copyFromFloats(x: number, y: number, z: number): Vector3;
  2112. /**
  2113. * Copies the given floats to the current Vector3 coordinates
  2114. * @param x defines the x coordinate of the operand
  2115. * @param y defines the y coordinate of the operand
  2116. * @param z defines the z coordinate of the operand
  2117. * @returns the current updated Vector3
  2118. */
  2119. set(x: number, y: number, z: number): Vector3;
  2120. /**
  2121. * Copies the given float to the current Vector3 coordinates
  2122. * @param v defines the x, y and z coordinates of the operand
  2123. * @returns the current updated Vector3
  2124. */
  2125. setAll(v: number): Vector3;
  2126. /**
  2127. * Get the clip factor between two vectors
  2128. * @param vector0 defines the first operand
  2129. * @param vector1 defines the second operand
  2130. * @param axis defines the axis to use
  2131. * @param size defines the size along the axis
  2132. * @returns the clip factor
  2133. */
  2134. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2135. /**
  2136. * Get angle between two vectors
  2137. * @param vector0 angle between vector0 and vector1
  2138. * @param vector1 angle between vector0 and vector1
  2139. * @param normal direction of the normal
  2140. * @return the angle between vector0 and vector1
  2141. */
  2142. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2143. /**
  2144. * Returns a new Vector3 set from the index "offset" of the given array
  2145. * @param array defines the source array
  2146. * @param offset defines the offset in the source array
  2147. * @returns the new Vector3
  2148. */
  2149. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2150. /**
  2151. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2152. * This function is deprecated. Use FromArray instead
  2153. * @param array defines the source array
  2154. * @param offset defines the offset in the source array
  2155. * @returns the new Vector3
  2156. */
  2157. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2158. /**
  2159. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2160. * @param array defines the source array
  2161. * @param offset defines the offset in the source array
  2162. * @param result defines the Vector3 where to store the result
  2163. */
  2164. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2165. /**
  2166. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2167. * This function is deprecated. Use FromArrayToRef instead.
  2168. * @param array defines the source array
  2169. * @param offset defines the offset in the source array
  2170. * @param result defines the Vector3 where to store the result
  2171. */
  2172. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2173. /**
  2174. * Sets the given vector "result" with the given floats.
  2175. * @param x defines the x coordinate of the source
  2176. * @param y defines the y coordinate of the source
  2177. * @param z defines the z coordinate of the source
  2178. * @param result defines the Vector3 where to store the result
  2179. */
  2180. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2181. /**
  2182. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2183. * @returns a new empty Vector3
  2184. */
  2185. static Zero(): Vector3;
  2186. /**
  2187. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2188. * @returns a new unit Vector3
  2189. */
  2190. static One(): Vector3;
  2191. /**
  2192. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2193. * @returns a new up Vector3
  2194. */
  2195. static Up(): Vector3;
  2196. /**
  2197. * Gets a up Vector3 that must not be updated
  2198. */
  2199. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2200. /**
  2201. * Gets a zero Vector3 that must not be updated
  2202. */
  2203. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2204. /**
  2205. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2206. * @returns a new down Vector3
  2207. */
  2208. static Down(): Vector3;
  2209. /**
  2210. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2211. * @returns a new forward Vector3
  2212. */
  2213. static Forward(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2216. * @returns a new forward Vector3
  2217. */
  2218. static Backward(): Vector3;
  2219. /**
  2220. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2221. * @returns a new right Vector3
  2222. */
  2223. static Right(): Vector3;
  2224. /**
  2225. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2226. * @returns a new left Vector3
  2227. */
  2228. static Left(): Vector3;
  2229. /**
  2230. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2231. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2232. * @param vector defines the Vector3 to transform
  2233. * @param transformation defines the transformation matrix
  2234. * @returns the transformed Vector3
  2235. */
  2236. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2237. /**
  2238. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2239. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2240. * @param vector defines the Vector3 to transform
  2241. * @param transformation defines the transformation matrix
  2242. * @param result defines the Vector3 where to store the result
  2243. */
  2244. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2245. /**
  2246. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2247. * This method computes tranformed coordinates only, not transformed direction vectors
  2248. * @param x define the x coordinate of the source vector
  2249. * @param y define the y coordinate of the source vector
  2250. * @param z define the z coordinate of the source vector
  2251. * @param transformation defines the transformation matrix
  2252. * @param result defines the Vector3 where to store the result
  2253. */
  2254. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2255. /**
  2256. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2257. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2258. * @param vector defines the Vector3 to transform
  2259. * @param transformation defines the transformation matrix
  2260. * @returns the new Vector3
  2261. */
  2262. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2263. /**
  2264. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2265. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2266. * @param vector defines the Vector3 to transform
  2267. * @param transformation defines the transformation matrix
  2268. * @param result defines the Vector3 where to store the result
  2269. */
  2270. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2271. /**
  2272. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2273. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2274. * @param x define the x coordinate of the source vector
  2275. * @param y define the y coordinate of the source vector
  2276. * @param z define the z coordinate of the source vector
  2277. * @param transformation defines the transformation matrix
  2278. * @param result defines the Vector3 where to store the result
  2279. */
  2280. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2281. /**
  2282. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2283. * @param value1 defines the first control point
  2284. * @param value2 defines the second control point
  2285. * @param value3 defines the third control point
  2286. * @param value4 defines the fourth control point
  2287. * @param amount defines the amount on the spline to use
  2288. * @returns the new Vector3
  2289. */
  2290. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2291. /**
  2292. * 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"
  2293. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2294. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2295. * @param value defines the current value
  2296. * @param min defines the lower range value
  2297. * @param max defines the upper range value
  2298. * @returns the new Vector3
  2299. */
  2300. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2301. /**
  2302. * 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"
  2303. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2304. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2305. * @param value defines the current value
  2306. * @param min defines the lower range value
  2307. * @param max defines the upper range value
  2308. * @param result defines the Vector3 where to store the result
  2309. */
  2310. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2311. /**
  2312. * Checks if a given vector is inside a specific range
  2313. * @param v defines the vector to test
  2314. * @param min defines the minimum range
  2315. * @param max defines the maximum range
  2316. */
  2317. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2318. /**
  2319. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2320. * @param value1 defines the first control point
  2321. * @param tangent1 defines the first tangent vector
  2322. * @param value2 defines the second control point
  2323. * @param tangent2 defines the second tangent vector
  2324. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2325. * @returns the new Vector3
  2326. */
  2327. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2328. /**
  2329. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2330. * @param start defines the start value
  2331. * @param end defines the end value
  2332. * @param amount max defines amount between both (between 0 and 1)
  2333. * @returns the new Vector3
  2334. */
  2335. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2336. /**
  2337. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2338. * @param start defines the start value
  2339. * @param end defines the end value
  2340. * @param amount max defines amount between both (between 0 and 1)
  2341. * @param result defines the Vector3 where to store the result
  2342. */
  2343. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2344. /**
  2345. * Returns the dot product (float) between the vectors "left" and "right"
  2346. * @param left defines the left operand
  2347. * @param right defines the right operand
  2348. * @returns the dot product
  2349. */
  2350. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2351. /**
  2352. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2353. * The cross product is then orthogonal to both "left" and "right"
  2354. * @param left defines the left operand
  2355. * @param right defines the right operand
  2356. * @returns the cross product
  2357. */
  2358. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2359. /**
  2360. * Sets the given vector "result" with the cross product of "left" and "right"
  2361. * The cross product is then orthogonal to both "left" and "right"
  2362. * @param left defines the left operand
  2363. * @param right defines the right operand
  2364. * @param result defines the Vector3 where to store the result
  2365. */
  2366. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2367. /**
  2368. * Returns a new Vector3 as the normalization of the given vector
  2369. * @param vector defines the Vector3 to normalize
  2370. * @returns the new Vector3
  2371. */
  2372. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2373. /**
  2374. * Sets the given vector "result" with the normalization of the given first vector
  2375. * @param vector defines the Vector3 to normalize
  2376. * @param result defines the Vector3 where to store the result
  2377. */
  2378. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2379. /**
  2380. * Project a Vector3 onto screen space
  2381. * @param vector defines the Vector3 to project
  2382. * @param world defines the world matrix to use
  2383. * @param transform defines the transform (view x projection) matrix to use
  2384. * @param viewport defines the screen viewport to use
  2385. * @returns the new Vector3
  2386. */
  2387. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2388. /** @hidden */
  2389. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2390. /**
  2391. * Unproject from screen space to object space
  2392. * @param source defines the screen space Vector3 to use
  2393. * @param viewportWidth defines the current width of the viewport
  2394. * @param viewportHeight defines the current height of the viewport
  2395. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2396. * @param transform defines the transform (view x projection) matrix to use
  2397. * @returns the new Vector3
  2398. */
  2399. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2400. /**
  2401. * Unproject from screen space to object space
  2402. * @param source defines the screen space Vector3 to use
  2403. * @param viewportWidth defines the current width of the viewport
  2404. * @param viewportHeight defines the current height of the viewport
  2405. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2406. * @param view defines the view matrix to use
  2407. * @param projection defines the projection matrix to use
  2408. * @returns the new Vector3
  2409. */
  2410. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2411. /**
  2412. * Unproject from screen space to object space
  2413. * @param source defines the screen space Vector3 to use
  2414. * @param viewportWidth defines the current width of the viewport
  2415. * @param viewportHeight defines the current height of the viewport
  2416. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2417. * @param view defines the view matrix to use
  2418. * @param projection defines the projection matrix to use
  2419. * @param result defines the Vector3 where to store the result
  2420. */
  2421. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2422. /**
  2423. * Unproject from screen space to object space
  2424. * @param sourceX defines the screen space x coordinate to use
  2425. * @param sourceY defines the screen space y coordinate to use
  2426. * @param sourceZ defines the screen space z coordinate to use
  2427. * @param viewportWidth defines the current width of the viewport
  2428. * @param viewportHeight defines the current height of the viewport
  2429. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2430. * @param view defines the view matrix to use
  2431. * @param projection defines the projection matrix to use
  2432. * @param result defines the Vector3 where to store the result
  2433. */
  2434. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2435. /**
  2436. * Gets the minimal coordinate values between two Vector3
  2437. * @param left defines the first operand
  2438. * @param right defines the second operand
  2439. * @returns the new Vector3
  2440. */
  2441. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2442. /**
  2443. * Gets the maximal coordinate values between two Vector3
  2444. * @param left defines the first operand
  2445. * @param right defines the second operand
  2446. * @returns the new Vector3
  2447. */
  2448. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2449. /**
  2450. * Returns the distance between the vectors "value1" and "value2"
  2451. * @param value1 defines the first operand
  2452. * @param value2 defines the second operand
  2453. * @returns the distance
  2454. */
  2455. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2456. /**
  2457. * Returns the squared distance between the vectors "value1" and "value2"
  2458. * @param value1 defines the first operand
  2459. * @param value2 defines the second operand
  2460. * @returns the squared distance
  2461. */
  2462. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2463. /**
  2464. * Returns a new Vector3 located at the center between "value1" and "value2"
  2465. * @param value1 defines the first operand
  2466. * @param value2 defines the second operand
  2467. * @returns the new Vector3
  2468. */
  2469. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2470. /**
  2471. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2472. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2473. * to something in order to rotate it from its local system to the given target system
  2474. * Note: axis1, axis2 and axis3 are normalized during this operation
  2475. * @param axis1 defines the first axis
  2476. * @param axis2 defines the second axis
  2477. * @param axis3 defines the third axis
  2478. * @returns a new Vector3
  2479. */
  2480. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2481. /**
  2482. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2483. * @param axis1 defines the first axis
  2484. * @param axis2 defines the second axis
  2485. * @param axis3 defines the third axis
  2486. * @param ref defines the Vector3 where to store the result
  2487. */
  2488. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2489. }
  2490. /**
  2491. * Vector4 class created for EulerAngle class conversion to Quaternion
  2492. */
  2493. export class Vector4 {
  2494. /** x value of the vector */
  2495. x: number;
  2496. /** y value of the vector */
  2497. y: number;
  2498. /** z value of the vector */
  2499. z: number;
  2500. /** w value of the vector */
  2501. w: number;
  2502. /**
  2503. * Creates a Vector4 object from the given floats.
  2504. * @param x x value of the vector
  2505. * @param y y value of the vector
  2506. * @param z z value of the vector
  2507. * @param w w value of the vector
  2508. */
  2509. constructor(
  2510. /** x value of the vector */
  2511. x: number,
  2512. /** y value of the vector */
  2513. y: number,
  2514. /** z value of the vector */
  2515. z: number,
  2516. /** w value of the vector */
  2517. w: number);
  2518. /**
  2519. * Returns the string with the Vector4 coordinates.
  2520. * @returns a string containing all the vector values
  2521. */
  2522. toString(): string;
  2523. /**
  2524. * Returns the string "Vector4".
  2525. * @returns "Vector4"
  2526. */
  2527. getClassName(): string;
  2528. /**
  2529. * Returns the Vector4 hash code.
  2530. * @returns a unique hash code
  2531. */
  2532. getHashCode(): number;
  2533. /**
  2534. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2535. * @returns the resulting array
  2536. */
  2537. asArray(): number[];
  2538. /**
  2539. * Populates the given array from the given index with the Vector4 coordinates.
  2540. * @param array array to populate
  2541. * @param index index of the array to start at (default: 0)
  2542. * @returns the Vector4.
  2543. */
  2544. toArray(array: FloatArray, index?: number): Vector4;
  2545. /**
  2546. * Adds the given vector to the current Vector4.
  2547. * @param otherVector the vector to add
  2548. * @returns the updated Vector4.
  2549. */
  2550. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2551. /**
  2552. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2553. * @param otherVector the vector to add
  2554. * @returns the resulting vector
  2555. */
  2556. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2557. /**
  2558. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2559. * @param otherVector the vector to add
  2560. * @param result the vector to store the result
  2561. * @returns the current Vector4.
  2562. */
  2563. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2564. /**
  2565. * Subtract in place the given vector from the current Vector4.
  2566. * @param otherVector the vector to subtract
  2567. * @returns the updated Vector4.
  2568. */
  2569. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2570. /**
  2571. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2572. * @param otherVector the vector to add
  2573. * @returns the new vector with the result
  2574. */
  2575. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2576. /**
  2577. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2578. * @param otherVector the vector to subtract
  2579. * @param result the vector to store the result
  2580. * @returns the current Vector4.
  2581. */
  2582. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2583. /**
  2584. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2585. */
  2586. /**
  2587. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2588. * @param x value to subtract
  2589. * @param y value to subtract
  2590. * @param z value to subtract
  2591. * @param w value to subtract
  2592. * @returns new vector containing the result
  2593. */
  2594. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2595. /**
  2596. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2597. * @param x value to subtract
  2598. * @param y value to subtract
  2599. * @param z value to subtract
  2600. * @param w value to subtract
  2601. * @param result the vector to store the result in
  2602. * @returns the current Vector4.
  2603. */
  2604. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2605. /**
  2606. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2607. * @returns a new vector with the negated values
  2608. */
  2609. negate(): Vector4;
  2610. /**
  2611. * Multiplies the current Vector4 coordinates by scale (float).
  2612. * @param scale the number to scale with
  2613. * @returns the updated Vector4.
  2614. */
  2615. scaleInPlace(scale: number): Vector4;
  2616. /**
  2617. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2618. * @param scale the number to scale with
  2619. * @returns a new vector with the result
  2620. */
  2621. scale(scale: number): Vector4;
  2622. /**
  2623. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2624. * @param scale the number to scale with
  2625. * @param result a vector to store the result in
  2626. * @returns the current Vector4.
  2627. */
  2628. scaleToRef(scale: number, result: Vector4): Vector4;
  2629. /**
  2630. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2631. * @param scale defines the scale factor
  2632. * @param result defines the Vector4 object where to store the result
  2633. * @returns the unmodified current Vector4
  2634. */
  2635. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2636. /**
  2637. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2638. * @param otherVector the vector to compare against
  2639. * @returns true if they are equal
  2640. */
  2641. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2642. /**
  2643. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2644. * @param otherVector vector to compare against
  2645. * @param epsilon (Default: very small number)
  2646. * @returns true if they are equal
  2647. */
  2648. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2649. /**
  2650. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2651. * @param x x value to compare against
  2652. * @param y y value to compare against
  2653. * @param z z value to compare against
  2654. * @param w w value to compare against
  2655. * @returns true if equal
  2656. */
  2657. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2658. /**
  2659. * Multiplies in place the current Vector4 by the given one.
  2660. * @param otherVector vector to multiple with
  2661. * @returns the updated Vector4.
  2662. */
  2663. multiplyInPlace(otherVector: Vector4): Vector4;
  2664. /**
  2665. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2666. * @param otherVector vector to multiple with
  2667. * @returns resulting new vector
  2668. */
  2669. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2670. /**
  2671. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2672. * @param otherVector vector to multiple with
  2673. * @param result vector to store the result
  2674. * @returns the current Vector4.
  2675. */
  2676. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2677. /**
  2678. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2679. * @param x x value multiply with
  2680. * @param y y value multiply with
  2681. * @param z z value multiply with
  2682. * @param w w value multiply with
  2683. * @returns resulting new vector
  2684. */
  2685. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2686. /**
  2687. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2688. * @param otherVector vector to devide with
  2689. * @returns resulting new vector
  2690. */
  2691. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2692. /**
  2693. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2694. * @param otherVector vector to devide with
  2695. * @param result vector to store the result
  2696. * @returns the current Vector4.
  2697. */
  2698. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2699. /**
  2700. * Divides the current Vector3 coordinates by the given ones.
  2701. * @param otherVector vector to devide with
  2702. * @returns the updated Vector3.
  2703. */
  2704. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2705. /**
  2706. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2707. * @param other defines the second operand
  2708. * @returns the current updated Vector4
  2709. */
  2710. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2711. /**
  2712. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2713. * @param other defines the second operand
  2714. * @returns the current updated Vector4
  2715. */
  2716. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2717. /**
  2718. * Gets a new Vector4 from current Vector4 floored values
  2719. * @returns a new Vector4
  2720. */
  2721. floor(): Vector4;
  2722. /**
  2723. * Gets a new Vector4 from current Vector3 floored values
  2724. * @returns a new Vector4
  2725. */
  2726. fract(): Vector4;
  2727. /**
  2728. * Returns the Vector4 length (float).
  2729. * @returns the length
  2730. */
  2731. length(): number;
  2732. /**
  2733. * Returns the Vector4 squared length (float).
  2734. * @returns the length squared
  2735. */
  2736. lengthSquared(): number;
  2737. /**
  2738. * Normalizes in place the Vector4.
  2739. * @returns the updated Vector4.
  2740. */
  2741. normalize(): Vector4;
  2742. /**
  2743. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2744. * @returns this converted to a new vector3
  2745. */
  2746. toVector3(): Vector3;
  2747. /**
  2748. * Returns a new Vector4 copied from the current one.
  2749. * @returns the new cloned vector
  2750. */
  2751. clone(): Vector4;
  2752. /**
  2753. * Updates the current Vector4 with the given one coordinates.
  2754. * @param source the source vector to copy from
  2755. * @returns the updated Vector4.
  2756. */
  2757. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2758. /**
  2759. * Updates the current Vector4 coordinates with the given floats.
  2760. * @param x float to copy from
  2761. * @param y float to copy from
  2762. * @param z float to copy from
  2763. * @param w float to copy from
  2764. * @returns the updated Vector4.
  2765. */
  2766. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2767. /**
  2768. * Updates the current Vector4 coordinates with the given floats.
  2769. * @param x float to set from
  2770. * @param y float to set from
  2771. * @param z float to set from
  2772. * @param w float to set from
  2773. * @returns the updated Vector4.
  2774. */
  2775. set(x: number, y: number, z: number, w: number): Vector4;
  2776. /**
  2777. * Copies the given float to the current Vector3 coordinates
  2778. * @param v defines the x, y, z and w coordinates of the operand
  2779. * @returns the current updated Vector3
  2780. */
  2781. setAll(v: number): Vector4;
  2782. /**
  2783. * Returns a new Vector4 set from the starting index of the given array.
  2784. * @param array the array to pull values from
  2785. * @param offset the offset into the array to start at
  2786. * @returns the new vector
  2787. */
  2788. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2789. /**
  2790. * Updates the given vector "result" from the starting index of the given array.
  2791. * @param array the array to pull values from
  2792. * @param offset the offset into the array to start at
  2793. * @param result the vector to store the result in
  2794. */
  2795. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2796. /**
  2797. * Updates the given vector "result" from the starting index of the given Float32Array.
  2798. * @param array the array to pull values from
  2799. * @param offset the offset into the array to start at
  2800. * @param result the vector to store the result in
  2801. */
  2802. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2803. /**
  2804. * Updates the given vector "result" coordinates from the given floats.
  2805. * @param x float to set from
  2806. * @param y float to set from
  2807. * @param z float to set from
  2808. * @param w float to set from
  2809. * @param result the vector to the floats in
  2810. */
  2811. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2812. /**
  2813. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2814. * @returns the new vector
  2815. */
  2816. static Zero(): Vector4;
  2817. /**
  2818. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2819. * @returns the new vector
  2820. */
  2821. static One(): Vector4;
  2822. /**
  2823. * Returns a new normalized Vector4 from the given one.
  2824. * @param vector the vector to normalize
  2825. * @returns the vector
  2826. */
  2827. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2828. /**
  2829. * Updates the given vector "result" from the normalization of the given one.
  2830. * @param vector the vector to normalize
  2831. * @param result the vector to store the result in
  2832. */
  2833. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2834. /**
  2835. * Returns a vector with the minimum values from the left and right vectors
  2836. * @param left left vector to minimize
  2837. * @param right right vector to minimize
  2838. * @returns a new vector with the minimum of the left and right vector values
  2839. */
  2840. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2841. /**
  2842. * Returns a vector with the maximum values from the left and right vectors
  2843. * @param left left vector to maximize
  2844. * @param right right vector to maximize
  2845. * @returns a new vector with the maximum of the left and right vector values
  2846. */
  2847. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2848. /**
  2849. * Returns the distance (float) between the vectors "value1" and "value2".
  2850. * @param value1 value to calulate the distance between
  2851. * @param value2 value to calulate the distance between
  2852. * @return the distance between the two vectors
  2853. */
  2854. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2855. /**
  2856. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2857. * @param value1 value to calulate the distance between
  2858. * @param value2 value to calulate the distance between
  2859. * @return the distance between the two vectors squared
  2860. */
  2861. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2862. /**
  2863. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2864. * @param value1 value to calulate the center between
  2865. * @param value2 value to calulate the center between
  2866. * @return the center between the two vectors
  2867. */
  2868. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2869. /**
  2870. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2871. * This methods computes transformed normalized direction vectors only.
  2872. * @param vector the vector to transform
  2873. * @param transformation the transformation matrix to apply
  2874. * @returns the new vector
  2875. */
  2876. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2877. /**
  2878. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2879. * This methods computes transformed normalized direction vectors only.
  2880. * @param vector the vector to transform
  2881. * @param transformation the transformation matrix to apply
  2882. * @param result the vector to store the result in
  2883. */
  2884. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2885. /**
  2886. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2887. * This methods computes transformed normalized direction vectors only.
  2888. * @param x value to transform
  2889. * @param y value to transform
  2890. * @param z value to transform
  2891. * @param w value to transform
  2892. * @param transformation the transformation matrix to apply
  2893. * @param result the vector to store the results in
  2894. */
  2895. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2896. /**
  2897. * Creates a new Vector4 from a Vector3
  2898. * @param source defines the source data
  2899. * @param w defines the 4th component (default is 0)
  2900. * @returns a new Vector4
  2901. */
  2902. static FromVector3(source: Vector3, w?: number): Vector4;
  2903. }
  2904. /**
  2905. * Class used to store quaternion data
  2906. * @see https://en.wikipedia.org/wiki/Quaternion
  2907. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2908. */
  2909. export class Quaternion {
  2910. /** defines the first component (0 by default) */
  2911. x: number;
  2912. /** defines the second component (0 by default) */
  2913. y: number;
  2914. /** defines the third component (0 by default) */
  2915. z: number;
  2916. /** defines the fourth component (1.0 by default) */
  2917. w: number;
  2918. /**
  2919. * Creates a new Quaternion from the given floats
  2920. * @param x defines the first component (0 by default)
  2921. * @param y defines the second component (0 by default)
  2922. * @param z defines the third component (0 by default)
  2923. * @param w defines the fourth component (1.0 by default)
  2924. */
  2925. constructor(
  2926. /** defines the first component (0 by default) */
  2927. x?: number,
  2928. /** defines the second component (0 by default) */
  2929. y?: number,
  2930. /** defines the third component (0 by default) */
  2931. z?: number,
  2932. /** defines the fourth component (1.0 by default) */
  2933. w?: number);
  2934. /**
  2935. * Gets a string representation for the current quaternion
  2936. * @returns a string with the Quaternion coordinates
  2937. */
  2938. toString(): string;
  2939. /**
  2940. * Gets the class name of the quaternion
  2941. * @returns the string "Quaternion"
  2942. */
  2943. getClassName(): string;
  2944. /**
  2945. * Gets a hash code for this quaternion
  2946. * @returns the quaternion hash code
  2947. */
  2948. getHashCode(): number;
  2949. /**
  2950. * Copy the quaternion to an array
  2951. * @returns a new array populated with 4 elements from the quaternion coordinates
  2952. */
  2953. asArray(): number[];
  2954. /**
  2955. * Check if two quaternions are equals
  2956. * @param otherQuaternion defines the second operand
  2957. * @return true if the current quaternion and the given one coordinates are strictly equals
  2958. */
  2959. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2960. /**
  2961. * Clone the current quaternion
  2962. * @returns a new quaternion copied from the current one
  2963. */
  2964. clone(): Quaternion;
  2965. /**
  2966. * Copy a quaternion to the current one
  2967. * @param other defines the other quaternion
  2968. * @returns the updated current quaternion
  2969. */
  2970. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2971. /**
  2972. * Updates the current quaternion with the given float coordinates
  2973. * @param x defines the x coordinate
  2974. * @param y defines the y coordinate
  2975. * @param z defines the z coordinate
  2976. * @param w defines the w coordinate
  2977. * @returns the updated current quaternion
  2978. */
  2979. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2980. /**
  2981. * Updates the current quaternion from the given float coordinates
  2982. * @param x defines the x coordinate
  2983. * @param y defines the y coordinate
  2984. * @param z defines the z coordinate
  2985. * @param w defines the w coordinate
  2986. * @returns the updated current quaternion
  2987. */
  2988. set(x: number, y: number, z: number, w: number): Quaternion;
  2989. /**
  2990. * Adds two quaternions
  2991. * @param other defines the second operand
  2992. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2993. */
  2994. add(other: DeepImmutable<Quaternion>): Quaternion;
  2995. /**
  2996. * Add a quaternion to the current one
  2997. * @param other defines the quaternion to add
  2998. * @returns the current quaternion
  2999. */
  3000. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3001. /**
  3002. * Subtract two quaternions
  3003. * @param other defines the second operand
  3004. * @returns a new quaternion as the subtraction result of the given one from the current one
  3005. */
  3006. subtract(other: Quaternion): Quaternion;
  3007. /**
  3008. * Multiplies the current quaternion by a scale factor
  3009. * @param value defines the scale factor
  3010. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3011. */
  3012. scale(value: number): Quaternion;
  3013. /**
  3014. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3015. * @param scale defines the scale factor
  3016. * @param result defines the Quaternion object where to store the result
  3017. * @returns the unmodified current quaternion
  3018. */
  3019. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3020. /**
  3021. * Multiplies in place the current quaternion by a scale factor
  3022. * @param value defines the scale factor
  3023. * @returns the current modified quaternion
  3024. */
  3025. scaleInPlace(value: number): Quaternion;
  3026. /**
  3027. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3028. * @param scale defines the scale factor
  3029. * @param result defines the Quaternion object where to store the result
  3030. * @returns the unmodified current quaternion
  3031. */
  3032. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3033. /**
  3034. * Multiplies two quaternions
  3035. * @param q1 defines the second operand
  3036. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3037. */
  3038. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3039. /**
  3040. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3041. * @param q1 defines the second operand
  3042. * @param result defines the target quaternion
  3043. * @returns the current quaternion
  3044. */
  3045. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3046. /**
  3047. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3048. * @param q1 defines the second operand
  3049. * @returns the currentupdated quaternion
  3050. */
  3051. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3052. /**
  3053. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3054. * @param ref defines the target quaternion
  3055. * @returns the current quaternion
  3056. */
  3057. conjugateToRef(ref: Quaternion): Quaternion;
  3058. /**
  3059. * Conjugates in place (1-q) the current quaternion
  3060. * @returns the current updated quaternion
  3061. */
  3062. conjugateInPlace(): Quaternion;
  3063. /**
  3064. * Conjugates in place (1-q) the current quaternion
  3065. * @returns a new quaternion
  3066. */
  3067. conjugate(): Quaternion;
  3068. /**
  3069. * Gets length of current quaternion
  3070. * @returns the quaternion length (float)
  3071. */
  3072. length(): number;
  3073. /**
  3074. * Normalize in place the current quaternion
  3075. * @returns the current updated quaternion
  3076. */
  3077. normalize(): Quaternion;
  3078. /**
  3079. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3080. * @param order is a reserved parameter and is ignore for now
  3081. * @returns a new Vector3 containing the Euler angles
  3082. */
  3083. toEulerAngles(order?: string): Vector3;
  3084. /**
  3085. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3086. * @param result defines the vector which will be filled with the Euler angles
  3087. * @param order is a reserved parameter and is ignore for now
  3088. * @returns the current unchanged quaternion
  3089. */
  3090. toEulerAnglesToRef(result: Vector3): Quaternion;
  3091. /**
  3092. * Updates the given rotation matrix with the current quaternion values
  3093. * @param result defines the target matrix
  3094. * @returns the current unchanged quaternion
  3095. */
  3096. toRotationMatrix(result: Matrix): Quaternion;
  3097. /**
  3098. * Updates the current quaternion from the given rotation matrix values
  3099. * @param matrix defines the source matrix
  3100. * @returns the current updated quaternion
  3101. */
  3102. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3103. /**
  3104. * Creates a new quaternion from a rotation matrix
  3105. * @param matrix defines the source matrix
  3106. * @returns a new quaternion created from the given rotation matrix values
  3107. */
  3108. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3109. /**
  3110. * Updates the given quaternion with the given rotation matrix values
  3111. * @param matrix defines the source matrix
  3112. * @param result defines the target quaternion
  3113. */
  3114. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3115. /**
  3116. * Returns the dot product (float) between the quaternions "left" and "right"
  3117. * @param left defines the left operand
  3118. * @param right defines the right operand
  3119. * @returns the dot product
  3120. */
  3121. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3122. /**
  3123. * Checks if the two quaternions are close to each other
  3124. * @param quat0 defines the first quaternion to check
  3125. * @param quat1 defines the second quaternion to check
  3126. * @returns true if the two quaternions are close to each other
  3127. */
  3128. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3129. /**
  3130. * Creates an empty quaternion
  3131. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3132. */
  3133. static Zero(): Quaternion;
  3134. /**
  3135. * Inverse a given quaternion
  3136. * @param q defines the source quaternion
  3137. * @returns a new quaternion as the inverted current quaternion
  3138. */
  3139. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3140. /**
  3141. * Inverse a given quaternion
  3142. * @param q defines the source quaternion
  3143. * @param result the quaternion the result will be stored in
  3144. * @returns the result quaternion
  3145. */
  3146. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3147. /**
  3148. * Creates an identity quaternion
  3149. * @returns the identity quaternion
  3150. */
  3151. static Identity(): Quaternion;
  3152. /**
  3153. * Gets a boolean indicating if the given quaternion is identity
  3154. * @param quaternion defines the quaternion to check
  3155. * @returns true if the quaternion is identity
  3156. */
  3157. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3158. /**
  3159. * Creates a quaternion from a rotation around an axis
  3160. * @param axis defines the axis to use
  3161. * @param angle defines the angle to use
  3162. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3163. */
  3164. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3165. /**
  3166. * Creates a rotation around an axis and stores it into the given quaternion
  3167. * @param axis defines the axis to use
  3168. * @param angle defines the angle to use
  3169. * @param result defines the target quaternion
  3170. * @returns the target quaternion
  3171. */
  3172. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3173. /**
  3174. * Creates a new quaternion from data stored into an array
  3175. * @param array defines the data source
  3176. * @param offset defines the offset in the source array where the data starts
  3177. * @returns a new quaternion
  3178. */
  3179. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3180. /**
  3181. * Create a quaternion from Euler rotation angles
  3182. * @param x Pitch
  3183. * @param y Yaw
  3184. * @param z Roll
  3185. * @returns the new Quaternion
  3186. */
  3187. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3188. /**
  3189. * Updates a quaternion from Euler rotation angles
  3190. * @param x Pitch
  3191. * @param y Yaw
  3192. * @param z Roll
  3193. * @param result the quaternion to store the result
  3194. * @returns the updated quaternion
  3195. */
  3196. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3197. /**
  3198. * Create a quaternion from Euler rotation vector
  3199. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3200. * @returns the new Quaternion
  3201. */
  3202. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3203. /**
  3204. * Updates a quaternion from Euler rotation vector
  3205. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3206. * @param result the quaternion to store the result
  3207. * @returns the updated quaternion
  3208. */
  3209. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3210. /**
  3211. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3212. * @param yaw defines the rotation around Y axis
  3213. * @param pitch defines the rotation around X axis
  3214. * @param roll defines the rotation around Z axis
  3215. * @returns the new quaternion
  3216. */
  3217. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3218. /**
  3219. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3220. * @param yaw defines the rotation around Y axis
  3221. * @param pitch defines the rotation around X axis
  3222. * @param roll defines the rotation around Z axis
  3223. * @param result defines the target quaternion
  3224. */
  3225. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3226. /**
  3227. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3228. * @param alpha defines the rotation around first axis
  3229. * @param beta defines the rotation around second axis
  3230. * @param gamma defines the rotation around third axis
  3231. * @returns the new quaternion
  3232. */
  3233. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3234. /**
  3235. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3236. * @param alpha defines the rotation around first axis
  3237. * @param beta defines the rotation around second axis
  3238. * @param gamma defines the rotation around third axis
  3239. * @param result defines the target quaternion
  3240. */
  3241. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3242. /**
  3243. * 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)
  3244. * @param axis1 defines the first axis
  3245. * @param axis2 defines the second axis
  3246. * @param axis3 defines the third axis
  3247. * @returns the new quaternion
  3248. */
  3249. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3250. /**
  3251. * 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
  3252. * @param axis1 defines the first axis
  3253. * @param axis2 defines the second axis
  3254. * @param axis3 defines the third axis
  3255. * @param ref defines the target quaternion
  3256. */
  3257. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3258. /**
  3259. * Interpolates between two quaternions
  3260. * @param left defines first quaternion
  3261. * @param right defines second quaternion
  3262. * @param amount defines the gradient to use
  3263. * @returns the new interpolated quaternion
  3264. */
  3265. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3266. /**
  3267. * Interpolates between two quaternions and stores it into a target quaternion
  3268. * @param left defines first quaternion
  3269. * @param right defines second quaternion
  3270. * @param amount defines the gradient to use
  3271. * @param result defines the target quaternion
  3272. */
  3273. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3274. /**
  3275. * Interpolate between two quaternions using Hermite interpolation
  3276. * @param value1 defines first quaternion
  3277. * @param tangent1 defines the incoming tangent
  3278. * @param value2 defines second quaternion
  3279. * @param tangent2 defines the outgoing tangent
  3280. * @param amount defines the target quaternion
  3281. * @returns the new interpolated quaternion
  3282. */
  3283. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3284. }
  3285. /**
  3286. * Class used to store matrix data (4x4)
  3287. */
  3288. export class Matrix {
  3289. private static _updateFlagSeed;
  3290. private static _identityReadOnly;
  3291. private _isIdentity;
  3292. private _isIdentityDirty;
  3293. private _isIdentity3x2;
  3294. private _isIdentity3x2Dirty;
  3295. /**
  3296. * Gets the update flag of the matrix which is an unique number for the matrix.
  3297. * It will be incremented every time the matrix data change.
  3298. * You can use it to speed the comparison between two versions of the same matrix.
  3299. */
  3300. updateFlag: number;
  3301. private readonly _m;
  3302. /**
  3303. * Gets the internal data of the matrix
  3304. */
  3305. readonly m: DeepImmutable<Float32Array>;
  3306. /** @hidden */
  3307. _markAsUpdated(): void;
  3308. /** @hidden */
  3309. private _updateIdentityStatus;
  3310. /**
  3311. * Creates an empty matrix (filled with zeros)
  3312. */
  3313. constructor();
  3314. /**
  3315. * Check if the current matrix is identity
  3316. * @returns true is the matrix is the identity matrix
  3317. */
  3318. isIdentity(): boolean;
  3319. /**
  3320. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3321. * @returns true is the matrix is the identity matrix
  3322. */
  3323. isIdentityAs3x2(): boolean;
  3324. /**
  3325. * Gets the determinant of the matrix
  3326. * @returns the matrix determinant
  3327. */
  3328. determinant(): number;
  3329. /**
  3330. * Returns the matrix as a Float32Array
  3331. * @returns the matrix underlying array
  3332. */
  3333. toArray(): DeepImmutable<Float32Array>;
  3334. /**
  3335. * Returns the matrix as a Float32Array
  3336. * @returns the matrix underlying array.
  3337. */
  3338. asArray(): DeepImmutable<Float32Array>;
  3339. /**
  3340. * Inverts the current matrix in place
  3341. * @returns the current inverted matrix
  3342. */
  3343. invert(): Matrix;
  3344. /**
  3345. * Sets all the matrix elements to zero
  3346. * @returns the current matrix
  3347. */
  3348. reset(): Matrix;
  3349. /**
  3350. * Adds the current matrix with a second one
  3351. * @param other defines the matrix to add
  3352. * @returns a new matrix as the addition of the current matrix and the given one
  3353. */
  3354. add(other: DeepImmutable<Matrix>): Matrix;
  3355. /**
  3356. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3357. * @param other defines the matrix to add
  3358. * @param result defines the target matrix
  3359. * @returns the current matrix
  3360. */
  3361. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3362. /**
  3363. * Adds in place the given matrix to the current matrix
  3364. * @param other defines the second operand
  3365. * @returns the current updated matrix
  3366. */
  3367. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3368. /**
  3369. * Sets the given matrix to the current inverted Matrix
  3370. * @param other defines the target matrix
  3371. * @returns the unmodified current matrix
  3372. */
  3373. invertToRef(other: Matrix): Matrix;
  3374. /**
  3375. * add a value at the specified position in the current Matrix
  3376. * @param index the index of the value within the matrix. between 0 and 15.
  3377. * @param value the value to be added
  3378. * @returns the current updated matrix
  3379. */
  3380. addAtIndex(index: number, value: number): Matrix;
  3381. /**
  3382. * mutiply the specified position in the current Matrix by a value
  3383. * @param index the index of the value within the matrix. between 0 and 15.
  3384. * @param value the value to be added
  3385. * @returns the current updated matrix
  3386. */
  3387. multiplyAtIndex(index: number, value: number): Matrix;
  3388. /**
  3389. * Inserts the translation vector (using 3 floats) in the current matrix
  3390. * @param x defines the 1st component of the translation
  3391. * @param y defines the 2nd component of the translation
  3392. * @param z defines the 3rd component of the translation
  3393. * @returns the current updated matrix
  3394. */
  3395. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3396. /**
  3397. * Adds the translation vector (using 3 floats) in the current matrix
  3398. * @param x defines the 1st component of the translation
  3399. * @param y defines the 2nd component of the translation
  3400. * @param z defines the 3rd component of the translation
  3401. * @returns the current updated matrix
  3402. */
  3403. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3404. /**
  3405. * Inserts the translation vector in the current matrix
  3406. * @param vector3 defines the translation to insert
  3407. * @returns the current updated matrix
  3408. */
  3409. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3410. /**
  3411. * Gets the translation value of the current matrix
  3412. * @returns a new Vector3 as the extracted translation from the matrix
  3413. */
  3414. getTranslation(): Vector3;
  3415. /**
  3416. * Fill a Vector3 with the extracted translation from the matrix
  3417. * @param result defines the Vector3 where to store the translation
  3418. * @returns the current matrix
  3419. */
  3420. getTranslationToRef(result: Vector3): Matrix;
  3421. /**
  3422. * Remove rotation and scaling part from the matrix
  3423. * @returns the updated matrix
  3424. */
  3425. removeRotationAndScaling(): Matrix;
  3426. /**
  3427. * Multiply two matrices
  3428. * @param other defines the second operand
  3429. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3430. */
  3431. multiply(other: DeepImmutable<Matrix>): Matrix;
  3432. /**
  3433. * Copy the current matrix from the given one
  3434. * @param other defines the source matrix
  3435. * @returns the current updated matrix
  3436. */
  3437. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3438. /**
  3439. * Populates the given array from the starting index with the current matrix values
  3440. * @param array defines the target array
  3441. * @param offset defines the offset in the target array where to start storing values
  3442. * @returns the current matrix
  3443. */
  3444. copyToArray(array: Float32Array, offset?: number): Matrix;
  3445. /**
  3446. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3447. * @param other defines the second operand
  3448. * @param result defines the matrix where to store the multiplication
  3449. * @returns the current matrix
  3450. */
  3451. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3452. /**
  3453. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3454. * @param other defines the second operand
  3455. * @param result defines the array where to store the multiplication
  3456. * @param offset defines the offset in the target array where to start storing values
  3457. * @returns the current matrix
  3458. */
  3459. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3460. /**
  3461. * Check equality between this matrix and a second one
  3462. * @param value defines the second matrix to compare
  3463. * @returns true is the current matrix and the given one values are strictly equal
  3464. */
  3465. equals(value: DeepImmutable<Matrix>): boolean;
  3466. /**
  3467. * Clone the current matrix
  3468. * @returns a new matrix from the current matrix
  3469. */
  3470. clone(): Matrix;
  3471. /**
  3472. * Returns the name of the current matrix class
  3473. * @returns the string "Matrix"
  3474. */
  3475. getClassName(): string;
  3476. /**
  3477. * Gets the hash code of the current matrix
  3478. * @returns the hash code
  3479. */
  3480. getHashCode(): number;
  3481. /**
  3482. * Decomposes the current Matrix into a translation, rotation and scaling components
  3483. * @param scale defines the scale vector3 given as a reference to update
  3484. * @param rotation defines the rotation quaternion given as a reference to update
  3485. * @param translation defines the translation vector3 given as a reference to update
  3486. * @returns true if operation was successful
  3487. */
  3488. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3489. /**
  3490. * Gets specific row of the matrix
  3491. * @param index defines the number of the row to get
  3492. * @returns the index-th row of the current matrix as a new Vector4
  3493. */
  3494. getRow(index: number): Nullable<Vector4>;
  3495. /**
  3496. * Sets the index-th row of the current matrix to the vector4 values
  3497. * @param index defines the number of the row to set
  3498. * @param row defines the target vector4
  3499. * @returns the updated current matrix
  3500. */
  3501. setRow(index: number, row: Vector4): Matrix;
  3502. /**
  3503. * Compute the transpose of the matrix
  3504. * @returns the new transposed matrix
  3505. */
  3506. transpose(): Matrix;
  3507. /**
  3508. * Compute the transpose of the matrix and store it in a given matrix
  3509. * @param result defines the target matrix
  3510. * @returns the current matrix
  3511. */
  3512. transposeToRef(result: Matrix): Matrix;
  3513. /**
  3514. * Sets the index-th row of the current matrix with the given 4 x float values
  3515. * @param index defines the row index
  3516. * @param x defines the x component to set
  3517. * @param y defines the y component to set
  3518. * @param z defines the z component to set
  3519. * @param w defines the w component to set
  3520. * @returns the updated current matrix
  3521. */
  3522. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3523. /**
  3524. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3525. * @param scale defines the scale factor
  3526. * @returns a new matrix
  3527. */
  3528. scale(scale: number): Matrix;
  3529. /**
  3530. * Scale the current matrix values by a factor to a given result matrix
  3531. * @param scale defines the scale factor
  3532. * @param result defines the matrix to store the result
  3533. * @returns the current matrix
  3534. */
  3535. scaleToRef(scale: number, result: Matrix): Matrix;
  3536. /**
  3537. * Scale the current matrix values by a factor and add the result to a given matrix
  3538. * @param scale defines the scale factor
  3539. * @param result defines the Matrix to store the result
  3540. * @returns the current matrix
  3541. */
  3542. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3543. /**
  3544. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3545. * @param ref matrix to store the result
  3546. */
  3547. toNormalMatrix(ref: Matrix): void;
  3548. /**
  3549. * Gets only rotation part of the current matrix
  3550. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3551. */
  3552. getRotationMatrix(): Matrix;
  3553. /**
  3554. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3555. * @param result defines the target matrix to store data to
  3556. * @returns the current matrix
  3557. */
  3558. getRotationMatrixToRef(result: Matrix): Matrix;
  3559. /**
  3560. * Toggles model matrix from being right handed to left handed in place and vice versa
  3561. */
  3562. toggleModelMatrixHandInPlace(): void;
  3563. /**
  3564. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3565. */
  3566. toggleProjectionMatrixHandInPlace(): void;
  3567. /**
  3568. * Creates a matrix from an array
  3569. * @param array defines the source array
  3570. * @param offset defines an offset in the source array
  3571. * @returns a new Matrix set from the starting index of the given array
  3572. */
  3573. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3574. /**
  3575. * Copy the content of an array into a given matrix
  3576. * @param array defines the source array
  3577. * @param offset defines an offset in the source array
  3578. * @param result defines the target matrix
  3579. */
  3580. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3581. /**
  3582. * Stores an array into a matrix after having multiplied each component by a given factor
  3583. * @param array defines the source array
  3584. * @param offset defines the offset in the source array
  3585. * @param scale defines the scaling factor
  3586. * @param result defines the target matrix
  3587. */
  3588. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3589. /**
  3590. * Gets an identity matrix that must not be updated
  3591. */
  3592. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3593. /**
  3594. * Stores a list of values (16) inside a given matrix
  3595. * @param initialM11 defines 1st value of 1st row
  3596. * @param initialM12 defines 2nd value of 1st row
  3597. * @param initialM13 defines 3rd value of 1st row
  3598. * @param initialM14 defines 4th value of 1st row
  3599. * @param initialM21 defines 1st value of 2nd row
  3600. * @param initialM22 defines 2nd value of 2nd row
  3601. * @param initialM23 defines 3rd value of 2nd row
  3602. * @param initialM24 defines 4th value of 2nd row
  3603. * @param initialM31 defines 1st value of 3rd row
  3604. * @param initialM32 defines 2nd value of 3rd row
  3605. * @param initialM33 defines 3rd value of 3rd row
  3606. * @param initialM34 defines 4th value of 3rd row
  3607. * @param initialM41 defines 1st value of 4th row
  3608. * @param initialM42 defines 2nd value of 4th row
  3609. * @param initialM43 defines 3rd value of 4th row
  3610. * @param initialM44 defines 4th value of 4th row
  3611. * @param result defines the target matrix
  3612. */
  3613. 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;
  3614. /**
  3615. * Creates new matrix from a list of values (16)
  3616. * @param initialM11 defines 1st value of 1st row
  3617. * @param initialM12 defines 2nd value of 1st row
  3618. * @param initialM13 defines 3rd value of 1st row
  3619. * @param initialM14 defines 4th value of 1st row
  3620. * @param initialM21 defines 1st value of 2nd row
  3621. * @param initialM22 defines 2nd value of 2nd row
  3622. * @param initialM23 defines 3rd value of 2nd row
  3623. * @param initialM24 defines 4th value of 2nd row
  3624. * @param initialM31 defines 1st value of 3rd row
  3625. * @param initialM32 defines 2nd value of 3rd row
  3626. * @param initialM33 defines 3rd value of 3rd row
  3627. * @param initialM34 defines 4th value of 3rd row
  3628. * @param initialM41 defines 1st value of 4th row
  3629. * @param initialM42 defines 2nd value of 4th row
  3630. * @param initialM43 defines 3rd value of 4th row
  3631. * @param initialM44 defines 4th value of 4th row
  3632. * @returns the new matrix
  3633. */
  3634. 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;
  3635. /**
  3636. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3637. * @param scale defines the scale vector3
  3638. * @param rotation defines the rotation quaternion
  3639. * @param translation defines the translation vector3
  3640. * @returns a new matrix
  3641. */
  3642. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3643. /**
  3644. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3645. * @param scale defines the scale vector3
  3646. * @param rotation defines the rotation quaternion
  3647. * @param translation defines the translation vector3
  3648. * @param result defines the target matrix
  3649. */
  3650. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3651. /**
  3652. * Creates a new identity matrix
  3653. * @returns a new identity matrix
  3654. */
  3655. static Identity(): Matrix;
  3656. /**
  3657. * Creates a new identity matrix and stores the result in a given matrix
  3658. * @param result defines the target matrix
  3659. */
  3660. static IdentityToRef(result: Matrix): void;
  3661. /**
  3662. * Creates a new zero matrix
  3663. * @returns a new zero matrix
  3664. */
  3665. static Zero(): Matrix;
  3666. /**
  3667. * Creates a new rotation matrix for "angle" radians around the X axis
  3668. * @param angle defines the angle (in radians) to use
  3669. * @return the new matrix
  3670. */
  3671. static RotationX(angle: number): Matrix;
  3672. /**
  3673. * Creates a new matrix as the invert of a given matrix
  3674. * @param source defines the source matrix
  3675. * @returns the new matrix
  3676. */
  3677. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3678. /**
  3679. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3680. * @param angle defines the angle (in radians) to use
  3681. * @param result defines the target matrix
  3682. */
  3683. static RotationXToRef(angle: number, result: Matrix): void;
  3684. /**
  3685. * Creates a new rotation matrix for "angle" radians around the Y axis
  3686. * @param angle defines the angle (in radians) to use
  3687. * @return the new matrix
  3688. */
  3689. static RotationY(angle: number): Matrix;
  3690. /**
  3691. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3692. * @param angle defines the angle (in radians) to use
  3693. * @param result defines the target matrix
  3694. */
  3695. static RotationYToRef(angle: number, result: Matrix): void;
  3696. /**
  3697. * Creates a new rotation matrix for "angle" radians around the Z axis
  3698. * @param angle defines the angle (in radians) to use
  3699. * @return the new matrix
  3700. */
  3701. static RotationZ(angle: number): Matrix;
  3702. /**
  3703. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3704. * @param angle defines the angle (in radians) to use
  3705. * @param result defines the target matrix
  3706. */
  3707. static RotationZToRef(angle: number, result: Matrix): void;
  3708. /**
  3709. * Creates a new rotation matrix for "angle" radians around the given axis
  3710. * @param axis defines the axis to use
  3711. * @param angle defines the angle (in radians) to use
  3712. * @return the new matrix
  3713. */
  3714. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3715. /**
  3716. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3717. * @param axis defines the axis to use
  3718. * @param angle defines the angle (in radians) to use
  3719. * @param result defines the target matrix
  3720. */
  3721. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3722. /**
  3723. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3724. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3725. * @param from defines the vector to align
  3726. * @param to defines the vector to align to
  3727. * @param result defines the target matrix
  3728. */
  3729. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3730. /**
  3731. * Creates a rotation matrix
  3732. * @param yaw defines the yaw angle in radians (Y axis)
  3733. * @param pitch defines the pitch angle in radians (X axis)
  3734. * @param roll defines the roll angle in radians (X axis)
  3735. * @returns the new rotation matrix
  3736. */
  3737. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3738. /**
  3739. * Creates a rotation matrix and stores it in a given matrix
  3740. * @param yaw defines the yaw angle in radians (Y axis)
  3741. * @param pitch defines the pitch angle in radians (X axis)
  3742. * @param roll defines the roll angle in radians (X axis)
  3743. * @param result defines the target matrix
  3744. */
  3745. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3746. /**
  3747. * Creates a scaling matrix
  3748. * @param x defines the scale factor on X axis
  3749. * @param y defines the scale factor on Y axis
  3750. * @param z defines the scale factor on Z axis
  3751. * @returns the new matrix
  3752. */
  3753. static Scaling(x: number, y: number, z: number): Matrix;
  3754. /**
  3755. * Creates a scaling matrix and stores it in a given matrix
  3756. * @param x defines the scale factor on X axis
  3757. * @param y defines the scale factor on Y axis
  3758. * @param z defines the scale factor on Z axis
  3759. * @param result defines the target matrix
  3760. */
  3761. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3762. /**
  3763. * Creates a translation matrix
  3764. * @param x defines the translation on X axis
  3765. * @param y defines the translation on Y axis
  3766. * @param z defines the translationon Z axis
  3767. * @returns the new matrix
  3768. */
  3769. static Translation(x: number, y: number, z: number): Matrix;
  3770. /**
  3771. * Creates a translation matrix and stores it in a given matrix
  3772. * @param x defines the translation on X axis
  3773. * @param y defines the translation on Y axis
  3774. * @param z defines the translationon Z axis
  3775. * @param result defines the target matrix
  3776. */
  3777. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3778. /**
  3779. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3780. * @param startValue defines the start value
  3781. * @param endValue defines the end value
  3782. * @param gradient defines the gradient factor
  3783. * @returns the new matrix
  3784. */
  3785. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3786. /**
  3787. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3788. * @param startValue defines the start value
  3789. * @param endValue defines the end value
  3790. * @param gradient defines the gradient factor
  3791. * @param result defines the Matrix object where to store data
  3792. */
  3793. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3794. /**
  3795. * Builds a new matrix whose values are computed by:
  3796. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3797. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3798. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3799. * @param startValue defines the first matrix
  3800. * @param endValue defines the second matrix
  3801. * @param gradient defines the gradient between the two matrices
  3802. * @returns the new matrix
  3803. */
  3804. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3805. /**
  3806. * Update a matrix to values which are computed by:
  3807. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3808. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3809. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3810. * @param startValue defines the first matrix
  3811. * @param endValue defines the second matrix
  3812. * @param gradient defines the gradient between the two matrices
  3813. * @param result defines the target matrix
  3814. */
  3815. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3816. /**
  3817. * 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"
  3818. * This function works in left handed mode
  3819. * @param eye defines the final position of the entity
  3820. * @param target defines where the entity should look at
  3821. * @param up defines the up vector for the entity
  3822. * @returns the new matrix
  3823. */
  3824. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3825. /**
  3826. * 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".
  3827. * This function works in left handed mode
  3828. * @param eye defines the final position of the entity
  3829. * @param target defines where the entity should look at
  3830. * @param up defines the up vector for the entity
  3831. * @param result defines the target matrix
  3832. */
  3833. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3834. /**
  3835. * 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"
  3836. * This function works in right handed mode
  3837. * @param eye defines the final position of the entity
  3838. * @param target defines where the entity should look at
  3839. * @param up defines the up vector for the entity
  3840. * @returns the new matrix
  3841. */
  3842. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3843. /**
  3844. * 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".
  3845. * This function works in right handed mode
  3846. * @param eye defines the final position of the entity
  3847. * @param target defines where the entity should look at
  3848. * @param up defines the up vector for the entity
  3849. * @param result defines the target matrix
  3850. */
  3851. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3852. /**
  3853. * Create a left-handed orthographic projection matrix
  3854. * @param width defines the viewport width
  3855. * @param height defines the viewport height
  3856. * @param znear defines the near clip plane
  3857. * @param zfar defines the far clip plane
  3858. * @returns a new matrix as a left-handed orthographic projection matrix
  3859. */
  3860. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3861. /**
  3862. * Store a left-handed orthographic projection to a given matrix
  3863. * @param width defines the viewport width
  3864. * @param height defines the viewport height
  3865. * @param znear defines the near clip plane
  3866. * @param zfar defines the far clip plane
  3867. * @param result defines the target matrix
  3868. */
  3869. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3870. /**
  3871. * Create a left-handed orthographic projection matrix
  3872. * @param left defines the viewport left coordinate
  3873. * @param right defines the viewport right coordinate
  3874. * @param bottom defines the viewport bottom coordinate
  3875. * @param top defines the viewport top coordinate
  3876. * @param znear defines the near clip plane
  3877. * @param zfar defines the far clip plane
  3878. * @returns a new matrix as a left-handed orthographic projection matrix
  3879. */
  3880. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3881. /**
  3882. * Stores a left-handed orthographic projection into a given matrix
  3883. * @param left defines the viewport left coordinate
  3884. * @param right defines the viewport right coordinate
  3885. * @param bottom defines the viewport bottom coordinate
  3886. * @param top defines the viewport top coordinate
  3887. * @param znear defines the near clip plane
  3888. * @param zfar defines the far clip plane
  3889. * @param result defines the target matrix
  3890. */
  3891. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3892. /**
  3893. * Creates a right-handed orthographic projection matrix
  3894. * @param left defines the viewport left coordinate
  3895. * @param right defines the viewport right coordinate
  3896. * @param bottom defines the viewport bottom coordinate
  3897. * @param top defines the viewport top coordinate
  3898. * @param znear defines the near clip plane
  3899. * @param zfar defines the far clip plane
  3900. * @returns a new matrix as a right-handed orthographic projection matrix
  3901. */
  3902. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3903. /**
  3904. * Stores a right-handed orthographic projection into a given matrix
  3905. * @param left defines the viewport left coordinate
  3906. * @param right defines the viewport right coordinate
  3907. * @param bottom defines the viewport bottom coordinate
  3908. * @param top defines the viewport top coordinate
  3909. * @param znear defines the near clip plane
  3910. * @param zfar defines the far clip plane
  3911. * @param result defines the target matrix
  3912. */
  3913. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3914. /**
  3915. * Creates a left-handed perspective projection matrix
  3916. * @param width defines the viewport width
  3917. * @param height defines the viewport height
  3918. * @param znear defines the near clip plane
  3919. * @param zfar defines the far clip plane
  3920. * @returns a new matrix as a left-handed perspective projection matrix
  3921. */
  3922. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3923. /**
  3924. * Creates a left-handed perspective projection matrix
  3925. * @param fov defines the horizontal field of view
  3926. * @param aspect defines the aspect ratio
  3927. * @param znear defines the near clip plane
  3928. * @param zfar defines the far clip plane
  3929. * @returns a new matrix as a left-handed perspective projection matrix
  3930. */
  3931. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3932. /**
  3933. * Stores a left-handed perspective projection into a given matrix
  3934. * @param fov defines the horizontal field of view
  3935. * @param aspect defines the aspect ratio
  3936. * @param znear defines the near clip plane
  3937. * @param zfar defines the far clip plane
  3938. * @param result defines the target matrix
  3939. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3940. */
  3941. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3942. /**
  3943. * Creates a right-handed perspective projection matrix
  3944. * @param fov defines the horizontal field of view
  3945. * @param aspect defines the aspect ratio
  3946. * @param znear defines the near clip plane
  3947. * @param zfar defines the far clip plane
  3948. * @returns a new matrix as a right-handed perspective projection matrix
  3949. */
  3950. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3951. /**
  3952. * Stores a right-handed perspective projection into a given matrix
  3953. * @param fov defines the horizontal field of view
  3954. * @param aspect defines the aspect ratio
  3955. * @param znear defines the near clip plane
  3956. * @param zfar defines the far clip plane
  3957. * @param result defines the target matrix
  3958. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3959. */
  3960. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3961. /**
  3962. * Stores a perspective projection for WebVR info a given matrix
  3963. * @param fov defines the field of view
  3964. * @param znear defines the near clip plane
  3965. * @param zfar defines the far clip plane
  3966. * @param result defines the target matrix
  3967. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3968. */
  3969. static PerspectiveFovWebVRToRef(fov: {
  3970. upDegrees: number;
  3971. downDegrees: number;
  3972. leftDegrees: number;
  3973. rightDegrees: number;
  3974. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3975. /**
  3976. * Computes a complete transformation matrix
  3977. * @param viewport defines the viewport to use
  3978. * @param world defines the world matrix
  3979. * @param view defines the view matrix
  3980. * @param projection defines the projection matrix
  3981. * @param zmin defines the near clip plane
  3982. * @param zmax defines the far clip plane
  3983. * @returns the transformation matrix
  3984. */
  3985. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3986. /**
  3987. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3988. * @param matrix defines the matrix to use
  3989. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3990. */
  3991. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3992. /**
  3993. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3994. * @param matrix defines the matrix to use
  3995. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3996. */
  3997. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3998. /**
  3999. * Compute the transpose of a given matrix
  4000. * @param matrix defines the matrix to transpose
  4001. * @returns the new matrix
  4002. */
  4003. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4004. /**
  4005. * Compute the transpose of a matrix and store it in a target matrix
  4006. * @param matrix defines the matrix to transpose
  4007. * @param result defines the target matrix
  4008. */
  4009. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4010. /**
  4011. * Computes a reflection matrix from a plane
  4012. * @param plane defines the reflection plane
  4013. * @returns a new matrix
  4014. */
  4015. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4016. /**
  4017. * Computes a reflection matrix from a plane
  4018. * @param plane defines the reflection plane
  4019. * @param result defines the target matrix
  4020. */
  4021. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4022. /**
  4023. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4024. * @param xaxis defines the value of the 1st axis
  4025. * @param yaxis defines the value of the 2nd axis
  4026. * @param zaxis defines the value of the 3rd axis
  4027. * @param result defines the target matrix
  4028. */
  4029. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4030. /**
  4031. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4032. * @param quat defines the quaternion to use
  4033. * @param result defines the target matrix
  4034. */
  4035. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4036. }
  4037. /**
  4038. * @hidden
  4039. */
  4040. export class TmpVectors {
  4041. static Vector2: Vector2[];
  4042. static Vector3: Vector3[];
  4043. static Vector4: Vector4[];
  4044. static Quaternion: Quaternion[];
  4045. static Matrix: Matrix[];
  4046. }
  4047. }
  4048. declare module "babylonjs/Engines/constants" {
  4049. /** Defines the cross module used constants to avoid circular dependncies */
  4050. export class Constants {
  4051. /** Defines that alpha blending is disabled */
  4052. static readonly ALPHA_DISABLE: number;
  4053. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4054. static readonly ALPHA_ADD: number;
  4055. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4056. static readonly ALPHA_COMBINE: number;
  4057. /** Defines that alpha blending to DEST - SRC * DEST */
  4058. static readonly ALPHA_SUBTRACT: number;
  4059. /** Defines that alpha blending to SRC * DEST */
  4060. static readonly ALPHA_MULTIPLY: number;
  4061. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4062. static readonly ALPHA_MAXIMIZED: number;
  4063. /** Defines that alpha blending to SRC + DEST */
  4064. static readonly ALPHA_ONEONE: number;
  4065. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4066. static readonly ALPHA_PREMULTIPLIED: number;
  4067. /**
  4068. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4069. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4070. */
  4071. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4072. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4073. static readonly ALPHA_INTERPOLATE: number;
  4074. /**
  4075. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4076. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4077. */
  4078. static readonly ALPHA_SCREENMODE: number;
  4079. /** Defines that the ressource is not delayed*/
  4080. static readonly DELAYLOADSTATE_NONE: number;
  4081. /** Defines that the ressource was successfully delay loaded */
  4082. static readonly DELAYLOADSTATE_LOADED: number;
  4083. /** Defines that the ressource is currently delay loading */
  4084. static readonly DELAYLOADSTATE_LOADING: number;
  4085. /** Defines that the ressource is delayed and has not started loading */
  4086. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4087. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4088. static readonly NEVER: number;
  4089. /** 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 */
  4090. static readonly ALWAYS: number;
  4091. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4092. static readonly LESS: number;
  4093. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4094. static readonly EQUAL: number;
  4095. /** 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 */
  4096. static readonly LEQUAL: number;
  4097. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4098. static readonly GREATER: number;
  4099. /** 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 */
  4100. static readonly GEQUAL: number;
  4101. /** 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 */
  4102. static readonly NOTEQUAL: number;
  4103. /** Passed to stencilOperation to specify that stencil value must be kept */
  4104. static readonly KEEP: number;
  4105. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4106. static readonly REPLACE: number;
  4107. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4108. static readonly INCR: number;
  4109. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4110. static readonly DECR: number;
  4111. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4112. static readonly INVERT: number;
  4113. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4114. static readonly INCR_WRAP: number;
  4115. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4116. static readonly DECR_WRAP: number;
  4117. /** Texture is not repeating outside of 0..1 UVs */
  4118. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4119. /** Texture is repeating outside of 0..1 UVs */
  4120. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4121. /** Texture is repeating and mirrored */
  4122. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4123. /** ALPHA */
  4124. static readonly TEXTUREFORMAT_ALPHA: number;
  4125. /** LUMINANCE */
  4126. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4127. /** LUMINANCE_ALPHA */
  4128. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4129. /** RGB */
  4130. static readonly TEXTUREFORMAT_RGB: number;
  4131. /** RGBA */
  4132. static readonly TEXTUREFORMAT_RGBA: number;
  4133. /** RED */
  4134. static readonly TEXTUREFORMAT_RED: number;
  4135. /** RED (2nd reference) */
  4136. static readonly TEXTUREFORMAT_R: number;
  4137. /** RG */
  4138. static readonly TEXTUREFORMAT_RG: number;
  4139. /** RED_INTEGER */
  4140. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4141. /** RED_INTEGER (2nd reference) */
  4142. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4143. /** RG_INTEGER */
  4144. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4145. /** RGB_INTEGER */
  4146. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4147. /** RGBA_INTEGER */
  4148. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4149. /** UNSIGNED_BYTE */
  4150. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4151. /** UNSIGNED_BYTE (2nd reference) */
  4152. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4153. /** FLOAT */
  4154. static readonly TEXTURETYPE_FLOAT: number;
  4155. /** HALF_FLOAT */
  4156. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4157. /** BYTE */
  4158. static readonly TEXTURETYPE_BYTE: number;
  4159. /** SHORT */
  4160. static readonly TEXTURETYPE_SHORT: number;
  4161. /** UNSIGNED_SHORT */
  4162. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4163. /** INT */
  4164. static readonly TEXTURETYPE_INT: number;
  4165. /** UNSIGNED_INT */
  4166. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4167. /** UNSIGNED_SHORT_4_4_4_4 */
  4168. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4169. /** UNSIGNED_SHORT_5_5_5_1 */
  4170. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4171. /** UNSIGNED_SHORT_5_6_5 */
  4172. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4173. /** UNSIGNED_INT_2_10_10_10_REV */
  4174. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4175. /** UNSIGNED_INT_24_8 */
  4176. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4177. /** UNSIGNED_INT_10F_11F_11F_REV */
  4178. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4179. /** UNSIGNED_INT_5_9_9_9_REV */
  4180. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4181. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4182. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4183. /** nearest is mag = nearest and min = nearest and mip = linear */
  4184. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4185. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4186. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4187. /** Trilinear is mag = linear and min = linear and mip = linear */
  4188. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4189. /** nearest is mag = nearest and min = nearest and mip = linear */
  4190. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4191. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4192. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4193. /** Trilinear is mag = linear and min = linear and mip = linear */
  4194. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4195. /** mag = nearest and min = nearest and mip = nearest */
  4196. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4197. /** mag = nearest and min = linear and mip = nearest */
  4198. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4199. /** mag = nearest and min = linear and mip = linear */
  4200. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4201. /** mag = nearest and min = linear and mip = none */
  4202. static readonly TEXTURE_NEAREST_LINEAR: number;
  4203. /** mag = nearest and min = nearest and mip = none */
  4204. static readonly TEXTURE_NEAREST_NEAREST: number;
  4205. /** mag = linear and min = nearest and mip = nearest */
  4206. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4207. /** mag = linear and min = nearest and mip = linear */
  4208. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4209. /** mag = linear and min = linear and mip = none */
  4210. static readonly TEXTURE_LINEAR_LINEAR: number;
  4211. /** mag = linear and min = nearest and mip = none */
  4212. static readonly TEXTURE_LINEAR_NEAREST: number;
  4213. /** Explicit coordinates mode */
  4214. static readonly TEXTURE_EXPLICIT_MODE: number;
  4215. /** Spherical coordinates mode */
  4216. static readonly TEXTURE_SPHERICAL_MODE: number;
  4217. /** Planar coordinates mode */
  4218. static readonly TEXTURE_PLANAR_MODE: number;
  4219. /** Cubic coordinates mode */
  4220. static readonly TEXTURE_CUBIC_MODE: number;
  4221. /** Projection coordinates mode */
  4222. static readonly TEXTURE_PROJECTION_MODE: number;
  4223. /** Skybox coordinates mode */
  4224. static readonly TEXTURE_SKYBOX_MODE: number;
  4225. /** Inverse Cubic coordinates mode */
  4226. static readonly TEXTURE_INVCUBIC_MODE: number;
  4227. /** Equirectangular coordinates mode */
  4228. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4229. /** Equirectangular Fixed coordinates mode */
  4230. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4231. /** Equirectangular Fixed Mirrored coordinates mode */
  4232. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4233. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4234. static readonly SCALEMODE_FLOOR: number;
  4235. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4236. static readonly SCALEMODE_NEAREST: number;
  4237. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4238. static readonly SCALEMODE_CEILING: number;
  4239. /**
  4240. * The dirty texture flag value
  4241. */
  4242. static readonly MATERIAL_TextureDirtyFlag: number;
  4243. /**
  4244. * The dirty light flag value
  4245. */
  4246. static readonly MATERIAL_LightDirtyFlag: number;
  4247. /**
  4248. * The dirty fresnel flag value
  4249. */
  4250. static readonly MATERIAL_FresnelDirtyFlag: number;
  4251. /**
  4252. * The dirty attribute flag value
  4253. */
  4254. static readonly MATERIAL_AttributesDirtyFlag: number;
  4255. /**
  4256. * The dirty misc flag value
  4257. */
  4258. static readonly MATERIAL_MiscDirtyFlag: number;
  4259. /**
  4260. * The all dirty flag value
  4261. */
  4262. static readonly MATERIAL_AllDirtyFlag: number;
  4263. /**
  4264. * Returns the triangle fill mode
  4265. */
  4266. static readonly MATERIAL_TriangleFillMode: number;
  4267. /**
  4268. * Returns the wireframe mode
  4269. */
  4270. static readonly MATERIAL_WireFrameFillMode: number;
  4271. /**
  4272. * Returns the point fill mode
  4273. */
  4274. static readonly MATERIAL_PointFillMode: number;
  4275. /**
  4276. * Returns the point list draw mode
  4277. */
  4278. static readonly MATERIAL_PointListDrawMode: number;
  4279. /**
  4280. * Returns the line list draw mode
  4281. */
  4282. static readonly MATERIAL_LineListDrawMode: number;
  4283. /**
  4284. * Returns the line loop draw mode
  4285. */
  4286. static readonly MATERIAL_LineLoopDrawMode: number;
  4287. /**
  4288. * Returns the line strip draw mode
  4289. */
  4290. static readonly MATERIAL_LineStripDrawMode: number;
  4291. /**
  4292. * Returns the triangle strip draw mode
  4293. */
  4294. static readonly MATERIAL_TriangleStripDrawMode: number;
  4295. /**
  4296. * Returns the triangle fan draw mode
  4297. */
  4298. static readonly MATERIAL_TriangleFanDrawMode: number;
  4299. /**
  4300. * Stores the clock-wise side orientation
  4301. */
  4302. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4303. /**
  4304. * Stores the counter clock-wise side orientation
  4305. */
  4306. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4307. /**
  4308. * Nothing
  4309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4310. */
  4311. static readonly ACTION_NothingTrigger: number;
  4312. /**
  4313. * On pick
  4314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4315. */
  4316. static readonly ACTION_OnPickTrigger: number;
  4317. /**
  4318. * On left pick
  4319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4320. */
  4321. static readonly ACTION_OnLeftPickTrigger: number;
  4322. /**
  4323. * On right pick
  4324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4325. */
  4326. static readonly ACTION_OnRightPickTrigger: number;
  4327. /**
  4328. * On center pick
  4329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4330. */
  4331. static readonly ACTION_OnCenterPickTrigger: number;
  4332. /**
  4333. * On pick down
  4334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4335. */
  4336. static readonly ACTION_OnPickDownTrigger: number;
  4337. /**
  4338. * On double pick
  4339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4340. */
  4341. static readonly ACTION_OnDoublePickTrigger: number;
  4342. /**
  4343. * On pick up
  4344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4345. */
  4346. static readonly ACTION_OnPickUpTrigger: number;
  4347. /**
  4348. * On pick out.
  4349. * This trigger will only be raised if you also declared a OnPickDown
  4350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4351. */
  4352. static readonly ACTION_OnPickOutTrigger: number;
  4353. /**
  4354. * On long press
  4355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4356. */
  4357. static readonly ACTION_OnLongPressTrigger: number;
  4358. /**
  4359. * On pointer over
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_OnPointerOverTrigger: number;
  4363. /**
  4364. * On pointer out
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnPointerOutTrigger: number;
  4368. /**
  4369. * On every frame
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnEveryFrameTrigger: number;
  4373. /**
  4374. * On intersection enter
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4378. /**
  4379. * On intersection exit
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnIntersectionExitTrigger: number;
  4383. /**
  4384. * On key down
  4385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4386. */
  4387. static readonly ACTION_OnKeyDownTrigger: number;
  4388. /**
  4389. * On key up
  4390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4391. */
  4392. static readonly ACTION_OnKeyUpTrigger: number;
  4393. /**
  4394. * Billboard mode will only apply to Y axis
  4395. */
  4396. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4397. /**
  4398. * Billboard mode will apply to all axes
  4399. */
  4400. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4401. /**
  4402. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4403. */
  4404. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4405. /**
  4406. * Gets or sets base Assets URL
  4407. */
  4408. static PARTICLES_BaseAssetsUrl: string;
  4409. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4410. * Test order :
  4411. * Is the bounding sphere outside the frustum ?
  4412. * If not, are the bounding box vertices outside the frustum ?
  4413. * It not, then the cullable object is in the frustum.
  4414. */
  4415. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4416. /** Culling strategy : Bounding Sphere Only.
  4417. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4418. * It's also less accurate than the standard because some not visible objects can still be selected.
  4419. * Test : is the bounding sphere outside the frustum ?
  4420. * If not, then the cullable object is in the frustum.
  4421. */
  4422. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4423. /** Culling strategy : Optimistic Inclusion.
  4424. * This in an inclusion test first, then the standard exclusion test.
  4425. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4426. * 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.
  4427. * Anyway, it's as accurate as the standard strategy.
  4428. * Test :
  4429. * Is the cullable object bounding sphere center in the frustum ?
  4430. * If not, apply the default culling strategy.
  4431. */
  4432. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4433. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4434. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4435. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4436. * 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.
  4437. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4438. * Test :
  4439. * Is the cullable object bounding sphere center in the frustum ?
  4440. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4441. */
  4442. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4443. /**
  4444. * No logging while loading
  4445. */
  4446. static readonly SCENELOADER_NO_LOGGING: number;
  4447. /**
  4448. * Minimal logging while loading
  4449. */
  4450. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4451. /**
  4452. * Summary logging while loading
  4453. */
  4454. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4455. /**
  4456. * Detailled logging while loading
  4457. */
  4458. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4459. }
  4460. }
  4461. declare module "babylonjs/Engines/IPipelineContext" {
  4462. /**
  4463. * Class used to store and describe the pipeline context associated with an effect
  4464. */
  4465. export interface IPipelineContext {
  4466. /**
  4467. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4468. */
  4469. isAsync: boolean;
  4470. /**
  4471. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4472. */
  4473. isReady: boolean;
  4474. /** @hidden */
  4475. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4476. }
  4477. }
  4478. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4479. /** @hidden */
  4480. export interface IShaderProcessor {
  4481. attributeProcessor?: (attribute: string) => string;
  4482. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4483. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4484. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4485. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4486. lineProcessor?: (line: string, isFragment: boolean) => string;
  4487. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4488. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4489. }
  4490. }
  4491. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4492. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4493. /** @hidden */
  4494. export interface ProcessingOptions {
  4495. defines: string[];
  4496. indexParameters: any;
  4497. isFragment: boolean;
  4498. shouldUseHighPrecisionShader: boolean;
  4499. supportsUniformBuffers: boolean;
  4500. shadersRepository: string;
  4501. includesShadersStore: {
  4502. [key: string]: string;
  4503. };
  4504. processor?: IShaderProcessor;
  4505. version: string;
  4506. platformName: string;
  4507. lookForClosingBracketForUniformBuffer?: boolean;
  4508. }
  4509. }
  4510. declare module "babylonjs/Misc/stringTools" {
  4511. /**
  4512. * Helper to manipulate strings
  4513. */
  4514. export class StringTools {
  4515. /**
  4516. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4517. * @param str Source string
  4518. * @param suffix Suffix to search for in the source string
  4519. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4520. */
  4521. static EndsWith(str: string, suffix: string): boolean;
  4522. /**
  4523. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4524. * @param str Source string
  4525. * @param suffix Suffix to search for in the source string
  4526. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4527. */
  4528. static StartsWith(str: string, suffix: string): boolean;
  4529. }
  4530. }
  4531. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4532. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4533. /** @hidden */
  4534. export class ShaderCodeNode {
  4535. line: string;
  4536. children: ShaderCodeNode[];
  4537. additionalDefineKey?: string;
  4538. additionalDefineValue?: string;
  4539. isValid(preprocessors: {
  4540. [key: string]: string;
  4541. }): boolean;
  4542. process(preprocessors: {
  4543. [key: string]: string;
  4544. }, options: ProcessingOptions): string;
  4545. }
  4546. }
  4547. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4548. /** @hidden */
  4549. export class ShaderCodeCursor {
  4550. private _lines;
  4551. lineIndex: number;
  4552. readonly currentLine: string;
  4553. readonly canRead: boolean;
  4554. lines: string[];
  4555. }
  4556. }
  4557. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4558. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4559. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4560. /** @hidden */
  4561. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4562. process(preprocessors: {
  4563. [key: string]: string;
  4564. }, options: ProcessingOptions): string;
  4565. }
  4566. }
  4567. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4568. /** @hidden */
  4569. export class ShaderDefineExpression {
  4570. isTrue(preprocessors: {
  4571. [key: string]: string;
  4572. }): boolean;
  4573. }
  4574. }
  4575. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4576. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4577. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4578. /** @hidden */
  4579. export class ShaderCodeTestNode extends ShaderCodeNode {
  4580. testExpression: ShaderDefineExpression;
  4581. isValid(preprocessors: {
  4582. [key: string]: string;
  4583. }): boolean;
  4584. }
  4585. }
  4586. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4587. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4588. /** @hidden */
  4589. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4590. define: string;
  4591. not: boolean;
  4592. constructor(define: string, not?: boolean);
  4593. isTrue(preprocessors: {
  4594. [key: string]: string;
  4595. }): boolean;
  4596. }
  4597. }
  4598. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4599. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4600. /** @hidden */
  4601. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4602. leftOperand: ShaderDefineExpression;
  4603. rightOperand: ShaderDefineExpression;
  4604. isTrue(preprocessors: {
  4605. [key: string]: string;
  4606. }): boolean;
  4607. }
  4608. }
  4609. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4610. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4611. /** @hidden */
  4612. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4613. leftOperand: ShaderDefineExpression;
  4614. rightOperand: ShaderDefineExpression;
  4615. isTrue(preprocessors: {
  4616. [key: string]: string;
  4617. }): boolean;
  4618. }
  4619. }
  4620. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  4621. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4622. /** @hidden */
  4623. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4624. define: string;
  4625. operand: string;
  4626. testValue: string;
  4627. constructor(define: string, operand: string, testValue: string);
  4628. isTrue(preprocessors: {
  4629. [key: string]: string;
  4630. }): boolean;
  4631. }
  4632. }
  4633. declare module "babylonjs/Misc/loadFileError" {
  4634. import { WebRequest } from "babylonjs/Misc/webRequest";
  4635. /**
  4636. * @ignore
  4637. * Application error to support additional information when loading a file
  4638. */
  4639. export class LoadFileError extends Error {
  4640. /** defines the optional web request */
  4641. request?: WebRequest | undefined;
  4642. private static _setPrototypeOf;
  4643. /**
  4644. * Creates a new LoadFileError
  4645. * @param message defines the message of the error
  4646. * @param request defines the optional web request
  4647. */
  4648. constructor(message: string,
  4649. /** defines the optional web request */
  4650. request?: WebRequest | undefined);
  4651. }
  4652. }
  4653. declare module "babylonjs/Offline/IOfflineProvider" {
  4654. /**
  4655. * Class used to enable access to offline support
  4656. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4657. */
  4658. export interface IOfflineProvider {
  4659. /**
  4660. * Gets a boolean indicating if scene must be saved in the database
  4661. */
  4662. enableSceneOffline: boolean;
  4663. /**
  4664. * Gets a boolean indicating if textures must be saved in the database
  4665. */
  4666. enableTexturesOffline: boolean;
  4667. /**
  4668. * Open the offline support and make it available
  4669. * @param successCallback defines the callback to call on success
  4670. * @param errorCallback defines the callback to call on error
  4671. */
  4672. open(successCallback: () => void, errorCallback: () => void): void;
  4673. /**
  4674. * Loads an image from the offline support
  4675. * @param url defines the url to load from
  4676. * @param image defines the target DOM image
  4677. */
  4678. loadImage(url: string, image: HTMLImageElement): void;
  4679. /**
  4680. * Loads a file from offline support
  4681. * @param url defines the URL to load from
  4682. * @param sceneLoaded defines a callback to call on success
  4683. * @param progressCallBack defines a callback to call when progress changed
  4684. * @param errorCallback defines a callback to call on error
  4685. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4686. */
  4687. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4688. }
  4689. }
  4690. declare module "babylonjs/Misc/filesInputStore" {
  4691. /**
  4692. * Class used to help managing file picking and drag'n'drop
  4693. * File Storage
  4694. */
  4695. export class FilesInputStore {
  4696. /**
  4697. * List of files ready to be loaded
  4698. */
  4699. static FilesToLoad: {
  4700. [key: string]: File;
  4701. };
  4702. }
  4703. }
  4704. declare module "babylonjs/Misc/retryStrategy" {
  4705. import { WebRequest } from "babylonjs/Misc/webRequest";
  4706. /**
  4707. * Class used to define a retry strategy when error happens while loading assets
  4708. */
  4709. export class RetryStrategy {
  4710. /**
  4711. * Function used to defines an exponential back off strategy
  4712. * @param maxRetries defines the maximum number of retries (3 by default)
  4713. * @param baseInterval defines the interval between retries
  4714. * @returns the strategy function to use
  4715. */
  4716. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4717. }
  4718. }
  4719. declare module "babylonjs/Misc/fileTools" {
  4720. import { WebRequest } from "babylonjs/Misc/webRequest";
  4721. import { Nullable } from "babylonjs/types";
  4722. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  4723. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  4724. /**
  4725. * @hidden
  4726. */
  4727. export class FileTools {
  4728. /**
  4729. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4730. */
  4731. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4732. /**
  4733. * Gets or sets the base URL to use to load assets
  4734. */
  4735. static BaseUrl: string;
  4736. /**
  4737. * Default behaviour for cors in the application.
  4738. * It can be a string if the expected behavior is identical in the entire app.
  4739. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4740. */
  4741. static CorsBehavior: string | ((url: string | string[]) => string);
  4742. /**
  4743. * Gets or sets a function used to pre-process url before using them to load assets
  4744. */
  4745. static PreprocessUrl: (url: string) => string;
  4746. /**
  4747. * Removes unwanted characters from an url
  4748. * @param url defines the url to clean
  4749. * @returns the cleaned url
  4750. */
  4751. private static _CleanUrl;
  4752. /**
  4753. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4754. * @param url define the url we are trying
  4755. * @param element define the dom element where to configure the cors policy
  4756. */
  4757. static SetCorsBehavior(url: string | string[], element: {
  4758. crossOrigin: string | null;
  4759. }): void;
  4760. /**
  4761. * Loads an image as an HTMLImageElement.
  4762. * @param input url string, ArrayBuffer, or Blob to load
  4763. * @param onLoad callback called when the image successfully loads
  4764. * @param onError callback called when the image fails to load
  4765. * @param offlineProvider offline provider for caching
  4766. * @returns the HTMLImageElement of the loaded image
  4767. */
  4768. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4769. /**
  4770. * Loads a file
  4771. * @param fileToLoad defines the file to load
  4772. * @param callback defines the callback to call when data is loaded
  4773. * @param progressCallBack defines the callback to call during loading process
  4774. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4775. * @returns a file request object
  4776. */
  4777. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4778. /**
  4779. * Loads a file
  4780. * @param url url string, ArrayBuffer, or Blob to load
  4781. * @param onSuccess callback called when the file successfully loads
  4782. * @param onProgress callback called while file is loading (if the server supports this mode)
  4783. * @param offlineProvider defines the offline provider for caching
  4784. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4785. * @param onError callback called when the file fails to load
  4786. * @returns a file request object
  4787. */
  4788. 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;
  4789. /**
  4790. * Checks if the loaded document was accessed via `file:`-Protocol.
  4791. * @returns boolean
  4792. */
  4793. static IsFileURL(): boolean;
  4794. }
  4795. }
  4796. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  4797. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4798. /** @hidden */
  4799. export class ShaderProcessor {
  4800. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4801. private static _ProcessPrecision;
  4802. private static _ExtractOperation;
  4803. private static _BuildSubExpression;
  4804. private static _BuildExpression;
  4805. private static _MoveCursorWithinIf;
  4806. private static _MoveCursor;
  4807. private static _EvaluatePreProcessors;
  4808. private static _PreparePreProcessors;
  4809. private static _ProcessShaderConversion;
  4810. private static _ProcessIncludes;
  4811. }
  4812. }
  4813. declare module "babylonjs/Maths/math.color" {
  4814. import { DeepImmutable, FloatArray } from "babylonjs/types";
  4815. /**
  4816. * Class used to hold a RBG color
  4817. */
  4818. export class Color3 {
  4819. /**
  4820. * Defines the red component (between 0 and 1, default is 0)
  4821. */
  4822. r: number;
  4823. /**
  4824. * Defines the green component (between 0 and 1, default is 0)
  4825. */
  4826. g: number;
  4827. /**
  4828. * Defines the blue component (between 0 and 1, default is 0)
  4829. */
  4830. b: number;
  4831. /**
  4832. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4833. * @param r defines the red component (between 0 and 1, default is 0)
  4834. * @param g defines the green component (between 0 and 1, default is 0)
  4835. * @param b defines the blue component (between 0 and 1, default is 0)
  4836. */
  4837. constructor(
  4838. /**
  4839. * Defines the red component (between 0 and 1, default is 0)
  4840. */
  4841. r?: number,
  4842. /**
  4843. * Defines the green component (between 0 and 1, default is 0)
  4844. */
  4845. g?: number,
  4846. /**
  4847. * Defines the blue component (between 0 and 1, default is 0)
  4848. */
  4849. b?: number);
  4850. /**
  4851. * Creates a string with the Color3 current values
  4852. * @returns the string representation of the Color3 object
  4853. */
  4854. toString(): string;
  4855. /**
  4856. * Returns the string "Color3"
  4857. * @returns "Color3"
  4858. */
  4859. getClassName(): string;
  4860. /**
  4861. * Compute the Color3 hash code
  4862. * @returns an unique number that can be used to hash Color3 objects
  4863. */
  4864. getHashCode(): number;
  4865. /**
  4866. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4867. * @param array defines the array where to store the r,g,b components
  4868. * @param index defines an optional index in the target array to define where to start storing values
  4869. * @returns the current Color3 object
  4870. */
  4871. toArray(array: FloatArray, index?: number): Color3;
  4872. /**
  4873. * Returns a new Color4 object from the current Color3 and the given alpha
  4874. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4875. * @returns a new Color4 object
  4876. */
  4877. toColor4(alpha?: number): Color4;
  4878. /**
  4879. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4880. * @returns the new array
  4881. */
  4882. asArray(): number[];
  4883. /**
  4884. * Returns the luminance value
  4885. * @returns a float value
  4886. */
  4887. toLuminance(): number;
  4888. /**
  4889. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4890. * @param otherColor defines the second operand
  4891. * @returns the new Color3 object
  4892. */
  4893. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4894. /**
  4895. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4896. * @param otherColor defines the second operand
  4897. * @param result defines the Color3 object where to store the result
  4898. * @returns the current Color3
  4899. */
  4900. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4901. /**
  4902. * Determines equality between Color3 objects
  4903. * @param otherColor defines the second operand
  4904. * @returns true if the rgb values are equal to the given ones
  4905. */
  4906. equals(otherColor: DeepImmutable<Color3>): boolean;
  4907. /**
  4908. * Determines equality between the current Color3 object and a set of r,b,g values
  4909. * @param r defines the red component to check
  4910. * @param g defines the green component to check
  4911. * @param b defines the blue component to check
  4912. * @returns true if the rgb values are equal to the given ones
  4913. */
  4914. equalsFloats(r: number, g: number, b: number): boolean;
  4915. /**
  4916. * Multiplies in place each rgb value by scale
  4917. * @param scale defines the scaling factor
  4918. * @returns the updated Color3
  4919. */
  4920. scale(scale: number): Color3;
  4921. /**
  4922. * Multiplies the rgb values by scale and stores the result into "result"
  4923. * @param scale defines the scaling factor
  4924. * @param result defines the Color3 object where to store the result
  4925. * @returns the unmodified current Color3
  4926. */
  4927. scaleToRef(scale: number, result: Color3): Color3;
  4928. /**
  4929. * Scale the current Color3 values by a factor and add the result to a given Color3
  4930. * @param scale defines the scale factor
  4931. * @param result defines color to store the result into
  4932. * @returns the unmodified current Color3
  4933. */
  4934. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4935. /**
  4936. * Clamps the rgb values by the min and max values and stores the result into "result"
  4937. * @param min defines minimum clamping value (default is 0)
  4938. * @param max defines maximum clamping value (default is 1)
  4939. * @param result defines color to store the result into
  4940. * @returns the original Color3
  4941. */
  4942. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4943. /**
  4944. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4945. * @param otherColor defines the second operand
  4946. * @returns the new Color3
  4947. */
  4948. add(otherColor: DeepImmutable<Color3>): Color3;
  4949. /**
  4950. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4951. * @param otherColor defines the second operand
  4952. * @param result defines Color3 object to store the result into
  4953. * @returns the unmodified current Color3
  4954. */
  4955. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4956. /**
  4957. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4958. * @param otherColor defines the second operand
  4959. * @returns the new Color3
  4960. */
  4961. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4962. /**
  4963. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4964. * @param otherColor defines the second operand
  4965. * @param result defines Color3 object to store the result into
  4966. * @returns the unmodified current Color3
  4967. */
  4968. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4969. /**
  4970. * Copy the current object
  4971. * @returns a new Color3 copied the current one
  4972. */
  4973. clone(): Color3;
  4974. /**
  4975. * Copies the rgb values from the source in the current Color3
  4976. * @param source defines the source Color3 object
  4977. * @returns the updated Color3 object
  4978. */
  4979. copyFrom(source: DeepImmutable<Color3>): Color3;
  4980. /**
  4981. * Updates the Color3 rgb values from the given floats
  4982. * @param r defines the red component to read from
  4983. * @param g defines the green component to read from
  4984. * @param b defines the blue component to read from
  4985. * @returns the current Color3 object
  4986. */
  4987. copyFromFloats(r: number, g: number, b: number): Color3;
  4988. /**
  4989. * Updates the Color3 rgb values from the given floats
  4990. * @param r defines the red component to read from
  4991. * @param g defines the green component to read from
  4992. * @param b defines the blue component to read from
  4993. * @returns the current Color3 object
  4994. */
  4995. set(r: number, g: number, b: number): Color3;
  4996. /**
  4997. * Compute the Color3 hexadecimal code as a string
  4998. * @returns a string containing the hexadecimal representation of the Color3 object
  4999. */
  5000. toHexString(): string;
  5001. /**
  5002. * Computes a new Color3 converted from the current one to linear space
  5003. * @returns a new Color3 object
  5004. */
  5005. toLinearSpace(): Color3;
  5006. /**
  5007. * Converts current color in rgb space to HSV values
  5008. * @returns a new color3 representing the HSV values
  5009. */
  5010. toHSV(): Color3;
  5011. /**
  5012. * Converts current color in rgb space to HSV values
  5013. * @param result defines the Color3 where to store the HSV values
  5014. */
  5015. toHSVToRef(result: Color3): void;
  5016. /**
  5017. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5018. * @param convertedColor defines the Color3 object where to store the linear space version
  5019. * @returns the unmodified Color3
  5020. */
  5021. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5022. /**
  5023. * Computes a new Color3 converted from the current one to gamma space
  5024. * @returns a new Color3 object
  5025. */
  5026. toGammaSpace(): Color3;
  5027. /**
  5028. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5029. * @param convertedColor defines the Color3 object where to store the gamma space version
  5030. * @returns the unmodified Color3
  5031. */
  5032. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5033. private static _BlackReadOnly;
  5034. /**
  5035. * Convert Hue, saturation and value to a Color3 (RGB)
  5036. * @param hue defines the hue
  5037. * @param saturation defines the saturation
  5038. * @param value defines the value
  5039. * @param result defines the Color3 where to store the RGB values
  5040. */
  5041. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5042. /**
  5043. * Creates a new Color3 from the string containing valid hexadecimal values
  5044. * @param hex defines a string containing valid hexadecimal values
  5045. * @returns a new Color3 object
  5046. */
  5047. static FromHexString(hex: string): Color3;
  5048. /**
  5049. * Creates a new Color3 from the starting index of the given array
  5050. * @param array defines the source array
  5051. * @param offset defines an offset in the source array
  5052. * @returns a new Color3 object
  5053. */
  5054. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5055. /**
  5056. * Creates a new Color3 from integer values (< 256)
  5057. * @param r defines the red component to read from (value between 0 and 255)
  5058. * @param g defines the green component to read from (value between 0 and 255)
  5059. * @param b defines the blue component to read from (value between 0 and 255)
  5060. * @returns a new Color3 object
  5061. */
  5062. static FromInts(r: number, g: number, b: number): Color3;
  5063. /**
  5064. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5065. * @param start defines the start Color3 value
  5066. * @param end defines the end Color3 value
  5067. * @param amount defines the gradient value between start and end
  5068. * @returns a new Color3 object
  5069. */
  5070. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5071. /**
  5072. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5073. * @param left defines the start value
  5074. * @param right defines the end value
  5075. * @param amount defines the gradient factor
  5076. * @param result defines the Color3 object where to store the result
  5077. */
  5078. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5079. /**
  5080. * Returns a Color3 value containing a red color
  5081. * @returns a new Color3 object
  5082. */
  5083. static Red(): Color3;
  5084. /**
  5085. * Returns a Color3 value containing a green color
  5086. * @returns a new Color3 object
  5087. */
  5088. static Green(): Color3;
  5089. /**
  5090. * Returns a Color3 value containing a blue color
  5091. * @returns a new Color3 object
  5092. */
  5093. static Blue(): Color3;
  5094. /**
  5095. * Returns a Color3 value containing a black color
  5096. * @returns a new Color3 object
  5097. */
  5098. static Black(): Color3;
  5099. /**
  5100. * Gets a Color3 value containing a black color that must not be updated
  5101. */
  5102. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5103. /**
  5104. * Returns a Color3 value containing a white color
  5105. * @returns a new Color3 object
  5106. */
  5107. static White(): Color3;
  5108. /**
  5109. * Returns a Color3 value containing a purple color
  5110. * @returns a new Color3 object
  5111. */
  5112. static Purple(): Color3;
  5113. /**
  5114. * Returns a Color3 value containing a magenta color
  5115. * @returns a new Color3 object
  5116. */
  5117. static Magenta(): Color3;
  5118. /**
  5119. * Returns a Color3 value containing a yellow color
  5120. * @returns a new Color3 object
  5121. */
  5122. static Yellow(): Color3;
  5123. /**
  5124. * Returns a Color3 value containing a gray color
  5125. * @returns a new Color3 object
  5126. */
  5127. static Gray(): Color3;
  5128. /**
  5129. * Returns a Color3 value containing a teal color
  5130. * @returns a new Color3 object
  5131. */
  5132. static Teal(): Color3;
  5133. /**
  5134. * Returns a Color3 value containing a random color
  5135. * @returns a new Color3 object
  5136. */
  5137. static Random(): Color3;
  5138. }
  5139. /**
  5140. * Class used to hold a RBGA color
  5141. */
  5142. export class Color4 {
  5143. /**
  5144. * Defines the red component (between 0 and 1, default is 0)
  5145. */
  5146. r: number;
  5147. /**
  5148. * Defines the green component (between 0 and 1, default is 0)
  5149. */
  5150. g: number;
  5151. /**
  5152. * Defines the blue component (between 0 and 1, default is 0)
  5153. */
  5154. b: number;
  5155. /**
  5156. * Defines the alpha component (between 0 and 1, default is 1)
  5157. */
  5158. a: number;
  5159. /**
  5160. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5161. * @param r defines the red component (between 0 and 1, default is 0)
  5162. * @param g defines the green component (between 0 and 1, default is 0)
  5163. * @param b defines the blue component (between 0 and 1, default is 0)
  5164. * @param a defines the alpha component (between 0 and 1, default is 1)
  5165. */
  5166. constructor(
  5167. /**
  5168. * Defines the red component (between 0 and 1, default is 0)
  5169. */
  5170. r?: number,
  5171. /**
  5172. * Defines the green component (between 0 and 1, default is 0)
  5173. */
  5174. g?: number,
  5175. /**
  5176. * Defines the blue component (between 0 and 1, default is 0)
  5177. */
  5178. b?: number,
  5179. /**
  5180. * Defines the alpha component (between 0 and 1, default is 1)
  5181. */
  5182. a?: number);
  5183. /**
  5184. * Adds in place the given Color4 values to the current Color4 object
  5185. * @param right defines the second operand
  5186. * @returns the current updated Color4 object
  5187. */
  5188. addInPlace(right: DeepImmutable<Color4>): Color4;
  5189. /**
  5190. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5191. * @returns the new array
  5192. */
  5193. asArray(): number[];
  5194. /**
  5195. * Stores from the starting index in the given array the Color4 successive values
  5196. * @param array defines the array where to store the r,g,b components
  5197. * @param index defines an optional index in the target array to define where to start storing values
  5198. * @returns the current Color4 object
  5199. */
  5200. toArray(array: number[], index?: number): Color4;
  5201. /**
  5202. * Determines equality between Color4 objects
  5203. * @param otherColor defines the second operand
  5204. * @returns true if the rgba values are equal to the given ones
  5205. */
  5206. equals(otherColor: DeepImmutable<Color4>): boolean;
  5207. /**
  5208. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5209. * @param right defines the second operand
  5210. * @returns a new Color4 object
  5211. */
  5212. add(right: DeepImmutable<Color4>): Color4;
  5213. /**
  5214. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5215. * @param right defines the second operand
  5216. * @returns a new Color4 object
  5217. */
  5218. subtract(right: DeepImmutable<Color4>): Color4;
  5219. /**
  5220. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5221. * @param right defines the second operand
  5222. * @param result defines the Color4 object where to store the result
  5223. * @returns the current Color4 object
  5224. */
  5225. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5226. /**
  5227. * Creates a new Color4 with the current Color4 values multiplied by scale
  5228. * @param scale defines the scaling factor to apply
  5229. * @returns a new Color4 object
  5230. */
  5231. scale(scale: number): Color4;
  5232. /**
  5233. * Multiplies the current Color4 values by scale and stores the result in "result"
  5234. * @param scale defines the scaling factor to apply
  5235. * @param result defines the Color4 object where to store the result
  5236. * @returns the current unmodified Color4
  5237. */
  5238. scaleToRef(scale: number, result: Color4): Color4;
  5239. /**
  5240. * Scale the current Color4 values by a factor and add the result to a given Color4
  5241. * @param scale defines the scale factor
  5242. * @param result defines the Color4 object where to store the result
  5243. * @returns the unmodified current Color4
  5244. */
  5245. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5246. /**
  5247. * Clamps the rgb values by the min and max values and stores the result into "result"
  5248. * @param min defines minimum clamping value (default is 0)
  5249. * @param max defines maximum clamping value (default is 1)
  5250. * @param result defines color to store the result into.
  5251. * @returns the cuurent Color4
  5252. */
  5253. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5254. /**
  5255. * Multipy an Color4 value by another and return a new Color4 object
  5256. * @param color defines the Color4 value to multiply by
  5257. * @returns a new Color4 object
  5258. */
  5259. multiply(color: Color4): Color4;
  5260. /**
  5261. * Multipy a Color4 value by another and push the result in a reference value
  5262. * @param color defines the Color4 value to multiply by
  5263. * @param result defines the Color4 to fill the result in
  5264. * @returns the result Color4
  5265. */
  5266. multiplyToRef(color: Color4, result: Color4): Color4;
  5267. /**
  5268. * Creates a string with the Color4 current values
  5269. * @returns the string representation of the Color4 object
  5270. */
  5271. toString(): string;
  5272. /**
  5273. * Returns the string "Color4"
  5274. * @returns "Color4"
  5275. */
  5276. getClassName(): string;
  5277. /**
  5278. * Compute the Color4 hash code
  5279. * @returns an unique number that can be used to hash Color4 objects
  5280. */
  5281. getHashCode(): number;
  5282. /**
  5283. * Creates a new Color4 copied from the current one
  5284. * @returns a new Color4 object
  5285. */
  5286. clone(): Color4;
  5287. /**
  5288. * Copies the given Color4 values into the current one
  5289. * @param source defines the source Color4 object
  5290. * @returns the current updated Color4 object
  5291. */
  5292. copyFrom(source: Color4): Color4;
  5293. /**
  5294. * Copies the given float values into the current one
  5295. * @param r defines the red component to read from
  5296. * @param g defines the green component to read from
  5297. * @param b defines the blue component to read from
  5298. * @param a defines the alpha component to read from
  5299. * @returns the current updated Color4 object
  5300. */
  5301. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5302. /**
  5303. * Copies the given float values into the current one
  5304. * @param r defines the red component to read from
  5305. * @param g defines the green component to read from
  5306. * @param b defines the blue component to read from
  5307. * @param a defines the alpha component to read from
  5308. * @returns the current updated Color4 object
  5309. */
  5310. set(r: number, g: number, b: number, a: number): Color4;
  5311. /**
  5312. * Compute the Color4 hexadecimal code as a string
  5313. * @returns a string containing the hexadecimal representation of the Color4 object
  5314. */
  5315. toHexString(): string;
  5316. /**
  5317. * Computes a new Color4 converted from the current one to linear space
  5318. * @returns a new Color4 object
  5319. */
  5320. toLinearSpace(): Color4;
  5321. /**
  5322. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5323. * @param convertedColor defines the Color4 object where to store the linear space version
  5324. * @returns the unmodified Color4
  5325. */
  5326. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5327. /**
  5328. * Computes a new Color4 converted from the current one to gamma space
  5329. * @returns a new Color4 object
  5330. */
  5331. toGammaSpace(): Color4;
  5332. /**
  5333. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5334. * @param convertedColor defines the Color4 object where to store the gamma space version
  5335. * @returns the unmodified Color4
  5336. */
  5337. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5338. /**
  5339. * Creates a new Color4 from the string containing valid hexadecimal values
  5340. * @param hex defines a string containing valid hexadecimal values
  5341. * @returns a new Color4 object
  5342. */
  5343. static FromHexString(hex: string): Color4;
  5344. /**
  5345. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5346. * @param left defines the start value
  5347. * @param right defines the end value
  5348. * @param amount defines the gradient factor
  5349. * @returns a new Color4 object
  5350. */
  5351. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5352. /**
  5353. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5354. * @param left defines the start value
  5355. * @param right defines the end value
  5356. * @param amount defines the gradient factor
  5357. * @param result defines the Color4 object where to store data
  5358. */
  5359. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5360. /**
  5361. * Creates a new Color4 from a Color3 and an alpha value
  5362. * @param color3 defines the source Color3 to read from
  5363. * @param alpha defines the alpha component (1.0 by default)
  5364. * @returns a new Color4 object
  5365. */
  5366. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5367. /**
  5368. * Creates a new Color4 from the starting index element of the given array
  5369. * @param array defines the source array to read from
  5370. * @param offset defines the offset in the source array
  5371. * @returns a new Color4 object
  5372. */
  5373. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5374. /**
  5375. * Creates a new Color3 from integer values (< 256)
  5376. * @param r defines the red component to read from (value between 0 and 255)
  5377. * @param g defines the green component to read from (value between 0 and 255)
  5378. * @param b defines the blue component to read from (value between 0 and 255)
  5379. * @param a defines the alpha component to read from (value between 0 and 255)
  5380. * @returns a new Color3 object
  5381. */
  5382. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5383. /**
  5384. * Check the content of a given array and convert it to an array containing RGBA data
  5385. * If the original array was already containing count * 4 values then it is returned directly
  5386. * @param colors defines the array to check
  5387. * @param count defines the number of RGBA data to expect
  5388. * @returns an array containing count * 4 values (RGBA)
  5389. */
  5390. static CheckColors4(colors: number[], count: number): number[];
  5391. }
  5392. /**
  5393. * @hidden
  5394. */
  5395. export class TmpColors {
  5396. static Color3: Color3[];
  5397. static Color4: Color4[];
  5398. }
  5399. }
  5400. declare module "babylonjs/Maths/sphericalPolynomial" {
  5401. import { Vector3 } from "babylonjs/Maths/math.vector";
  5402. import { Color3 } from "babylonjs/Maths/math.color";
  5403. /**
  5404. * Class representing spherical harmonics coefficients to the 3rd degree
  5405. */
  5406. export class SphericalHarmonics {
  5407. /**
  5408. * Defines whether or not the harmonics have been prescaled for rendering.
  5409. */
  5410. preScaled: boolean;
  5411. /**
  5412. * The l0,0 coefficients of the spherical harmonics
  5413. */
  5414. l00: Vector3;
  5415. /**
  5416. * The l1,-1 coefficients of the spherical harmonics
  5417. */
  5418. l1_1: Vector3;
  5419. /**
  5420. * The l1,0 coefficients of the spherical harmonics
  5421. */
  5422. l10: Vector3;
  5423. /**
  5424. * The l1,1 coefficients of the spherical harmonics
  5425. */
  5426. l11: Vector3;
  5427. /**
  5428. * The l2,-2 coefficients of the spherical harmonics
  5429. */
  5430. l2_2: Vector3;
  5431. /**
  5432. * The l2,-1 coefficients of the spherical harmonics
  5433. */
  5434. l2_1: Vector3;
  5435. /**
  5436. * The l2,0 coefficients of the spherical harmonics
  5437. */
  5438. l20: Vector3;
  5439. /**
  5440. * The l2,1 coefficients of the spherical harmonics
  5441. */
  5442. l21: Vector3;
  5443. /**
  5444. * The l2,2 coefficients of the spherical harmonics
  5445. */
  5446. l22: Vector3;
  5447. /**
  5448. * Adds a light to the spherical harmonics
  5449. * @param direction the direction of the light
  5450. * @param color the color of the light
  5451. * @param deltaSolidAngle the delta solid angle of the light
  5452. */
  5453. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5454. /**
  5455. * Scales the spherical harmonics by the given amount
  5456. * @param scale the amount to scale
  5457. */
  5458. scaleInPlace(scale: number): void;
  5459. /**
  5460. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5461. *
  5462. * ```
  5463. * E_lm = A_l * L_lm
  5464. * ```
  5465. *
  5466. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5467. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5468. * the scaling factors are given in equation 9.
  5469. */
  5470. convertIncidentRadianceToIrradiance(): void;
  5471. /**
  5472. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5473. *
  5474. * ```
  5475. * L = (1/pi) * E * rho
  5476. * ```
  5477. *
  5478. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5479. */
  5480. convertIrradianceToLambertianRadiance(): void;
  5481. /**
  5482. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5483. * required operations at run time.
  5484. *
  5485. * This is simply done by scaling back the SH with Ylm constants parameter.
  5486. * The trigonometric part being applied by the shader at run time.
  5487. */
  5488. preScaleForRendering(): void;
  5489. /**
  5490. * Constructs a spherical harmonics from an array.
  5491. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5492. * @returns the spherical harmonics
  5493. */
  5494. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5495. /**
  5496. * Gets the spherical harmonics from polynomial
  5497. * @param polynomial the spherical polynomial
  5498. * @returns the spherical harmonics
  5499. */
  5500. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5501. }
  5502. /**
  5503. * Class representing spherical polynomial coefficients to the 3rd degree
  5504. */
  5505. export class SphericalPolynomial {
  5506. private _harmonics;
  5507. /**
  5508. * The spherical harmonics used to create the polynomials.
  5509. */
  5510. readonly preScaledHarmonics: SphericalHarmonics;
  5511. /**
  5512. * The x coefficients of the spherical polynomial
  5513. */
  5514. x: Vector3;
  5515. /**
  5516. * The y coefficients of the spherical polynomial
  5517. */
  5518. y: Vector3;
  5519. /**
  5520. * The z coefficients of the spherical polynomial
  5521. */
  5522. z: Vector3;
  5523. /**
  5524. * The xx coefficients of the spherical polynomial
  5525. */
  5526. xx: Vector3;
  5527. /**
  5528. * The yy coefficients of the spherical polynomial
  5529. */
  5530. yy: Vector3;
  5531. /**
  5532. * The zz coefficients of the spherical polynomial
  5533. */
  5534. zz: Vector3;
  5535. /**
  5536. * The xy coefficients of the spherical polynomial
  5537. */
  5538. xy: Vector3;
  5539. /**
  5540. * The yz coefficients of the spherical polynomial
  5541. */
  5542. yz: Vector3;
  5543. /**
  5544. * The zx coefficients of the spherical polynomial
  5545. */
  5546. zx: Vector3;
  5547. /**
  5548. * Adds an ambient color to the spherical polynomial
  5549. * @param color the color to add
  5550. */
  5551. addAmbient(color: Color3): void;
  5552. /**
  5553. * Scales the spherical polynomial by the given amount
  5554. * @param scale the amount to scale
  5555. */
  5556. scaleInPlace(scale: number): void;
  5557. /**
  5558. * Gets the spherical polynomial from harmonics
  5559. * @param harmonics the spherical harmonics
  5560. * @returns the spherical polynomial
  5561. */
  5562. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5563. /**
  5564. * Constructs a spherical polynomial from an array.
  5565. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5566. * @returns the spherical polynomial
  5567. */
  5568. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5569. }
  5570. }
  5571. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5572. /**
  5573. * Define options used to create a render target texture
  5574. */
  5575. export class RenderTargetCreationOptions {
  5576. /**
  5577. * Specifies is mipmaps must be generated
  5578. */
  5579. generateMipMaps?: boolean;
  5580. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5581. generateDepthBuffer?: boolean;
  5582. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5583. generateStencilBuffer?: boolean;
  5584. /** Defines texture type (int by default) */
  5585. type?: number;
  5586. /** Defines sampling mode (trilinear by default) */
  5587. samplingMode?: number;
  5588. /** Defines format (RGBA by default) */
  5589. format?: number;
  5590. }
  5591. }
  5592. declare module "babylonjs/States/alphaCullingState" {
  5593. /**
  5594. * @hidden
  5595. **/
  5596. export class _AlphaState {
  5597. private _isAlphaBlendDirty;
  5598. private _isBlendFunctionParametersDirty;
  5599. private _isBlendEquationParametersDirty;
  5600. private _isBlendConstantsDirty;
  5601. private _alphaBlend;
  5602. private _blendFunctionParameters;
  5603. private _blendEquationParameters;
  5604. private _blendConstants;
  5605. /**
  5606. * Initializes the state.
  5607. */
  5608. constructor();
  5609. readonly isDirty: boolean;
  5610. alphaBlend: boolean;
  5611. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5612. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5613. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5614. reset(): void;
  5615. apply(gl: WebGLRenderingContext): void;
  5616. }
  5617. }
  5618. declare module "babylonjs/States/depthCullingState" {
  5619. import { Nullable } from "babylonjs/types";
  5620. /**
  5621. * @hidden
  5622. **/
  5623. export class _DepthCullingState {
  5624. private _isDepthTestDirty;
  5625. private _isDepthMaskDirty;
  5626. private _isDepthFuncDirty;
  5627. private _isCullFaceDirty;
  5628. private _isCullDirty;
  5629. private _isZOffsetDirty;
  5630. private _isFrontFaceDirty;
  5631. private _depthTest;
  5632. private _depthMask;
  5633. private _depthFunc;
  5634. private _cull;
  5635. private _cullFace;
  5636. private _zOffset;
  5637. private _frontFace;
  5638. /**
  5639. * Initializes the state.
  5640. */
  5641. constructor();
  5642. readonly isDirty: boolean;
  5643. zOffset: number;
  5644. cullFace: Nullable<number>;
  5645. cull: Nullable<boolean>;
  5646. depthFunc: Nullable<number>;
  5647. depthMask: boolean;
  5648. depthTest: boolean;
  5649. frontFace: Nullable<number>;
  5650. reset(): void;
  5651. apply(gl: WebGLRenderingContext): void;
  5652. }
  5653. }
  5654. declare module "babylonjs/States/stencilState" {
  5655. /**
  5656. * @hidden
  5657. **/
  5658. export class _StencilState {
  5659. /** 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 */
  5660. static readonly ALWAYS: number;
  5661. /** Passed to stencilOperation to specify that stencil value must be kept */
  5662. static readonly KEEP: number;
  5663. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5664. static readonly REPLACE: number;
  5665. private _isStencilTestDirty;
  5666. private _isStencilMaskDirty;
  5667. private _isStencilFuncDirty;
  5668. private _isStencilOpDirty;
  5669. private _stencilTest;
  5670. private _stencilMask;
  5671. private _stencilFunc;
  5672. private _stencilFuncRef;
  5673. private _stencilFuncMask;
  5674. private _stencilOpStencilFail;
  5675. private _stencilOpDepthFail;
  5676. private _stencilOpStencilDepthPass;
  5677. readonly isDirty: boolean;
  5678. stencilFunc: number;
  5679. stencilFuncRef: number;
  5680. stencilFuncMask: number;
  5681. stencilOpStencilFail: number;
  5682. stencilOpDepthFail: number;
  5683. stencilOpStencilDepthPass: number;
  5684. stencilMask: number;
  5685. stencilTest: boolean;
  5686. constructor();
  5687. reset(): void;
  5688. apply(gl: WebGLRenderingContext): void;
  5689. }
  5690. }
  5691. declare module "babylonjs/States/index" {
  5692. export * from "babylonjs/States/alphaCullingState";
  5693. export * from "babylonjs/States/depthCullingState";
  5694. export * from "babylonjs/States/stencilState";
  5695. }
  5696. declare module "babylonjs/Instrumentation/timeToken" {
  5697. import { Nullable } from "babylonjs/types";
  5698. /**
  5699. * @hidden
  5700. **/
  5701. export class _TimeToken {
  5702. _startTimeQuery: Nullable<WebGLQuery>;
  5703. _endTimeQuery: Nullable<WebGLQuery>;
  5704. _timeElapsedQuery: Nullable<WebGLQuery>;
  5705. _timeElapsedQueryEnded: boolean;
  5706. }
  5707. }
  5708. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5709. /**
  5710. * Class used to evalaute queries containing `and` and `or` operators
  5711. */
  5712. export class AndOrNotEvaluator {
  5713. /**
  5714. * Evaluate a query
  5715. * @param query defines the query to evaluate
  5716. * @param evaluateCallback defines the callback used to filter result
  5717. * @returns true if the query matches
  5718. */
  5719. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5720. private static _HandleParenthesisContent;
  5721. private static _SimplifyNegation;
  5722. }
  5723. }
  5724. declare module "babylonjs/Misc/tags" {
  5725. /**
  5726. * Class used to store custom tags
  5727. */
  5728. export class Tags {
  5729. /**
  5730. * Adds support for tags on the given object
  5731. * @param obj defines the object to use
  5732. */
  5733. static EnableFor(obj: any): void;
  5734. /**
  5735. * Removes tags support
  5736. * @param obj defines the object to use
  5737. */
  5738. static DisableFor(obj: any): void;
  5739. /**
  5740. * Gets a boolean indicating if the given object has tags
  5741. * @param obj defines the object to use
  5742. * @returns a boolean
  5743. */
  5744. static HasTags(obj: any): boolean;
  5745. /**
  5746. * Gets the tags available on a given object
  5747. * @param obj defines the object to use
  5748. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5749. * @returns the tags
  5750. */
  5751. static GetTags(obj: any, asString?: boolean): any;
  5752. /**
  5753. * Adds tags to an object
  5754. * @param obj defines the object to use
  5755. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5756. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5757. */
  5758. static AddTagsTo(obj: any, tagsString: string): void;
  5759. /**
  5760. * @hidden
  5761. */
  5762. static _AddTagTo(obj: any, tag: string): void;
  5763. /**
  5764. * Removes specific tags from a specific object
  5765. * @param obj defines the object to use
  5766. * @param tagsString defines the tags to remove
  5767. */
  5768. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5769. /**
  5770. * @hidden
  5771. */
  5772. static _RemoveTagFrom(obj: any, tag: string): void;
  5773. /**
  5774. * Defines if tags hosted on an object match a given query
  5775. * @param obj defines the object to use
  5776. * @param tagsQuery defines the tag query
  5777. * @returns a boolean
  5778. */
  5779. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5780. }
  5781. }
  5782. declare module "babylonjs/Maths/math.path" {
  5783. import { DeepImmutable, Nullable } from "babylonjs/types";
  5784. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5785. /**
  5786. * Defines potential orientation for back face culling
  5787. */
  5788. export enum Orientation {
  5789. /**
  5790. * Clockwise
  5791. */
  5792. CW = 0,
  5793. /** Counter clockwise */
  5794. CCW = 1
  5795. }
  5796. /** Class used to represent a Bezier curve */
  5797. export class BezierCurve {
  5798. /**
  5799. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5800. * @param t defines the time
  5801. * @param x1 defines the left coordinate on X axis
  5802. * @param y1 defines the left coordinate on Y axis
  5803. * @param x2 defines the right coordinate on X axis
  5804. * @param y2 defines the right coordinate on Y axis
  5805. * @returns the interpolated value
  5806. */
  5807. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5808. }
  5809. /**
  5810. * Defines angle representation
  5811. */
  5812. export class Angle {
  5813. private _radians;
  5814. /**
  5815. * Creates an Angle object of "radians" radians (float).
  5816. * @param radians the angle in radians
  5817. */
  5818. constructor(radians: number);
  5819. /**
  5820. * Get value in degrees
  5821. * @returns the Angle value in degrees (float)
  5822. */
  5823. degrees(): number;
  5824. /**
  5825. * Get value in radians
  5826. * @returns the Angle value in radians (float)
  5827. */
  5828. radians(): number;
  5829. /**
  5830. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5831. * @param a defines first vector
  5832. * @param b defines second vector
  5833. * @returns a new Angle
  5834. */
  5835. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5836. /**
  5837. * Gets a new Angle object from the given float in radians
  5838. * @param radians defines the angle value in radians
  5839. * @returns a new Angle
  5840. */
  5841. static FromRadians(radians: number): Angle;
  5842. /**
  5843. * Gets a new Angle object from the given float in degrees
  5844. * @param degrees defines the angle value in degrees
  5845. * @returns a new Angle
  5846. */
  5847. static FromDegrees(degrees: number): Angle;
  5848. }
  5849. /**
  5850. * This represents an arc in a 2d space.
  5851. */
  5852. export class Arc2 {
  5853. /** Defines the start point of the arc */
  5854. startPoint: Vector2;
  5855. /** Defines the mid point of the arc */
  5856. midPoint: Vector2;
  5857. /** Defines the end point of the arc */
  5858. endPoint: Vector2;
  5859. /**
  5860. * Defines the center point of the arc.
  5861. */
  5862. centerPoint: Vector2;
  5863. /**
  5864. * Defines the radius of the arc.
  5865. */
  5866. radius: number;
  5867. /**
  5868. * Defines the angle of the arc (from mid point to end point).
  5869. */
  5870. angle: Angle;
  5871. /**
  5872. * Defines the start angle of the arc (from start point to middle point).
  5873. */
  5874. startAngle: Angle;
  5875. /**
  5876. * Defines the orientation of the arc (clock wise/counter clock wise).
  5877. */
  5878. orientation: Orientation;
  5879. /**
  5880. * Creates an Arc object from the three given points : start, middle and end.
  5881. * @param startPoint Defines the start point of the arc
  5882. * @param midPoint Defines the midlle point of the arc
  5883. * @param endPoint Defines the end point of the arc
  5884. */
  5885. constructor(
  5886. /** Defines the start point of the arc */
  5887. startPoint: Vector2,
  5888. /** Defines the mid point of the arc */
  5889. midPoint: Vector2,
  5890. /** Defines the end point of the arc */
  5891. endPoint: Vector2);
  5892. }
  5893. /**
  5894. * Represents a 2D path made up of multiple 2D points
  5895. */
  5896. export class Path2 {
  5897. private _points;
  5898. private _length;
  5899. /**
  5900. * If the path start and end point are the same
  5901. */
  5902. closed: boolean;
  5903. /**
  5904. * Creates a Path2 object from the starting 2D coordinates x and y.
  5905. * @param x the starting points x value
  5906. * @param y the starting points y value
  5907. */
  5908. constructor(x: number, y: number);
  5909. /**
  5910. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5911. * @param x the added points x value
  5912. * @param y the added points y value
  5913. * @returns the updated Path2.
  5914. */
  5915. addLineTo(x: number, y: number): Path2;
  5916. /**
  5917. * 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.
  5918. * @param midX middle point x value
  5919. * @param midY middle point y value
  5920. * @param endX end point x value
  5921. * @param endY end point y value
  5922. * @param numberOfSegments (default: 36)
  5923. * @returns the updated Path2.
  5924. */
  5925. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5926. /**
  5927. * Closes the Path2.
  5928. * @returns the Path2.
  5929. */
  5930. close(): Path2;
  5931. /**
  5932. * Gets the sum of the distance between each sequential point in the path
  5933. * @returns the Path2 total length (float).
  5934. */
  5935. length(): number;
  5936. /**
  5937. * Gets the points which construct the path
  5938. * @returns the Path2 internal array of points.
  5939. */
  5940. getPoints(): Vector2[];
  5941. /**
  5942. * Retreives the point at the distance aways from the starting point
  5943. * @param normalizedLengthPosition the length along the path to retreive the point from
  5944. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5945. */
  5946. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5947. /**
  5948. * Creates a new path starting from an x and y position
  5949. * @param x starting x value
  5950. * @param y starting y value
  5951. * @returns a new Path2 starting at the coordinates (x, y).
  5952. */
  5953. static StartingAt(x: number, y: number): Path2;
  5954. }
  5955. /**
  5956. * Represents a 3D path made up of multiple 3D points
  5957. */
  5958. export class Path3D {
  5959. /**
  5960. * an array of Vector3, the curve axis of the Path3D
  5961. */
  5962. path: Vector3[];
  5963. private _curve;
  5964. private _distances;
  5965. private _tangents;
  5966. private _normals;
  5967. private _binormals;
  5968. private _raw;
  5969. /**
  5970. * new Path3D(path, normal, raw)
  5971. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5972. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5973. * @param path an array of Vector3, the curve axis of the Path3D
  5974. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5975. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5976. */
  5977. constructor(
  5978. /**
  5979. * an array of Vector3, the curve axis of the Path3D
  5980. */
  5981. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5982. /**
  5983. * Returns the Path3D array of successive Vector3 designing its curve.
  5984. * @returns the Path3D array of successive Vector3 designing its curve.
  5985. */
  5986. getCurve(): Vector3[];
  5987. /**
  5988. * Returns an array populated with tangent vectors on each Path3D curve point.
  5989. * @returns an array populated with tangent vectors on each Path3D curve point.
  5990. */
  5991. getTangents(): Vector3[];
  5992. /**
  5993. * Returns an array populated with normal vectors on each Path3D curve point.
  5994. * @returns an array populated with normal vectors on each Path3D curve point.
  5995. */
  5996. getNormals(): Vector3[];
  5997. /**
  5998. * Returns an array populated with binormal vectors on each Path3D curve point.
  5999. * @returns an array populated with binormal vectors on each Path3D curve point.
  6000. */
  6001. getBinormals(): Vector3[];
  6002. /**
  6003. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  6004. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  6005. */
  6006. getDistances(): number[];
  6007. /**
  6008. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  6009. * @param path path which all values are copied into the curves points
  6010. * @param firstNormal which should be projected onto the curve
  6011. * @returns the same object updated.
  6012. */
  6013. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  6014. private _compute;
  6015. private _getFirstNonNullVector;
  6016. private _getLastNonNullVector;
  6017. private _normalVector;
  6018. }
  6019. /**
  6020. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6021. * A Curve3 is designed from a series of successive Vector3.
  6022. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  6023. */
  6024. export class Curve3 {
  6025. private _points;
  6026. private _length;
  6027. /**
  6028. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  6029. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  6030. * @param v1 (Vector3) the control point
  6031. * @param v2 (Vector3) the end point of the Quadratic Bezier
  6032. * @param nbPoints (integer) the wanted number of points in the curve
  6033. * @returns the created Curve3
  6034. */
  6035. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6036. /**
  6037. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6038. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6039. * @param v1 (Vector3) the first control point
  6040. * @param v2 (Vector3) the second control point
  6041. * @param v3 (Vector3) the end point of the Cubic Bezier
  6042. * @param nbPoints (integer) the wanted number of points in the curve
  6043. * @returns the created Curve3
  6044. */
  6045. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6046. /**
  6047. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6048. * @param p1 (Vector3) the origin point of the Hermite Spline
  6049. * @param t1 (Vector3) the tangent vector at the origin point
  6050. * @param p2 (Vector3) the end point of the Hermite Spline
  6051. * @param t2 (Vector3) the tangent vector at the end point
  6052. * @param nbPoints (integer) the wanted number of points in the curve
  6053. * @returns the created Curve3
  6054. */
  6055. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6056. /**
  6057. * Returns a Curve3 object along a CatmullRom Spline curve :
  6058. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6059. * @param nbPoints (integer) the wanted number of points between each curve control points
  6060. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6061. * @returns the created Curve3
  6062. */
  6063. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6064. /**
  6065. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6066. * A Curve3 is designed from a series of successive Vector3.
  6067. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6068. * @param points points which make up the curve
  6069. */
  6070. constructor(points: Vector3[]);
  6071. /**
  6072. * @returns the Curve3 stored array of successive Vector3
  6073. */
  6074. getPoints(): Vector3[];
  6075. /**
  6076. * @returns the computed length (float) of the curve.
  6077. */
  6078. length(): number;
  6079. /**
  6080. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6081. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6082. * curveA and curveB keep unchanged.
  6083. * @param curve the curve to continue from this curve
  6084. * @returns the newly constructed curve
  6085. */
  6086. continue(curve: DeepImmutable<Curve3>): Curve3;
  6087. private _computeLength;
  6088. }
  6089. }
  6090. declare module "babylonjs/Animations/easing" {
  6091. /**
  6092. * This represents the main contract an easing function should follow.
  6093. * Easing functions are used throughout the animation system.
  6094. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6095. */
  6096. export interface IEasingFunction {
  6097. /**
  6098. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6099. * of the easing function.
  6100. * The link below provides some of the most common examples of easing functions.
  6101. * @see https://easings.net/
  6102. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6103. * @returns the corresponding value on the curve defined by the easing function
  6104. */
  6105. ease(gradient: number): number;
  6106. }
  6107. /**
  6108. * Base class used for every default easing function.
  6109. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6110. */
  6111. export class EasingFunction implements IEasingFunction {
  6112. /**
  6113. * Interpolation follows the mathematical formula associated with the easing function.
  6114. */
  6115. static readonly EASINGMODE_EASEIN: number;
  6116. /**
  6117. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6118. */
  6119. static readonly EASINGMODE_EASEOUT: number;
  6120. /**
  6121. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6122. */
  6123. static readonly EASINGMODE_EASEINOUT: number;
  6124. private _easingMode;
  6125. /**
  6126. * Sets the easing mode of the current function.
  6127. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6128. */
  6129. setEasingMode(easingMode: number): void;
  6130. /**
  6131. * Gets the current easing mode.
  6132. * @returns the easing mode
  6133. */
  6134. getEasingMode(): number;
  6135. /**
  6136. * @hidden
  6137. */
  6138. easeInCore(gradient: number): number;
  6139. /**
  6140. * Given an input gradient between 0 and 1, this returns the corresponding value
  6141. * of the easing function.
  6142. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6143. * @returns the corresponding value on the curve defined by the easing function
  6144. */
  6145. ease(gradient: number): number;
  6146. }
  6147. /**
  6148. * Easing function with a circle shape (see link below).
  6149. * @see https://easings.net/#easeInCirc
  6150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6151. */
  6152. export class CircleEase extends EasingFunction implements IEasingFunction {
  6153. /** @hidden */
  6154. easeInCore(gradient: number): number;
  6155. }
  6156. /**
  6157. * Easing function with a ease back shape (see link below).
  6158. * @see https://easings.net/#easeInBack
  6159. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6160. */
  6161. export class BackEase extends EasingFunction implements IEasingFunction {
  6162. /** Defines the amplitude of the function */
  6163. amplitude: number;
  6164. /**
  6165. * Instantiates a back ease easing
  6166. * @see https://easings.net/#easeInBack
  6167. * @param amplitude Defines the amplitude of the function
  6168. */
  6169. constructor(
  6170. /** Defines the amplitude of the function */
  6171. amplitude?: number);
  6172. /** @hidden */
  6173. easeInCore(gradient: number): number;
  6174. }
  6175. /**
  6176. * Easing function with a bouncing shape (see link below).
  6177. * @see https://easings.net/#easeInBounce
  6178. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6179. */
  6180. export class BounceEase extends EasingFunction implements IEasingFunction {
  6181. /** Defines the number of bounces */
  6182. bounces: number;
  6183. /** Defines the amplitude of the bounce */
  6184. bounciness: number;
  6185. /**
  6186. * Instantiates a bounce easing
  6187. * @see https://easings.net/#easeInBounce
  6188. * @param bounces Defines the number of bounces
  6189. * @param bounciness Defines the amplitude of the bounce
  6190. */
  6191. constructor(
  6192. /** Defines the number of bounces */
  6193. bounces?: number,
  6194. /** Defines the amplitude of the bounce */
  6195. bounciness?: number);
  6196. /** @hidden */
  6197. easeInCore(gradient: number): number;
  6198. }
  6199. /**
  6200. * Easing function with a power of 3 shape (see link below).
  6201. * @see https://easings.net/#easeInCubic
  6202. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6203. */
  6204. export class CubicEase extends EasingFunction implements IEasingFunction {
  6205. /** @hidden */
  6206. easeInCore(gradient: number): number;
  6207. }
  6208. /**
  6209. * Easing function with an elastic shape (see link below).
  6210. * @see https://easings.net/#easeInElastic
  6211. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6212. */
  6213. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6214. /** Defines the number of oscillations*/
  6215. oscillations: number;
  6216. /** Defines the amplitude of the oscillations*/
  6217. springiness: number;
  6218. /**
  6219. * Instantiates an elastic easing function
  6220. * @see https://easings.net/#easeInElastic
  6221. * @param oscillations Defines the number of oscillations
  6222. * @param springiness Defines the amplitude of the oscillations
  6223. */
  6224. constructor(
  6225. /** Defines the number of oscillations*/
  6226. oscillations?: number,
  6227. /** Defines the amplitude of the oscillations*/
  6228. springiness?: number);
  6229. /** @hidden */
  6230. easeInCore(gradient: number): number;
  6231. }
  6232. /**
  6233. * Easing function with an exponential shape (see link below).
  6234. * @see https://easings.net/#easeInExpo
  6235. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6236. */
  6237. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6238. /** Defines the exponent of the function */
  6239. exponent: number;
  6240. /**
  6241. * Instantiates an exponential easing function
  6242. * @see https://easings.net/#easeInExpo
  6243. * @param exponent Defines the exponent of the function
  6244. */
  6245. constructor(
  6246. /** Defines the exponent of the function */
  6247. exponent?: number);
  6248. /** @hidden */
  6249. easeInCore(gradient: number): number;
  6250. }
  6251. /**
  6252. * Easing function with a power shape (see link below).
  6253. * @see https://easings.net/#easeInQuad
  6254. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6255. */
  6256. export class PowerEase extends EasingFunction implements IEasingFunction {
  6257. /** Defines the power of the function */
  6258. power: number;
  6259. /**
  6260. * Instantiates an power base easing function
  6261. * @see https://easings.net/#easeInQuad
  6262. * @param power Defines the power of the function
  6263. */
  6264. constructor(
  6265. /** Defines the power of the function */
  6266. power?: number);
  6267. /** @hidden */
  6268. easeInCore(gradient: number): number;
  6269. }
  6270. /**
  6271. * Easing function with a power of 2 shape (see link below).
  6272. * @see https://easings.net/#easeInQuad
  6273. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6274. */
  6275. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6276. /** @hidden */
  6277. easeInCore(gradient: number): number;
  6278. }
  6279. /**
  6280. * Easing function with a power of 4 shape (see link below).
  6281. * @see https://easings.net/#easeInQuart
  6282. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6283. */
  6284. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6285. /** @hidden */
  6286. easeInCore(gradient: number): number;
  6287. }
  6288. /**
  6289. * Easing function with a power of 5 shape (see link below).
  6290. * @see https://easings.net/#easeInQuint
  6291. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6292. */
  6293. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6294. /** @hidden */
  6295. easeInCore(gradient: number): number;
  6296. }
  6297. /**
  6298. * Easing function with a sin shape (see link below).
  6299. * @see https://easings.net/#easeInSine
  6300. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6301. */
  6302. export class SineEase extends EasingFunction implements IEasingFunction {
  6303. /** @hidden */
  6304. easeInCore(gradient: number): number;
  6305. }
  6306. /**
  6307. * Easing function with a bezier shape (see link below).
  6308. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6309. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6310. */
  6311. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6312. /** Defines the x component of the start tangent in the bezier curve */
  6313. x1: number;
  6314. /** Defines the y component of the start tangent in the bezier curve */
  6315. y1: number;
  6316. /** Defines the x component of the end tangent in the bezier curve */
  6317. x2: number;
  6318. /** Defines the y component of the end tangent in the bezier curve */
  6319. y2: number;
  6320. /**
  6321. * Instantiates a bezier function
  6322. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6323. * @param x1 Defines the x component of the start tangent in the bezier curve
  6324. * @param y1 Defines the y component of the start tangent in the bezier curve
  6325. * @param x2 Defines the x component of the end tangent in the bezier curve
  6326. * @param y2 Defines the y component of the end tangent in the bezier curve
  6327. */
  6328. constructor(
  6329. /** Defines the x component of the start tangent in the bezier curve */
  6330. x1?: number,
  6331. /** Defines the y component of the start tangent in the bezier curve */
  6332. y1?: number,
  6333. /** Defines the x component of the end tangent in the bezier curve */
  6334. x2?: number,
  6335. /** Defines the y component of the end tangent in the bezier curve */
  6336. y2?: number);
  6337. /** @hidden */
  6338. easeInCore(gradient: number): number;
  6339. }
  6340. }
  6341. declare module "babylonjs/Animations/animationKey" {
  6342. /**
  6343. * Defines an interface which represents an animation key frame
  6344. */
  6345. export interface IAnimationKey {
  6346. /**
  6347. * Frame of the key frame
  6348. */
  6349. frame: number;
  6350. /**
  6351. * Value at the specifies key frame
  6352. */
  6353. value: any;
  6354. /**
  6355. * The input tangent for the cubic hermite spline
  6356. */
  6357. inTangent?: any;
  6358. /**
  6359. * The output tangent for the cubic hermite spline
  6360. */
  6361. outTangent?: any;
  6362. /**
  6363. * The animation interpolation type
  6364. */
  6365. interpolation?: AnimationKeyInterpolation;
  6366. }
  6367. /**
  6368. * Enum for the animation key frame interpolation type
  6369. */
  6370. export enum AnimationKeyInterpolation {
  6371. /**
  6372. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6373. */
  6374. STEP = 1
  6375. }
  6376. }
  6377. declare module "babylonjs/Animations/animationRange" {
  6378. /**
  6379. * Represents the range of an animation
  6380. */
  6381. export class AnimationRange {
  6382. /**The name of the animation range**/
  6383. name: string;
  6384. /**The starting frame of the animation */
  6385. from: number;
  6386. /**The ending frame of the animation*/
  6387. to: number;
  6388. /**
  6389. * Initializes the range of an animation
  6390. * @param name The name of the animation range
  6391. * @param from The starting frame of the animation
  6392. * @param to The ending frame of the animation
  6393. */
  6394. constructor(
  6395. /**The name of the animation range**/
  6396. name: string,
  6397. /**The starting frame of the animation */
  6398. from: number,
  6399. /**The ending frame of the animation*/
  6400. to: number);
  6401. /**
  6402. * Makes a copy of the animation range
  6403. * @returns A copy of the animation range
  6404. */
  6405. clone(): AnimationRange;
  6406. }
  6407. }
  6408. declare module "babylonjs/Animations/animationEvent" {
  6409. /**
  6410. * Composed of a frame, and an action function
  6411. */
  6412. export class AnimationEvent {
  6413. /** The frame for which the event is triggered **/
  6414. frame: number;
  6415. /** The event to perform when triggered **/
  6416. action: (currentFrame: number) => void;
  6417. /** Specifies if the event should be triggered only once**/
  6418. onlyOnce?: boolean | undefined;
  6419. /**
  6420. * Specifies if the animation event is done
  6421. */
  6422. isDone: boolean;
  6423. /**
  6424. * Initializes the animation event
  6425. * @param frame The frame for which the event is triggered
  6426. * @param action The event to perform when triggered
  6427. * @param onlyOnce Specifies if the event should be triggered only once
  6428. */
  6429. constructor(
  6430. /** The frame for which the event is triggered **/
  6431. frame: number,
  6432. /** The event to perform when triggered **/
  6433. action: (currentFrame: number) => void,
  6434. /** Specifies if the event should be triggered only once**/
  6435. onlyOnce?: boolean | undefined);
  6436. /** @hidden */
  6437. _clone(): AnimationEvent;
  6438. }
  6439. }
  6440. declare module "babylonjs/Behaviors/behavior" {
  6441. import { Nullable } from "babylonjs/types";
  6442. /**
  6443. * Interface used to define a behavior
  6444. */
  6445. export interface Behavior<T> {
  6446. /** gets or sets behavior's name */
  6447. name: string;
  6448. /**
  6449. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6450. */
  6451. init(): void;
  6452. /**
  6453. * Called when the behavior is attached to a target
  6454. * @param target defines the target where the behavior is attached to
  6455. */
  6456. attach(target: T): void;
  6457. /**
  6458. * Called when the behavior is detached from its target
  6459. */
  6460. detach(): void;
  6461. }
  6462. /**
  6463. * Interface implemented by classes supporting behaviors
  6464. */
  6465. export interface IBehaviorAware<T> {
  6466. /**
  6467. * Attach a behavior
  6468. * @param behavior defines the behavior to attach
  6469. * @returns the current host
  6470. */
  6471. addBehavior(behavior: Behavior<T>): T;
  6472. /**
  6473. * Remove a behavior from the current object
  6474. * @param behavior defines the behavior to detach
  6475. * @returns the current host
  6476. */
  6477. removeBehavior(behavior: Behavior<T>): T;
  6478. /**
  6479. * Gets a behavior using its name to search
  6480. * @param name defines the name to search
  6481. * @returns the behavior or null if not found
  6482. */
  6483. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6484. }
  6485. }
  6486. declare module "babylonjs/Misc/smartArray" {
  6487. /**
  6488. * Defines an array and its length.
  6489. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6490. */
  6491. export interface ISmartArrayLike<T> {
  6492. /**
  6493. * The data of the array.
  6494. */
  6495. data: Array<T>;
  6496. /**
  6497. * The active length of the array.
  6498. */
  6499. length: number;
  6500. }
  6501. /**
  6502. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6503. */
  6504. export class SmartArray<T> implements ISmartArrayLike<T> {
  6505. /**
  6506. * The full set of data from the array.
  6507. */
  6508. data: Array<T>;
  6509. /**
  6510. * The active length of the array.
  6511. */
  6512. length: number;
  6513. protected _id: number;
  6514. /**
  6515. * Instantiates a Smart Array.
  6516. * @param capacity defines the default capacity of the array.
  6517. */
  6518. constructor(capacity: number);
  6519. /**
  6520. * Pushes a value at the end of the active data.
  6521. * @param value defines the object to push in the array.
  6522. */
  6523. push(value: T): void;
  6524. /**
  6525. * Iterates over the active data and apply the lambda to them.
  6526. * @param func defines the action to apply on each value.
  6527. */
  6528. forEach(func: (content: T) => void): void;
  6529. /**
  6530. * Sorts the full sets of data.
  6531. * @param compareFn defines the comparison function to apply.
  6532. */
  6533. sort(compareFn: (a: T, b: T) => number): void;
  6534. /**
  6535. * Resets the active data to an empty array.
  6536. */
  6537. reset(): void;
  6538. /**
  6539. * Releases all the data from the array as well as the array.
  6540. */
  6541. dispose(): void;
  6542. /**
  6543. * Concats the active data with a given array.
  6544. * @param array defines the data to concatenate with.
  6545. */
  6546. concat(array: any): void;
  6547. /**
  6548. * Returns the position of a value in the active data.
  6549. * @param value defines the value to find the index for
  6550. * @returns the index if found in the active data otherwise -1
  6551. */
  6552. indexOf(value: T): number;
  6553. /**
  6554. * Returns whether an element is part of the active data.
  6555. * @param value defines the value to look for
  6556. * @returns true if found in the active data otherwise false
  6557. */
  6558. contains(value: T): boolean;
  6559. private static _GlobalId;
  6560. }
  6561. /**
  6562. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6563. * The data in this array can only be present once
  6564. */
  6565. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6566. private _duplicateId;
  6567. /**
  6568. * Pushes a value at the end of the active data.
  6569. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6570. * @param value defines the object to push in the array.
  6571. */
  6572. push(value: T): void;
  6573. /**
  6574. * Pushes a value at the end of the active data.
  6575. * If the data is already present, it won t be added again
  6576. * @param value defines the object to push in the array.
  6577. * @returns true if added false if it was already present
  6578. */
  6579. pushNoDuplicate(value: T): boolean;
  6580. /**
  6581. * Resets the active data to an empty array.
  6582. */
  6583. reset(): void;
  6584. /**
  6585. * Concats the active data with a given array.
  6586. * This ensures no dupplicate will be present in the result.
  6587. * @param array defines the data to concatenate with.
  6588. */
  6589. concatWithNoDuplicate(array: any): void;
  6590. }
  6591. }
  6592. declare module "babylonjs/Cameras/cameraInputsManager" {
  6593. import { Nullable } from "babylonjs/types";
  6594. import { Camera } from "babylonjs/Cameras/camera";
  6595. /**
  6596. * @ignore
  6597. * This is a list of all the different input types that are available in the application.
  6598. * Fo instance: ArcRotateCameraGamepadInput...
  6599. */
  6600. export var CameraInputTypes: {};
  6601. /**
  6602. * This is the contract to implement in order to create a new input class.
  6603. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6604. */
  6605. export interface ICameraInput<TCamera extends Camera> {
  6606. /**
  6607. * Defines the camera the input is attached to.
  6608. */
  6609. camera: Nullable<TCamera>;
  6610. /**
  6611. * Gets the class name of the current intput.
  6612. * @returns the class name
  6613. */
  6614. getClassName(): string;
  6615. /**
  6616. * Get the friendly name associated with the input class.
  6617. * @returns the input friendly name
  6618. */
  6619. getSimpleName(): string;
  6620. /**
  6621. * Attach the input controls to a specific dom element to get the input from.
  6622. * @param element Defines the element the controls should be listened from
  6623. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6624. */
  6625. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6626. /**
  6627. * Detach the current controls from the specified dom element.
  6628. * @param element Defines the element to stop listening the inputs from
  6629. */
  6630. detachControl(element: Nullable<HTMLElement>): void;
  6631. /**
  6632. * Update the current camera state depending on the inputs that have been used this frame.
  6633. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6634. */
  6635. checkInputs?: () => void;
  6636. }
  6637. /**
  6638. * Represents a map of input types to input instance or input index to input instance.
  6639. */
  6640. export interface CameraInputsMap<TCamera extends Camera> {
  6641. /**
  6642. * Accessor to the input by input type.
  6643. */
  6644. [name: string]: ICameraInput<TCamera>;
  6645. /**
  6646. * Accessor to the input by input index.
  6647. */
  6648. [idx: number]: ICameraInput<TCamera>;
  6649. }
  6650. /**
  6651. * This represents the input manager used within a camera.
  6652. * It helps dealing with all the different kind of input attached to a camera.
  6653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6654. */
  6655. export class CameraInputsManager<TCamera extends Camera> {
  6656. /**
  6657. * Defines the list of inputs attahed to the camera.
  6658. */
  6659. attached: CameraInputsMap<TCamera>;
  6660. /**
  6661. * Defines the dom element the camera is collecting inputs from.
  6662. * This is null if the controls have not been attached.
  6663. */
  6664. attachedElement: Nullable<HTMLElement>;
  6665. /**
  6666. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6667. */
  6668. noPreventDefault: boolean;
  6669. /**
  6670. * Defined the camera the input manager belongs to.
  6671. */
  6672. camera: TCamera;
  6673. /**
  6674. * Update the current camera state depending on the inputs that have been used this frame.
  6675. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6676. */
  6677. checkInputs: () => void;
  6678. /**
  6679. * Instantiate a new Camera Input Manager.
  6680. * @param camera Defines the camera the input manager blongs to
  6681. */
  6682. constructor(camera: TCamera);
  6683. /**
  6684. * Add an input method to a camera
  6685. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6686. * @param input camera input method
  6687. */
  6688. add(input: ICameraInput<TCamera>): void;
  6689. /**
  6690. * Remove a specific input method from a camera
  6691. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6692. * @param inputToRemove camera input method
  6693. */
  6694. remove(inputToRemove: ICameraInput<TCamera>): void;
  6695. /**
  6696. * Remove a specific input type from a camera
  6697. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6698. * @param inputType the type of the input to remove
  6699. */
  6700. removeByType(inputType: string): void;
  6701. private _addCheckInputs;
  6702. /**
  6703. * Attach the input controls to the currently attached dom element to listen the events from.
  6704. * @param input Defines the input to attach
  6705. */
  6706. attachInput(input: ICameraInput<TCamera>): void;
  6707. /**
  6708. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6709. * @param element Defines the dom element to collect the events from
  6710. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6711. */
  6712. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6713. /**
  6714. * Detach the current manager inputs controls from a specific dom element.
  6715. * @param element Defines the dom element to collect the events from
  6716. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6717. */
  6718. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6719. /**
  6720. * Rebuild the dynamic inputCheck function from the current list of
  6721. * defined inputs in the manager.
  6722. */
  6723. rebuildInputCheck(): void;
  6724. /**
  6725. * Remove all attached input methods from a camera
  6726. */
  6727. clear(): void;
  6728. /**
  6729. * Serialize the current input manager attached to a camera.
  6730. * This ensures than once parsed,
  6731. * the input associated to the camera will be identical to the current ones
  6732. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6733. */
  6734. serialize(serializedCamera: any): void;
  6735. /**
  6736. * Parses an input manager serialized JSON to restore the previous list of inputs
  6737. * and states associated to a camera.
  6738. * @param parsedCamera Defines the JSON to parse
  6739. */
  6740. parse(parsedCamera: any): void;
  6741. }
  6742. }
  6743. declare module "babylonjs/Collisions/intersectionInfo" {
  6744. import { Nullable } from "babylonjs/types";
  6745. /**
  6746. * @hidden
  6747. */
  6748. export class IntersectionInfo {
  6749. bu: Nullable<number>;
  6750. bv: Nullable<number>;
  6751. distance: number;
  6752. faceId: number;
  6753. subMeshId: number;
  6754. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6755. }
  6756. }
  6757. declare module "babylonjs/Maths/math.plane" {
  6758. import { DeepImmutable } from "babylonjs/types";
  6759. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6760. /**
  6761. * Represens a plane by the equation ax + by + cz + d = 0
  6762. */
  6763. export class Plane {
  6764. private static _TmpMatrix;
  6765. /**
  6766. * Normal of the plane (a,b,c)
  6767. */
  6768. normal: Vector3;
  6769. /**
  6770. * d component of the plane
  6771. */
  6772. d: number;
  6773. /**
  6774. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6775. * @param a a component of the plane
  6776. * @param b b component of the plane
  6777. * @param c c component of the plane
  6778. * @param d d component of the plane
  6779. */
  6780. constructor(a: number, b: number, c: number, d: number);
  6781. /**
  6782. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6783. */
  6784. asArray(): number[];
  6785. /**
  6786. * @returns a new plane copied from the current Plane.
  6787. */
  6788. clone(): Plane;
  6789. /**
  6790. * @returns the string "Plane".
  6791. */
  6792. getClassName(): string;
  6793. /**
  6794. * @returns the Plane hash code.
  6795. */
  6796. getHashCode(): number;
  6797. /**
  6798. * Normalize the current Plane in place.
  6799. * @returns the updated Plane.
  6800. */
  6801. normalize(): Plane;
  6802. /**
  6803. * Applies a transformation the plane and returns the result
  6804. * @param transformation the transformation matrix to be applied to the plane
  6805. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6806. */
  6807. transform(transformation: DeepImmutable<Matrix>): Plane;
  6808. /**
  6809. * Calcualtte the dot product between the point and the plane normal
  6810. * @param point point to calculate the dot product with
  6811. * @returns the dot product (float) of the point coordinates and the plane normal.
  6812. */
  6813. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6814. /**
  6815. * Updates the current Plane from the plane defined by the three given points.
  6816. * @param point1 one of the points used to contruct the plane
  6817. * @param point2 one of the points used to contruct the plane
  6818. * @param point3 one of the points used to contruct the plane
  6819. * @returns the updated Plane.
  6820. */
  6821. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6822. /**
  6823. * Checks if the plane is facing a given direction
  6824. * @param direction the direction to check if the plane is facing
  6825. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6826. * @returns True is the vector "direction" is the same side than the plane normal.
  6827. */
  6828. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6829. /**
  6830. * Calculates the distance to a point
  6831. * @param point point to calculate distance to
  6832. * @returns the signed distance (float) from the given point to the Plane.
  6833. */
  6834. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6835. /**
  6836. * Creates a plane from an array
  6837. * @param array the array to create a plane from
  6838. * @returns a new Plane from the given array.
  6839. */
  6840. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6841. /**
  6842. * Creates a plane from three points
  6843. * @param point1 point used to create the plane
  6844. * @param point2 point used to create the plane
  6845. * @param point3 point used to create the plane
  6846. * @returns a new Plane defined by the three given points.
  6847. */
  6848. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6849. /**
  6850. * Creates a plane from an origin point and a normal
  6851. * @param origin origin of the plane to be constructed
  6852. * @param normal normal of the plane to be constructed
  6853. * @returns a new Plane the normal vector to this plane at the given origin point.
  6854. * Note : the vector "normal" is updated because normalized.
  6855. */
  6856. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6857. /**
  6858. * Calculates the distance from a plane and a point
  6859. * @param origin origin of the plane to be constructed
  6860. * @param normal normal of the plane to be constructed
  6861. * @param point point to calculate distance to
  6862. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6863. */
  6864. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6865. }
  6866. }
  6867. declare module "babylonjs/Culling/boundingSphere" {
  6868. import { DeepImmutable } from "babylonjs/types";
  6869. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6870. import { Plane } from "babylonjs/Maths/math.plane";
  6871. /**
  6872. * Class used to store bounding sphere information
  6873. */
  6874. export class BoundingSphere {
  6875. /**
  6876. * Gets the center of the bounding sphere in local space
  6877. */
  6878. readonly center: Vector3;
  6879. /**
  6880. * Radius of the bounding sphere in local space
  6881. */
  6882. radius: number;
  6883. /**
  6884. * Gets the center of the bounding sphere in world space
  6885. */
  6886. readonly centerWorld: Vector3;
  6887. /**
  6888. * Radius of the bounding sphere in world space
  6889. */
  6890. radiusWorld: number;
  6891. /**
  6892. * Gets the minimum vector in local space
  6893. */
  6894. readonly minimum: Vector3;
  6895. /**
  6896. * Gets the maximum vector in local space
  6897. */
  6898. readonly maximum: Vector3;
  6899. private _worldMatrix;
  6900. private static readonly TmpVector3;
  6901. /**
  6902. * Creates a new bounding sphere
  6903. * @param min defines the minimum vector (in local space)
  6904. * @param max defines the maximum vector (in local space)
  6905. * @param worldMatrix defines the new world matrix
  6906. */
  6907. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6908. /**
  6909. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6910. * @param min defines the new minimum vector (in local space)
  6911. * @param max defines the new maximum vector (in local space)
  6912. * @param worldMatrix defines the new world matrix
  6913. */
  6914. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6915. /**
  6916. * Scale the current bounding sphere by applying a scale factor
  6917. * @param factor defines the scale factor to apply
  6918. * @returns the current bounding box
  6919. */
  6920. scale(factor: number): BoundingSphere;
  6921. /**
  6922. * Gets the world matrix of the bounding box
  6923. * @returns a matrix
  6924. */
  6925. getWorldMatrix(): DeepImmutable<Matrix>;
  6926. /** @hidden */
  6927. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6928. /**
  6929. * Tests if the bounding sphere is intersecting the frustum planes
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @returns true if there is an intersection
  6932. */
  6933. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if the bounding sphere center is in between the frustum planes.
  6936. * Used for optimistic fast inclusion.
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @returns true if the sphere center is in between the frustum planes
  6939. */
  6940. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. /**
  6942. * Tests if a point is inside the bounding sphere
  6943. * @param point defines the point to test
  6944. * @returns true if the point is inside the bounding sphere
  6945. */
  6946. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6947. /**
  6948. * Checks if two sphere intersct
  6949. * @param sphere0 sphere 0
  6950. * @param sphere1 sphere 1
  6951. * @returns true if the speres intersect
  6952. */
  6953. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6954. }
  6955. }
  6956. declare module "babylonjs/Culling/boundingBox" {
  6957. import { DeepImmutable } from "babylonjs/types";
  6958. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6959. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6960. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6961. import { Plane } from "babylonjs/Maths/math.plane";
  6962. /**
  6963. * Class used to store bounding box information
  6964. */
  6965. export class BoundingBox implements ICullable {
  6966. /**
  6967. * Gets the 8 vectors representing the bounding box in local space
  6968. */
  6969. readonly vectors: Vector3[];
  6970. /**
  6971. * Gets the center of the bounding box in local space
  6972. */
  6973. readonly center: Vector3;
  6974. /**
  6975. * Gets the center of the bounding box in world space
  6976. */
  6977. readonly centerWorld: Vector3;
  6978. /**
  6979. * Gets the extend size in local space
  6980. */
  6981. readonly extendSize: Vector3;
  6982. /**
  6983. * Gets the extend size in world space
  6984. */
  6985. readonly extendSizeWorld: Vector3;
  6986. /**
  6987. * Gets the OBB (object bounding box) directions
  6988. */
  6989. readonly directions: Vector3[];
  6990. /**
  6991. * Gets the 8 vectors representing the bounding box in world space
  6992. */
  6993. readonly vectorsWorld: Vector3[];
  6994. /**
  6995. * Gets the minimum vector in world space
  6996. */
  6997. readonly minimumWorld: Vector3;
  6998. /**
  6999. * Gets the maximum vector in world space
  7000. */
  7001. readonly maximumWorld: Vector3;
  7002. /**
  7003. * Gets the minimum vector in local space
  7004. */
  7005. readonly minimum: Vector3;
  7006. /**
  7007. * Gets the maximum vector in local space
  7008. */
  7009. readonly maximum: Vector3;
  7010. private _worldMatrix;
  7011. private static readonly TmpVector3;
  7012. /**
  7013. * @hidden
  7014. */
  7015. _tag: number;
  7016. /**
  7017. * Creates a new bounding box
  7018. * @param min defines the minimum vector (in local space)
  7019. * @param max defines the maximum vector (in local space)
  7020. * @param worldMatrix defines the new world matrix
  7021. */
  7022. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7023. /**
  7024. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7025. * @param min defines the new minimum vector (in local space)
  7026. * @param max defines the new maximum vector (in local space)
  7027. * @param worldMatrix defines the new world matrix
  7028. */
  7029. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7030. /**
  7031. * Scale the current bounding box by applying a scale factor
  7032. * @param factor defines the scale factor to apply
  7033. * @returns the current bounding box
  7034. */
  7035. scale(factor: number): BoundingBox;
  7036. /**
  7037. * Gets the world matrix of the bounding box
  7038. * @returns a matrix
  7039. */
  7040. getWorldMatrix(): DeepImmutable<Matrix>;
  7041. /** @hidden */
  7042. _update(world: DeepImmutable<Matrix>): void;
  7043. /**
  7044. * Tests if the bounding box is intersecting the frustum planes
  7045. * @param frustumPlanes defines the frustum planes to test
  7046. * @returns true if there is an intersection
  7047. */
  7048. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7049. /**
  7050. * Tests if the bounding box is entirely inside the frustum planes
  7051. * @param frustumPlanes defines the frustum planes to test
  7052. * @returns true if there is an inclusion
  7053. */
  7054. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7055. /**
  7056. * Tests if a point is inside the bounding box
  7057. * @param point defines the point to test
  7058. * @returns true if the point is inside the bounding box
  7059. */
  7060. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7061. /**
  7062. * Tests if the bounding box intersects with a bounding sphere
  7063. * @param sphere defines the sphere to test
  7064. * @returns true if there is an intersection
  7065. */
  7066. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7067. /**
  7068. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7069. * @param min defines the min vector to use
  7070. * @param max defines the max vector to use
  7071. * @returns true if there is an intersection
  7072. */
  7073. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7074. /**
  7075. * Tests if two bounding boxes are intersections
  7076. * @param box0 defines the first box to test
  7077. * @param box1 defines the second box to test
  7078. * @returns true if there is an intersection
  7079. */
  7080. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7081. /**
  7082. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7083. * @param minPoint defines the minimum vector of the bounding box
  7084. * @param maxPoint defines the maximum vector of the bounding box
  7085. * @param sphereCenter defines the sphere center
  7086. * @param sphereRadius defines the sphere radius
  7087. * @returns true if there is an intersection
  7088. */
  7089. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7090. /**
  7091. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7092. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7093. * @param frustumPlanes defines the frustum planes to test
  7094. * @return true if there is an inclusion
  7095. */
  7096. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7097. /**
  7098. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7099. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7100. * @param frustumPlanes defines the frustum planes to test
  7101. * @return true if there is an intersection
  7102. */
  7103. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7104. }
  7105. }
  7106. declare module "babylonjs/Collisions/collider" {
  7107. import { Nullable, IndicesArray } from "babylonjs/types";
  7108. import { Vector3 } from "babylonjs/Maths/math.vector";
  7109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7110. import { Plane } from "babylonjs/Maths/math.plane";
  7111. /** @hidden */
  7112. export class Collider {
  7113. /** Define if a collision was found */
  7114. collisionFound: boolean;
  7115. /**
  7116. * Define last intersection point in local space
  7117. */
  7118. intersectionPoint: Vector3;
  7119. /**
  7120. * Define last collided mesh
  7121. */
  7122. collidedMesh: Nullable<AbstractMesh>;
  7123. private _collisionPoint;
  7124. private _planeIntersectionPoint;
  7125. private _tempVector;
  7126. private _tempVector2;
  7127. private _tempVector3;
  7128. private _tempVector4;
  7129. private _edge;
  7130. private _baseToVertex;
  7131. private _destinationPoint;
  7132. private _slidePlaneNormal;
  7133. private _displacementVector;
  7134. /** @hidden */
  7135. _radius: Vector3;
  7136. /** @hidden */
  7137. _retry: number;
  7138. private _velocity;
  7139. private _basePoint;
  7140. private _epsilon;
  7141. /** @hidden */
  7142. _velocityWorldLength: number;
  7143. /** @hidden */
  7144. _basePointWorld: Vector3;
  7145. private _velocityWorld;
  7146. private _normalizedVelocity;
  7147. /** @hidden */
  7148. _initialVelocity: Vector3;
  7149. /** @hidden */
  7150. _initialPosition: Vector3;
  7151. private _nearestDistance;
  7152. private _collisionMask;
  7153. collisionMask: number;
  7154. /**
  7155. * Gets the plane normal used to compute the sliding response (in local space)
  7156. */
  7157. readonly slidePlaneNormal: Vector3;
  7158. /** @hidden */
  7159. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7160. /** @hidden */
  7161. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7162. /** @hidden */
  7163. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7164. /** @hidden */
  7165. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7166. /** @hidden */
  7167. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7168. /** @hidden */
  7169. _getResponse(pos: Vector3, vel: Vector3): void;
  7170. }
  7171. }
  7172. declare module "babylonjs/Culling/boundingInfo" {
  7173. import { DeepImmutable } from "babylonjs/types";
  7174. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7175. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7176. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7177. import { Plane } from "babylonjs/Maths/math.plane";
  7178. import { Collider } from "babylonjs/Collisions/collider";
  7179. /**
  7180. * Interface for cullable objects
  7181. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7182. */
  7183. export interface ICullable {
  7184. /**
  7185. * Checks if the object or part of the object is in the frustum
  7186. * @param frustumPlanes Camera near/planes
  7187. * @returns true if the object is in frustum otherwise false
  7188. */
  7189. isInFrustum(frustumPlanes: Plane[]): boolean;
  7190. /**
  7191. * Checks if a cullable object (mesh...) is in the camera frustum
  7192. * Unlike isInFrustum this cheks the full bounding box
  7193. * @param frustumPlanes Camera near/planes
  7194. * @returns true if the object is in frustum otherwise false
  7195. */
  7196. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7197. }
  7198. /**
  7199. * Info for a bounding data of a mesh
  7200. */
  7201. export class BoundingInfo implements ICullable {
  7202. /**
  7203. * Bounding box for the mesh
  7204. */
  7205. readonly boundingBox: BoundingBox;
  7206. /**
  7207. * Bounding sphere for the mesh
  7208. */
  7209. readonly boundingSphere: BoundingSphere;
  7210. private _isLocked;
  7211. private static readonly TmpVector3;
  7212. /**
  7213. * Constructs bounding info
  7214. * @param minimum min vector of the bounding box/sphere
  7215. * @param maximum max vector of the bounding box/sphere
  7216. * @param worldMatrix defines the new world matrix
  7217. */
  7218. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7219. /**
  7220. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7221. * @param min defines the new minimum vector (in local space)
  7222. * @param max defines the new maximum vector (in local space)
  7223. * @param worldMatrix defines the new world matrix
  7224. */
  7225. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7226. /**
  7227. * min vector of the bounding box/sphere
  7228. */
  7229. readonly minimum: Vector3;
  7230. /**
  7231. * max vector of the bounding box/sphere
  7232. */
  7233. readonly maximum: Vector3;
  7234. /**
  7235. * If the info is locked and won't be updated to avoid perf overhead
  7236. */
  7237. isLocked: boolean;
  7238. /**
  7239. * Updates the bounding sphere and box
  7240. * @param world world matrix to be used to update
  7241. */
  7242. update(world: DeepImmutable<Matrix>): void;
  7243. /**
  7244. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7245. * @param center New center of the bounding info
  7246. * @param extend New extend of the bounding info
  7247. * @returns the current bounding info
  7248. */
  7249. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7250. /**
  7251. * Scale the current bounding info by applying a scale factor
  7252. * @param factor defines the scale factor to apply
  7253. * @returns the current bounding info
  7254. */
  7255. scale(factor: number): BoundingInfo;
  7256. /**
  7257. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7258. * @param frustumPlanes defines the frustum to test
  7259. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7260. * @returns true if the bounding info is in the frustum planes
  7261. */
  7262. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7263. /**
  7264. * Gets the world distance between the min and max points of the bounding box
  7265. */
  7266. readonly diagonalLength: number;
  7267. /**
  7268. * Checks if a cullable object (mesh...) is in the camera frustum
  7269. * Unlike isInFrustum this cheks the full bounding box
  7270. * @param frustumPlanes Camera near/planes
  7271. * @returns true if the object is in frustum otherwise false
  7272. */
  7273. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7274. /** @hidden */
  7275. _checkCollision(collider: Collider): boolean;
  7276. /**
  7277. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7278. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7279. * @param point the point to check intersection with
  7280. * @returns if the point intersects
  7281. */
  7282. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7283. /**
  7284. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7285. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7286. * @param boundingInfo the bounding info to check intersection with
  7287. * @param precise if the intersection should be done using OBB
  7288. * @returns if the bounding info intersects
  7289. */
  7290. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7291. }
  7292. }
  7293. declare module "babylonjs/Maths/math.functions" {
  7294. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7295. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7296. /**
  7297. * Extracts minimum and maximum values from a list of indexed positions
  7298. * @param positions defines the positions to use
  7299. * @param indices defines the indices to the positions
  7300. * @param indexStart defines the start index
  7301. * @param indexCount defines the end index
  7302. * @param bias defines bias value to add to the result
  7303. * @return minimum and maximum values
  7304. */
  7305. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7306. minimum: Vector3;
  7307. maximum: Vector3;
  7308. };
  7309. /**
  7310. * Extracts minimum and maximum values from a list of positions
  7311. * @param positions defines the positions to use
  7312. * @param start defines the start index in the positions array
  7313. * @param count defines the number of positions to handle
  7314. * @param bias defines bias value to add to the result
  7315. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7316. * @return minimum and maximum values
  7317. */
  7318. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7319. minimum: Vector3;
  7320. maximum: Vector3;
  7321. };
  7322. }
  7323. declare module "babylonjs/Misc/iInspectable" {
  7324. /**
  7325. * Enum that determines the text-wrapping mode to use.
  7326. */
  7327. export enum InspectableType {
  7328. /**
  7329. * Checkbox for booleans
  7330. */
  7331. Checkbox = 0,
  7332. /**
  7333. * Sliders for numbers
  7334. */
  7335. Slider = 1,
  7336. /**
  7337. * Vector3
  7338. */
  7339. Vector3 = 2,
  7340. /**
  7341. * Quaternions
  7342. */
  7343. Quaternion = 3,
  7344. /**
  7345. * Color3
  7346. */
  7347. Color3 = 4,
  7348. /**
  7349. * String
  7350. */
  7351. String = 5
  7352. }
  7353. /**
  7354. * Interface used to define custom inspectable properties.
  7355. * This interface is used by the inspector to display custom property grids
  7356. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7357. */
  7358. export interface IInspectable {
  7359. /**
  7360. * Gets the label to display
  7361. */
  7362. label: string;
  7363. /**
  7364. * Gets the name of the property to edit
  7365. */
  7366. propertyName: string;
  7367. /**
  7368. * Gets the type of the editor to use
  7369. */
  7370. type: InspectableType;
  7371. /**
  7372. * Gets the minimum value of the property when using in "slider" mode
  7373. */
  7374. min?: number;
  7375. /**
  7376. * Gets the maximum value of the property when using in "slider" mode
  7377. */
  7378. max?: number;
  7379. /**
  7380. * Gets the setp to use when using in "slider" mode
  7381. */
  7382. step?: number;
  7383. }
  7384. }
  7385. declare module "babylonjs/Misc/timingTools" {
  7386. /**
  7387. * Class used to provide helper for timing
  7388. */
  7389. export class TimingTools {
  7390. /**
  7391. * Polyfill for setImmediate
  7392. * @param action defines the action to execute after the current execution block
  7393. */
  7394. static SetImmediate(action: () => void): void;
  7395. }
  7396. }
  7397. declare module "babylonjs/Misc/instantiationTools" {
  7398. /**
  7399. * Class used to enable instatition of objects by class name
  7400. */
  7401. export class InstantiationTools {
  7402. /**
  7403. * Use this object to register external classes like custom textures or material
  7404. * to allow the laoders to instantiate them
  7405. */
  7406. static RegisteredExternalClasses: {
  7407. [key: string]: Object;
  7408. };
  7409. /**
  7410. * Tries to instantiate a new object from a given class name
  7411. * @param className defines the class name to instantiate
  7412. * @returns the new object or null if the system was not able to do the instantiation
  7413. */
  7414. static Instantiate(className: string): any;
  7415. }
  7416. }
  7417. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7418. import { Nullable } from "babylonjs/types";
  7419. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7420. /**
  7421. * This represents the required contract to create a new type of texture loader.
  7422. */
  7423. export interface IInternalTextureLoader {
  7424. /**
  7425. * Defines wether the loader supports cascade loading the different faces.
  7426. */
  7427. supportCascades: boolean;
  7428. /**
  7429. * This returns if the loader support the current file information.
  7430. * @param extension defines the file extension of the file being loaded
  7431. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7432. * @param fallback defines the fallback internal texture if any
  7433. * @param isBase64 defines whether the texture is encoded as a base64
  7434. * @param isBuffer defines whether the texture data are stored as a buffer
  7435. * @returns true if the loader can load the specified file
  7436. */
  7437. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7438. /**
  7439. * Transform the url before loading if required.
  7440. * @param rootUrl the url of the texture
  7441. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7442. * @returns the transformed texture
  7443. */
  7444. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7445. /**
  7446. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7447. * @param rootUrl the url of the texture
  7448. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7449. * @returns the fallback texture
  7450. */
  7451. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7452. /**
  7453. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7454. * @param data contains the texture data
  7455. * @param texture defines the BabylonJS internal texture
  7456. * @param createPolynomials will be true if polynomials have been requested
  7457. * @param onLoad defines the callback to trigger once the texture is ready
  7458. * @param onError defines the callback to trigger in case of error
  7459. */
  7460. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7461. /**
  7462. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7463. * @param data contains the texture data
  7464. * @param texture defines the BabylonJS internal texture
  7465. * @param callback defines the method to call once ready to upload
  7466. */
  7467. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7468. }
  7469. }
  7470. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7471. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7472. import { Nullable } from "babylonjs/types";
  7473. import { Scene } from "babylonjs/scene";
  7474. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7475. module "babylonjs/Engines/engine" {
  7476. interface Engine {
  7477. /**
  7478. * Creates a depth stencil cube texture.
  7479. * This is only available in WebGL 2.
  7480. * @param size The size of face edge in the cube texture.
  7481. * @param options The options defining the cube texture.
  7482. * @returns The cube texture
  7483. */
  7484. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7485. /**
  7486. * Creates a cube texture
  7487. * @param rootUrl defines the url where the files to load is located
  7488. * @param scene defines the current scene
  7489. * @param files defines the list of files to load (1 per face)
  7490. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7491. * @param onLoad defines an optional callback raised when the texture is loaded
  7492. * @param onError defines an optional callback raised if there is an issue to load the texture
  7493. * @param format defines the format of the data
  7494. * @param forcedExtension defines the extension to use to pick the right loader
  7495. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7496. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7497. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7498. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7499. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7500. * @returns the cube texture as an InternalTexture
  7501. */
  7502. 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;
  7503. /**
  7504. * Creates a cube texture
  7505. * @param rootUrl defines the url where the files to load is located
  7506. * @param scene defines the current scene
  7507. * @param files defines the list of files to load (1 per face)
  7508. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7509. * @param onLoad defines an optional callback raised when the texture is loaded
  7510. * @param onError defines an optional callback raised if there is an issue to load the texture
  7511. * @param format defines the format of the data
  7512. * @param forcedExtension defines the extension to use to pick the right loader
  7513. * @returns the cube texture as an InternalTexture
  7514. */
  7515. 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;
  7516. /**
  7517. * Creates a cube texture
  7518. * @param rootUrl defines the url where the files to load is located
  7519. * @param scene defines the current scene
  7520. * @param files defines the list of files to load (1 per face)
  7521. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7522. * @param onLoad defines an optional callback raised when the texture is loaded
  7523. * @param onError defines an optional callback raised if there is an issue to load the texture
  7524. * @param format defines the format of the data
  7525. * @param forcedExtension defines the extension to use to pick the right loader
  7526. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7527. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7528. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7529. * @returns the cube texture as an InternalTexture
  7530. */
  7531. 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;
  7532. /** @hidden */
  7533. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7534. /** @hidden */
  7535. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7536. /** @hidden */
  7537. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7538. /** @hidden */
  7539. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7540. }
  7541. }
  7542. }
  7543. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7544. import { Nullable } from "babylonjs/types";
  7545. import { Scene } from "babylonjs/scene";
  7546. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7547. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7548. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7549. /**
  7550. * Class for creating a cube texture
  7551. */
  7552. export class CubeTexture extends BaseTexture {
  7553. private _delayedOnLoad;
  7554. /**
  7555. * The url of the texture
  7556. */
  7557. url: string;
  7558. /**
  7559. * Gets or sets the center of the bounding box associated with the cube texture.
  7560. * It must define where the camera used to render the texture was set
  7561. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7562. */
  7563. boundingBoxPosition: Vector3;
  7564. private _boundingBoxSize;
  7565. /**
  7566. * Gets or sets the size of the bounding box associated with the cube texture
  7567. * When defined, the cubemap will switch to local mode
  7568. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7569. * @example https://www.babylonjs-playground.com/#RNASML
  7570. */
  7571. /**
  7572. * Returns the bounding box size
  7573. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7574. */
  7575. boundingBoxSize: Vector3;
  7576. protected _rotationY: number;
  7577. /**
  7578. * Sets texture matrix rotation angle around Y axis in radians.
  7579. */
  7580. /**
  7581. * Gets texture matrix rotation angle around Y axis radians.
  7582. */
  7583. rotationY: number;
  7584. /**
  7585. * Are mip maps generated for this texture or not.
  7586. */
  7587. readonly noMipmap: boolean;
  7588. private _noMipmap;
  7589. private _files;
  7590. private _extensions;
  7591. private _textureMatrix;
  7592. private _format;
  7593. private _createPolynomials;
  7594. /** @hidden */
  7595. _prefiltered: boolean;
  7596. /**
  7597. * Creates a cube texture from an array of image urls
  7598. * @param files defines an array of image urls
  7599. * @param scene defines the hosting scene
  7600. * @param noMipmap specifies if mip maps are not used
  7601. * @returns a cube texture
  7602. */
  7603. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7604. /**
  7605. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7606. * @param url defines the url of the prefiltered texture
  7607. * @param scene defines the scene the texture is attached to
  7608. * @param forcedExtension defines the extension of the file if different from the url
  7609. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7610. * @return the prefiltered texture
  7611. */
  7612. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7613. /**
  7614. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7615. * as prefiltered data.
  7616. * @param rootUrl defines the url of the texture or the root name of the six images
  7617. * @param scene defines the scene the texture is attached to
  7618. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7619. * @param noMipmap defines if mipmaps should be created or not
  7620. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7621. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7622. * @param onError defines a callback triggered in case of error during load
  7623. * @param format defines the internal format to use for the texture once loaded
  7624. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7625. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7626. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7627. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7628. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7629. * @return the cube texture
  7630. */
  7631. 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);
  7632. /**
  7633. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7634. */
  7635. readonly isPrefiltered: boolean;
  7636. /**
  7637. * Get the current class name of the texture useful for serialization or dynamic coding.
  7638. * @returns "CubeTexture"
  7639. */
  7640. getClassName(): string;
  7641. /**
  7642. * Update the url (and optional buffer) of this texture if url was null during construction.
  7643. * @param url the url of the texture
  7644. * @param forcedExtension defines the extension to use
  7645. * @param onLoad callback called when the texture is loaded (defaults to null)
  7646. */
  7647. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7648. /**
  7649. * Delays loading of the cube texture
  7650. * @param forcedExtension defines the extension to use
  7651. */
  7652. delayLoad(forcedExtension?: string): void;
  7653. /**
  7654. * Returns the reflection texture matrix
  7655. * @returns the reflection texture matrix
  7656. */
  7657. getReflectionTextureMatrix(): Matrix;
  7658. /**
  7659. * Sets the reflection texture matrix
  7660. * @param value Reflection texture matrix
  7661. */
  7662. setReflectionTextureMatrix(value: Matrix): void;
  7663. /**
  7664. * Parses text to create a cube texture
  7665. * @param parsedTexture define the serialized text to read from
  7666. * @param scene defines the hosting scene
  7667. * @param rootUrl defines the root url of the cube texture
  7668. * @returns a cube texture
  7669. */
  7670. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7671. /**
  7672. * Makes a clone, or deep copy, of the cube texture
  7673. * @returns a new cube texture
  7674. */
  7675. clone(): CubeTexture;
  7676. }
  7677. }
  7678. declare module "babylonjs/Materials/materialDefines" {
  7679. /**
  7680. * Manages the defines for the Material
  7681. */
  7682. export class MaterialDefines {
  7683. /** @hidden */
  7684. protected _keys: string[];
  7685. private _isDirty;
  7686. /** @hidden */
  7687. _renderId: number;
  7688. /** @hidden */
  7689. _areLightsDirty: boolean;
  7690. /** @hidden */
  7691. _areAttributesDirty: boolean;
  7692. /** @hidden */
  7693. _areTexturesDirty: boolean;
  7694. /** @hidden */
  7695. _areFresnelDirty: boolean;
  7696. /** @hidden */
  7697. _areMiscDirty: boolean;
  7698. /** @hidden */
  7699. _areImageProcessingDirty: boolean;
  7700. /** @hidden */
  7701. _normals: boolean;
  7702. /** @hidden */
  7703. _uvs: boolean;
  7704. /** @hidden */
  7705. _needNormals: boolean;
  7706. /** @hidden */
  7707. _needUVs: boolean;
  7708. [id: string]: any;
  7709. /**
  7710. * Specifies if the material needs to be re-calculated
  7711. */
  7712. readonly isDirty: boolean;
  7713. /**
  7714. * Marks the material to indicate that it has been re-calculated
  7715. */
  7716. markAsProcessed(): void;
  7717. /**
  7718. * Marks the material to indicate that it needs to be re-calculated
  7719. */
  7720. markAsUnprocessed(): void;
  7721. /**
  7722. * Marks the material to indicate all of its defines need to be re-calculated
  7723. */
  7724. markAllAsDirty(): void;
  7725. /**
  7726. * Marks the material to indicate that image processing needs to be re-calculated
  7727. */
  7728. markAsImageProcessingDirty(): void;
  7729. /**
  7730. * Marks the material to indicate the lights need to be re-calculated
  7731. */
  7732. markAsLightDirty(): void;
  7733. /**
  7734. * Marks the attribute state as changed
  7735. */
  7736. markAsAttributesDirty(): void;
  7737. /**
  7738. * Marks the texture state as changed
  7739. */
  7740. markAsTexturesDirty(): void;
  7741. /**
  7742. * Marks the fresnel state as changed
  7743. */
  7744. markAsFresnelDirty(): void;
  7745. /**
  7746. * Marks the misc state as changed
  7747. */
  7748. markAsMiscDirty(): void;
  7749. /**
  7750. * Rebuilds the material defines
  7751. */
  7752. rebuild(): void;
  7753. /**
  7754. * Specifies if two material defines are equal
  7755. * @param other - A material define instance to compare to
  7756. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7757. */
  7758. isEqual(other: MaterialDefines): boolean;
  7759. /**
  7760. * Clones this instance's defines to another instance
  7761. * @param other - material defines to clone values to
  7762. */
  7763. cloneTo(other: MaterialDefines): void;
  7764. /**
  7765. * Resets the material define values
  7766. */
  7767. reset(): void;
  7768. /**
  7769. * Converts the material define values to a string
  7770. * @returns - String of material define information
  7771. */
  7772. toString(): string;
  7773. }
  7774. }
  7775. declare module "babylonjs/Materials/colorCurves" {
  7776. import { Effect } from "babylonjs/Materials/effect";
  7777. /**
  7778. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7779. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7780. * 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;
  7781. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7782. */
  7783. export class ColorCurves {
  7784. private _dirty;
  7785. private _tempColor;
  7786. private _globalCurve;
  7787. private _highlightsCurve;
  7788. private _midtonesCurve;
  7789. private _shadowsCurve;
  7790. private _positiveCurve;
  7791. private _negativeCurve;
  7792. private _globalHue;
  7793. private _globalDensity;
  7794. private _globalSaturation;
  7795. private _globalExposure;
  7796. /**
  7797. * Gets the global Hue value.
  7798. * 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).
  7799. */
  7800. /**
  7801. * Sets the global Hue value.
  7802. * 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).
  7803. */
  7804. globalHue: number;
  7805. /**
  7806. * Gets the global Density value.
  7807. * 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.
  7808. * Values less than zero provide a filter of opposite hue.
  7809. */
  7810. /**
  7811. * Sets the global Density value.
  7812. * 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.
  7813. * Values less than zero provide a filter of opposite hue.
  7814. */
  7815. globalDensity: number;
  7816. /**
  7817. * Gets the global Saturation value.
  7818. * 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.
  7819. */
  7820. /**
  7821. * Sets the global Saturation value.
  7822. * 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.
  7823. */
  7824. globalSaturation: number;
  7825. /**
  7826. * Gets the global Exposure value.
  7827. * 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.
  7828. */
  7829. /**
  7830. * Sets the global Exposure value.
  7831. * 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.
  7832. */
  7833. globalExposure: number;
  7834. private _highlightsHue;
  7835. private _highlightsDensity;
  7836. private _highlightsSaturation;
  7837. private _highlightsExposure;
  7838. /**
  7839. * Gets the highlights Hue value.
  7840. * 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).
  7841. */
  7842. /**
  7843. * Sets the highlights Hue value.
  7844. * 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).
  7845. */
  7846. highlightsHue: number;
  7847. /**
  7848. * Gets the highlights Density value.
  7849. * 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.
  7850. * Values less than zero provide a filter of opposite hue.
  7851. */
  7852. /**
  7853. * Sets the highlights Density value.
  7854. * 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.
  7855. * Values less than zero provide a filter of opposite hue.
  7856. */
  7857. highlightsDensity: number;
  7858. /**
  7859. * Gets the highlights Saturation value.
  7860. * 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.
  7861. */
  7862. /**
  7863. * Sets the highlights Saturation value.
  7864. * 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.
  7865. */
  7866. highlightsSaturation: number;
  7867. /**
  7868. * Gets the highlights Exposure value.
  7869. * 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.
  7870. */
  7871. /**
  7872. * Sets the highlights Exposure value.
  7873. * 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.
  7874. */
  7875. highlightsExposure: number;
  7876. private _midtonesHue;
  7877. private _midtonesDensity;
  7878. private _midtonesSaturation;
  7879. private _midtonesExposure;
  7880. /**
  7881. * Gets the midtones Hue value.
  7882. * 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).
  7883. */
  7884. /**
  7885. * Sets the midtones Hue value.
  7886. * 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).
  7887. */
  7888. midtonesHue: number;
  7889. /**
  7890. * Gets the midtones Density value.
  7891. * 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.
  7892. * Values less than zero provide a filter of opposite hue.
  7893. */
  7894. /**
  7895. * Sets the midtones Density value.
  7896. * 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.
  7897. * Values less than zero provide a filter of opposite hue.
  7898. */
  7899. midtonesDensity: number;
  7900. /**
  7901. * Gets the midtones Saturation value.
  7902. * 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.
  7903. */
  7904. /**
  7905. * Sets the midtones Saturation value.
  7906. * 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.
  7907. */
  7908. midtonesSaturation: number;
  7909. /**
  7910. * Gets the midtones Exposure value.
  7911. * 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.
  7912. */
  7913. /**
  7914. * Sets the midtones Exposure value.
  7915. * 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.
  7916. */
  7917. midtonesExposure: number;
  7918. private _shadowsHue;
  7919. private _shadowsDensity;
  7920. private _shadowsSaturation;
  7921. private _shadowsExposure;
  7922. /**
  7923. * Gets the shadows Hue value.
  7924. * 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).
  7925. */
  7926. /**
  7927. * Sets the shadows Hue value.
  7928. * 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).
  7929. */
  7930. shadowsHue: number;
  7931. /**
  7932. * Gets the shadows Density value.
  7933. * 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.
  7934. * Values less than zero provide a filter of opposite hue.
  7935. */
  7936. /**
  7937. * Sets the shadows Density value.
  7938. * 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.
  7939. * Values less than zero provide a filter of opposite hue.
  7940. */
  7941. shadowsDensity: number;
  7942. /**
  7943. * Gets the shadows Saturation value.
  7944. * 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.
  7945. */
  7946. /**
  7947. * Sets the shadows Saturation value.
  7948. * 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.
  7949. */
  7950. shadowsSaturation: number;
  7951. /**
  7952. * Gets the shadows Exposure value.
  7953. * 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.
  7954. */
  7955. /**
  7956. * Sets the shadows Exposure value.
  7957. * 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.
  7958. */
  7959. shadowsExposure: number;
  7960. /**
  7961. * Returns the class name
  7962. * @returns The class name
  7963. */
  7964. getClassName(): string;
  7965. /**
  7966. * Binds the color curves to the shader.
  7967. * @param colorCurves The color curve to bind
  7968. * @param effect The effect to bind to
  7969. * @param positiveUniform The positive uniform shader parameter
  7970. * @param neutralUniform The neutral uniform shader parameter
  7971. * @param negativeUniform The negative uniform shader parameter
  7972. */
  7973. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7974. /**
  7975. * Prepare the list of uniforms associated with the ColorCurves effects.
  7976. * @param uniformsList The list of uniforms used in the effect
  7977. */
  7978. static PrepareUniforms(uniformsList: string[]): void;
  7979. /**
  7980. * Returns color grading data based on a hue, density, saturation and exposure value.
  7981. * @param filterHue The hue of the color filter.
  7982. * @param filterDensity The density of the color filter.
  7983. * @param saturation The saturation.
  7984. * @param exposure The exposure.
  7985. * @param result The result data container.
  7986. */
  7987. private getColorGradingDataToRef;
  7988. /**
  7989. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7990. * @param value The input slider value in range [-100,100].
  7991. * @returns Adjusted value.
  7992. */
  7993. private static applyColorGradingSliderNonlinear;
  7994. /**
  7995. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7996. * @param hue The hue (H) input.
  7997. * @param saturation The saturation (S) input.
  7998. * @param brightness The brightness (B) input.
  7999. * @result An RGBA color represented as Vector4.
  8000. */
  8001. private static fromHSBToRef;
  8002. /**
  8003. * Returns a value clamped between min and max
  8004. * @param value The value to clamp
  8005. * @param min The minimum of value
  8006. * @param max The maximum of value
  8007. * @returns The clamped value.
  8008. */
  8009. private static clamp;
  8010. /**
  8011. * Clones the current color curve instance.
  8012. * @return The cloned curves
  8013. */
  8014. clone(): ColorCurves;
  8015. /**
  8016. * Serializes the current color curve instance to a json representation.
  8017. * @return a JSON representation
  8018. */
  8019. serialize(): any;
  8020. /**
  8021. * Parses the color curve from a json representation.
  8022. * @param source the JSON source to parse
  8023. * @return The parsed curves
  8024. */
  8025. static Parse(source: any): ColorCurves;
  8026. }
  8027. }
  8028. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8029. import { Observable } from "babylonjs/Misc/observable";
  8030. import { Nullable } from "babylonjs/types";
  8031. import { Color4 } from "babylonjs/Maths/math.color";
  8032. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8033. import { Effect } from "babylonjs/Materials/effect";
  8034. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8035. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8036. /**
  8037. * Interface to follow in your material defines to integrate easily the
  8038. * Image proccessing functions.
  8039. * @hidden
  8040. */
  8041. export interface IImageProcessingConfigurationDefines {
  8042. IMAGEPROCESSING: boolean;
  8043. VIGNETTE: boolean;
  8044. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8045. VIGNETTEBLENDMODEOPAQUE: boolean;
  8046. TONEMAPPING: boolean;
  8047. TONEMAPPING_ACES: boolean;
  8048. CONTRAST: boolean;
  8049. EXPOSURE: boolean;
  8050. COLORCURVES: boolean;
  8051. COLORGRADING: boolean;
  8052. COLORGRADING3D: boolean;
  8053. SAMPLER3DGREENDEPTH: boolean;
  8054. SAMPLER3DBGRMAP: boolean;
  8055. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8056. }
  8057. /**
  8058. * @hidden
  8059. */
  8060. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8061. IMAGEPROCESSING: boolean;
  8062. VIGNETTE: boolean;
  8063. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8064. VIGNETTEBLENDMODEOPAQUE: boolean;
  8065. TONEMAPPING: boolean;
  8066. TONEMAPPING_ACES: boolean;
  8067. CONTRAST: boolean;
  8068. COLORCURVES: boolean;
  8069. COLORGRADING: boolean;
  8070. COLORGRADING3D: boolean;
  8071. SAMPLER3DGREENDEPTH: boolean;
  8072. SAMPLER3DBGRMAP: boolean;
  8073. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8074. EXPOSURE: boolean;
  8075. constructor();
  8076. }
  8077. /**
  8078. * This groups together the common properties used for image processing either in direct forward pass
  8079. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8080. * or not.
  8081. */
  8082. export class ImageProcessingConfiguration {
  8083. /**
  8084. * Default tone mapping applied in BabylonJS.
  8085. */
  8086. static readonly TONEMAPPING_STANDARD: number;
  8087. /**
  8088. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8089. * to other engines rendering to increase portability.
  8090. */
  8091. static readonly TONEMAPPING_ACES: number;
  8092. /**
  8093. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8094. */
  8095. colorCurves: Nullable<ColorCurves>;
  8096. private _colorCurvesEnabled;
  8097. /**
  8098. * Gets wether the color curves effect is enabled.
  8099. */
  8100. /**
  8101. * Sets wether the color curves effect is enabled.
  8102. */
  8103. colorCurvesEnabled: boolean;
  8104. private _colorGradingTexture;
  8105. /**
  8106. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8107. */
  8108. /**
  8109. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8110. */
  8111. colorGradingTexture: Nullable<BaseTexture>;
  8112. private _colorGradingEnabled;
  8113. /**
  8114. * Gets wether the color grading effect is enabled.
  8115. */
  8116. /**
  8117. * Sets wether the color grading effect is enabled.
  8118. */
  8119. colorGradingEnabled: boolean;
  8120. private _colorGradingWithGreenDepth;
  8121. /**
  8122. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8123. */
  8124. /**
  8125. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8126. */
  8127. colorGradingWithGreenDepth: boolean;
  8128. private _colorGradingBGR;
  8129. /**
  8130. * Gets wether the color grading texture contains BGR values.
  8131. */
  8132. /**
  8133. * Sets wether the color grading texture contains BGR values.
  8134. */
  8135. colorGradingBGR: boolean;
  8136. /** @hidden */
  8137. _exposure: number;
  8138. /**
  8139. * Gets the Exposure used in the effect.
  8140. */
  8141. /**
  8142. * Sets the Exposure used in the effect.
  8143. */
  8144. exposure: number;
  8145. private _toneMappingEnabled;
  8146. /**
  8147. * Gets wether the tone mapping effect is enabled.
  8148. */
  8149. /**
  8150. * Sets wether the tone mapping effect is enabled.
  8151. */
  8152. toneMappingEnabled: boolean;
  8153. private _toneMappingType;
  8154. /**
  8155. * Gets the type of tone mapping effect.
  8156. */
  8157. /**
  8158. * Sets the type of tone mapping effect used in BabylonJS.
  8159. */
  8160. toneMappingType: number;
  8161. protected _contrast: number;
  8162. /**
  8163. * Gets the contrast used in the effect.
  8164. */
  8165. /**
  8166. * Sets the contrast used in the effect.
  8167. */
  8168. contrast: number;
  8169. /**
  8170. * Vignette stretch size.
  8171. */
  8172. vignetteStretch: number;
  8173. /**
  8174. * Vignette centre X Offset.
  8175. */
  8176. vignetteCentreX: number;
  8177. /**
  8178. * Vignette centre Y Offset.
  8179. */
  8180. vignetteCentreY: number;
  8181. /**
  8182. * Vignette weight or intensity of the vignette effect.
  8183. */
  8184. vignetteWeight: number;
  8185. /**
  8186. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8187. * if vignetteEnabled is set to true.
  8188. */
  8189. vignetteColor: Color4;
  8190. /**
  8191. * Camera field of view used by the Vignette effect.
  8192. */
  8193. vignetteCameraFov: number;
  8194. private _vignetteBlendMode;
  8195. /**
  8196. * Gets the vignette blend mode allowing different kind of effect.
  8197. */
  8198. /**
  8199. * Sets the vignette blend mode allowing different kind of effect.
  8200. */
  8201. vignetteBlendMode: number;
  8202. private _vignetteEnabled;
  8203. /**
  8204. * Gets wether the vignette effect is enabled.
  8205. */
  8206. /**
  8207. * Sets wether the vignette effect is enabled.
  8208. */
  8209. vignetteEnabled: boolean;
  8210. private _applyByPostProcess;
  8211. /**
  8212. * Gets wether the image processing is applied through a post process or not.
  8213. */
  8214. /**
  8215. * Sets wether the image processing is applied through a post process or not.
  8216. */
  8217. applyByPostProcess: boolean;
  8218. private _isEnabled;
  8219. /**
  8220. * Gets wether the image processing is enabled or not.
  8221. */
  8222. /**
  8223. * Sets wether the image processing is enabled or not.
  8224. */
  8225. isEnabled: boolean;
  8226. /**
  8227. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8228. */
  8229. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8230. /**
  8231. * Method called each time the image processing information changes requires to recompile the effect.
  8232. */
  8233. protected _updateParameters(): void;
  8234. /**
  8235. * Gets the current class name.
  8236. * @return "ImageProcessingConfiguration"
  8237. */
  8238. getClassName(): string;
  8239. /**
  8240. * Prepare the list of uniforms associated with the Image Processing effects.
  8241. * @param uniforms The list of uniforms used in the effect
  8242. * @param defines the list of defines currently in use
  8243. */
  8244. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8245. /**
  8246. * Prepare the list of samplers associated with the Image Processing effects.
  8247. * @param samplersList The list of uniforms used in the effect
  8248. * @param defines the list of defines currently in use
  8249. */
  8250. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8251. /**
  8252. * Prepare the list of defines associated to the shader.
  8253. * @param defines the list of defines to complete
  8254. * @param forPostProcess Define if we are currently in post process mode or not
  8255. */
  8256. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8257. /**
  8258. * Returns true if all the image processing information are ready.
  8259. * @returns True if ready, otherwise, false
  8260. */
  8261. isReady(): boolean;
  8262. /**
  8263. * Binds the image processing to the shader.
  8264. * @param effect The effect to bind to
  8265. * @param aspectRatio Define the current aspect ratio of the effect
  8266. */
  8267. bind(effect: Effect, aspectRatio?: number): void;
  8268. /**
  8269. * Clones the current image processing instance.
  8270. * @return The cloned image processing
  8271. */
  8272. clone(): ImageProcessingConfiguration;
  8273. /**
  8274. * Serializes the current image processing instance to a json representation.
  8275. * @return a JSON representation
  8276. */
  8277. serialize(): any;
  8278. /**
  8279. * Parses the image processing from a json representation.
  8280. * @param source the JSON source to parse
  8281. * @return The parsed image processing
  8282. */
  8283. static Parse(source: any): ImageProcessingConfiguration;
  8284. private static _VIGNETTEMODE_MULTIPLY;
  8285. private static _VIGNETTEMODE_OPAQUE;
  8286. /**
  8287. * Used to apply the vignette as a mix with the pixel color.
  8288. */
  8289. static readonly VIGNETTEMODE_MULTIPLY: number;
  8290. /**
  8291. * Used to apply the vignette as a replacement of the pixel color.
  8292. */
  8293. static readonly VIGNETTEMODE_OPAQUE: number;
  8294. }
  8295. }
  8296. declare module "babylonjs/Shaders/postprocess.vertex" {
  8297. /** @hidden */
  8298. export var postprocessVertexShader: {
  8299. name: string;
  8300. shader: string;
  8301. };
  8302. }
  8303. declare module "babylonjs/Maths/math.axis" {
  8304. import { Vector3 } from "babylonjs/Maths/math.vector";
  8305. /** Defines supported spaces */
  8306. export enum Space {
  8307. /** Local (object) space */
  8308. LOCAL = 0,
  8309. /** World space */
  8310. WORLD = 1,
  8311. /** Bone space */
  8312. BONE = 2
  8313. }
  8314. /** Defines the 3 main axes */
  8315. export class Axis {
  8316. /** X axis */
  8317. static X: Vector3;
  8318. /** Y axis */
  8319. static Y: Vector3;
  8320. /** Z axis */
  8321. static Z: Vector3;
  8322. }
  8323. }
  8324. declare module "babylonjs/Cameras/targetCamera" {
  8325. import { Nullable } from "babylonjs/types";
  8326. import { Camera } from "babylonjs/Cameras/camera";
  8327. import { Scene } from "babylonjs/scene";
  8328. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8329. /**
  8330. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8331. * This is the base of the follow, arc rotate cameras and Free camera
  8332. * @see http://doc.babylonjs.com/features/cameras
  8333. */
  8334. export class TargetCamera extends Camera {
  8335. private static _RigCamTransformMatrix;
  8336. private static _TargetTransformMatrix;
  8337. private static _TargetFocalPoint;
  8338. /**
  8339. * Define the current direction the camera is moving to
  8340. */
  8341. cameraDirection: Vector3;
  8342. /**
  8343. * Define the current rotation the camera is rotating to
  8344. */
  8345. cameraRotation: Vector2;
  8346. /**
  8347. * When set, the up vector of the camera will be updated by the rotation of the camera
  8348. */
  8349. updateUpVectorFromRotation: boolean;
  8350. private _tmpQuaternion;
  8351. /**
  8352. * Define the current rotation of the camera
  8353. */
  8354. rotation: Vector3;
  8355. /**
  8356. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8357. */
  8358. rotationQuaternion: Quaternion;
  8359. /**
  8360. * Define the current speed of the camera
  8361. */
  8362. speed: number;
  8363. /**
  8364. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8365. * around all axis.
  8366. */
  8367. noRotationConstraint: boolean;
  8368. /**
  8369. * Define the current target of the camera as an object or a position.
  8370. */
  8371. lockedTarget: any;
  8372. /** @hidden */
  8373. _currentTarget: Vector3;
  8374. /** @hidden */
  8375. _initialFocalDistance: number;
  8376. /** @hidden */
  8377. _viewMatrix: Matrix;
  8378. /** @hidden */
  8379. _camMatrix: Matrix;
  8380. /** @hidden */
  8381. _cameraTransformMatrix: Matrix;
  8382. /** @hidden */
  8383. _cameraRotationMatrix: Matrix;
  8384. /** @hidden */
  8385. _referencePoint: Vector3;
  8386. /** @hidden */
  8387. _transformedReferencePoint: Vector3;
  8388. protected _globalCurrentTarget: Vector3;
  8389. protected _globalCurrentUpVector: Vector3;
  8390. /** @hidden */
  8391. _reset: () => void;
  8392. private _defaultUp;
  8393. /**
  8394. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8395. * This is the base of the follow, arc rotate cameras and Free camera
  8396. * @see http://doc.babylonjs.com/features/cameras
  8397. * @param name Defines the name of the camera in the scene
  8398. * @param position Defines the start position of the camera in the scene
  8399. * @param scene Defines the scene the camera belongs to
  8400. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8401. */
  8402. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8403. /**
  8404. * Gets the position in front of the camera at a given distance.
  8405. * @param distance The distance from the camera we want the position to be
  8406. * @returns the position
  8407. */
  8408. getFrontPosition(distance: number): Vector3;
  8409. /** @hidden */
  8410. _getLockedTargetPosition(): Nullable<Vector3>;
  8411. private _storedPosition;
  8412. private _storedRotation;
  8413. private _storedRotationQuaternion;
  8414. /**
  8415. * Store current camera state of the camera (fov, position, rotation, etc..)
  8416. * @returns the camera
  8417. */
  8418. storeState(): Camera;
  8419. /**
  8420. * Restored camera state. You must call storeState() first
  8421. * @returns whether it was successful or not
  8422. * @hidden
  8423. */
  8424. _restoreStateValues(): boolean;
  8425. /** @hidden */
  8426. _initCache(): void;
  8427. /** @hidden */
  8428. _updateCache(ignoreParentClass?: boolean): void;
  8429. /** @hidden */
  8430. _isSynchronizedViewMatrix(): boolean;
  8431. /** @hidden */
  8432. _computeLocalCameraSpeed(): number;
  8433. /**
  8434. * Defines the target the camera should look at.
  8435. * @param target Defines the new target as a Vector or a mesh
  8436. */
  8437. setTarget(target: Vector3): void;
  8438. /**
  8439. * Return the current target position of the camera. This value is expressed in local space.
  8440. * @returns the target position
  8441. */
  8442. getTarget(): Vector3;
  8443. /** @hidden */
  8444. _decideIfNeedsToMove(): boolean;
  8445. /** @hidden */
  8446. _updatePosition(): void;
  8447. /** @hidden */
  8448. _checkInputs(): void;
  8449. protected _updateCameraRotationMatrix(): void;
  8450. /**
  8451. * 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)
  8452. * @returns the current camera
  8453. */
  8454. private _rotateUpVectorWithCameraRotationMatrix;
  8455. private _cachedRotationZ;
  8456. private _cachedQuaternionRotationZ;
  8457. /** @hidden */
  8458. _getViewMatrix(): Matrix;
  8459. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8460. /**
  8461. * @hidden
  8462. */
  8463. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8464. /**
  8465. * @hidden
  8466. */
  8467. _updateRigCameras(): void;
  8468. private _getRigCamPositionAndTarget;
  8469. /**
  8470. * Gets the current object class name.
  8471. * @return the class name
  8472. */
  8473. getClassName(): string;
  8474. }
  8475. }
  8476. declare module "babylonjs/Events/keyboardEvents" {
  8477. /**
  8478. * Gather the list of keyboard event types as constants.
  8479. */
  8480. export class KeyboardEventTypes {
  8481. /**
  8482. * The keydown event is fired when a key becomes active (pressed).
  8483. */
  8484. static readonly KEYDOWN: number;
  8485. /**
  8486. * The keyup event is fired when a key has been released.
  8487. */
  8488. static readonly KEYUP: number;
  8489. }
  8490. /**
  8491. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8492. */
  8493. export class KeyboardInfo {
  8494. /**
  8495. * Defines the type of event (KeyboardEventTypes)
  8496. */
  8497. type: number;
  8498. /**
  8499. * Defines the related dom event
  8500. */
  8501. event: KeyboardEvent;
  8502. /**
  8503. * Instantiates a new keyboard info.
  8504. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8505. * @param type Defines the type of event (KeyboardEventTypes)
  8506. * @param event Defines the related dom event
  8507. */
  8508. constructor(
  8509. /**
  8510. * Defines the type of event (KeyboardEventTypes)
  8511. */
  8512. type: number,
  8513. /**
  8514. * Defines the related dom event
  8515. */
  8516. event: KeyboardEvent);
  8517. }
  8518. /**
  8519. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8520. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8521. */
  8522. export class KeyboardInfoPre extends KeyboardInfo {
  8523. /**
  8524. * Defines the type of event (KeyboardEventTypes)
  8525. */
  8526. type: number;
  8527. /**
  8528. * Defines the related dom event
  8529. */
  8530. event: KeyboardEvent;
  8531. /**
  8532. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8533. */
  8534. skipOnPointerObservable: boolean;
  8535. /**
  8536. * Instantiates a new keyboard pre info.
  8537. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8538. * @param type Defines the type of event (KeyboardEventTypes)
  8539. * @param event Defines the related dom event
  8540. */
  8541. constructor(
  8542. /**
  8543. * Defines the type of event (KeyboardEventTypes)
  8544. */
  8545. type: number,
  8546. /**
  8547. * Defines the related dom event
  8548. */
  8549. event: KeyboardEvent);
  8550. }
  8551. }
  8552. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8553. import { Nullable } from "babylonjs/types";
  8554. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8555. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8556. /**
  8557. * Manage the keyboard inputs to control the movement of a free camera.
  8558. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8559. */
  8560. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8561. /**
  8562. * Defines the camera the input is attached to.
  8563. */
  8564. camera: FreeCamera;
  8565. /**
  8566. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8567. */
  8568. keysUp: number[];
  8569. /**
  8570. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8571. */
  8572. keysDown: number[];
  8573. /**
  8574. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8575. */
  8576. keysLeft: number[];
  8577. /**
  8578. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8579. */
  8580. keysRight: number[];
  8581. private _keys;
  8582. private _onCanvasBlurObserver;
  8583. private _onKeyboardObserver;
  8584. private _engine;
  8585. private _scene;
  8586. /**
  8587. * Attach the input controls to a specific dom element to get the input from.
  8588. * @param element Defines the element the controls should be listened from
  8589. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8590. */
  8591. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8592. /**
  8593. * Detach the current controls from the specified dom element.
  8594. * @param element Defines the element to stop listening the inputs from
  8595. */
  8596. detachControl(element: Nullable<HTMLElement>): void;
  8597. /**
  8598. * Update the current camera state depending on the inputs that have been used this frame.
  8599. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8600. */
  8601. checkInputs(): void;
  8602. /**
  8603. * Gets the class name of the current intput.
  8604. * @returns the class name
  8605. */
  8606. getClassName(): string;
  8607. /** @hidden */
  8608. _onLostFocus(): void;
  8609. /**
  8610. * Get the friendly name associated with the input class.
  8611. * @returns the input friendly name
  8612. */
  8613. getSimpleName(): string;
  8614. }
  8615. }
  8616. declare module "babylonjs/Lights/shadowLight" {
  8617. import { Camera } from "babylonjs/Cameras/camera";
  8618. import { Scene } from "babylonjs/scene";
  8619. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8621. import { Light } from "babylonjs/Lights/light";
  8622. /**
  8623. * Interface describing all the common properties and methods a shadow light needs to implement.
  8624. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8625. * as well as binding the different shadow properties to the effects.
  8626. */
  8627. export interface IShadowLight extends Light {
  8628. /**
  8629. * The light id in the scene (used in scene.findLighById for instance)
  8630. */
  8631. id: string;
  8632. /**
  8633. * The position the shdow will be casted from.
  8634. */
  8635. position: Vector3;
  8636. /**
  8637. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8638. */
  8639. direction: Vector3;
  8640. /**
  8641. * The transformed position. Position of the light in world space taking parenting in account.
  8642. */
  8643. transformedPosition: Vector3;
  8644. /**
  8645. * The transformed direction. Direction of the light in world space taking parenting in account.
  8646. */
  8647. transformedDirection: Vector3;
  8648. /**
  8649. * The friendly name of the light in the scene.
  8650. */
  8651. name: string;
  8652. /**
  8653. * Defines the shadow projection clipping minimum z value.
  8654. */
  8655. shadowMinZ: number;
  8656. /**
  8657. * Defines the shadow projection clipping maximum z value.
  8658. */
  8659. shadowMaxZ: number;
  8660. /**
  8661. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8662. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8663. */
  8664. computeTransformedInformation(): boolean;
  8665. /**
  8666. * Gets the scene the light belongs to.
  8667. * @returns The scene
  8668. */
  8669. getScene(): Scene;
  8670. /**
  8671. * Callback defining a custom Projection Matrix Builder.
  8672. * This can be used to override the default projection matrix computation.
  8673. */
  8674. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8675. /**
  8676. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8677. * @param matrix The materix to updated with the projection information
  8678. * @param viewMatrix The transform matrix of the light
  8679. * @param renderList The list of mesh to render in the map
  8680. * @returns The current light
  8681. */
  8682. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8683. /**
  8684. * Gets the current depth scale used in ESM.
  8685. * @returns The scale
  8686. */
  8687. getDepthScale(): number;
  8688. /**
  8689. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8690. * @returns true if a cube texture needs to be use
  8691. */
  8692. needCube(): boolean;
  8693. /**
  8694. * Detects if the projection matrix requires to be recomputed this frame.
  8695. * @returns true if it requires to be recomputed otherwise, false.
  8696. */
  8697. needProjectionMatrixCompute(): boolean;
  8698. /**
  8699. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8700. */
  8701. forceProjectionMatrixCompute(): void;
  8702. /**
  8703. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8704. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8705. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8706. */
  8707. getShadowDirection(faceIndex?: number): Vector3;
  8708. /**
  8709. * Gets the minZ used for shadow according to both the scene and the light.
  8710. * @param activeCamera The camera we are returning the min for
  8711. * @returns the depth min z
  8712. */
  8713. getDepthMinZ(activeCamera: Camera): number;
  8714. /**
  8715. * Gets the maxZ used for shadow according to both the scene and the light.
  8716. * @param activeCamera The camera we are returning the max for
  8717. * @returns the depth max z
  8718. */
  8719. getDepthMaxZ(activeCamera: Camera): number;
  8720. }
  8721. /**
  8722. * Base implementation IShadowLight
  8723. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8724. */
  8725. export abstract class ShadowLight extends Light implements IShadowLight {
  8726. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8727. protected _position: Vector3;
  8728. protected _setPosition(value: Vector3): void;
  8729. /**
  8730. * Sets the position the shadow will be casted from. Also use as the light position for both
  8731. * point and spot lights.
  8732. */
  8733. /**
  8734. * Sets the position the shadow will be casted from. Also use as the light position for both
  8735. * point and spot lights.
  8736. */
  8737. position: Vector3;
  8738. protected _direction: Vector3;
  8739. protected _setDirection(value: Vector3): void;
  8740. /**
  8741. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8742. * Also use as the light direction on spot and directional lights.
  8743. */
  8744. /**
  8745. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8746. * Also use as the light direction on spot and directional lights.
  8747. */
  8748. direction: Vector3;
  8749. private _shadowMinZ;
  8750. /**
  8751. * Gets the shadow projection clipping minimum z value.
  8752. */
  8753. /**
  8754. * Sets the shadow projection clipping minimum z value.
  8755. */
  8756. shadowMinZ: number;
  8757. private _shadowMaxZ;
  8758. /**
  8759. * Sets the shadow projection clipping maximum z value.
  8760. */
  8761. /**
  8762. * Gets the shadow projection clipping maximum z value.
  8763. */
  8764. shadowMaxZ: number;
  8765. /**
  8766. * Callback defining a custom Projection Matrix Builder.
  8767. * This can be used to override the default projection matrix computation.
  8768. */
  8769. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8770. /**
  8771. * The transformed position. Position of the light in world space taking parenting in account.
  8772. */
  8773. transformedPosition: Vector3;
  8774. /**
  8775. * The transformed direction. Direction of the light in world space taking parenting in account.
  8776. */
  8777. transformedDirection: Vector3;
  8778. private _needProjectionMatrixCompute;
  8779. /**
  8780. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8781. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8782. */
  8783. computeTransformedInformation(): boolean;
  8784. /**
  8785. * Return the depth scale used for the shadow map.
  8786. * @returns the depth scale.
  8787. */
  8788. getDepthScale(): number;
  8789. /**
  8790. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8791. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8792. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8793. */
  8794. getShadowDirection(faceIndex?: number): Vector3;
  8795. /**
  8796. * Returns the ShadowLight absolute position in the World.
  8797. * @returns the position vector in world space
  8798. */
  8799. getAbsolutePosition(): Vector3;
  8800. /**
  8801. * Sets the ShadowLight direction toward the passed target.
  8802. * @param target The point to target in local space
  8803. * @returns the updated ShadowLight direction
  8804. */
  8805. setDirectionToTarget(target: Vector3): Vector3;
  8806. /**
  8807. * Returns the light rotation in euler definition.
  8808. * @returns the x y z rotation in local space.
  8809. */
  8810. getRotation(): Vector3;
  8811. /**
  8812. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8813. * @returns true if a cube texture needs to be use
  8814. */
  8815. needCube(): boolean;
  8816. /**
  8817. * Detects if the projection matrix requires to be recomputed this frame.
  8818. * @returns true if it requires to be recomputed otherwise, false.
  8819. */
  8820. needProjectionMatrixCompute(): boolean;
  8821. /**
  8822. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8823. */
  8824. forceProjectionMatrixCompute(): void;
  8825. /** @hidden */
  8826. _initCache(): void;
  8827. /** @hidden */
  8828. _isSynchronized(): boolean;
  8829. /**
  8830. * Computes the world matrix of the node
  8831. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8832. * @returns the world matrix
  8833. */
  8834. computeWorldMatrix(force?: boolean): Matrix;
  8835. /**
  8836. * Gets the minZ used for shadow according to both the scene and the light.
  8837. * @param activeCamera The camera we are returning the min for
  8838. * @returns the depth min z
  8839. */
  8840. getDepthMinZ(activeCamera: Camera): number;
  8841. /**
  8842. * Gets the maxZ used for shadow according to both the scene and the light.
  8843. * @param activeCamera The camera we are returning the max for
  8844. * @returns the depth max z
  8845. */
  8846. getDepthMaxZ(activeCamera: Camera): number;
  8847. /**
  8848. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8849. * @param matrix The materix to updated with the projection information
  8850. * @param viewMatrix The transform matrix of the light
  8851. * @param renderList The list of mesh to render in the map
  8852. * @returns The current light
  8853. */
  8854. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8855. }
  8856. }
  8857. declare module "babylonjs/Materials/materialHelper" {
  8858. import { Nullable } from "babylonjs/types";
  8859. import { Scene } from "babylonjs/scene";
  8860. import { Engine } from "babylonjs/Engines/engine";
  8861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8862. import { Light } from "babylonjs/Lights/light";
  8863. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8864. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  8865. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8866. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8867. /**
  8868. * "Static Class" containing the most commonly used helper while dealing with material for
  8869. * rendering purpose.
  8870. *
  8871. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8872. *
  8873. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8874. */
  8875. export class MaterialHelper {
  8876. /**
  8877. * Bind the current view position to an effect.
  8878. * @param effect The effect to be bound
  8879. * @param scene The scene the eyes position is used from
  8880. */
  8881. static BindEyePosition(effect: Effect, scene: Scene): void;
  8882. /**
  8883. * Helps preparing the defines values about the UVs in used in the effect.
  8884. * UVs are shared as much as we can accross channels in the shaders.
  8885. * @param texture The texture we are preparing the UVs for
  8886. * @param defines The defines to update
  8887. * @param key The channel key "diffuse", "specular"... used in the shader
  8888. */
  8889. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8890. /**
  8891. * Binds a texture matrix value to its corrsponding uniform
  8892. * @param texture The texture to bind the matrix for
  8893. * @param uniformBuffer The uniform buffer receivin the data
  8894. * @param key The channel key "diffuse", "specular"... used in the shader
  8895. */
  8896. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8897. /**
  8898. * Gets the current status of the fog (should it be enabled?)
  8899. * @param mesh defines the mesh to evaluate for fog support
  8900. * @param scene defines the hosting scene
  8901. * @returns true if fog must be enabled
  8902. */
  8903. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8904. /**
  8905. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8906. * @param mesh defines the current mesh
  8907. * @param scene defines the current scene
  8908. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8909. * @param pointsCloud defines if point cloud rendering has to be turned on
  8910. * @param fogEnabled defines if fog has to be turned on
  8911. * @param alphaTest defines if alpha testing has to be turned on
  8912. * @param defines defines the current list of defines
  8913. */
  8914. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8915. /**
  8916. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8917. * @param scene defines the current scene
  8918. * @param engine defines the current engine
  8919. * @param defines specifies the list of active defines
  8920. * @param useInstances defines if instances have to be turned on
  8921. * @param useClipPlane defines if clip plane have to be turned on
  8922. */
  8923. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8924. /**
  8925. * Prepares the defines for bones
  8926. * @param mesh The mesh containing the geometry data we will draw
  8927. * @param defines The defines to update
  8928. */
  8929. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8930. /**
  8931. * Prepares the defines for morph targets
  8932. * @param mesh The mesh containing the geometry data we will draw
  8933. * @param defines The defines to update
  8934. */
  8935. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8936. /**
  8937. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8938. * @param mesh The mesh containing the geometry data we will draw
  8939. * @param defines The defines to update
  8940. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8941. * @param useBones Precise whether bones should be used or not (override mesh info)
  8942. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8943. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8944. * @returns false if defines are considered not dirty and have not been checked
  8945. */
  8946. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8947. /**
  8948. * Prepares the defines related to multiview
  8949. * @param scene The scene we are intending to draw
  8950. * @param defines The defines to update
  8951. */
  8952. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8953. /**
  8954. * Prepares the defines related to the light information passed in parameter
  8955. * @param scene The scene we are intending to draw
  8956. * @param mesh The mesh the effect is compiling for
  8957. * @param light The light the effect is compiling for
  8958. * @param lightIndex The index of the light
  8959. * @param defines The defines to update
  8960. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8961. * @param state Defines the current state regarding what is needed (normals, etc...)
  8962. */
  8963. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8964. needNormals: boolean;
  8965. needRebuild: boolean;
  8966. shadowEnabled: boolean;
  8967. specularEnabled: boolean;
  8968. lightmapMode: boolean;
  8969. }): void;
  8970. /**
  8971. * Prepares the defines related to the light information passed in parameter
  8972. * @param scene The scene we are intending to draw
  8973. * @param mesh The mesh the effect is compiling for
  8974. * @param defines The defines to update
  8975. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8976. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8977. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8978. * @returns true if normals will be required for the rest of the effect
  8979. */
  8980. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8981. /**
  8982. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8983. * @param lightIndex defines the light index
  8984. * @param uniformsList The uniform list
  8985. * @param samplersList The sampler list
  8986. * @param projectedLightTexture defines if projected texture must be used
  8987. * @param uniformBuffersList defines an optional list of uniform buffers
  8988. */
  8989. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8990. /**
  8991. * Prepares the uniforms and samplers list to be used in the effect
  8992. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8993. * @param samplersList The sampler list
  8994. * @param defines The defines helping in the list generation
  8995. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8996. */
  8997. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8998. /**
  8999. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9000. * @param defines The defines to update while falling back
  9001. * @param fallbacks The authorized effect fallbacks
  9002. * @param maxSimultaneousLights The maximum number of lights allowed
  9003. * @param rank the current rank of the Effect
  9004. * @returns The newly affected rank
  9005. */
  9006. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9007. private static _TmpMorphInfluencers;
  9008. /**
  9009. * Prepares the list of attributes required for morph targets according to the effect defines.
  9010. * @param attribs The current list of supported attribs
  9011. * @param mesh The mesh to prepare the morph targets attributes for
  9012. * @param influencers The number of influencers
  9013. */
  9014. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9015. /**
  9016. * Prepares the list of attributes required for morph targets according to the effect defines.
  9017. * @param attribs The current list of supported attribs
  9018. * @param mesh The mesh to prepare the morph targets attributes for
  9019. * @param defines The current Defines of the effect
  9020. */
  9021. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9022. /**
  9023. * Prepares the list of attributes required for bones according to the effect defines.
  9024. * @param attribs The current list of supported attribs
  9025. * @param mesh The mesh to prepare the bones attributes for
  9026. * @param defines The current Defines of the effect
  9027. * @param fallbacks The current efffect fallback strategy
  9028. */
  9029. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9030. /**
  9031. * Check and prepare the list of attributes required for instances according to the effect defines.
  9032. * @param attribs The current list of supported attribs
  9033. * @param defines The current MaterialDefines of the effect
  9034. */
  9035. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9036. /**
  9037. * Add the list of attributes required for instances to the attribs array.
  9038. * @param attribs The current list of supported attribs
  9039. */
  9040. static PushAttributesForInstances(attribs: string[]): void;
  9041. /**
  9042. * Binds the light shadow information to the effect for the given mesh.
  9043. * @param light The light containing the generator
  9044. * @param scene The scene the lights belongs to
  9045. * @param mesh The mesh we are binding the information to render
  9046. * @param lightIndex The light index in the effect used to render the mesh
  9047. * @param effect The effect we are binding the data to
  9048. */
  9049. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9050. /**
  9051. * Binds the light information to the effect.
  9052. * @param light The light containing the generator
  9053. * @param effect The effect we are binding the data to
  9054. * @param lightIndex The light index in the effect used to render
  9055. */
  9056. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9057. /**
  9058. * Binds the lights information from the scene to the effect for the given mesh.
  9059. * @param light Light to bind
  9060. * @param lightIndex Light index
  9061. * @param scene The scene where the light belongs to
  9062. * @param mesh The mesh we are binding the information to render
  9063. * @param effect The effect we are binding the data to
  9064. * @param useSpecular Defines if specular is supported
  9065. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9066. */
  9067. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  9068. /**
  9069. * Binds the lights information from the scene to the effect for the given mesh.
  9070. * @param scene The scene the lights belongs to
  9071. * @param mesh The mesh we are binding the information to render
  9072. * @param effect The effect we are binding the data to
  9073. * @param defines The generated defines for the effect
  9074. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9075. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9076. */
  9077. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9078. private static _tempFogColor;
  9079. /**
  9080. * Binds the fog information from the scene to the effect for the given mesh.
  9081. * @param scene The scene the lights belongs to
  9082. * @param mesh The mesh we are binding the information to render
  9083. * @param effect The effect we are binding the data to
  9084. * @param linearSpace Defines if the fog effect is applied in linear space
  9085. */
  9086. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9087. /**
  9088. * Binds the bones information from the mesh to the effect.
  9089. * @param mesh The mesh we are binding the information to render
  9090. * @param effect The effect we are binding the data to
  9091. */
  9092. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9093. /**
  9094. * Binds the morph targets information from the mesh to the effect.
  9095. * @param abstractMesh The mesh we are binding the information to render
  9096. * @param effect The effect we are binding the data to
  9097. */
  9098. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9099. /**
  9100. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9101. * @param defines The generated defines used in the effect
  9102. * @param effect The effect we are binding the data to
  9103. * @param scene The scene we are willing to render with logarithmic scale for
  9104. */
  9105. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9106. /**
  9107. * Binds the clip plane information from the scene to the effect.
  9108. * @param scene The scene the clip plane information are extracted from
  9109. * @param effect The effect we are binding the data to
  9110. */
  9111. static BindClipPlane(effect: Effect, scene: Scene): void;
  9112. }
  9113. }
  9114. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9115. /** @hidden */
  9116. export var packingFunctions: {
  9117. name: string;
  9118. shader: string;
  9119. };
  9120. }
  9121. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9122. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9123. /** @hidden */
  9124. export var shadowMapPixelShader: {
  9125. name: string;
  9126. shader: string;
  9127. };
  9128. }
  9129. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9130. /** @hidden */
  9131. export var bonesDeclaration: {
  9132. name: string;
  9133. shader: string;
  9134. };
  9135. }
  9136. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9137. /** @hidden */
  9138. export var morphTargetsVertexGlobalDeclaration: {
  9139. name: string;
  9140. shader: string;
  9141. };
  9142. }
  9143. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9144. /** @hidden */
  9145. export var morphTargetsVertexDeclaration: {
  9146. name: string;
  9147. shader: string;
  9148. };
  9149. }
  9150. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9151. /** @hidden */
  9152. export var instancesDeclaration: {
  9153. name: string;
  9154. shader: string;
  9155. };
  9156. }
  9157. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9158. /** @hidden */
  9159. export var helperFunctions: {
  9160. name: string;
  9161. shader: string;
  9162. };
  9163. }
  9164. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9165. /** @hidden */
  9166. export var morphTargetsVertex: {
  9167. name: string;
  9168. shader: string;
  9169. };
  9170. }
  9171. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9172. /** @hidden */
  9173. export var instancesVertex: {
  9174. name: string;
  9175. shader: string;
  9176. };
  9177. }
  9178. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9179. /** @hidden */
  9180. export var bonesVertex: {
  9181. name: string;
  9182. shader: string;
  9183. };
  9184. }
  9185. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9186. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9187. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9188. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9189. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9190. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9191. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9192. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9193. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9194. /** @hidden */
  9195. export var shadowMapVertexShader: {
  9196. name: string;
  9197. shader: string;
  9198. };
  9199. }
  9200. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9201. /** @hidden */
  9202. export var depthBoxBlurPixelShader: {
  9203. name: string;
  9204. shader: string;
  9205. };
  9206. }
  9207. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9208. import { Nullable } from "babylonjs/types";
  9209. import { Scene } from "babylonjs/scene";
  9210. import { Matrix } from "babylonjs/Maths/math.vector";
  9211. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9213. import { Mesh } from "babylonjs/Meshes/mesh";
  9214. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9215. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9216. import { Effect } from "babylonjs/Materials/effect";
  9217. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9218. import "babylonjs/Shaders/shadowMap.fragment";
  9219. import "babylonjs/Shaders/shadowMap.vertex";
  9220. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9221. import { Observable } from "babylonjs/Misc/observable";
  9222. /**
  9223. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9224. */
  9225. export interface ICustomShaderOptions {
  9226. /**
  9227. * Gets or sets the custom shader name to use
  9228. */
  9229. shaderName: string;
  9230. /**
  9231. * The list of attribute names used in the shader
  9232. */
  9233. attributes?: string[];
  9234. /**
  9235. * The list of unifrom names used in the shader
  9236. */
  9237. uniforms?: string[];
  9238. /**
  9239. * The list of sampler names used in the shader
  9240. */
  9241. samplers?: string[];
  9242. /**
  9243. * The list of defines used in the shader
  9244. */
  9245. defines?: string[];
  9246. }
  9247. /**
  9248. * Interface to implement to create a shadow generator compatible with BJS.
  9249. */
  9250. export interface IShadowGenerator {
  9251. /**
  9252. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9253. * @returns The render target texture if present otherwise, null
  9254. */
  9255. getShadowMap(): Nullable<RenderTargetTexture>;
  9256. /**
  9257. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9258. * @returns The render target texture if the shadow map is present otherwise, null
  9259. */
  9260. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9261. /**
  9262. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9263. * @param subMesh The submesh we want to render in the shadow map
  9264. * @param useInstances Defines wether will draw in the map using instances
  9265. * @returns true if ready otherwise, false
  9266. */
  9267. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9268. /**
  9269. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9270. * @param defines Defines of the material we want to update
  9271. * @param lightIndex Index of the light in the enabled light list of the material
  9272. */
  9273. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9274. /**
  9275. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9276. * defined in the generator but impacting the effect).
  9277. * It implies the unifroms available on the materials are the standard BJS ones.
  9278. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9279. * @param effect The effect we are binfing the information for
  9280. */
  9281. bindShadowLight(lightIndex: string, effect: Effect): void;
  9282. /**
  9283. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9284. * (eq to shadow prjection matrix * light transform matrix)
  9285. * @returns The transform matrix used to create the shadow map
  9286. */
  9287. getTransformMatrix(): Matrix;
  9288. /**
  9289. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9290. * Cube and 2D textures for instance.
  9291. */
  9292. recreateShadowMap(): void;
  9293. /**
  9294. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9295. * @param onCompiled Callback triggered at the and of the effects compilation
  9296. * @param options Sets of optional options forcing the compilation with different modes
  9297. */
  9298. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9299. useInstances: boolean;
  9300. }>): void;
  9301. /**
  9302. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9303. * @param options Sets of optional options forcing the compilation with different modes
  9304. * @returns A promise that resolves when the compilation completes
  9305. */
  9306. forceCompilationAsync(options?: Partial<{
  9307. useInstances: boolean;
  9308. }>): Promise<void>;
  9309. /**
  9310. * Serializes the shadow generator setup to a json object.
  9311. * @returns The serialized JSON object
  9312. */
  9313. serialize(): any;
  9314. /**
  9315. * Disposes the Shadow map and related Textures and effects.
  9316. */
  9317. dispose(): void;
  9318. }
  9319. /**
  9320. * Default implementation IShadowGenerator.
  9321. * This is the main object responsible of generating shadows in the framework.
  9322. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9323. */
  9324. export class ShadowGenerator implements IShadowGenerator {
  9325. /**
  9326. * Shadow generator mode None: no filtering applied.
  9327. */
  9328. static readonly FILTER_NONE: number;
  9329. /**
  9330. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9331. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9332. */
  9333. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9334. /**
  9335. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9336. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9337. */
  9338. static readonly FILTER_POISSONSAMPLING: number;
  9339. /**
  9340. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9341. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9342. */
  9343. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9344. /**
  9345. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9346. * edge artifacts on steep falloff.
  9347. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9348. */
  9349. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9350. /**
  9351. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9352. * edge artifacts on steep falloff.
  9353. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9354. */
  9355. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9356. /**
  9357. * Shadow generator mode PCF: Percentage Closer Filtering
  9358. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9359. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9360. */
  9361. static readonly FILTER_PCF: number;
  9362. /**
  9363. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9364. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9365. * Contact Hardening
  9366. */
  9367. static readonly FILTER_PCSS: number;
  9368. /**
  9369. * Reserved for PCF and PCSS
  9370. * Highest Quality.
  9371. *
  9372. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9373. *
  9374. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9375. */
  9376. static readonly QUALITY_HIGH: number;
  9377. /**
  9378. * Reserved for PCF and PCSS
  9379. * Good tradeoff for quality/perf cross devices
  9380. *
  9381. * Execute PCF on a 3*3 kernel.
  9382. *
  9383. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9384. */
  9385. static readonly QUALITY_MEDIUM: number;
  9386. /**
  9387. * Reserved for PCF and PCSS
  9388. * The lowest quality but the fastest.
  9389. *
  9390. * Execute PCF on a 1*1 kernel.
  9391. *
  9392. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9393. */
  9394. static readonly QUALITY_LOW: number;
  9395. /** Gets or sets the custom shader name to use */
  9396. customShaderOptions: ICustomShaderOptions;
  9397. /**
  9398. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9399. */
  9400. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9401. /**
  9402. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9403. */
  9404. onAfterShadowMapRenderObservable: Observable<Effect>;
  9405. /**
  9406. * Observable triggered before a mesh is rendered in the shadow map.
  9407. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9408. */
  9409. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9410. /**
  9411. * Observable triggered after a mesh is rendered in the shadow map.
  9412. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9413. */
  9414. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9415. private _bias;
  9416. /**
  9417. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9418. */
  9419. /**
  9420. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9421. */
  9422. bias: number;
  9423. private _normalBias;
  9424. /**
  9425. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9426. */
  9427. /**
  9428. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9429. */
  9430. normalBias: number;
  9431. private _blurBoxOffset;
  9432. /**
  9433. * Gets the blur box offset: offset applied during the blur pass.
  9434. * Only useful if useKernelBlur = false
  9435. */
  9436. /**
  9437. * Sets the blur box offset: offset applied during the blur pass.
  9438. * Only useful if useKernelBlur = false
  9439. */
  9440. blurBoxOffset: number;
  9441. private _blurScale;
  9442. /**
  9443. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9444. * 2 means half of the size.
  9445. */
  9446. /**
  9447. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9448. * 2 means half of the size.
  9449. */
  9450. blurScale: number;
  9451. private _blurKernel;
  9452. /**
  9453. * Gets the blur kernel: kernel size of the blur pass.
  9454. * Only useful if useKernelBlur = true
  9455. */
  9456. /**
  9457. * Sets the blur kernel: kernel size of the blur pass.
  9458. * Only useful if useKernelBlur = true
  9459. */
  9460. blurKernel: number;
  9461. private _useKernelBlur;
  9462. /**
  9463. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9464. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9465. */
  9466. /**
  9467. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9468. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9469. */
  9470. useKernelBlur: boolean;
  9471. private _depthScale;
  9472. /**
  9473. * Gets the depth scale used in ESM mode.
  9474. */
  9475. /**
  9476. * Sets the depth scale used in ESM mode.
  9477. * This can override the scale stored on the light.
  9478. */
  9479. depthScale: number;
  9480. private _filter;
  9481. /**
  9482. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9483. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9484. */
  9485. /**
  9486. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9487. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9488. */
  9489. filter: number;
  9490. /**
  9491. * Gets if the current filter is set to Poisson Sampling.
  9492. */
  9493. /**
  9494. * Sets the current filter to Poisson Sampling.
  9495. */
  9496. usePoissonSampling: boolean;
  9497. /**
  9498. * Gets if the current filter is set to ESM.
  9499. */
  9500. /**
  9501. * Sets the current filter is to ESM.
  9502. */
  9503. useExponentialShadowMap: boolean;
  9504. /**
  9505. * Gets if the current filter is set to filtered ESM.
  9506. */
  9507. /**
  9508. * Gets if the current filter is set to filtered ESM.
  9509. */
  9510. useBlurExponentialShadowMap: boolean;
  9511. /**
  9512. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9513. * exponential to prevent steep falloff artifacts).
  9514. */
  9515. /**
  9516. * Sets the current filter to "close ESM" (using the inverse of the
  9517. * exponential to prevent steep falloff artifacts).
  9518. */
  9519. useCloseExponentialShadowMap: boolean;
  9520. /**
  9521. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9522. * exponential to prevent steep falloff artifacts).
  9523. */
  9524. /**
  9525. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9526. * exponential to prevent steep falloff artifacts).
  9527. */
  9528. useBlurCloseExponentialShadowMap: boolean;
  9529. /**
  9530. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9531. */
  9532. /**
  9533. * Sets the current filter to "PCF" (percentage closer filtering).
  9534. */
  9535. usePercentageCloserFiltering: boolean;
  9536. private _filteringQuality;
  9537. /**
  9538. * Gets the PCF or PCSS Quality.
  9539. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9540. */
  9541. /**
  9542. * Sets the PCF or PCSS Quality.
  9543. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9544. */
  9545. filteringQuality: number;
  9546. /**
  9547. * Gets if the current filter is set to "PCSS" (contact hardening).
  9548. */
  9549. /**
  9550. * Sets the current filter to "PCSS" (contact hardening).
  9551. */
  9552. useContactHardeningShadow: boolean;
  9553. private _contactHardeningLightSizeUVRatio;
  9554. /**
  9555. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9556. * Using a ratio helps keeping shape stability independently of the map size.
  9557. *
  9558. * It does not account for the light projection as it was having too much
  9559. * instability during the light setup or during light position changes.
  9560. *
  9561. * Only valid if useContactHardeningShadow is true.
  9562. */
  9563. /**
  9564. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9565. * Using a ratio helps keeping shape stability independently of the map size.
  9566. *
  9567. * It does not account for the light projection as it was having too much
  9568. * instability during the light setup or during light position changes.
  9569. *
  9570. * Only valid if useContactHardeningShadow is true.
  9571. */
  9572. contactHardeningLightSizeUVRatio: number;
  9573. private _darkness;
  9574. /** Gets or sets the actual darkness of a shadow */
  9575. darkness: number;
  9576. /**
  9577. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9578. * 0 means strongest and 1 would means no shadow.
  9579. * @returns the darkness.
  9580. */
  9581. getDarkness(): number;
  9582. /**
  9583. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9584. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9585. * @returns the shadow generator allowing fluent coding.
  9586. */
  9587. setDarkness(darkness: number): ShadowGenerator;
  9588. private _transparencyShadow;
  9589. /** Gets or sets the ability to have transparent shadow */
  9590. transparencyShadow: boolean;
  9591. /**
  9592. * Sets the ability to have transparent shadow (boolean).
  9593. * @param transparent True if transparent else False
  9594. * @returns the shadow generator allowing fluent coding
  9595. */
  9596. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9597. private _shadowMap;
  9598. private _shadowMap2;
  9599. /**
  9600. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9601. * @returns The render target texture if present otherwise, null
  9602. */
  9603. getShadowMap(): Nullable<RenderTargetTexture>;
  9604. /**
  9605. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9606. * @returns The render target texture if the shadow map is present otherwise, null
  9607. */
  9608. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9609. /**
  9610. * Gets the class name of that object
  9611. * @returns "ShadowGenerator"
  9612. */
  9613. getClassName(): string;
  9614. /**
  9615. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9616. * @param mesh Mesh to add
  9617. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9618. * @returns the Shadow Generator itself
  9619. */
  9620. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9621. /**
  9622. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9623. * @param mesh Mesh to remove
  9624. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9625. * @returns the Shadow Generator itself
  9626. */
  9627. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9628. /**
  9629. * Controls the extent to which the shadows fade out at the edge of the frustum
  9630. * Used only by directionals and spots
  9631. */
  9632. frustumEdgeFalloff: number;
  9633. private _light;
  9634. /**
  9635. * Returns the associated light object.
  9636. * @returns the light generating the shadow
  9637. */
  9638. getLight(): IShadowLight;
  9639. /**
  9640. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9641. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9642. * It might on the other hand introduce peter panning.
  9643. */
  9644. forceBackFacesOnly: boolean;
  9645. private _scene;
  9646. private _lightDirection;
  9647. private _effect;
  9648. private _viewMatrix;
  9649. private _projectionMatrix;
  9650. private _transformMatrix;
  9651. private _cachedPosition;
  9652. private _cachedDirection;
  9653. private _cachedDefines;
  9654. private _currentRenderID;
  9655. private _boxBlurPostprocess;
  9656. private _kernelBlurXPostprocess;
  9657. private _kernelBlurYPostprocess;
  9658. private _blurPostProcesses;
  9659. private _mapSize;
  9660. private _currentFaceIndex;
  9661. private _currentFaceIndexCache;
  9662. private _textureType;
  9663. private _defaultTextureMatrix;
  9664. /** @hidden */
  9665. static _SceneComponentInitialization: (scene: Scene) => void;
  9666. /**
  9667. * Creates a ShadowGenerator object.
  9668. * A ShadowGenerator is the required tool to use the shadows.
  9669. * Each light casting shadows needs to use its own ShadowGenerator.
  9670. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9671. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9672. * @param light The light object generating the shadows.
  9673. * @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.
  9674. */
  9675. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9676. private _initializeGenerator;
  9677. private _initializeShadowMap;
  9678. private _initializeBlurRTTAndPostProcesses;
  9679. private _renderForShadowMap;
  9680. private _renderSubMeshForShadowMap;
  9681. private _applyFilterValues;
  9682. /**
  9683. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9684. * @param onCompiled Callback triggered at the and of the effects compilation
  9685. * @param options Sets of optional options forcing the compilation with different modes
  9686. */
  9687. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9688. useInstances: boolean;
  9689. }>): void;
  9690. /**
  9691. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9692. * @param options Sets of optional options forcing the compilation with different modes
  9693. * @returns A promise that resolves when the compilation completes
  9694. */
  9695. forceCompilationAsync(options?: Partial<{
  9696. useInstances: boolean;
  9697. }>): Promise<void>;
  9698. /**
  9699. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9700. * @param subMesh The submesh we want to render in the shadow map
  9701. * @param useInstances Defines wether will draw in the map using instances
  9702. * @returns true if ready otherwise, false
  9703. */
  9704. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9705. /**
  9706. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9707. * @param defines Defines of the material we want to update
  9708. * @param lightIndex Index of the light in the enabled light list of the material
  9709. */
  9710. prepareDefines(defines: any, lightIndex: number): void;
  9711. /**
  9712. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9713. * defined in the generator but impacting the effect).
  9714. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9715. * @param effect The effect we are binfing the information for
  9716. */
  9717. bindShadowLight(lightIndex: string, effect: Effect): void;
  9718. /**
  9719. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9720. * (eq to shadow prjection matrix * light transform matrix)
  9721. * @returns The transform matrix used to create the shadow map
  9722. */
  9723. getTransformMatrix(): Matrix;
  9724. /**
  9725. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9726. * Cube and 2D textures for instance.
  9727. */
  9728. recreateShadowMap(): void;
  9729. private _disposeBlurPostProcesses;
  9730. private _disposeRTTandPostProcesses;
  9731. /**
  9732. * Disposes the ShadowGenerator.
  9733. * Returns nothing.
  9734. */
  9735. dispose(): void;
  9736. /**
  9737. * Serializes the shadow generator setup to a json object.
  9738. * @returns The serialized JSON object
  9739. */
  9740. serialize(): any;
  9741. /**
  9742. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9743. * @param parsedShadowGenerator The JSON object to parse
  9744. * @param scene The scene to create the shadow map for
  9745. * @returns The parsed shadow generator
  9746. */
  9747. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9748. }
  9749. }
  9750. declare module "babylonjs/Lights/light" {
  9751. import { Nullable } from "babylonjs/types";
  9752. import { Scene } from "babylonjs/scene";
  9753. import { Vector3 } from "babylonjs/Maths/math.vector";
  9754. import { Color3 } from "babylonjs/Maths/math.color";
  9755. import { Node } from "babylonjs/node";
  9756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9757. import { Effect } from "babylonjs/Materials/effect";
  9758. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9759. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9760. /**
  9761. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9762. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9763. * 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.
  9764. */
  9765. export abstract class Light extends Node {
  9766. /**
  9767. * Falloff Default: light is falling off following the material specification:
  9768. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9769. */
  9770. static readonly FALLOFF_DEFAULT: number;
  9771. /**
  9772. * Falloff Physical: light is falling off following the inverse squared distance law.
  9773. */
  9774. static readonly FALLOFF_PHYSICAL: number;
  9775. /**
  9776. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9777. * to enhance interoperability with other engines.
  9778. */
  9779. static readonly FALLOFF_GLTF: number;
  9780. /**
  9781. * Falloff Standard: light is falling off like in the standard material
  9782. * to enhance interoperability with other materials.
  9783. */
  9784. static readonly FALLOFF_STANDARD: number;
  9785. /**
  9786. * If every light affecting the material is in this lightmapMode,
  9787. * material.lightmapTexture adds or multiplies
  9788. * (depends on material.useLightmapAsShadowmap)
  9789. * after every other light calculations.
  9790. */
  9791. static readonly LIGHTMAP_DEFAULT: number;
  9792. /**
  9793. * material.lightmapTexture as only diffuse lighting from this light
  9794. * adds only specular lighting from this light
  9795. * adds dynamic shadows
  9796. */
  9797. static readonly LIGHTMAP_SPECULAR: number;
  9798. /**
  9799. * material.lightmapTexture as only lighting
  9800. * no light calculation from this light
  9801. * only adds dynamic shadows from this light
  9802. */
  9803. static readonly LIGHTMAP_SHADOWSONLY: number;
  9804. /**
  9805. * Each light type uses the default quantity according to its type:
  9806. * point/spot lights use luminous intensity
  9807. * directional lights use illuminance
  9808. */
  9809. static readonly INTENSITYMODE_AUTOMATIC: number;
  9810. /**
  9811. * lumen (lm)
  9812. */
  9813. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9814. /**
  9815. * candela (lm/sr)
  9816. */
  9817. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9818. /**
  9819. * lux (lm/m^2)
  9820. */
  9821. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9822. /**
  9823. * nit (cd/m^2)
  9824. */
  9825. static readonly INTENSITYMODE_LUMINANCE: number;
  9826. /**
  9827. * Light type const id of the point light.
  9828. */
  9829. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9830. /**
  9831. * Light type const id of the directional light.
  9832. */
  9833. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9834. /**
  9835. * Light type const id of the spot light.
  9836. */
  9837. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9838. /**
  9839. * Light type const id of the hemispheric light.
  9840. */
  9841. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9842. /**
  9843. * Diffuse gives the basic color to an object.
  9844. */
  9845. diffuse: Color3;
  9846. /**
  9847. * Specular produces a highlight color on an object.
  9848. * Note: This is note affecting PBR materials.
  9849. */
  9850. specular: Color3;
  9851. /**
  9852. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9853. * falling off base on range or angle.
  9854. * This can be set to any values in Light.FALLOFF_x.
  9855. *
  9856. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9857. * other types of materials.
  9858. */
  9859. falloffType: number;
  9860. /**
  9861. * Strength of the light.
  9862. * Note: By default it is define in the framework own unit.
  9863. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9864. */
  9865. intensity: number;
  9866. private _range;
  9867. protected _inverseSquaredRange: number;
  9868. /**
  9869. * Defines how far from the source the light is impacting in scene units.
  9870. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9871. */
  9872. /**
  9873. * Defines how far from the source the light is impacting in scene units.
  9874. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9875. */
  9876. range: number;
  9877. /**
  9878. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9879. * of light.
  9880. */
  9881. private _photometricScale;
  9882. private _intensityMode;
  9883. /**
  9884. * Gets the photometric scale used to interpret the intensity.
  9885. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9886. */
  9887. /**
  9888. * Sets the photometric scale used to interpret the intensity.
  9889. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9890. */
  9891. intensityMode: number;
  9892. private _radius;
  9893. /**
  9894. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9895. */
  9896. /**
  9897. * sets the light radius used by PBR Materials to simulate soft area lights.
  9898. */
  9899. radius: number;
  9900. private _renderPriority;
  9901. /**
  9902. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9903. * exceeding the number allowed of the materials.
  9904. */
  9905. renderPriority: number;
  9906. private _shadowEnabled;
  9907. /**
  9908. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9909. * the current shadow generator.
  9910. */
  9911. /**
  9912. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9913. * the current shadow generator.
  9914. */
  9915. shadowEnabled: boolean;
  9916. private _includedOnlyMeshes;
  9917. /**
  9918. * Gets the only meshes impacted by this light.
  9919. */
  9920. /**
  9921. * Sets the only meshes impacted by this light.
  9922. */
  9923. includedOnlyMeshes: AbstractMesh[];
  9924. private _excludedMeshes;
  9925. /**
  9926. * Gets the meshes not impacted by this light.
  9927. */
  9928. /**
  9929. * Sets the meshes not impacted by this light.
  9930. */
  9931. excludedMeshes: AbstractMesh[];
  9932. private _excludeWithLayerMask;
  9933. /**
  9934. * Gets the layer id use to find what meshes are not impacted by the light.
  9935. * Inactive if 0
  9936. */
  9937. /**
  9938. * Sets the layer id use to find what meshes are not impacted by the light.
  9939. * Inactive if 0
  9940. */
  9941. excludeWithLayerMask: number;
  9942. private _includeOnlyWithLayerMask;
  9943. /**
  9944. * Gets the layer id use to find what meshes are impacted by the light.
  9945. * Inactive if 0
  9946. */
  9947. /**
  9948. * Sets the layer id use to find what meshes are impacted by the light.
  9949. * Inactive if 0
  9950. */
  9951. includeOnlyWithLayerMask: number;
  9952. private _lightmapMode;
  9953. /**
  9954. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9955. */
  9956. /**
  9957. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9958. */
  9959. lightmapMode: number;
  9960. /**
  9961. * Shadow generator associted to the light.
  9962. * @hidden Internal use only.
  9963. */
  9964. _shadowGenerator: Nullable<IShadowGenerator>;
  9965. /**
  9966. * @hidden Internal use only.
  9967. */
  9968. _excludedMeshesIds: string[];
  9969. /**
  9970. * @hidden Internal use only.
  9971. */
  9972. _includedOnlyMeshesIds: string[];
  9973. /**
  9974. * The current light unifom buffer.
  9975. * @hidden Internal use only.
  9976. */
  9977. _uniformBuffer: UniformBuffer;
  9978. /**
  9979. * Creates a Light object in the scene.
  9980. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9981. * @param name The firendly name of the light
  9982. * @param scene The scene the light belongs too
  9983. */
  9984. constructor(name: string, scene: Scene);
  9985. protected abstract _buildUniformLayout(): void;
  9986. /**
  9987. * Sets the passed Effect "effect" with the Light information.
  9988. * @param effect The effect to update
  9989. * @param lightIndex The index of the light in the effect to update
  9990. * @returns The light
  9991. */
  9992. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9993. /**
  9994. * Returns the string "Light".
  9995. * @returns the class name
  9996. */
  9997. getClassName(): string;
  9998. /** @hidden */
  9999. readonly _isLight: boolean;
  10000. /**
  10001. * Converts the light information to a readable string for debug purpose.
  10002. * @param fullDetails Supports for multiple levels of logging within scene loading
  10003. * @returns the human readable light info
  10004. */
  10005. toString(fullDetails?: boolean): string;
  10006. /** @hidden */
  10007. protected _syncParentEnabledState(): void;
  10008. /**
  10009. * Set the enabled state of this node.
  10010. * @param value - the new enabled state
  10011. */
  10012. setEnabled(value: boolean): void;
  10013. /**
  10014. * Returns the Light associated shadow generator if any.
  10015. * @return the associated shadow generator.
  10016. */
  10017. getShadowGenerator(): Nullable<IShadowGenerator>;
  10018. /**
  10019. * Returns a Vector3, the absolute light position in the World.
  10020. * @returns the world space position of the light
  10021. */
  10022. getAbsolutePosition(): Vector3;
  10023. /**
  10024. * Specifies if the light will affect the passed mesh.
  10025. * @param mesh The mesh to test against the light
  10026. * @return true the mesh is affected otherwise, false.
  10027. */
  10028. canAffectMesh(mesh: AbstractMesh): boolean;
  10029. /**
  10030. * Sort function to order lights for rendering.
  10031. * @param a First Light object to compare to second.
  10032. * @param b Second Light object to compare first.
  10033. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10034. */
  10035. static CompareLightsPriority(a: Light, b: Light): number;
  10036. /**
  10037. * Releases resources associated with this node.
  10038. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10039. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10040. */
  10041. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10042. /**
  10043. * Returns the light type ID (integer).
  10044. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10045. */
  10046. getTypeID(): number;
  10047. /**
  10048. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10049. * @returns the scaled intensity in intensity mode unit
  10050. */
  10051. getScaledIntensity(): number;
  10052. /**
  10053. * Returns a new Light object, named "name", from the current one.
  10054. * @param name The name of the cloned light
  10055. * @returns the new created light
  10056. */
  10057. clone(name: string): Nullable<Light>;
  10058. /**
  10059. * Serializes the current light into a Serialization object.
  10060. * @returns the serialized object.
  10061. */
  10062. serialize(): any;
  10063. /**
  10064. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10065. * This new light is named "name" and added to the passed scene.
  10066. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10067. * @param name The friendly name of the light
  10068. * @param scene The scene the new light will belong to
  10069. * @returns the constructor function
  10070. */
  10071. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10072. /**
  10073. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10074. * @param parsedLight The JSON representation of the light
  10075. * @param scene The scene to create the parsed light in
  10076. * @returns the created light after parsing
  10077. */
  10078. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10079. private _hookArrayForExcluded;
  10080. private _hookArrayForIncludedOnly;
  10081. private _resyncMeshes;
  10082. /**
  10083. * Forces the meshes to update their light related information in their rendering used effects
  10084. * @hidden Internal Use Only
  10085. */
  10086. _markMeshesAsLightDirty(): void;
  10087. /**
  10088. * Recomputes the cached photometric scale if needed.
  10089. */
  10090. private _computePhotometricScale;
  10091. /**
  10092. * Returns the Photometric Scale according to the light type and intensity mode.
  10093. */
  10094. private _getPhotometricScale;
  10095. /**
  10096. * Reorder the light in the scene according to their defined priority.
  10097. * @hidden Internal Use Only
  10098. */
  10099. _reorderLightsInScene(): void;
  10100. /**
  10101. * Prepares the list of defines specific to the light type.
  10102. * @param defines the list of defines
  10103. * @param lightIndex defines the index of the light for the effect
  10104. */
  10105. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10106. }
  10107. }
  10108. declare module "babylonjs/Actions/action" {
  10109. import { Observable } from "babylonjs/Misc/observable";
  10110. import { Condition } from "babylonjs/Actions/condition";
  10111. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10112. import { ActionManager } from "babylonjs/Actions/actionManager";
  10113. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10114. /**
  10115. * Interface used to define Action
  10116. */
  10117. export interface IAction {
  10118. /**
  10119. * Trigger for the action
  10120. */
  10121. trigger: number;
  10122. /** Options of the trigger */
  10123. triggerOptions: any;
  10124. /**
  10125. * Gets the trigger parameters
  10126. * @returns the trigger parameters
  10127. */
  10128. getTriggerParameter(): any;
  10129. /**
  10130. * Internal only - executes current action event
  10131. * @hidden
  10132. */
  10133. _executeCurrent(evt?: ActionEvent): void;
  10134. /**
  10135. * Serialize placeholder for child classes
  10136. * @param parent of child
  10137. * @returns the serialized object
  10138. */
  10139. serialize(parent: any): any;
  10140. /**
  10141. * Internal only
  10142. * @hidden
  10143. */
  10144. _prepare(): void;
  10145. /**
  10146. * Internal only - manager for action
  10147. * @hidden
  10148. */
  10149. _actionManager: AbstractActionManager;
  10150. /**
  10151. * Adds action to chain of actions, may be a DoNothingAction
  10152. * @param action defines the next action to execute
  10153. * @returns The action passed in
  10154. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10155. */
  10156. then(action: IAction): IAction;
  10157. }
  10158. /**
  10159. * The action to be carried out following a trigger
  10160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10161. */
  10162. export class Action implements IAction {
  10163. /** the trigger, with or without parameters, for the action */
  10164. triggerOptions: any;
  10165. /**
  10166. * Trigger for the action
  10167. */
  10168. trigger: number;
  10169. /**
  10170. * Internal only - manager for action
  10171. * @hidden
  10172. */
  10173. _actionManager: ActionManager;
  10174. private _nextActiveAction;
  10175. private _child;
  10176. private _condition?;
  10177. private _triggerParameter;
  10178. /**
  10179. * An event triggered prior to action being executed.
  10180. */
  10181. onBeforeExecuteObservable: Observable<Action>;
  10182. /**
  10183. * Creates a new Action
  10184. * @param triggerOptions the trigger, with or without parameters, for the action
  10185. * @param condition an optional determinant of action
  10186. */
  10187. constructor(
  10188. /** the trigger, with or without parameters, for the action */
  10189. triggerOptions: any, condition?: Condition);
  10190. /**
  10191. * Internal only
  10192. * @hidden
  10193. */
  10194. _prepare(): void;
  10195. /**
  10196. * Gets the trigger parameters
  10197. * @returns the trigger parameters
  10198. */
  10199. getTriggerParameter(): any;
  10200. /**
  10201. * Internal only - executes current action event
  10202. * @hidden
  10203. */
  10204. _executeCurrent(evt?: ActionEvent): void;
  10205. /**
  10206. * Execute placeholder for child classes
  10207. * @param evt optional action event
  10208. */
  10209. execute(evt?: ActionEvent): void;
  10210. /**
  10211. * Skips to next active action
  10212. */
  10213. skipToNextActiveAction(): void;
  10214. /**
  10215. * Adds action to chain of actions, may be a DoNothingAction
  10216. * @param action defines the next action to execute
  10217. * @returns The action passed in
  10218. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10219. */
  10220. then(action: Action): Action;
  10221. /**
  10222. * Internal only
  10223. * @hidden
  10224. */
  10225. _getProperty(propertyPath: string): string;
  10226. /**
  10227. * Internal only
  10228. * @hidden
  10229. */
  10230. _getEffectiveTarget(target: any, propertyPath: string): any;
  10231. /**
  10232. * Serialize placeholder for child classes
  10233. * @param parent of child
  10234. * @returns the serialized object
  10235. */
  10236. serialize(parent: any): any;
  10237. /**
  10238. * Internal only called by serialize
  10239. * @hidden
  10240. */
  10241. protected _serialize(serializedAction: any, parent?: any): any;
  10242. /**
  10243. * Internal only
  10244. * @hidden
  10245. */
  10246. static _SerializeValueAsString: (value: any) => string;
  10247. /**
  10248. * Internal only
  10249. * @hidden
  10250. */
  10251. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10252. name: string;
  10253. targetType: string;
  10254. value: string;
  10255. };
  10256. }
  10257. }
  10258. declare module "babylonjs/Actions/condition" {
  10259. import { ActionManager } from "babylonjs/Actions/actionManager";
  10260. /**
  10261. * A Condition applied to an Action
  10262. */
  10263. export class Condition {
  10264. /**
  10265. * Internal only - manager for action
  10266. * @hidden
  10267. */
  10268. _actionManager: ActionManager;
  10269. /**
  10270. * Internal only
  10271. * @hidden
  10272. */
  10273. _evaluationId: number;
  10274. /**
  10275. * Internal only
  10276. * @hidden
  10277. */
  10278. _currentResult: boolean;
  10279. /**
  10280. * Creates a new Condition
  10281. * @param actionManager the manager of the action the condition is applied to
  10282. */
  10283. constructor(actionManager: ActionManager);
  10284. /**
  10285. * Check if the current condition is valid
  10286. * @returns a boolean
  10287. */
  10288. isValid(): boolean;
  10289. /**
  10290. * Internal only
  10291. * @hidden
  10292. */
  10293. _getProperty(propertyPath: string): string;
  10294. /**
  10295. * Internal only
  10296. * @hidden
  10297. */
  10298. _getEffectiveTarget(target: any, propertyPath: string): any;
  10299. /**
  10300. * Serialize placeholder for child classes
  10301. * @returns the serialized object
  10302. */
  10303. serialize(): any;
  10304. /**
  10305. * Internal only
  10306. * @hidden
  10307. */
  10308. protected _serialize(serializedCondition: any): any;
  10309. }
  10310. /**
  10311. * Defines specific conditional operators as extensions of Condition
  10312. */
  10313. export class ValueCondition extends Condition {
  10314. /** path to specify the property of the target the conditional operator uses */
  10315. propertyPath: string;
  10316. /** the value compared by the conditional operator against the current value of the property */
  10317. value: any;
  10318. /** the conditional operator, default ValueCondition.IsEqual */
  10319. operator: number;
  10320. /**
  10321. * Internal only
  10322. * @hidden
  10323. */
  10324. private static _IsEqual;
  10325. /**
  10326. * Internal only
  10327. * @hidden
  10328. */
  10329. private static _IsDifferent;
  10330. /**
  10331. * Internal only
  10332. * @hidden
  10333. */
  10334. private static _IsGreater;
  10335. /**
  10336. * Internal only
  10337. * @hidden
  10338. */
  10339. private static _IsLesser;
  10340. /**
  10341. * returns the number for IsEqual
  10342. */
  10343. static readonly IsEqual: number;
  10344. /**
  10345. * Returns the number for IsDifferent
  10346. */
  10347. static readonly IsDifferent: number;
  10348. /**
  10349. * Returns the number for IsGreater
  10350. */
  10351. static readonly IsGreater: number;
  10352. /**
  10353. * Returns the number for IsLesser
  10354. */
  10355. static readonly IsLesser: number;
  10356. /**
  10357. * Internal only The action manager for the condition
  10358. * @hidden
  10359. */
  10360. _actionManager: ActionManager;
  10361. /**
  10362. * Internal only
  10363. * @hidden
  10364. */
  10365. private _target;
  10366. /**
  10367. * Internal only
  10368. * @hidden
  10369. */
  10370. private _effectiveTarget;
  10371. /**
  10372. * Internal only
  10373. * @hidden
  10374. */
  10375. private _property;
  10376. /**
  10377. * Creates a new ValueCondition
  10378. * @param actionManager manager for the action the condition applies to
  10379. * @param target for the action
  10380. * @param propertyPath path to specify the property of the target the conditional operator uses
  10381. * @param value the value compared by the conditional operator against the current value of the property
  10382. * @param operator the conditional operator, default ValueCondition.IsEqual
  10383. */
  10384. constructor(actionManager: ActionManager, target: any,
  10385. /** path to specify the property of the target the conditional operator uses */
  10386. propertyPath: string,
  10387. /** the value compared by the conditional operator against the current value of the property */
  10388. value: any,
  10389. /** the conditional operator, default ValueCondition.IsEqual */
  10390. operator?: number);
  10391. /**
  10392. * Compares the given value with the property value for the specified conditional operator
  10393. * @returns the result of the comparison
  10394. */
  10395. isValid(): boolean;
  10396. /**
  10397. * Serialize the ValueCondition into a JSON compatible object
  10398. * @returns serialization object
  10399. */
  10400. serialize(): any;
  10401. /**
  10402. * Gets the name of the conditional operator for the ValueCondition
  10403. * @param operator the conditional operator
  10404. * @returns the name
  10405. */
  10406. static GetOperatorName(operator: number): string;
  10407. }
  10408. /**
  10409. * Defines a predicate condition as an extension of Condition
  10410. */
  10411. export class PredicateCondition extends Condition {
  10412. /** defines the predicate function used to validate the condition */
  10413. predicate: () => boolean;
  10414. /**
  10415. * Internal only - manager for action
  10416. * @hidden
  10417. */
  10418. _actionManager: ActionManager;
  10419. /**
  10420. * Creates a new PredicateCondition
  10421. * @param actionManager manager for the action the condition applies to
  10422. * @param predicate defines the predicate function used to validate the condition
  10423. */
  10424. constructor(actionManager: ActionManager,
  10425. /** defines the predicate function used to validate the condition */
  10426. predicate: () => boolean);
  10427. /**
  10428. * @returns the validity of the predicate condition
  10429. */
  10430. isValid(): boolean;
  10431. }
  10432. /**
  10433. * Defines a state condition as an extension of Condition
  10434. */
  10435. export class StateCondition extends Condition {
  10436. /** Value to compare with target state */
  10437. value: string;
  10438. /**
  10439. * Internal only - manager for action
  10440. * @hidden
  10441. */
  10442. _actionManager: ActionManager;
  10443. /**
  10444. * Internal only
  10445. * @hidden
  10446. */
  10447. private _target;
  10448. /**
  10449. * Creates a new StateCondition
  10450. * @param actionManager manager for the action the condition applies to
  10451. * @param target of the condition
  10452. * @param value to compare with target state
  10453. */
  10454. constructor(actionManager: ActionManager, target: any,
  10455. /** Value to compare with target state */
  10456. value: string);
  10457. /**
  10458. * Gets a boolean indicating if the current condition is met
  10459. * @returns the validity of the state
  10460. */
  10461. isValid(): boolean;
  10462. /**
  10463. * Serialize the StateCondition into a JSON compatible object
  10464. * @returns serialization object
  10465. */
  10466. serialize(): any;
  10467. }
  10468. }
  10469. declare module "babylonjs/Actions/directActions" {
  10470. import { Action } from "babylonjs/Actions/action";
  10471. import { Condition } from "babylonjs/Actions/condition";
  10472. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10473. /**
  10474. * This defines an action responsible to toggle a boolean once triggered.
  10475. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10476. */
  10477. export class SwitchBooleanAction extends Action {
  10478. /**
  10479. * The path to the boolean property in the target object
  10480. */
  10481. propertyPath: string;
  10482. private _target;
  10483. private _effectiveTarget;
  10484. private _property;
  10485. /**
  10486. * Instantiate the action
  10487. * @param triggerOptions defines the trigger options
  10488. * @param target defines the object containing the boolean
  10489. * @param propertyPath defines the path to the boolean property in the target object
  10490. * @param condition defines the trigger related conditions
  10491. */
  10492. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10493. /** @hidden */
  10494. _prepare(): void;
  10495. /**
  10496. * Execute the action toggle the boolean value.
  10497. */
  10498. execute(): void;
  10499. /**
  10500. * Serializes the actions and its related information.
  10501. * @param parent defines the object to serialize in
  10502. * @returns the serialized object
  10503. */
  10504. serialize(parent: any): any;
  10505. }
  10506. /**
  10507. * This defines an action responsible to set a the state field of the target
  10508. * to a desired value once triggered.
  10509. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10510. */
  10511. export class SetStateAction extends Action {
  10512. /**
  10513. * The value to store in the state field.
  10514. */
  10515. value: string;
  10516. private _target;
  10517. /**
  10518. * Instantiate the action
  10519. * @param triggerOptions defines the trigger options
  10520. * @param target defines the object containing the state property
  10521. * @param value defines the value to store in the state field
  10522. * @param condition defines the trigger related conditions
  10523. */
  10524. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10525. /**
  10526. * Execute the action and store the value on the target state property.
  10527. */
  10528. execute(): void;
  10529. /**
  10530. * Serializes the actions and its related information.
  10531. * @param parent defines the object to serialize in
  10532. * @returns the serialized object
  10533. */
  10534. serialize(parent: any): any;
  10535. }
  10536. /**
  10537. * This defines an action responsible to set a property of the target
  10538. * to a desired value once triggered.
  10539. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10540. */
  10541. export class SetValueAction extends Action {
  10542. /**
  10543. * The path of the property to set in the target.
  10544. */
  10545. propertyPath: string;
  10546. /**
  10547. * The value to set in the property
  10548. */
  10549. value: any;
  10550. private _target;
  10551. private _effectiveTarget;
  10552. private _property;
  10553. /**
  10554. * Instantiate the action
  10555. * @param triggerOptions defines the trigger options
  10556. * @param target defines the object containing the property
  10557. * @param propertyPath defines the path of the property to set in the target
  10558. * @param value defines the value to set in the property
  10559. * @param condition defines the trigger related conditions
  10560. */
  10561. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10562. /** @hidden */
  10563. _prepare(): void;
  10564. /**
  10565. * Execute the action and set the targetted property to the desired value.
  10566. */
  10567. execute(): void;
  10568. /**
  10569. * Serializes the actions and its related information.
  10570. * @param parent defines the object to serialize in
  10571. * @returns the serialized object
  10572. */
  10573. serialize(parent: any): any;
  10574. }
  10575. /**
  10576. * This defines an action responsible to increment the target value
  10577. * to a desired value once triggered.
  10578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10579. */
  10580. export class IncrementValueAction extends Action {
  10581. /**
  10582. * The path of the property to increment in the target.
  10583. */
  10584. propertyPath: string;
  10585. /**
  10586. * The value we should increment the property by.
  10587. */
  10588. value: any;
  10589. private _target;
  10590. private _effectiveTarget;
  10591. private _property;
  10592. /**
  10593. * Instantiate the action
  10594. * @param triggerOptions defines the trigger options
  10595. * @param target defines the object containing the property
  10596. * @param propertyPath defines the path of the property to increment in the target
  10597. * @param value defines the value value we should increment the property by
  10598. * @param condition defines the trigger related conditions
  10599. */
  10600. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10601. /** @hidden */
  10602. _prepare(): void;
  10603. /**
  10604. * Execute the action and increment the target of the value amount.
  10605. */
  10606. execute(): void;
  10607. /**
  10608. * Serializes the actions and its related information.
  10609. * @param parent defines the object to serialize in
  10610. * @returns the serialized object
  10611. */
  10612. serialize(parent: any): any;
  10613. }
  10614. /**
  10615. * This defines an action responsible to start an animation once triggered.
  10616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10617. */
  10618. export class PlayAnimationAction extends Action {
  10619. /**
  10620. * Where the animation should start (animation frame)
  10621. */
  10622. from: number;
  10623. /**
  10624. * Where the animation should stop (animation frame)
  10625. */
  10626. to: number;
  10627. /**
  10628. * Define if the animation should loop or stop after the first play.
  10629. */
  10630. loop?: boolean;
  10631. private _target;
  10632. /**
  10633. * Instantiate the action
  10634. * @param triggerOptions defines the trigger options
  10635. * @param target defines the target animation or animation name
  10636. * @param from defines from where the animation should start (animation frame)
  10637. * @param end defines where the animation should stop (animation frame)
  10638. * @param loop defines if the animation should loop or stop after the first play
  10639. * @param condition defines the trigger related conditions
  10640. */
  10641. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10642. /** @hidden */
  10643. _prepare(): void;
  10644. /**
  10645. * Execute the action and play the animation.
  10646. */
  10647. execute(): void;
  10648. /**
  10649. * Serializes the actions and its related information.
  10650. * @param parent defines the object to serialize in
  10651. * @returns the serialized object
  10652. */
  10653. serialize(parent: any): any;
  10654. }
  10655. /**
  10656. * This defines an action responsible to stop an animation once triggered.
  10657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10658. */
  10659. export class StopAnimationAction extends Action {
  10660. private _target;
  10661. /**
  10662. * Instantiate the action
  10663. * @param triggerOptions defines the trigger options
  10664. * @param target defines the target animation or animation name
  10665. * @param condition defines the trigger related conditions
  10666. */
  10667. constructor(triggerOptions: any, target: any, condition?: Condition);
  10668. /** @hidden */
  10669. _prepare(): void;
  10670. /**
  10671. * Execute the action and stop the animation.
  10672. */
  10673. execute(): void;
  10674. /**
  10675. * Serializes the actions and its related information.
  10676. * @param parent defines the object to serialize in
  10677. * @returns the serialized object
  10678. */
  10679. serialize(parent: any): any;
  10680. }
  10681. /**
  10682. * This defines an action responsible that does nothing once triggered.
  10683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10684. */
  10685. export class DoNothingAction extends Action {
  10686. /**
  10687. * Instantiate the action
  10688. * @param triggerOptions defines the trigger options
  10689. * @param condition defines the trigger related conditions
  10690. */
  10691. constructor(triggerOptions?: any, condition?: Condition);
  10692. /**
  10693. * Execute the action and do nothing.
  10694. */
  10695. execute(): void;
  10696. /**
  10697. * Serializes the actions and its related information.
  10698. * @param parent defines the object to serialize in
  10699. * @returns the serialized object
  10700. */
  10701. serialize(parent: any): any;
  10702. }
  10703. /**
  10704. * This defines an action responsible to trigger several actions once triggered.
  10705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10706. */
  10707. export class CombineAction extends Action {
  10708. /**
  10709. * The list of aggregated animations to run.
  10710. */
  10711. children: Action[];
  10712. /**
  10713. * Instantiate the action
  10714. * @param triggerOptions defines the trigger options
  10715. * @param children defines the list of aggregated animations to run
  10716. * @param condition defines the trigger related conditions
  10717. */
  10718. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10719. /** @hidden */
  10720. _prepare(): void;
  10721. /**
  10722. * Execute the action and executes all the aggregated actions.
  10723. */
  10724. execute(evt: ActionEvent): void;
  10725. /**
  10726. * Serializes the actions and its related information.
  10727. * @param parent defines the object to serialize in
  10728. * @returns the serialized object
  10729. */
  10730. serialize(parent: any): any;
  10731. }
  10732. /**
  10733. * This defines an action responsible to run code (external event) once triggered.
  10734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10735. */
  10736. export class ExecuteCodeAction extends Action {
  10737. /**
  10738. * The callback function to run.
  10739. */
  10740. func: (evt: ActionEvent) => void;
  10741. /**
  10742. * Instantiate the action
  10743. * @param triggerOptions defines the trigger options
  10744. * @param func defines the callback function to run
  10745. * @param condition defines the trigger related conditions
  10746. */
  10747. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10748. /**
  10749. * Execute the action and run the attached code.
  10750. */
  10751. execute(evt: ActionEvent): void;
  10752. }
  10753. /**
  10754. * This defines an action responsible to set the parent property of the target once triggered.
  10755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10756. */
  10757. export class SetParentAction extends Action {
  10758. private _parent;
  10759. private _target;
  10760. /**
  10761. * Instantiate the action
  10762. * @param triggerOptions defines the trigger options
  10763. * @param target defines the target containing the parent property
  10764. * @param parent defines from where the animation should start (animation frame)
  10765. * @param condition defines the trigger related conditions
  10766. */
  10767. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10768. /** @hidden */
  10769. _prepare(): void;
  10770. /**
  10771. * Execute the action and set the parent property.
  10772. */
  10773. execute(): void;
  10774. /**
  10775. * Serializes the actions and its related information.
  10776. * @param parent defines the object to serialize in
  10777. * @returns the serialized object
  10778. */
  10779. serialize(parent: any): any;
  10780. }
  10781. }
  10782. declare module "babylonjs/Actions/actionManager" {
  10783. import { Nullable } from "babylonjs/types";
  10784. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10785. import { Scene } from "babylonjs/scene";
  10786. import { IAction } from "babylonjs/Actions/action";
  10787. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10788. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10789. /**
  10790. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10791. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10793. */
  10794. export class ActionManager extends AbstractActionManager {
  10795. /**
  10796. * Nothing
  10797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10798. */
  10799. static readonly NothingTrigger: number;
  10800. /**
  10801. * On pick
  10802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10803. */
  10804. static readonly OnPickTrigger: number;
  10805. /**
  10806. * On left pick
  10807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10808. */
  10809. static readonly OnLeftPickTrigger: number;
  10810. /**
  10811. * On right pick
  10812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10813. */
  10814. static readonly OnRightPickTrigger: number;
  10815. /**
  10816. * On center pick
  10817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10818. */
  10819. static readonly OnCenterPickTrigger: number;
  10820. /**
  10821. * On pick down
  10822. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10823. */
  10824. static readonly OnPickDownTrigger: number;
  10825. /**
  10826. * On double pick
  10827. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10828. */
  10829. static readonly OnDoublePickTrigger: number;
  10830. /**
  10831. * On pick up
  10832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10833. */
  10834. static readonly OnPickUpTrigger: number;
  10835. /**
  10836. * On pick out.
  10837. * This trigger will only be raised if you also declared a OnPickDown
  10838. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10839. */
  10840. static readonly OnPickOutTrigger: number;
  10841. /**
  10842. * On long press
  10843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10844. */
  10845. static readonly OnLongPressTrigger: number;
  10846. /**
  10847. * On pointer over
  10848. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10849. */
  10850. static readonly OnPointerOverTrigger: number;
  10851. /**
  10852. * On pointer out
  10853. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10854. */
  10855. static readonly OnPointerOutTrigger: number;
  10856. /**
  10857. * On every frame
  10858. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10859. */
  10860. static readonly OnEveryFrameTrigger: number;
  10861. /**
  10862. * On intersection enter
  10863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10864. */
  10865. static readonly OnIntersectionEnterTrigger: number;
  10866. /**
  10867. * On intersection exit
  10868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10869. */
  10870. static readonly OnIntersectionExitTrigger: number;
  10871. /**
  10872. * On key down
  10873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10874. */
  10875. static readonly OnKeyDownTrigger: number;
  10876. /**
  10877. * On key up
  10878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10879. */
  10880. static readonly OnKeyUpTrigger: number;
  10881. private _scene;
  10882. /**
  10883. * Creates a new action manager
  10884. * @param scene defines the hosting scene
  10885. */
  10886. constructor(scene: Scene);
  10887. /**
  10888. * Releases all associated resources
  10889. */
  10890. dispose(): void;
  10891. /**
  10892. * Gets hosting scene
  10893. * @returns the hosting scene
  10894. */
  10895. getScene(): Scene;
  10896. /**
  10897. * Does this action manager handles actions of any of the given triggers
  10898. * @param triggers defines the triggers to be tested
  10899. * @return a boolean indicating whether one (or more) of the triggers is handled
  10900. */
  10901. hasSpecificTriggers(triggers: number[]): boolean;
  10902. /**
  10903. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10904. * speed.
  10905. * @param triggerA defines the trigger to be tested
  10906. * @param triggerB defines the trigger to be tested
  10907. * @return a boolean indicating whether one (or more) of the triggers is handled
  10908. */
  10909. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10910. /**
  10911. * Does this action manager handles actions of a given trigger
  10912. * @param trigger defines the trigger to be tested
  10913. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10914. * @return whether the trigger is handled
  10915. */
  10916. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10917. /**
  10918. * Does this action manager has pointer triggers
  10919. */
  10920. readonly hasPointerTriggers: boolean;
  10921. /**
  10922. * Does this action manager has pick triggers
  10923. */
  10924. readonly hasPickTriggers: boolean;
  10925. /**
  10926. * Registers an action to this action manager
  10927. * @param action defines the action to be registered
  10928. * @return the action amended (prepared) after registration
  10929. */
  10930. registerAction(action: IAction): Nullable<IAction>;
  10931. /**
  10932. * Unregisters an action to this action manager
  10933. * @param action defines the action to be unregistered
  10934. * @return a boolean indicating whether the action has been unregistered
  10935. */
  10936. unregisterAction(action: IAction): Boolean;
  10937. /**
  10938. * Process a specific trigger
  10939. * @param trigger defines the trigger to process
  10940. * @param evt defines the event details to be processed
  10941. */
  10942. processTrigger(trigger: number, evt?: IActionEvent): void;
  10943. /** @hidden */
  10944. _getEffectiveTarget(target: any, propertyPath: string): any;
  10945. /** @hidden */
  10946. _getProperty(propertyPath: string): string;
  10947. /**
  10948. * Serialize this manager to a JSON object
  10949. * @param name defines the property name to store this manager
  10950. * @returns a JSON representation of this manager
  10951. */
  10952. serialize(name: string): any;
  10953. /**
  10954. * Creates a new ActionManager from a JSON data
  10955. * @param parsedActions defines the JSON data to read from
  10956. * @param object defines the hosting mesh
  10957. * @param scene defines the hosting scene
  10958. */
  10959. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10960. /**
  10961. * Get a trigger name by index
  10962. * @param trigger defines the trigger index
  10963. * @returns a trigger name
  10964. */
  10965. static GetTriggerName(trigger: number): string;
  10966. }
  10967. }
  10968. declare module "babylonjs/Culling/ray" {
  10969. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10970. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10972. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10973. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10974. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10975. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10976. import { Plane } from "babylonjs/Maths/math.plane";
  10977. /**
  10978. * Class representing a ray with position and direction
  10979. */
  10980. export class Ray {
  10981. /** origin point */
  10982. origin: Vector3;
  10983. /** direction */
  10984. direction: Vector3;
  10985. /** length of the ray */
  10986. length: number;
  10987. private static readonly TmpVector3;
  10988. private _tmpRay;
  10989. /**
  10990. * Creates a new ray
  10991. * @param origin origin point
  10992. * @param direction direction
  10993. * @param length length of the ray
  10994. */
  10995. constructor(
  10996. /** origin point */
  10997. origin: Vector3,
  10998. /** direction */
  10999. direction: Vector3,
  11000. /** length of the ray */
  11001. length?: number);
  11002. /**
  11003. * Checks if the ray intersects a box
  11004. * @param minimum bound of the box
  11005. * @param maximum bound of the box
  11006. * @param intersectionTreshold extra extend to be added to the box in all direction
  11007. * @returns if the box was hit
  11008. */
  11009. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11010. /**
  11011. * Checks if the ray intersects a box
  11012. * @param box the bounding box to check
  11013. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11014. * @returns if the box was hit
  11015. */
  11016. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11017. /**
  11018. * If the ray hits a sphere
  11019. * @param sphere the bounding sphere to check
  11020. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11021. * @returns true if it hits the sphere
  11022. */
  11023. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11024. /**
  11025. * If the ray hits a triange
  11026. * @param vertex0 triangle vertex
  11027. * @param vertex1 triangle vertex
  11028. * @param vertex2 triangle vertex
  11029. * @returns intersection information if hit
  11030. */
  11031. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11032. /**
  11033. * Checks if ray intersects a plane
  11034. * @param plane the plane to check
  11035. * @returns the distance away it was hit
  11036. */
  11037. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11038. /**
  11039. * Calculate the intercept of a ray on a given axis
  11040. * @param axis to check 'x' | 'y' | 'z'
  11041. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11042. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11043. */
  11044. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11045. /**
  11046. * Checks if ray intersects a mesh
  11047. * @param mesh the mesh to check
  11048. * @param fastCheck if only the bounding box should checked
  11049. * @returns picking info of the intersecton
  11050. */
  11051. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11052. /**
  11053. * Checks if ray intersects a mesh
  11054. * @param meshes the meshes to check
  11055. * @param fastCheck if only the bounding box should checked
  11056. * @param results array to store result in
  11057. * @returns Array of picking infos
  11058. */
  11059. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11060. private _comparePickingInfo;
  11061. private static smallnum;
  11062. private static rayl;
  11063. /**
  11064. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11065. * @param sega the first point of the segment to test the intersection against
  11066. * @param segb the second point of the segment to test the intersection against
  11067. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11068. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11069. */
  11070. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11071. /**
  11072. * Update the ray from viewport position
  11073. * @param x position
  11074. * @param y y position
  11075. * @param viewportWidth viewport width
  11076. * @param viewportHeight viewport height
  11077. * @param world world matrix
  11078. * @param view view matrix
  11079. * @param projection projection matrix
  11080. * @returns this ray updated
  11081. */
  11082. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11083. /**
  11084. * Creates a ray with origin and direction of 0,0,0
  11085. * @returns the new ray
  11086. */
  11087. static Zero(): Ray;
  11088. /**
  11089. * Creates a new ray from screen space and viewport
  11090. * @param x position
  11091. * @param y y position
  11092. * @param viewportWidth viewport width
  11093. * @param viewportHeight viewport height
  11094. * @param world world matrix
  11095. * @param view view matrix
  11096. * @param projection projection matrix
  11097. * @returns new ray
  11098. */
  11099. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11100. /**
  11101. * 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
  11102. * transformed to the given world matrix.
  11103. * @param origin The origin point
  11104. * @param end The end point
  11105. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11106. * @returns the new ray
  11107. */
  11108. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11109. /**
  11110. * Transforms a ray by a matrix
  11111. * @param ray ray to transform
  11112. * @param matrix matrix to apply
  11113. * @returns the resulting new ray
  11114. */
  11115. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11116. /**
  11117. * Transforms a ray by a matrix
  11118. * @param ray ray to transform
  11119. * @param matrix matrix to apply
  11120. * @param result ray to store result in
  11121. */
  11122. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11123. /**
  11124. * Unproject a ray from screen space to object space
  11125. * @param sourceX defines the screen space x coordinate to use
  11126. * @param sourceY defines the screen space y coordinate to use
  11127. * @param viewportWidth defines the current width of the viewport
  11128. * @param viewportHeight defines the current height of the viewport
  11129. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11130. * @param view defines the view matrix to use
  11131. * @param projection defines the projection matrix to use
  11132. */
  11133. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11134. }
  11135. /**
  11136. * Type used to define predicate used to select faces when a mesh intersection is detected
  11137. */
  11138. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11139. module "babylonjs/scene" {
  11140. interface Scene {
  11141. /** @hidden */
  11142. _tempPickingRay: Nullable<Ray>;
  11143. /** @hidden */
  11144. _cachedRayForTransform: Ray;
  11145. /** @hidden */
  11146. _pickWithRayInverseMatrix: Matrix;
  11147. /** @hidden */
  11148. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11149. /** @hidden */
  11150. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11151. }
  11152. }
  11153. }
  11154. declare module "babylonjs/sceneComponent" {
  11155. import { Scene } from "babylonjs/scene";
  11156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11157. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11158. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11159. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11160. import { Nullable } from "babylonjs/types";
  11161. import { Camera } from "babylonjs/Cameras/camera";
  11162. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11163. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11164. import { AbstractScene } from "babylonjs/abstractScene";
  11165. /**
  11166. * Groups all the scene component constants in one place to ease maintenance.
  11167. * @hidden
  11168. */
  11169. export class SceneComponentConstants {
  11170. static readonly NAME_EFFECTLAYER: string;
  11171. static readonly NAME_LAYER: string;
  11172. static readonly NAME_LENSFLARESYSTEM: string;
  11173. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11174. static readonly NAME_PARTICLESYSTEM: string;
  11175. static readonly NAME_GAMEPAD: string;
  11176. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11177. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11178. static readonly NAME_DEPTHRENDERER: string;
  11179. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11180. static readonly NAME_SPRITE: string;
  11181. static readonly NAME_OUTLINERENDERER: string;
  11182. static readonly NAME_PROCEDURALTEXTURE: string;
  11183. static readonly NAME_SHADOWGENERATOR: string;
  11184. static readonly NAME_OCTREE: string;
  11185. static readonly NAME_PHYSICSENGINE: string;
  11186. static readonly NAME_AUDIO: string;
  11187. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11188. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11189. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11190. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11191. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11192. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11193. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11194. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11195. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11196. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11197. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11198. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11199. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11200. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11201. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11202. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11203. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11204. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11205. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11206. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11207. static readonly STEP_AFTERRENDER_AUDIO: number;
  11208. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11209. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11210. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11211. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11212. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11213. static readonly STEP_POINTERMOVE_SPRITE: number;
  11214. static readonly STEP_POINTERDOWN_SPRITE: number;
  11215. static readonly STEP_POINTERUP_SPRITE: number;
  11216. }
  11217. /**
  11218. * This represents a scene component.
  11219. *
  11220. * This is used to decouple the dependency the scene is having on the different workloads like
  11221. * layers, post processes...
  11222. */
  11223. export interface ISceneComponent {
  11224. /**
  11225. * The name of the component. Each component must have a unique name.
  11226. */
  11227. name: string;
  11228. /**
  11229. * The scene the component belongs to.
  11230. */
  11231. scene: Scene;
  11232. /**
  11233. * Register the component to one instance of a scene.
  11234. */
  11235. register(): void;
  11236. /**
  11237. * Rebuilds the elements related to this component in case of
  11238. * context lost for instance.
  11239. */
  11240. rebuild(): void;
  11241. /**
  11242. * Disposes the component and the associated ressources.
  11243. */
  11244. dispose(): void;
  11245. }
  11246. /**
  11247. * This represents a SERIALIZABLE scene component.
  11248. *
  11249. * This extends Scene Component to add Serialization methods on top.
  11250. */
  11251. export interface ISceneSerializableComponent extends ISceneComponent {
  11252. /**
  11253. * Adds all the elements from the container to the scene
  11254. * @param container the container holding the elements
  11255. */
  11256. addFromContainer(container: AbstractScene): void;
  11257. /**
  11258. * Removes all the elements in the container from the scene
  11259. * @param container contains the elements to remove
  11260. * @param dispose if the removed element should be disposed (default: false)
  11261. */
  11262. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11263. /**
  11264. * Serializes the component data to the specified json object
  11265. * @param serializationObject The object to serialize to
  11266. */
  11267. serialize(serializationObject: any): void;
  11268. }
  11269. /**
  11270. * Strong typing of a Mesh related stage step action
  11271. */
  11272. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11273. /**
  11274. * Strong typing of a Evaluate Sub Mesh related stage step action
  11275. */
  11276. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11277. /**
  11278. * Strong typing of a Active Mesh related stage step action
  11279. */
  11280. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11281. /**
  11282. * Strong typing of a Camera related stage step action
  11283. */
  11284. export type CameraStageAction = (camera: Camera) => void;
  11285. /**
  11286. * Strong typing of a Camera Frame buffer related stage step action
  11287. */
  11288. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11289. /**
  11290. * Strong typing of a Render Target related stage step action
  11291. */
  11292. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11293. /**
  11294. * Strong typing of a RenderingGroup related stage step action
  11295. */
  11296. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11297. /**
  11298. * Strong typing of a Mesh Render related stage step action
  11299. */
  11300. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11301. /**
  11302. * Strong typing of a simple stage step action
  11303. */
  11304. export type SimpleStageAction = () => void;
  11305. /**
  11306. * Strong typing of a render target action.
  11307. */
  11308. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11309. /**
  11310. * Strong typing of a pointer move action.
  11311. */
  11312. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11313. /**
  11314. * Strong typing of a pointer up/down action.
  11315. */
  11316. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11317. /**
  11318. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11319. * @hidden
  11320. */
  11321. export class Stage<T extends Function> extends Array<{
  11322. index: number;
  11323. component: ISceneComponent;
  11324. action: T;
  11325. }> {
  11326. /**
  11327. * Hide ctor from the rest of the world.
  11328. * @param items The items to add.
  11329. */
  11330. private constructor();
  11331. /**
  11332. * Creates a new Stage.
  11333. * @returns A new instance of a Stage
  11334. */
  11335. static Create<T extends Function>(): Stage<T>;
  11336. /**
  11337. * Registers a step in an ordered way in the targeted stage.
  11338. * @param index Defines the position to register the step in
  11339. * @param component Defines the component attached to the step
  11340. * @param action Defines the action to launch during the step
  11341. */
  11342. registerStep(index: number, component: ISceneComponent, action: T): void;
  11343. /**
  11344. * Clears all the steps from the stage.
  11345. */
  11346. clear(): void;
  11347. }
  11348. }
  11349. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11350. import { Nullable } from "babylonjs/types";
  11351. import { Observable } from "babylonjs/Misc/observable";
  11352. import { Scene } from "babylonjs/scene";
  11353. import { Sprite } from "babylonjs/Sprites/sprite";
  11354. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11355. import { Ray } from "babylonjs/Culling/ray";
  11356. import { Camera } from "babylonjs/Cameras/camera";
  11357. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11358. import { ISceneComponent } from "babylonjs/sceneComponent";
  11359. module "babylonjs/scene" {
  11360. interface Scene {
  11361. /** @hidden */
  11362. _pointerOverSprite: Nullable<Sprite>;
  11363. /** @hidden */
  11364. _pickedDownSprite: Nullable<Sprite>;
  11365. /** @hidden */
  11366. _tempSpritePickingRay: Nullable<Ray>;
  11367. /**
  11368. * All of the sprite managers added to this scene
  11369. * @see http://doc.babylonjs.com/babylon101/sprites
  11370. */
  11371. spriteManagers: Array<ISpriteManager>;
  11372. /**
  11373. * An event triggered when sprites rendering is about to start
  11374. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11375. */
  11376. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11377. /**
  11378. * An event triggered when sprites rendering is done
  11379. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11380. */
  11381. onAfterSpritesRenderingObservable: Observable<Scene>;
  11382. /** @hidden */
  11383. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11384. /** Launch a ray to try to pick a sprite in the scene
  11385. * @param x position on screen
  11386. * @param y position on screen
  11387. * @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
  11388. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11389. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11390. * @returns a PickingInfo
  11391. */
  11392. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11393. /** Use the given ray to pick a sprite in the scene
  11394. * @param ray The ray (in world space) to use to pick meshes
  11395. * @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
  11396. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11397. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11398. * @returns a PickingInfo
  11399. */
  11400. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11401. /**
  11402. * Force the sprite under the pointer
  11403. * @param sprite defines the sprite to use
  11404. */
  11405. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11406. /**
  11407. * Gets the sprite under the pointer
  11408. * @returns a Sprite or null if no sprite is under the pointer
  11409. */
  11410. getPointerOverSprite(): Nullable<Sprite>;
  11411. }
  11412. }
  11413. /**
  11414. * Defines the sprite scene component responsible to manage sprites
  11415. * in a given scene.
  11416. */
  11417. export class SpriteSceneComponent implements ISceneComponent {
  11418. /**
  11419. * The component name helpfull to identify the component in the list of scene components.
  11420. */
  11421. readonly name: string;
  11422. /**
  11423. * The scene the component belongs to.
  11424. */
  11425. scene: Scene;
  11426. /** @hidden */
  11427. private _spritePredicate;
  11428. /**
  11429. * Creates a new instance of the component for the given scene
  11430. * @param scene Defines the scene to register the component in
  11431. */
  11432. constructor(scene: Scene);
  11433. /**
  11434. * Registers the component in a given scene
  11435. */
  11436. register(): void;
  11437. /**
  11438. * Rebuilds the elements related to this component in case of
  11439. * context lost for instance.
  11440. */
  11441. rebuild(): void;
  11442. /**
  11443. * Disposes the component and the associated ressources.
  11444. */
  11445. dispose(): void;
  11446. private _pickSpriteButKeepRay;
  11447. private _pointerMove;
  11448. private _pointerDown;
  11449. private _pointerUp;
  11450. }
  11451. }
  11452. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11453. /** @hidden */
  11454. export var fogFragmentDeclaration: {
  11455. name: string;
  11456. shader: string;
  11457. };
  11458. }
  11459. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11460. /** @hidden */
  11461. export var fogFragment: {
  11462. name: string;
  11463. shader: string;
  11464. };
  11465. }
  11466. declare module "babylonjs/Shaders/sprites.fragment" {
  11467. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11468. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11469. /** @hidden */
  11470. export var spritesPixelShader: {
  11471. name: string;
  11472. shader: string;
  11473. };
  11474. }
  11475. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11476. /** @hidden */
  11477. export var fogVertexDeclaration: {
  11478. name: string;
  11479. shader: string;
  11480. };
  11481. }
  11482. declare module "babylonjs/Shaders/sprites.vertex" {
  11483. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11484. /** @hidden */
  11485. export var spritesVertexShader: {
  11486. name: string;
  11487. shader: string;
  11488. };
  11489. }
  11490. declare module "babylonjs/Sprites/spriteManager" {
  11491. import { IDisposable, Scene } from "babylonjs/scene";
  11492. import { Nullable } from "babylonjs/types";
  11493. import { Observable } from "babylonjs/Misc/observable";
  11494. import { Sprite } from "babylonjs/Sprites/sprite";
  11495. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11496. import { Camera } from "babylonjs/Cameras/camera";
  11497. import { Texture } from "babylonjs/Materials/Textures/texture";
  11498. import "babylonjs/Shaders/sprites.fragment";
  11499. import "babylonjs/Shaders/sprites.vertex";
  11500. import { Ray } from "babylonjs/Culling/ray";
  11501. /**
  11502. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11503. */
  11504. export interface ISpriteManager extends IDisposable {
  11505. /**
  11506. * Restricts the camera to viewing objects with the same layerMask.
  11507. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11508. */
  11509. layerMask: number;
  11510. /**
  11511. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11512. */
  11513. isPickable: boolean;
  11514. /**
  11515. * Specifies the rendering group id for this mesh (0 by default)
  11516. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11517. */
  11518. renderingGroupId: number;
  11519. /**
  11520. * Defines the list of sprites managed by the manager.
  11521. */
  11522. sprites: Array<Sprite>;
  11523. /**
  11524. * Tests the intersection of a sprite with a specific ray.
  11525. * @param ray The ray we are sending to test the collision
  11526. * @param camera The camera space we are sending rays in
  11527. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11528. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11529. * @returns picking info or null.
  11530. */
  11531. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11532. /**
  11533. * Renders the list of sprites on screen.
  11534. */
  11535. render(): void;
  11536. }
  11537. /**
  11538. * Class used to manage multiple sprites on the same spritesheet
  11539. * @see http://doc.babylonjs.com/babylon101/sprites
  11540. */
  11541. export class SpriteManager implements ISpriteManager {
  11542. /** defines the manager's name */
  11543. name: string;
  11544. /** Gets the list of sprites */
  11545. sprites: Sprite[];
  11546. /** Gets or sets the rendering group id (0 by default) */
  11547. renderingGroupId: number;
  11548. /** Gets or sets camera layer mask */
  11549. layerMask: number;
  11550. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11551. fogEnabled: boolean;
  11552. /** Gets or sets a boolean indicating if the sprites are pickable */
  11553. isPickable: boolean;
  11554. /** Defines the default width of a cell in the spritesheet */
  11555. cellWidth: number;
  11556. /** Defines the default height of a cell in the spritesheet */
  11557. cellHeight: number;
  11558. /**
  11559. * An event triggered when the manager is disposed.
  11560. */
  11561. onDisposeObservable: Observable<SpriteManager>;
  11562. private _onDisposeObserver;
  11563. /**
  11564. * Callback called when the manager is disposed
  11565. */
  11566. onDispose: () => void;
  11567. private _capacity;
  11568. private _spriteTexture;
  11569. private _epsilon;
  11570. private _scene;
  11571. private _vertexData;
  11572. private _buffer;
  11573. private _vertexBuffers;
  11574. private _indexBuffer;
  11575. private _effectBase;
  11576. private _effectFog;
  11577. /**
  11578. * Gets or sets the spritesheet texture
  11579. */
  11580. texture: Texture;
  11581. /**
  11582. * Creates a new sprite manager
  11583. * @param name defines the manager's name
  11584. * @param imgUrl defines the sprite sheet url
  11585. * @param capacity defines the maximum allowed number of sprites
  11586. * @param cellSize defines the size of a sprite cell
  11587. * @param scene defines the hosting scene
  11588. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11589. * @param samplingMode defines the smapling mode to use with spritesheet
  11590. */
  11591. constructor(
  11592. /** defines the manager's name */
  11593. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11594. private _appendSpriteVertex;
  11595. /**
  11596. * Intersects the sprites with a ray
  11597. * @param ray defines the ray to intersect with
  11598. * @param camera defines the current active camera
  11599. * @param predicate defines a predicate used to select candidate sprites
  11600. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11601. * @returns null if no hit or a PickingInfo
  11602. */
  11603. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11604. /**
  11605. * Render all child sprites
  11606. */
  11607. render(): void;
  11608. /**
  11609. * Release associated resources
  11610. */
  11611. dispose(): void;
  11612. }
  11613. }
  11614. declare module "babylonjs/Sprites/sprite" {
  11615. import { Vector3 } from "babylonjs/Maths/math.vector";
  11616. import { Nullable } from "babylonjs/types";
  11617. import { ActionManager } from "babylonjs/Actions/actionManager";
  11618. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11619. import { Color4 } from "babylonjs/Maths/math.color";
  11620. /**
  11621. * Class used to represent a sprite
  11622. * @see http://doc.babylonjs.com/babylon101/sprites
  11623. */
  11624. export class Sprite {
  11625. /** defines the name */
  11626. name: string;
  11627. /** Gets or sets the current world position */
  11628. position: Vector3;
  11629. /** Gets or sets the main color */
  11630. color: Color4;
  11631. /** Gets or sets the width */
  11632. width: number;
  11633. /** Gets or sets the height */
  11634. height: number;
  11635. /** Gets or sets rotation angle */
  11636. angle: number;
  11637. /** Gets or sets the cell index in the sprite sheet */
  11638. cellIndex: number;
  11639. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11640. invertU: number;
  11641. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11642. invertV: number;
  11643. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11644. disposeWhenFinishedAnimating: boolean;
  11645. /** Gets the list of attached animations */
  11646. animations: Animation[];
  11647. /** Gets or sets a boolean indicating if the sprite can be picked */
  11648. isPickable: boolean;
  11649. /**
  11650. * Gets or sets the associated action manager
  11651. */
  11652. actionManager: Nullable<ActionManager>;
  11653. private _animationStarted;
  11654. private _loopAnimation;
  11655. private _fromIndex;
  11656. private _toIndex;
  11657. private _delay;
  11658. private _direction;
  11659. private _manager;
  11660. private _time;
  11661. private _onAnimationEnd;
  11662. /**
  11663. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11664. */
  11665. isVisible: boolean;
  11666. /**
  11667. * Gets or sets the sprite size
  11668. */
  11669. size: number;
  11670. /**
  11671. * Creates a new Sprite
  11672. * @param name defines the name
  11673. * @param manager defines the manager
  11674. */
  11675. constructor(
  11676. /** defines the name */
  11677. name: string, manager: ISpriteManager);
  11678. /**
  11679. * Starts an animation
  11680. * @param from defines the initial key
  11681. * @param to defines the end key
  11682. * @param loop defines if the animation must loop
  11683. * @param delay defines the start delay (in ms)
  11684. * @param onAnimationEnd defines a callback to call when animation ends
  11685. */
  11686. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11687. /** Stops current animation (if any) */
  11688. stopAnimation(): void;
  11689. /** @hidden */
  11690. _animate(deltaTime: number): void;
  11691. /** Release associated resources */
  11692. dispose(): void;
  11693. }
  11694. }
  11695. declare module "babylonjs/Collisions/pickingInfo" {
  11696. import { Nullable } from "babylonjs/types";
  11697. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11698. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11699. import { Sprite } from "babylonjs/Sprites/sprite";
  11700. import { Ray } from "babylonjs/Culling/ray";
  11701. /**
  11702. * Information about the result of picking within a scene
  11703. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11704. */
  11705. export class PickingInfo {
  11706. /** @hidden */
  11707. _pickingUnavailable: boolean;
  11708. /**
  11709. * If the pick collided with an object
  11710. */
  11711. hit: boolean;
  11712. /**
  11713. * Distance away where the pick collided
  11714. */
  11715. distance: number;
  11716. /**
  11717. * The location of pick collision
  11718. */
  11719. pickedPoint: Nullable<Vector3>;
  11720. /**
  11721. * The mesh corresponding the the pick collision
  11722. */
  11723. pickedMesh: Nullable<AbstractMesh>;
  11724. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11725. bu: number;
  11726. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11727. bv: number;
  11728. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11729. faceId: number;
  11730. /** Id of the the submesh that was picked */
  11731. subMeshId: number;
  11732. /** If a sprite was picked, this will be the sprite the pick collided with */
  11733. pickedSprite: Nullable<Sprite>;
  11734. /**
  11735. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11736. */
  11737. originMesh: Nullable<AbstractMesh>;
  11738. /**
  11739. * The ray that was used to perform the picking.
  11740. */
  11741. ray: Nullable<Ray>;
  11742. /**
  11743. * Gets the normal correspodning to the face the pick collided with
  11744. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11745. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11746. * @returns The normal correspodning to the face the pick collided with
  11747. */
  11748. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11749. /**
  11750. * Gets the texture coordinates of where the pick occured
  11751. * @returns the vector containing the coordnates of the texture
  11752. */
  11753. getTextureCoordinates(): Nullable<Vector2>;
  11754. }
  11755. }
  11756. declare module "babylonjs/Events/pointerEvents" {
  11757. import { Nullable } from "babylonjs/types";
  11758. import { Vector2 } from "babylonjs/Maths/math.vector";
  11759. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11760. import { Ray } from "babylonjs/Culling/ray";
  11761. /**
  11762. * Gather the list of pointer event types as constants.
  11763. */
  11764. export class PointerEventTypes {
  11765. /**
  11766. * 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.
  11767. */
  11768. static readonly POINTERDOWN: number;
  11769. /**
  11770. * The pointerup event is fired when a pointer is no longer active.
  11771. */
  11772. static readonly POINTERUP: number;
  11773. /**
  11774. * The pointermove event is fired when a pointer changes coordinates.
  11775. */
  11776. static readonly POINTERMOVE: number;
  11777. /**
  11778. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11779. */
  11780. static readonly POINTERWHEEL: number;
  11781. /**
  11782. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11783. */
  11784. static readonly POINTERPICK: number;
  11785. /**
  11786. * The pointertap event is fired when a the object has been touched and released without drag.
  11787. */
  11788. static readonly POINTERTAP: number;
  11789. /**
  11790. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11791. */
  11792. static readonly POINTERDOUBLETAP: number;
  11793. }
  11794. /**
  11795. * Base class of pointer info types.
  11796. */
  11797. export class PointerInfoBase {
  11798. /**
  11799. * Defines the type of event (PointerEventTypes)
  11800. */
  11801. type: number;
  11802. /**
  11803. * Defines the related dom event
  11804. */
  11805. event: PointerEvent | MouseWheelEvent;
  11806. /**
  11807. * Instantiates the base class of pointers info.
  11808. * @param type Defines the type of event (PointerEventTypes)
  11809. * @param event Defines the related dom event
  11810. */
  11811. constructor(
  11812. /**
  11813. * Defines the type of event (PointerEventTypes)
  11814. */
  11815. type: number,
  11816. /**
  11817. * Defines the related dom event
  11818. */
  11819. event: PointerEvent | MouseWheelEvent);
  11820. }
  11821. /**
  11822. * This class is used to store pointer related info for the onPrePointerObservable event.
  11823. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11824. */
  11825. export class PointerInfoPre extends PointerInfoBase {
  11826. /**
  11827. * Ray from a pointer if availible (eg. 6dof controller)
  11828. */
  11829. ray: Nullable<Ray>;
  11830. /**
  11831. * Defines the local position of the pointer on the canvas.
  11832. */
  11833. localPosition: Vector2;
  11834. /**
  11835. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11836. */
  11837. skipOnPointerObservable: boolean;
  11838. /**
  11839. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11840. * @param type Defines the type of event (PointerEventTypes)
  11841. * @param event Defines the related dom event
  11842. * @param localX Defines the local x coordinates of the pointer when the event occured
  11843. * @param localY Defines the local y coordinates of the pointer when the event occured
  11844. */
  11845. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11846. }
  11847. /**
  11848. * This type contains all the data related to a pointer event in Babylon.js.
  11849. * 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.
  11850. */
  11851. export class PointerInfo extends PointerInfoBase {
  11852. /**
  11853. * Defines the picking info associated to the info (if any)\
  11854. */
  11855. pickInfo: Nullable<PickingInfo>;
  11856. /**
  11857. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11858. * @param type Defines the type of event (PointerEventTypes)
  11859. * @param event Defines the related dom event
  11860. * @param pickInfo Defines the picking info associated to the info (if any)\
  11861. */
  11862. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11863. /**
  11864. * Defines the picking info associated to the info (if any)\
  11865. */
  11866. pickInfo: Nullable<PickingInfo>);
  11867. }
  11868. /**
  11869. * Data relating to a touch event on the screen.
  11870. */
  11871. export interface PointerTouch {
  11872. /**
  11873. * X coordinate of touch.
  11874. */
  11875. x: number;
  11876. /**
  11877. * Y coordinate of touch.
  11878. */
  11879. y: number;
  11880. /**
  11881. * Id of touch. Unique for each finger.
  11882. */
  11883. pointerId: number;
  11884. /**
  11885. * Event type passed from DOM.
  11886. */
  11887. type: any;
  11888. }
  11889. }
  11890. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11891. import { Observable } from "babylonjs/Misc/observable";
  11892. import { Nullable } from "babylonjs/types";
  11893. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11894. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11895. /**
  11896. * Manage the mouse inputs to control the movement of a free camera.
  11897. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11898. */
  11899. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11900. /**
  11901. * Define if touch is enabled in the mouse input
  11902. */
  11903. touchEnabled: boolean;
  11904. /**
  11905. * Defines the camera the input is attached to.
  11906. */
  11907. camera: FreeCamera;
  11908. /**
  11909. * Defines the buttons associated with the input to handle camera move.
  11910. */
  11911. buttons: number[];
  11912. /**
  11913. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11914. */
  11915. angularSensibility: number;
  11916. private _pointerInput;
  11917. private _onMouseMove;
  11918. private _observer;
  11919. private previousPosition;
  11920. /**
  11921. * Observable for when a pointer move event occurs containing the move offset
  11922. */
  11923. onPointerMovedObservable: Observable<{
  11924. offsetX: number;
  11925. offsetY: number;
  11926. }>;
  11927. /**
  11928. * @hidden
  11929. * If the camera should be rotated automatically based on pointer movement
  11930. */
  11931. _allowCameraRotation: boolean;
  11932. /**
  11933. * Manage the mouse inputs to control the movement of a free camera.
  11934. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11935. * @param touchEnabled Defines if touch is enabled or not
  11936. */
  11937. constructor(
  11938. /**
  11939. * Define if touch is enabled in the mouse input
  11940. */
  11941. touchEnabled?: boolean);
  11942. /**
  11943. * Attach the input controls to a specific dom element to get the input from.
  11944. * @param element Defines the element the controls should be listened from
  11945. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11946. */
  11947. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11948. /**
  11949. * Called on JS contextmenu event.
  11950. * Override this method to provide functionality.
  11951. */
  11952. protected onContextMenu(evt: PointerEvent): void;
  11953. /**
  11954. * Detach the current controls from the specified dom element.
  11955. * @param element Defines the element to stop listening the inputs from
  11956. */
  11957. detachControl(element: Nullable<HTMLElement>): void;
  11958. /**
  11959. * Gets the class name of the current intput.
  11960. * @returns the class name
  11961. */
  11962. getClassName(): string;
  11963. /**
  11964. * Get the friendly name associated with the input class.
  11965. * @returns the input friendly name
  11966. */
  11967. getSimpleName(): string;
  11968. }
  11969. }
  11970. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  11971. import { Nullable } from "babylonjs/types";
  11972. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11973. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11974. /**
  11975. * Manage the touch inputs to control the movement of a free camera.
  11976. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11977. */
  11978. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11979. /**
  11980. * Defines the camera the input is attached to.
  11981. */
  11982. camera: FreeCamera;
  11983. /**
  11984. * Defines the touch sensibility for rotation.
  11985. * The higher the faster.
  11986. */
  11987. touchAngularSensibility: number;
  11988. /**
  11989. * Defines the touch sensibility for move.
  11990. * The higher the faster.
  11991. */
  11992. touchMoveSensibility: number;
  11993. private _offsetX;
  11994. private _offsetY;
  11995. private _pointerPressed;
  11996. private _pointerInput;
  11997. private _observer;
  11998. private _onLostFocus;
  11999. /**
  12000. * Attach the input controls to a specific dom element to get the input from.
  12001. * @param element Defines the element the controls should be listened from
  12002. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12003. */
  12004. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12005. /**
  12006. * Detach the current controls from the specified dom element.
  12007. * @param element Defines the element to stop listening the inputs from
  12008. */
  12009. detachControl(element: Nullable<HTMLElement>): void;
  12010. /**
  12011. * Update the current camera state depending on the inputs that have been used this frame.
  12012. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12013. */
  12014. checkInputs(): void;
  12015. /**
  12016. * Gets the class name of the current intput.
  12017. * @returns the class name
  12018. */
  12019. getClassName(): string;
  12020. /**
  12021. * Get the friendly name associated with the input class.
  12022. * @returns the input friendly name
  12023. */
  12024. getSimpleName(): string;
  12025. }
  12026. }
  12027. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12028. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12029. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12030. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12031. import { Nullable } from "babylonjs/types";
  12032. /**
  12033. * Default Inputs manager for the FreeCamera.
  12034. * It groups all the default supported inputs for ease of use.
  12035. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12036. */
  12037. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12038. /**
  12039. * @hidden
  12040. */
  12041. _mouseInput: Nullable<FreeCameraMouseInput>;
  12042. /**
  12043. * Instantiates a new FreeCameraInputsManager.
  12044. * @param camera Defines the camera the inputs belong to
  12045. */
  12046. constructor(camera: FreeCamera);
  12047. /**
  12048. * Add keyboard input support to the input manager.
  12049. * @returns the current input manager
  12050. */
  12051. addKeyboard(): FreeCameraInputsManager;
  12052. /**
  12053. * Add mouse input support to the input manager.
  12054. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12055. * @returns the current input manager
  12056. */
  12057. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12058. /**
  12059. * Removes the mouse input support from the manager
  12060. * @returns the current input manager
  12061. */
  12062. removeMouse(): FreeCameraInputsManager;
  12063. /**
  12064. * Add touch input support to the input manager.
  12065. * @returns the current input manager
  12066. */
  12067. addTouch(): FreeCameraInputsManager;
  12068. /**
  12069. * Remove all attached input methods from a camera
  12070. */
  12071. clear(): void;
  12072. }
  12073. }
  12074. declare module "babylonjs/Cameras/freeCamera" {
  12075. import { Vector3 } from "babylonjs/Maths/math.vector";
  12076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12077. import { Scene } from "babylonjs/scene";
  12078. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12079. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12080. /**
  12081. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12082. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12083. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12084. */
  12085. export class FreeCamera extends TargetCamera {
  12086. /**
  12087. * Define the collision ellipsoid of the camera.
  12088. * This is helpful to simulate a camera body like the player body around the camera
  12089. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12090. */
  12091. ellipsoid: Vector3;
  12092. /**
  12093. * Define an offset for the position of the ellipsoid around the camera.
  12094. * This can be helpful to determine the center of the body near the gravity center of the body
  12095. * instead of its head.
  12096. */
  12097. ellipsoidOffset: Vector3;
  12098. /**
  12099. * Enable or disable collisions of the camera with the rest of the scene objects.
  12100. */
  12101. checkCollisions: boolean;
  12102. /**
  12103. * Enable or disable gravity on the camera.
  12104. */
  12105. applyGravity: boolean;
  12106. /**
  12107. * Define the input manager associated to the camera.
  12108. */
  12109. inputs: FreeCameraInputsManager;
  12110. /**
  12111. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12112. * Higher values reduce sensitivity.
  12113. */
  12114. /**
  12115. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12116. * Higher values reduce sensitivity.
  12117. */
  12118. angularSensibility: number;
  12119. /**
  12120. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12121. */
  12122. keysUp: number[];
  12123. /**
  12124. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12125. */
  12126. keysDown: number[];
  12127. /**
  12128. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12129. */
  12130. keysLeft: number[];
  12131. /**
  12132. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12133. */
  12134. keysRight: number[];
  12135. /**
  12136. * Event raised when the camera collide with a mesh in the scene.
  12137. */
  12138. onCollide: (collidedMesh: AbstractMesh) => void;
  12139. private _collider;
  12140. private _needMoveForGravity;
  12141. private _oldPosition;
  12142. private _diffPosition;
  12143. private _newPosition;
  12144. /** @hidden */
  12145. _localDirection: Vector3;
  12146. /** @hidden */
  12147. _transformedDirection: Vector3;
  12148. /**
  12149. * Instantiates a Free Camera.
  12150. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12151. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12152. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12153. * @param name Define the name of the camera in the scene
  12154. * @param position Define the start position of the camera in the scene
  12155. * @param scene Define the scene the camera belongs to
  12156. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12157. */
  12158. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12159. /**
  12160. * Attached controls to the current camera.
  12161. * @param element Defines the element the controls should be listened from
  12162. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12163. */
  12164. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12165. /**
  12166. * Detach the current controls from the camera.
  12167. * The camera will stop reacting to inputs.
  12168. * @param element Defines the element to stop listening the inputs from
  12169. */
  12170. detachControl(element: HTMLElement): void;
  12171. private _collisionMask;
  12172. /**
  12173. * Define a collision mask to limit the list of object the camera can collide with
  12174. */
  12175. collisionMask: number;
  12176. /** @hidden */
  12177. _collideWithWorld(displacement: Vector3): void;
  12178. private _onCollisionPositionChange;
  12179. /** @hidden */
  12180. _checkInputs(): void;
  12181. /** @hidden */
  12182. _decideIfNeedsToMove(): boolean;
  12183. /** @hidden */
  12184. _updatePosition(): void;
  12185. /**
  12186. * Destroy the camera and release the current resources hold by it.
  12187. */
  12188. dispose(): void;
  12189. /**
  12190. * Gets the current object class name.
  12191. * @return the class name
  12192. */
  12193. getClassName(): string;
  12194. }
  12195. }
  12196. declare module "babylonjs/Gamepads/gamepad" {
  12197. import { Observable } from "babylonjs/Misc/observable";
  12198. /**
  12199. * Represents a gamepad control stick position
  12200. */
  12201. export class StickValues {
  12202. /**
  12203. * The x component of the control stick
  12204. */
  12205. x: number;
  12206. /**
  12207. * The y component of the control stick
  12208. */
  12209. y: number;
  12210. /**
  12211. * Initializes the gamepad x and y control stick values
  12212. * @param x The x component of the gamepad control stick value
  12213. * @param y The y component of the gamepad control stick value
  12214. */
  12215. constructor(
  12216. /**
  12217. * The x component of the control stick
  12218. */
  12219. x: number,
  12220. /**
  12221. * The y component of the control stick
  12222. */
  12223. y: number);
  12224. }
  12225. /**
  12226. * An interface which manages callbacks for gamepad button changes
  12227. */
  12228. export interface GamepadButtonChanges {
  12229. /**
  12230. * Called when a gamepad has been changed
  12231. */
  12232. changed: boolean;
  12233. /**
  12234. * Called when a gamepad press event has been triggered
  12235. */
  12236. pressChanged: boolean;
  12237. /**
  12238. * Called when a touch event has been triggered
  12239. */
  12240. touchChanged: boolean;
  12241. /**
  12242. * Called when a value has changed
  12243. */
  12244. valueChanged: boolean;
  12245. }
  12246. /**
  12247. * Represents a gamepad
  12248. */
  12249. export class Gamepad {
  12250. /**
  12251. * The id of the gamepad
  12252. */
  12253. id: string;
  12254. /**
  12255. * The index of the gamepad
  12256. */
  12257. index: number;
  12258. /**
  12259. * The browser gamepad
  12260. */
  12261. browserGamepad: any;
  12262. /**
  12263. * Specifies what type of gamepad this represents
  12264. */
  12265. type: number;
  12266. private _leftStick;
  12267. private _rightStick;
  12268. /** @hidden */
  12269. _isConnected: boolean;
  12270. private _leftStickAxisX;
  12271. private _leftStickAxisY;
  12272. private _rightStickAxisX;
  12273. private _rightStickAxisY;
  12274. /**
  12275. * Triggered when the left control stick has been changed
  12276. */
  12277. private _onleftstickchanged;
  12278. /**
  12279. * Triggered when the right control stick has been changed
  12280. */
  12281. private _onrightstickchanged;
  12282. /**
  12283. * Represents a gamepad controller
  12284. */
  12285. static GAMEPAD: number;
  12286. /**
  12287. * Represents a generic controller
  12288. */
  12289. static GENERIC: number;
  12290. /**
  12291. * Represents an XBox controller
  12292. */
  12293. static XBOX: number;
  12294. /**
  12295. * Represents a pose-enabled controller
  12296. */
  12297. static POSE_ENABLED: number;
  12298. /**
  12299. * Specifies whether the left control stick should be Y-inverted
  12300. */
  12301. protected _invertLeftStickY: boolean;
  12302. /**
  12303. * Specifies if the gamepad has been connected
  12304. */
  12305. readonly isConnected: boolean;
  12306. /**
  12307. * Initializes the gamepad
  12308. * @param id The id of the gamepad
  12309. * @param index The index of the gamepad
  12310. * @param browserGamepad The browser gamepad
  12311. * @param leftStickX The x component of the left joystick
  12312. * @param leftStickY The y component of the left joystick
  12313. * @param rightStickX The x component of the right joystick
  12314. * @param rightStickY The y component of the right joystick
  12315. */
  12316. constructor(
  12317. /**
  12318. * The id of the gamepad
  12319. */
  12320. id: string,
  12321. /**
  12322. * The index of the gamepad
  12323. */
  12324. index: number,
  12325. /**
  12326. * The browser gamepad
  12327. */
  12328. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12329. /**
  12330. * Callback triggered when the left joystick has changed
  12331. * @param callback
  12332. */
  12333. onleftstickchanged(callback: (values: StickValues) => void): void;
  12334. /**
  12335. * Callback triggered when the right joystick has changed
  12336. * @param callback
  12337. */
  12338. onrightstickchanged(callback: (values: StickValues) => void): void;
  12339. /**
  12340. * Gets the left joystick
  12341. */
  12342. /**
  12343. * Sets the left joystick values
  12344. */
  12345. leftStick: StickValues;
  12346. /**
  12347. * Gets the right joystick
  12348. */
  12349. /**
  12350. * Sets the right joystick value
  12351. */
  12352. rightStick: StickValues;
  12353. /**
  12354. * Updates the gamepad joystick positions
  12355. */
  12356. update(): void;
  12357. /**
  12358. * Disposes the gamepad
  12359. */
  12360. dispose(): void;
  12361. }
  12362. /**
  12363. * Represents a generic gamepad
  12364. */
  12365. export class GenericPad extends Gamepad {
  12366. private _buttons;
  12367. private _onbuttondown;
  12368. private _onbuttonup;
  12369. /**
  12370. * Observable triggered when a button has been pressed
  12371. */
  12372. onButtonDownObservable: Observable<number>;
  12373. /**
  12374. * Observable triggered when a button has been released
  12375. */
  12376. onButtonUpObservable: Observable<number>;
  12377. /**
  12378. * Callback triggered when a button has been pressed
  12379. * @param callback Called when a button has been pressed
  12380. */
  12381. onbuttondown(callback: (buttonPressed: number) => void): void;
  12382. /**
  12383. * Callback triggered when a button has been released
  12384. * @param callback Called when a button has been released
  12385. */
  12386. onbuttonup(callback: (buttonReleased: number) => void): void;
  12387. /**
  12388. * Initializes the generic gamepad
  12389. * @param id The id of the generic gamepad
  12390. * @param index The index of the generic gamepad
  12391. * @param browserGamepad The browser gamepad
  12392. */
  12393. constructor(id: string, index: number, browserGamepad: any);
  12394. private _setButtonValue;
  12395. /**
  12396. * Updates the generic gamepad
  12397. */
  12398. update(): void;
  12399. /**
  12400. * Disposes the generic gamepad
  12401. */
  12402. dispose(): void;
  12403. }
  12404. }
  12405. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12406. import { Nullable } from "babylonjs/types";
  12407. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12408. import { Scene } from "babylonjs/scene";
  12409. module "babylonjs/Engines/engine" {
  12410. interface Engine {
  12411. /**
  12412. * Creates a raw texture
  12413. * @param data defines the data to store in the texture
  12414. * @param width defines the width of the texture
  12415. * @param height defines the height of the texture
  12416. * @param format defines the format of the data
  12417. * @param generateMipMaps defines if the engine should generate the mip levels
  12418. * @param invertY defines if data must be stored with Y axis inverted
  12419. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12420. * @param compression defines the compression used (null by default)
  12421. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12422. * @returns the raw texture inside an InternalTexture
  12423. */
  12424. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12425. /**
  12426. * Update a raw texture
  12427. * @param texture defines the texture to update
  12428. * @param data defines the data to store in the texture
  12429. * @param format defines the format of the data
  12430. * @param invertY defines if data must be stored with Y axis inverted
  12431. */
  12432. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12433. /**
  12434. * Update a raw texture
  12435. * @param texture defines the texture to update
  12436. * @param data defines the data to store in the texture
  12437. * @param format defines the format of the data
  12438. * @param invertY defines if data must be stored with Y axis inverted
  12439. * @param compression defines the compression used (null by default)
  12440. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12441. */
  12442. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12443. /**
  12444. * Creates a new raw cube texture
  12445. * @param data defines the array of data to use to create each face
  12446. * @param size defines the size of the textures
  12447. * @param format defines the format of the data
  12448. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12449. * @param generateMipMaps defines if the engine should generate the mip levels
  12450. * @param invertY defines if data must be stored with Y axis inverted
  12451. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12452. * @param compression defines the compression used (null by default)
  12453. * @returns the cube texture as an InternalTexture
  12454. */
  12455. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12456. /**
  12457. * Update a raw cube texture
  12458. * @param texture defines the texture to udpdate
  12459. * @param data defines the data to store
  12460. * @param format defines the data format
  12461. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12462. * @param invertY defines if data must be stored with Y axis inverted
  12463. */
  12464. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12465. /**
  12466. * Update a raw cube texture
  12467. * @param texture defines the texture to udpdate
  12468. * @param data defines the data to store
  12469. * @param format defines the data format
  12470. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12471. * @param invertY defines if data must be stored with Y axis inverted
  12472. * @param compression defines the compression used (null by default)
  12473. */
  12474. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12475. /**
  12476. * Update a raw cube texture
  12477. * @param texture defines the texture to udpdate
  12478. * @param data defines the data to store
  12479. * @param format defines the data format
  12480. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12481. * @param invertY defines if data must be stored with Y axis inverted
  12482. * @param compression defines the compression used (null by default)
  12483. * @param level defines which level of the texture to update
  12484. */
  12485. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12486. /**
  12487. * Creates a new raw cube texture from a specified url
  12488. * @param url defines the url where the data is located
  12489. * @param scene defines the current scene
  12490. * @param size defines the size of the textures
  12491. * @param format defines the format of the data
  12492. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12493. * @param noMipmap defines if the engine should avoid generating the mip levels
  12494. * @param callback defines a callback used to extract texture data from loaded data
  12495. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12496. * @param onLoad defines a callback called when texture is loaded
  12497. * @param onError defines a callback called if there is an error
  12498. * @returns the cube texture as an InternalTexture
  12499. */
  12500. 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;
  12501. /**
  12502. * Creates a new raw cube texture from a specified url
  12503. * @param url defines the url where the data is located
  12504. * @param scene defines the current scene
  12505. * @param size defines the size of the textures
  12506. * @param format defines the format of the data
  12507. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12508. * @param noMipmap defines if the engine should avoid generating the mip levels
  12509. * @param callback defines a callback used to extract texture data from loaded data
  12510. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12511. * @param onLoad defines a callback called when texture is loaded
  12512. * @param onError defines a callback called if there is an error
  12513. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12514. * @param invertY defines if data must be stored with Y axis inverted
  12515. * @returns the cube texture as an InternalTexture
  12516. */
  12517. 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;
  12518. /**
  12519. * Creates a new raw 3D texture
  12520. * @param data defines the data used to create the texture
  12521. * @param width defines the width of the texture
  12522. * @param height defines the height of the texture
  12523. * @param depth defines the depth of the texture
  12524. * @param format defines the format of the texture
  12525. * @param generateMipMaps defines if the engine must generate mip levels
  12526. * @param invertY defines if data must be stored with Y axis inverted
  12527. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12528. * @param compression defines the compressed used (can be null)
  12529. * @param textureType defines the compressed used (can be null)
  12530. * @returns a new raw 3D texture (stored in an InternalTexture)
  12531. */
  12532. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12533. /**
  12534. * Update a raw 3D texture
  12535. * @param texture defines the texture to update
  12536. * @param data defines the data to store
  12537. * @param format defines the data format
  12538. * @param invertY defines if data must be stored with Y axis inverted
  12539. */
  12540. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12541. /**
  12542. * Update a raw 3D texture
  12543. * @param texture defines the texture to update
  12544. * @param data defines the data to store
  12545. * @param format defines the data format
  12546. * @param invertY defines if data must be stored with Y axis inverted
  12547. * @param compression defines the used compression (can be null)
  12548. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12549. */
  12550. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12551. }
  12552. }
  12553. }
  12554. declare module "babylonjs/Materials/Textures/rawTexture" {
  12555. import { Scene } from "babylonjs/scene";
  12556. import { Texture } from "babylonjs/Materials/Textures/texture";
  12557. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12558. /**
  12559. * Raw texture can help creating a texture directly from an array of data.
  12560. * This can be super useful if you either get the data from an uncompressed source or
  12561. * if you wish to create your texture pixel by pixel.
  12562. */
  12563. export class RawTexture extends Texture {
  12564. /**
  12565. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12566. */
  12567. format: number;
  12568. private _engine;
  12569. /**
  12570. * Instantiates a new RawTexture.
  12571. * Raw texture can help creating a texture directly from an array of data.
  12572. * This can be super useful if you either get the data from an uncompressed source or
  12573. * if you wish to create your texture pixel by pixel.
  12574. * @param data define the array of data to use to create the texture
  12575. * @param width define the width of the texture
  12576. * @param height define the height of the texture
  12577. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12578. * @param scene define the scene the texture belongs to
  12579. * @param generateMipMaps define whether mip maps should be generated or not
  12580. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12581. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12582. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12583. */
  12584. constructor(data: ArrayBufferView, width: number, height: number,
  12585. /**
  12586. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12587. */
  12588. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12589. /**
  12590. * Updates the texture underlying data.
  12591. * @param data Define the new data of the texture
  12592. */
  12593. update(data: ArrayBufferView): void;
  12594. /**
  12595. * Creates a luminance texture from some data.
  12596. * @param data Define the texture data
  12597. * @param width Define the width of the texture
  12598. * @param height Define the height of the texture
  12599. * @param scene Define the scene the texture belongs to
  12600. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12601. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12602. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12603. * @returns the luminance texture
  12604. */
  12605. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12606. /**
  12607. * Creates a luminance alpha texture from some data.
  12608. * @param data Define the texture data
  12609. * @param width Define the width of the texture
  12610. * @param height Define the height of the texture
  12611. * @param scene Define the scene the texture belongs to
  12612. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12613. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12614. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12615. * @returns the luminance alpha texture
  12616. */
  12617. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12618. /**
  12619. * Creates an alpha texture from some data.
  12620. * @param data Define the texture data
  12621. * @param width Define the width of the texture
  12622. * @param height Define the height of the texture
  12623. * @param scene Define the scene the texture belongs to
  12624. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12625. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12626. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12627. * @returns the alpha texture
  12628. */
  12629. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12630. /**
  12631. * Creates a RGB texture from some data.
  12632. * @param data Define the texture data
  12633. * @param width Define the width of the texture
  12634. * @param height Define the height of the texture
  12635. * @param scene Define the scene the texture belongs to
  12636. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12637. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12638. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12639. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12640. * @returns the RGB alpha texture
  12641. */
  12642. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12643. /**
  12644. * Creates a RGBA texture from some data.
  12645. * @param data Define the texture data
  12646. * @param width Define the width of the texture
  12647. * @param height Define the height of the texture
  12648. * @param scene Define the scene the texture belongs to
  12649. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12650. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12651. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12652. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12653. * @returns the RGBA texture
  12654. */
  12655. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12656. /**
  12657. * Creates a R texture from some data.
  12658. * @param data Define the texture data
  12659. * @param width Define the width of the texture
  12660. * @param height Define the height of the texture
  12661. * @param scene Define the scene the texture belongs to
  12662. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12663. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12664. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12665. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12666. * @returns the R texture
  12667. */
  12668. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12669. }
  12670. }
  12671. declare module "babylonjs/Maths/math.size" {
  12672. /**
  12673. * Interface for the size containing width and height
  12674. */
  12675. export interface ISize {
  12676. /**
  12677. * Width
  12678. */
  12679. width: number;
  12680. /**
  12681. * Heighht
  12682. */
  12683. height: number;
  12684. }
  12685. /**
  12686. * Size containing widht and height
  12687. */
  12688. export class Size implements ISize {
  12689. /**
  12690. * Width
  12691. */
  12692. width: number;
  12693. /**
  12694. * Height
  12695. */
  12696. height: number;
  12697. /**
  12698. * Creates a Size object from the given width and height (floats).
  12699. * @param width width of the new size
  12700. * @param height height of the new size
  12701. */
  12702. constructor(width: number, height: number);
  12703. /**
  12704. * Returns a string with the Size width and height
  12705. * @returns a string with the Size width and height
  12706. */
  12707. toString(): string;
  12708. /**
  12709. * "Size"
  12710. * @returns the string "Size"
  12711. */
  12712. getClassName(): string;
  12713. /**
  12714. * Returns the Size hash code.
  12715. * @returns a hash code for a unique width and height
  12716. */
  12717. getHashCode(): number;
  12718. /**
  12719. * Updates the current size from the given one.
  12720. * @param src the given size
  12721. */
  12722. copyFrom(src: Size): void;
  12723. /**
  12724. * Updates in place the current Size from the given floats.
  12725. * @param width width of the new size
  12726. * @param height height of the new size
  12727. * @returns the updated Size.
  12728. */
  12729. copyFromFloats(width: number, height: number): Size;
  12730. /**
  12731. * Updates in place the current Size from the given floats.
  12732. * @param width width to set
  12733. * @param height height to set
  12734. * @returns the updated Size.
  12735. */
  12736. set(width: number, height: number): Size;
  12737. /**
  12738. * Multiplies the width and height by numbers
  12739. * @param w factor to multiple the width by
  12740. * @param h factor to multiple the height by
  12741. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12742. */
  12743. multiplyByFloats(w: number, h: number): Size;
  12744. /**
  12745. * Clones the size
  12746. * @returns a new Size copied from the given one.
  12747. */
  12748. clone(): Size;
  12749. /**
  12750. * True if the current Size and the given one width and height are strictly equal.
  12751. * @param other the other size to compare against
  12752. * @returns True if the current Size and the given one width and height are strictly equal.
  12753. */
  12754. equals(other: Size): boolean;
  12755. /**
  12756. * The surface of the Size : width * height (float).
  12757. */
  12758. readonly surface: number;
  12759. /**
  12760. * Create a new size of zero
  12761. * @returns a new Size set to (0.0, 0.0)
  12762. */
  12763. static Zero(): Size;
  12764. /**
  12765. * Sums the width and height of two sizes
  12766. * @param otherSize size to add to this size
  12767. * @returns a new Size set as the addition result of the current Size and the given one.
  12768. */
  12769. add(otherSize: Size): Size;
  12770. /**
  12771. * Subtracts the width and height of two
  12772. * @param otherSize size to subtract to this size
  12773. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12774. */
  12775. subtract(otherSize: Size): Size;
  12776. /**
  12777. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12778. * @param start starting size to lerp between
  12779. * @param end end size to lerp between
  12780. * @param amount amount to lerp between the start and end values
  12781. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12782. */
  12783. static Lerp(start: Size, end: Size, amount: number): Size;
  12784. }
  12785. }
  12786. declare module "babylonjs/Animations/runtimeAnimation" {
  12787. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12788. import { Animatable } from "babylonjs/Animations/animatable";
  12789. import { Scene } from "babylonjs/scene";
  12790. /**
  12791. * Defines a runtime animation
  12792. */
  12793. export class RuntimeAnimation {
  12794. private _events;
  12795. /**
  12796. * The current frame of the runtime animation
  12797. */
  12798. private _currentFrame;
  12799. /**
  12800. * The animation used by the runtime animation
  12801. */
  12802. private _animation;
  12803. /**
  12804. * The target of the runtime animation
  12805. */
  12806. private _target;
  12807. /**
  12808. * The initiating animatable
  12809. */
  12810. private _host;
  12811. /**
  12812. * The original value of the runtime animation
  12813. */
  12814. private _originalValue;
  12815. /**
  12816. * The original blend value of the runtime animation
  12817. */
  12818. private _originalBlendValue;
  12819. /**
  12820. * The offsets cache of the runtime animation
  12821. */
  12822. private _offsetsCache;
  12823. /**
  12824. * The high limits cache of the runtime animation
  12825. */
  12826. private _highLimitsCache;
  12827. /**
  12828. * Specifies if the runtime animation has been stopped
  12829. */
  12830. private _stopped;
  12831. /**
  12832. * The blending factor of the runtime animation
  12833. */
  12834. private _blendingFactor;
  12835. /**
  12836. * The BabylonJS scene
  12837. */
  12838. private _scene;
  12839. /**
  12840. * The current value of the runtime animation
  12841. */
  12842. private _currentValue;
  12843. /** @hidden */
  12844. _animationState: _IAnimationState;
  12845. /**
  12846. * The active target of the runtime animation
  12847. */
  12848. private _activeTargets;
  12849. private _currentActiveTarget;
  12850. private _directTarget;
  12851. /**
  12852. * The target path of the runtime animation
  12853. */
  12854. private _targetPath;
  12855. /**
  12856. * The weight of the runtime animation
  12857. */
  12858. private _weight;
  12859. /**
  12860. * The ratio offset of the runtime animation
  12861. */
  12862. private _ratioOffset;
  12863. /**
  12864. * The previous delay of the runtime animation
  12865. */
  12866. private _previousDelay;
  12867. /**
  12868. * The previous ratio of the runtime animation
  12869. */
  12870. private _previousRatio;
  12871. private _enableBlending;
  12872. private _keys;
  12873. private _minFrame;
  12874. private _maxFrame;
  12875. private _minValue;
  12876. private _maxValue;
  12877. private _targetIsArray;
  12878. /**
  12879. * Gets the current frame of the runtime animation
  12880. */
  12881. readonly currentFrame: number;
  12882. /**
  12883. * Gets the weight of the runtime animation
  12884. */
  12885. readonly weight: number;
  12886. /**
  12887. * Gets the current value of the runtime animation
  12888. */
  12889. readonly currentValue: any;
  12890. /**
  12891. * Gets the target path of the runtime animation
  12892. */
  12893. readonly targetPath: string;
  12894. /**
  12895. * Gets the actual target of the runtime animation
  12896. */
  12897. readonly target: any;
  12898. /** @hidden */
  12899. _onLoop: () => void;
  12900. /**
  12901. * Create a new RuntimeAnimation object
  12902. * @param target defines the target of the animation
  12903. * @param animation defines the source animation object
  12904. * @param scene defines the hosting scene
  12905. * @param host defines the initiating Animatable
  12906. */
  12907. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12908. private _preparePath;
  12909. /**
  12910. * Gets the animation from the runtime animation
  12911. */
  12912. readonly animation: Animation;
  12913. /**
  12914. * Resets the runtime animation to the beginning
  12915. * @param restoreOriginal defines whether to restore the target property to the original value
  12916. */
  12917. reset(restoreOriginal?: boolean): void;
  12918. /**
  12919. * Specifies if the runtime animation is stopped
  12920. * @returns Boolean specifying if the runtime animation is stopped
  12921. */
  12922. isStopped(): boolean;
  12923. /**
  12924. * Disposes of the runtime animation
  12925. */
  12926. dispose(): void;
  12927. /**
  12928. * Apply the interpolated value to the target
  12929. * @param currentValue defines the value computed by the animation
  12930. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12931. */
  12932. setValue(currentValue: any, weight: number): void;
  12933. private _getOriginalValues;
  12934. private _setValue;
  12935. /**
  12936. * Gets the loop pmode of the runtime animation
  12937. * @returns Loop Mode
  12938. */
  12939. private _getCorrectLoopMode;
  12940. /**
  12941. * Move the current animation to a given frame
  12942. * @param frame defines the frame to move to
  12943. */
  12944. goToFrame(frame: number): void;
  12945. /**
  12946. * @hidden Internal use only
  12947. */
  12948. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12949. /**
  12950. * Execute the current animation
  12951. * @param delay defines the delay to add to the current frame
  12952. * @param from defines the lower bound of the animation range
  12953. * @param to defines the upper bound of the animation range
  12954. * @param loop defines if the current animation must loop
  12955. * @param speedRatio defines the current speed ratio
  12956. * @param weight defines the weight of the animation (default is -1 so no weight)
  12957. * @param onLoop optional callback called when animation loops
  12958. * @returns a boolean indicating if the animation is running
  12959. */
  12960. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12961. }
  12962. }
  12963. declare module "babylonjs/Animations/animatable" {
  12964. import { Animation } from "babylonjs/Animations/animation";
  12965. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  12966. import { Nullable } from "babylonjs/types";
  12967. import { Observable } from "babylonjs/Misc/observable";
  12968. import { Scene } from "babylonjs/scene";
  12969. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  12970. import { Node } from "babylonjs/node";
  12971. /**
  12972. * Class used to store an actual running animation
  12973. */
  12974. export class Animatable {
  12975. /** defines the target object */
  12976. target: any;
  12977. /** defines the starting frame number (default is 0) */
  12978. fromFrame: number;
  12979. /** defines the ending frame number (default is 100) */
  12980. toFrame: number;
  12981. /** defines if the animation must loop (default is false) */
  12982. loopAnimation: boolean;
  12983. /** defines a callback to call when animation ends if it is not looping */
  12984. onAnimationEnd?: (() => void) | null | undefined;
  12985. /** defines a callback to call when animation loops */
  12986. onAnimationLoop?: (() => void) | null | undefined;
  12987. private _localDelayOffset;
  12988. private _pausedDelay;
  12989. private _runtimeAnimations;
  12990. private _paused;
  12991. private _scene;
  12992. private _speedRatio;
  12993. private _weight;
  12994. private _syncRoot;
  12995. /**
  12996. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12997. * This will only apply for non looping animation (default is true)
  12998. */
  12999. disposeOnEnd: boolean;
  13000. /**
  13001. * Gets a boolean indicating if the animation has started
  13002. */
  13003. animationStarted: boolean;
  13004. /**
  13005. * Observer raised when the animation ends
  13006. */
  13007. onAnimationEndObservable: Observable<Animatable>;
  13008. /**
  13009. * Observer raised when the animation loops
  13010. */
  13011. onAnimationLoopObservable: Observable<Animatable>;
  13012. /**
  13013. * Gets the root Animatable used to synchronize and normalize animations
  13014. */
  13015. readonly syncRoot: Nullable<Animatable>;
  13016. /**
  13017. * Gets the current frame of the first RuntimeAnimation
  13018. * Used to synchronize Animatables
  13019. */
  13020. readonly masterFrame: number;
  13021. /**
  13022. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13023. */
  13024. weight: number;
  13025. /**
  13026. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13027. */
  13028. speedRatio: number;
  13029. /**
  13030. * Creates a new Animatable
  13031. * @param scene defines the hosting scene
  13032. * @param target defines the target object
  13033. * @param fromFrame defines the starting frame number (default is 0)
  13034. * @param toFrame defines the ending frame number (default is 100)
  13035. * @param loopAnimation defines if the animation must loop (default is false)
  13036. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13037. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13038. * @param animations defines a group of animation to add to the new Animatable
  13039. * @param onAnimationLoop defines a callback to call when animation loops
  13040. */
  13041. constructor(scene: Scene,
  13042. /** defines the target object */
  13043. target: any,
  13044. /** defines the starting frame number (default is 0) */
  13045. fromFrame?: number,
  13046. /** defines the ending frame number (default is 100) */
  13047. toFrame?: number,
  13048. /** defines if the animation must loop (default is false) */
  13049. loopAnimation?: boolean, speedRatio?: number,
  13050. /** defines a callback to call when animation ends if it is not looping */
  13051. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13052. /** defines a callback to call when animation loops */
  13053. onAnimationLoop?: (() => void) | null | undefined);
  13054. /**
  13055. * Synchronize and normalize current Animatable with a source Animatable
  13056. * This is useful when using animation weights and when animations are not of the same length
  13057. * @param root defines the root Animatable to synchronize with
  13058. * @returns the current Animatable
  13059. */
  13060. syncWith(root: Animatable): Animatable;
  13061. /**
  13062. * Gets the list of runtime animations
  13063. * @returns an array of RuntimeAnimation
  13064. */
  13065. getAnimations(): RuntimeAnimation[];
  13066. /**
  13067. * Adds more animations to the current animatable
  13068. * @param target defines the target of the animations
  13069. * @param animations defines the new animations to add
  13070. */
  13071. appendAnimations(target: any, animations: Animation[]): void;
  13072. /**
  13073. * Gets the source animation for a specific property
  13074. * @param property defines the propertyu to look for
  13075. * @returns null or the source animation for the given property
  13076. */
  13077. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13078. /**
  13079. * Gets the runtime animation for a specific property
  13080. * @param property defines the propertyu to look for
  13081. * @returns null or the runtime animation for the given property
  13082. */
  13083. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13084. /**
  13085. * Resets the animatable to its original state
  13086. */
  13087. reset(): void;
  13088. /**
  13089. * Allows the animatable to blend with current running animations
  13090. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13091. * @param blendingSpeed defines the blending speed to use
  13092. */
  13093. enableBlending(blendingSpeed: number): void;
  13094. /**
  13095. * Disable animation blending
  13096. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13097. */
  13098. disableBlending(): void;
  13099. /**
  13100. * Jump directly to a given frame
  13101. * @param frame defines the frame to jump to
  13102. */
  13103. goToFrame(frame: number): void;
  13104. /**
  13105. * Pause the animation
  13106. */
  13107. pause(): void;
  13108. /**
  13109. * Restart the animation
  13110. */
  13111. restart(): void;
  13112. private _raiseOnAnimationEnd;
  13113. /**
  13114. * Stop and delete the current animation
  13115. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13116. * @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)
  13117. */
  13118. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13119. /**
  13120. * Wait asynchronously for the animation to end
  13121. * @returns a promise which will be fullfilled when the animation ends
  13122. */
  13123. waitAsync(): Promise<Animatable>;
  13124. /** @hidden */
  13125. _animate(delay: number): boolean;
  13126. }
  13127. module "babylonjs/scene" {
  13128. interface Scene {
  13129. /** @hidden */
  13130. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13131. /** @hidden */
  13132. _processLateAnimationBindingsForMatrices(holder: {
  13133. totalWeight: number;
  13134. animations: RuntimeAnimation[];
  13135. originalValue: Matrix;
  13136. }): any;
  13137. /** @hidden */
  13138. _processLateAnimationBindingsForQuaternions(holder: {
  13139. totalWeight: number;
  13140. animations: RuntimeAnimation[];
  13141. originalValue: Quaternion;
  13142. }, refQuaternion: Quaternion): Quaternion;
  13143. /** @hidden */
  13144. _processLateAnimationBindings(): void;
  13145. /**
  13146. * Will start the animation sequence of a given target
  13147. * @param target defines the target
  13148. * @param from defines from which frame should animation start
  13149. * @param to defines until which frame should animation run.
  13150. * @param weight defines the weight to apply to the animation (1.0 by default)
  13151. * @param loop defines if the animation loops
  13152. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13153. * @param onAnimationEnd defines the function to be executed when the animation ends
  13154. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13155. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13156. * @param onAnimationLoop defines the callback to call when an animation loops
  13157. * @returns the animatable object created for this animation
  13158. */
  13159. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13160. /**
  13161. * Will start the animation sequence of a given target
  13162. * @param target defines the target
  13163. * @param from defines from which frame should animation start
  13164. * @param to defines until which frame should animation run.
  13165. * @param loop defines if the animation loops
  13166. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13167. * @param onAnimationEnd defines the function to be executed when the animation ends
  13168. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13169. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13170. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13171. * @param onAnimationLoop defines the callback to call when an animation loops
  13172. * @returns the animatable object created for this animation
  13173. */
  13174. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13175. /**
  13176. * Will start the animation sequence of a given target and its hierarchy
  13177. * @param target defines the target
  13178. * @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.
  13179. * @param from defines from which frame should animation start
  13180. * @param to defines until which frame should animation run.
  13181. * @param loop defines if the animation loops
  13182. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13183. * @param onAnimationEnd defines the function to be executed when the animation ends
  13184. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13185. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13186. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13187. * @param onAnimationLoop defines the callback to call when an animation loops
  13188. * @returns the list of created animatables
  13189. */
  13190. 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[];
  13191. /**
  13192. * Begin a new animation on a given node
  13193. * @param target defines the target where the animation will take place
  13194. * @param animations defines the list of animations to start
  13195. * @param from defines the initial value
  13196. * @param to defines the final value
  13197. * @param loop defines if you want animation to loop (off by default)
  13198. * @param speedRatio defines the speed ratio to apply to all animations
  13199. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13200. * @param onAnimationLoop defines the callback to call when an animation loops
  13201. * @returns the list of created animatables
  13202. */
  13203. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13204. /**
  13205. * Begin a new animation on a given node and its hierarchy
  13206. * @param target defines the root node where the animation will take place
  13207. * @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.
  13208. * @param animations defines the list of animations to start
  13209. * @param from defines the initial value
  13210. * @param to defines the final value
  13211. * @param loop defines if you want animation to loop (off by default)
  13212. * @param speedRatio defines the speed ratio to apply to all animations
  13213. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13214. * @param onAnimationLoop defines the callback to call when an animation loops
  13215. * @returns the list of animatables created for all nodes
  13216. */
  13217. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13218. /**
  13219. * Gets the animatable associated with a specific target
  13220. * @param target defines the target of the animatable
  13221. * @returns the required animatable if found
  13222. */
  13223. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13224. /**
  13225. * Gets all animatables associated with a given target
  13226. * @param target defines the target to look animatables for
  13227. * @returns an array of Animatables
  13228. */
  13229. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13230. /**
  13231. * Stops and removes all animations that have been applied to the scene
  13232. */
  13233. stopAllAnimations(): void;
  13234. }
  13235. }
  13236. module "babylonjs/Bones/bone" {
  13237. interface Bone {
  13238. /**
  13239. * Copy an animation range from another bone
  13240. * @param source defines the source bone
  13241. * @param rangeName defines the range name to copy
  13242. * @param frameOffset defines the frame offset
  13243. * @param rescaleAsRequired defines if rescaling must be applied if required
  13244. * @param skelDimensionsRatio defines the scaling ratio
  13245. * @returns true if operation was successful
  13246. */
  13247. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13248. }
  13249. }
  13250. }
  13251. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13252. /**
  13253. * Class used to override all child animations of a given target
  13254. */
  13255. export class AnimationPropertiesOverride {
  13256. /**
  13257. * Gets or sets a value indicating if animation blending must be used
  13258. */
  13259. enableBlending: boolean;
  13260. /**
  13261. * Gets or sets the blending speed to use when enableBlending is true
  13262. */
  13263. blendingSpeed: number;
  13264. /**
  13265. * Gets or sets the default loop mode to use
  13266. */
  13267. loopMode: number;
  13268. }
  13269. }
  13270. declare module "babylonjs/Bones/skeleton" {
  13271. import { Bone } from "babylonjs/Bones/bone";
  13272. import { Observable } from "babylonjs/Misc/observable";
  13273. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13274. import { Scene } from "babylonjs/scene";
  13275. import { Nullable } from "babylonjs/types";
  13276. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13277. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13278. import { Animatable } from "babylonjs/Animations/animatable";
  13279. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13280. import { Animation } from "babylonjs/Animations/animation";
  13281. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13282. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13283. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13284. /**
  13285. * Class used to handle skinning animations
  13286. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13287. */
  13288. export class Skeleton implements IAnimatable {
  13289. /** defines the skeleton name */
  13290. name: string;
  13291. /** defines the skeleton Id */
  13292. id: string;
  13293. /**
  13294. * Defines the list of child bones
  13295. */
  13296. bones: Bone[];
  13297. /**
  13298. * Defines an estimate of the dimension of the skeleton at rest
  13299. */
  13300. dimensionsAtRest: Vector3;
  13301. /**
  13302. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13303. */
  13304. needInitialSkinMatrix: boolean;
  13305. /**
  13306. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13307. */
  13308. overrideMesh: Nullable<AbstractMesh>;
  13309. /**
  13310. * Gets the list of animations attached to this skeleton
  13311. */
  13312. animations: Array<Animation>;
  13313. private _scene;
  13314. private _isDirty;
  13315. private _transformMatrices;
  13316. private _transformMatrixTexture;
  13317. private _meshesWithPoseMatrix;
  13318. private _animatables;
  13319. private _identity;
  13320. private _synchronizedWithMesh;
  13321. private _ranges;
  13322. private _lastAbsoluteTransformsUpdateId;
  13323. private _canUseTextureForBones;
  13324. private _uniqueId;
  13325. /** @hidden */
  13326. _numBonesWithLinkedTransformNode: number;
  13327. /** @hidden */
  13328. _hasWaitingData: Nullable<boolean>;
  13329. /**
  13330. * Specifies if the skeleton should be serialized
  13331. */
  13332. doNotSerialize: boolean;
  13333. private _useTextureToStoreBoneMatrices;
  13334. /**
  13335. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13336. * Please note that this option is not available if the hardware does not support it
  13337. */
  13338. useTextureToStoreBoneMatrices: boolean;
  13339. private _animationPropertiesOverride;
  13340. /**
  13341. * Gets or sets the animation properties override
  13342. */
  13343. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13344. /**
  13345. * List of inspectable custom properties (used by the Inspector)
  13346. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13347. */
  13348. inspectableCustomProperties: IInspectable[];
  13349. /**
  13350. * An observable triggered before computing the skeleton's matrices
  13351. */
  13352. onBeforeComputeObservable: Observable<Skeleton>;
  13353. /**
  13354. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13355. */
  13356. readonly isUsingTextureForMatrices: boolean;
  13357. /**
  13358. * Gets the unique ID of this skeleton
  13359. */
  13360. readonly uniqueId: number;
  13361. /**
  13362. * Creates a new skeleton
  13363. * @param name defines the skeleton name
  13364. * @param id defines the skeleton Id
  13365. * @param scene defines the hosting scene
  13366. */
  13367. constructor(
  13368. /** defines the skeleton name */
  13369. name: string,
  13370. /** defines the skeleton Id */
  13371. id: string, scene: Scene);
  13372. /**
  13373. * Gets the current object class name.
  13374. * @return the class name
  13375. */
  13376. getClassName(): string;
  13377. /**
  13378. * Returns an array containing the root bones
  13379. * @returns an array containing the root bones
  13380. */
  13381. getChildren(): Array<Bone>;
  13382. /**
  13383. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13384. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13385. * @returns a Float32Array containing matrices data
  13386. */
  13387. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13388. /**
  13389. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13390. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13391. * @returns a raw texture containing the data
  13392. */
  13393. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13394. /**
  13395. * Gets the current hosting scene
  13396. * @returns a scene object
  13397. */
  13398. getScene(): Scene;
  13399. /**
  13400. * Gets a string representing the current skeleton data
  13401. * @param fullDetails defines a boolean indicating if we want a verbose version
  13402. * @returns a string representing the current skeleton data
  13403. */
  13404. toString(fullDetails?: boolean): string;
  13405. /**
  13406. * Get bone's index searching by name
  13407. * @param name defines bone's name to search for
  13408. * @return the indice of the bone. Returns -1 if not found
  13409. */
  13410. getBoneIndexByName(name: string): number;
  13411. /**
  13412. * Creater a new animation range
  13413. * @param name defines the name of the range
  13414. * @param from defines the start key
  13415. * @param to defines the end key
  13416. */
  13417. createAnimationRange(name: string, from: number, to: number): void;
  13418. /**
  13419. * Delete a specific animation range
  13420. * @param name defines the name of the range
  13421. * @param deleteFrames defines if frames must be removed as well
  13422. */
  13423. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13424. /**
  13425. * Gets a specific animation range
  13426. * @param name defines the name of the range to look for
  13427. * @returns the requested animation range or null if not found
  13428. */
  13429. getAnimationRange(name: string): Nullable<AnimationRange>;
  13430. /**
  13431. * Gets the list of all animation ranges defined on this skeleton
  13432. * @returns an array
  13433. */
  13434. getAnimationRanges(): Nullable<AnimationRange>[];
  13435. /**
  13436. * Copy animation range from a source skeleton.
  13437. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13438. * @param source defines the source skeleton
  13439. * @param name defines the name of the range to copy
  13440. * @param rescaleAsRequired defines if rescaling must be applied if required
  13441. * @returns true if operation was successful
  13442. */
  13443. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13444. /**
  13445. * Forces the skeleton to go to rest pose
  13446. */
  13447. returnToRest(): void;
  13448. private _getHighestAnimationFrame;
  13449. /**
  13450. * Begin a specific animation range
  13451. * @param name defines the name of the range to start
  13452. * @param loop defines if looping must be turned on (false by default)
  13453. * @param speedRatio defines the speed ratio to apply (1 by default)
  13454. * @param onAnimationEnd defines a callback which will be called when animation will end
  13455. * @returns a new animatable
  13456. */
  13457. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13458. /** @hidden */
  13459. _markAsDirty(): void;
  13460. /** @hidden */
  13461. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13462. /** @hidden */
  13463. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13464. private _computeTransformMatrices;
  13465. /**
  13466. * Build all resources required to render a skeleton
  13467. */
  13468. prepare(): void;
  13469. /**
  13470. * Gets the list of animatables currently running for this skeleton
  13471. * @returns an array of animatables
  13472. */
  13473. getAnimatables(): IAnimatable[];
  13474. /**
  13475. * Clone the current skeleton
  13476. * @param name defines the name of the new skeleton
  13477. * @param id defines the id of the new skeleton
  13478. * @returns the new skeleton
  13479. */
  13480. clone(name: string, id: string): Skeleton;
  13481. /**
  13482. * Enable animation blending for this skeleton
  13483. * @param blendingSpeed defines the blending speed to apply
  13484. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13485. */
  13486. enableBlending(blendingSpeed?: number): void;
  13487. /**
  13488. * Releases all resources associated with the current skeleton
  13489. */
  13490. dispose(): void;
  13491. /**
  13492. * Serialize the skeleton in a JSON object
  13493. * @returns a JSON object
  13494. */
  13495. serialize(): any;
  13496. /**
  13497. * Creates a new skeleton from serialized data
  13498. * @param parsedSkeleton defines the serialized data
  13499. * @param scene defines the hosting scene
  13500. * @returns a new skeleton
  13501. */
  13502. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13503. /**
  13504. * Compute all node absolute transforms
  13505. * @param forceUpdate defines if computation must be done even if cache is up to date
  13506. */
  13507. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13508. /**
  13509. * Gets the root pose matrix
  13510. * @returns a matrix
  13511. */
  13512. getPoseMatrix(): Nullable<Matrix>;
  13513. /**
  13514. * Sorts bones per internal index
  13515. */
  13516. sortBones(): void;
  13517. private _sortBones;
  13518. }
  13519. }
  13520. declare module "babylonjs/Bones/bone" {
  13521. import { Skeleton } from "babylonjs/Bones/skeleton";
  13522. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13523. import { Nullable } from "babylonjs/types";
  13524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13525. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13526. import { Node } from "babylonjs/node";
  13527. import { Space } from "babylonjs/Maths/math.axis";
  13528. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13529. /**
  13530. * Class used to store bone information
  13531. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13532. */
  13533. export class Bone extends Node {
  13534. /**
  13535. * defines the bone name
  13536. */
  13537. name: string;
  13538. private static _tmpVecs;
  13539. private static _tmpQuat;
  13540. private static _tmpMats;
  13541. /**
  13542. * Gets the list of child bones
  13543. */
  13544. children: Bone[];
  13545. /** Gets the animations associated with this bone */
  13546. animations: import("babylonjs/Animations/animation").Animation[];
  13547. /**
  13548. * Gets or sets bone length
  13549. */
  13550. length: number;
  13551. /**
  13552. * @hidden Internal only
  13553. * Set this value to map this bone to a different index in the transform matrices
  13554. * Set this value to -1 to exclude the bone from the transform matrices
  13555. */
  13556. _index: Nullable<number>;
  13557. private _skeleton;
  13558. private _localMatrix;
  13559. private _restPose;
  13560. private _baseMatrix;
  13561. private _absoluteTransform;
  13562. private _invertedAbsoluteTransform;
  13563. private _parent;
  13564. private _scalingDeterminant;
  13565. private _worldTransform;
  13566. private _localScaling;
  13567. private _localRotation;
  13568. private _localPosition;
  13569. private _needToDecompose;
  13570. private _needToCompose;
  13571. /** @hidden */
  13572. _linkedTransformNode: Nullable<TransformNode>;
  13573. /** @hidden */
  13574. _waitingTransformNodeId: Nullable<string>;
  13575. /** @hidden */
  13576. /** @hidden */
  13577. _matrix: Matrix;
  13578. /**
  13579. * Create a new bone
  13580. * @param name defines the bone name
  13581. * @param skeleton defines the parent skeleton
  13582. * @param parentBone defines the parent (can be null if the bone is the root)
  13583. * @param localMatrix defines the local matrix
  13584. * @param restPose defines the rest pose matrix
  13585. * @param baseMatrix defines the base matrix
  13586. * @param index defines index of the bone in the hiearchy
  13587. */
  13588. constructor(
  13589. /**
  13590. * defines the bone name
  13591. */
  13592. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13593. /**
  13594. * Gets the current object class name.
  13595. * @return the class name
  13596. */
  13597. getClassName(): string;
  13598. /**
  13599. * Gets the parent skeleton
  13600. * @returns a skeleton
  13601. */
  13602. getSkeleton(): Skeleton;
  13603. /**
  13604. * Gets parent bone
  13605. * @returns a bone or null if the bone is the root of the bone hierarchy
  13606. */
  13607. getParent(): Nullable<Bone>;
  13608. /**
  13609. * Returns an array containing the root bones
  13610. * @returns an array containing the root bones
  13611. */
  13612. getChildren(): Array<Bone>;
  13613. /**
  13614. * Sets the parent bone
  13615. * @param parent defines the parent (can be null if the bone is the root)
  13616. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13617. */
  13618. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13619. /**
  13620. * Gets the local matrix
  13621. * @returns a matrix
  13622. */
  13623. getLocalMatrix(): Matrix;
  13624. /**
  13625. * Gets the base matrix (initial matrix which remains unchanged)
  13626. * @returns a matrix
  13627. */
  13628. getBaseMatrix(): Matrix;
  13629. /**
  13630. * Gets the rest pose matrix
  13631. * @returns a matrix
  13632. */
  13633. getRestPose(): Matrix;
  13634. /**
  13635. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13636. */
  13637. getWorldMatrix(): Matrix;
  13638. /**
  13639. * Sets the local matrix to rest pose matrix
  13640. */
  13641. returnToRest(): void;
  13642. /**
  13643. * Gets the inverse of the absolute transform matrix.
  13644. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13645. * @returns a matrix
  13646. */
  13647. getInvertedAbsoluteTransform(): Matrix;
  13648. /**
  13649. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13650. * @returns a matrix
  13651. */
  13652. getAbsoluteTransform(): Matrix;
  13653. /**
  13654. * Links with the given transform node.
  13655. * The local matrix of this bone is copied from the transform node every frame.
  13656. * @param transformNode defines the transform node to link to
  13657. */
  13658. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13659. /**
  13660. * Gets the node used to drive the bone's transformation
  13661. * @returns a transform node or null
  13662. */
  13663. getTransformNode(): Nullable<TransformNode>;
  13664. /** Gets or sets current position (in local space) */
  13665. position: Vector3;
  13666. /** Gets or sets current rotation (in local space) */
  13667. rotation: Vector3;
  13668. /** Gets or sets current rotation quaternion (in local space) */
  13669. rotationQuaternion: Quaternion;
  13670. /** Gets or sets current scaling (in local space) */
  13671. scaling: Vector3;
  13672. /**
  13673. * Gets the animation properties override
  13674. */
  13675. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13676. private _decompose;
  13677. private _compose;
  13678. /**
  13679. * Update the base and local matrices
  13680. * @param matrix defines the new base or local matrix
  13681. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13682. * @param updateLocalMatrix defines if the local matrix should be updated
  13683. */
  13684. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13685. /** @hidden */
  13686. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13687. /**
  13688. * Flag the bone as dirty (Forcing it to update everything)
  13689. */
  13690. markAsDirty(): void;
  13691. /** @hidden */
  13692. _markAsDirtyAndCompose(): void;
  13693. private _markAsDirtyAndDecompose;
  13694. /**
  13695. * Translate the bone in local or world space
  13696. * @param vec The amount to translate the bone
  13697. * @param space The space that the translation is in
  13698. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13699. */
  13700. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13701. /**
  13702. * Set the postion of the bone in local or world space
  13703. * @param position The position to set the bone
  13704. * @param space The space that the position is in
  13705. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13706. */
  13707. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13708. /**
  13709. * Set the absolute position of the bone (world space)
  13710. * @param position The position to set the bone
  13711. * @param mesh The mesh that this bone is attached to
  13712. */
  13713. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13714. /**
  13715. * Scale the bone on the x, y and z axes (in local space)
  13716. * @param x The amount to scale the bone on the x axis
  13717. * @param y The amount to scale the bone on the y axis
  13718. * @param z The amount to scale the bone on the z axis
  13719. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13720. */
  13721. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13722. /**
  13723. * Set the bone scaling in local space
  13724. * @param scale defines the scaling vector
  13725. */
  13726. setScale(scale: Vector3): void;
  13727. /**
  13728. * Gets the current scaling in local space
  13729. * @returns the current scaling vector
  13730. */
  13731. getScale(): Vector3;
  13732. /**
  13733. * Gets the current scaling in local space and stores it in a target vector
  13734. * @param result defines the target vector
  13735. */
  13736. getScaleToRef(result: Vector3): void;
  13737. /**
  13738. * Set the yaw, pitch, and roll of the bone in local or world space
  13739. * @param yaw The rotation of the bone on the y axis
  13740. * @param pitch The rotation of the bone on the x axis
  13741. * @param roll The rotation of the bone on the z axis
  13742. * @param space The space that the axes of rotation are in
  13743. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13744. */
  13745. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13746. /**
  13747. * Add a rotation to the bone on an axis in local or world space
  13748. * @param axis The axis to rotate the bone on
  13749. * @param amount The amount to rotate the bone
  13750. * @param space The space that the axis is in
  13751. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13752. */
  13753. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13754. /**
  13755. * Set the rotation of the bone to a particular axis angle in local or world space
  13756. * @param axis The axis to rotate the bone on
  13757. * @param angle The angle that the bone should be rotated to
  13758. * @param space The space that the axis is in
  13759. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13760. */
  13761. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13762. /**
  13763. * Set the euler rotation of the bone in local of world space
  13764. * @param rotation The euler rotation that the bone should be set to
  13765. * @param space The space that the rotation is in
  13766. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13767. */
  13768. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13769. /**
  13770. * Set the quaternion rotation of the bone in local of world space
  13771. * @param quat The quaternion rotation that the bone should be set to
  13772. * @param space The space that the rotation is in
  13773. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13774. */
  13775. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13776. /**
  13777. * Set the rotation matrix of the bone in local of world space
  13778. * @param rotMat The rotation matrix that the bone should be set to
  13779. * @param space The space that the rotation is in
  13780. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13781. */
  13782. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13783. private _rotateWithMatrix;
  13784. private _getNegativeRotationToRef;
  13785. /**
  13786. * Get the position of the bone in local or world space
  13787. * @param space The space that the returned position is in
  13788. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13789. * @returns The position of the bone
  13790. */
  13791. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13792. /**
  13793. * Copy the position of the bone to a vector3 in local or world space
  13794. * @param space The space that the returned position is in
  13795. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13796. * @param result The vector3 to copy the position to
  13797. */
  13798. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13799. /**
  13800. * Get the absolute position of the bone (world space)
  13801. * @param mesh The mesh that this bone is attached to
  13802. * @returns The absolute position of the bone
  13803. */
  13804. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13805. /**
  13806. * Copy the absolute position of the bone (world space) to the result param
  13807. * @param mesh The mesh that this bone is attached to
  13808. * @param result The vector3 to copy the absolute position to
  13809. */
  13810. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13811. /**
  13812. * Compute the absolute transforms of this bone and its children
  13813. */
  13814. computeAbsoluteTransforms(): void;
  13815. /**
  13816. * Get the world direction from an axis that is in the local space of the bone
  13817. * @param localAxis The local direction that is used to compute the world direction
  13818. * @param mesh The mesh that this bone is attached to
  13819. * @returns The world direction
  13820. */
  13821. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13822. /**
  13823. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13824. * @param localAxis The local direction that is used to compute the world direction
  13825. * @param mesh The mesh that this bone is attached to
  13826. * @param result The vector3 that the world direction will be copied to
  13827. */
  13828. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13829. /**
  13830. * Get the euler rotation of the bone in local or world space
  13831. * @param space The space that the rotation should be in
  13832. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13833. * @returns The euler rotation
  13834. */
  13835. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13836. /**
  13837. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13838. * @param space The space that the rotation should be in
  13839. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13840. * @param result The vector3 that the rotation should be copied to
  13841. */
  13842. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13843. /**
  13844. * Get the quaternion rotation of the bone in either local or world space
  13845. * @param space The space that the rotation should be in
  13846. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13847. * @returns The quaternion rotation
  13848. */
  13849. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13850. /**
  13851. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13852. * @param space The space that the rotation should be in
  13853. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13854. * @param result The quaternion that the rotation should be copied to
  13855. */
  13856. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13857. /**
  13858. * Get the rotation matrix of the bone in local or world space
  13859. * @param space The space that the rotation should be in
  13860. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13861. * @returns The rotation matrix
  13862. */
  13863. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13864. /**
  13865. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13866. * @param space The space that the rotation should be in
  13867. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13868. * @param result The quaternion that the rotation should be copied to
  13869. */
  13870. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13871. /**
  13872. * Get the world position of a point that is in the local space of the bone
  13873. * @param position The local position
  13874. * @param mesh The mesh that this bone is attached to
  13875. * @returns The world position
  13876. */
  13877. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13878. /**
  13879. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13880. * @param position The local position
  13881. * @param mesh The mesh that this bone is attached to
  13882. * @param result The vector3 that the world position should be copied to
  13883. */
  13884. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13885. /**
  13886. * Get the local position of a point that is in world space
  13887. * @param position The world position
  13888. * @param mesh The mesh that this bone is attached to
  13889. * @returns The local position
  13890. */
  13891. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13892. /**
  13893. * Get the local position of a point that is in world space and copy it to the result param
  13894. * @param position The world position
  13895. * @param mesh The mesh that this bone is attached to
  13896. * @param result The vector3 that the local position should be copied to
  13897. */
  13898. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13899. }
  13900. }
  13901. declare module "babylonjs/Meshes/transformNode" {
  13902. import { DeepImmutable } from "babylonjs/types";
  13903. import { Observable } from "babylonjs/Misc/observable";
  13904. import { Nullable } from "babylonjs/types";
  13905. import { Camera } from "babylonjs/Cameras/camera";
  13906. import { Scene } from "babylonjs/scene";
  13907. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13908. import { Node } from "babylonjs/node";
  13909. import { Bone } from "babylonjs/Bones/bone";
  13910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13911. import { Space } from "babylonjs/Maths/math.axis";
  13912. /**
  13913. * 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.
  13914. * @see https://doc.babylonjs.com/how_to/transformnode
  13915. */
  13916. export class TransformNode extends Node {
  13917. /**
  13918. * Object will not rotate to face the camera
  13919. */
  13920. static BILLBOARDMODE_NONE: number;
  13921. /**
  13922. * Object will rotate to face the camera but only on the x axis
  13923. */
  13924. static BILLBOARDMODE_X: number;
  13925. /**
  13926. * Object will rotate to face the camera but only on the y axis
  13927. */
  13928. static BILLBOARDMODE_Y: number;
  13929. /**
  13930. * Object will rotate to face the camera but only on the z axis
  13931. */
  13932. static BILLBOARDMODE_Z: number;
  13933. /**
  13934. * Object will rotate to face the camera
  13935. */
  13936. static BILLBOARDMODE_ALL: number;
  13937. private _forward;
  13938. private _forwardInverted;
  13939. private _up;
  13940. private _right;
  13941. private _rightInverted;
  13942. private _position;
  13943. private _rotation;
  13944. private _rotationQuaternion;
  13945. protected _scaling: Vector3;
  13946. protected _isDirty: boolean;
  13947. private _transformToBoneReferal;
  13948. private _isAbsoluteSynced;
  13949. private _billboardMode;
  13950. /**
  13951. * Gets or sets the billboard mode. Default is 0.
  13952. *
  13953. * | Value | Type | Description |
  13954. * | --- | --- | --- |
  13955. * | 0 | BILLBOARDMODE_NONE | |
  13956. * | 1 | BILLBOARDMODE_X | |
  13957. * | 2 | BILLBOARDMODE_Y | |
  13958. * | 4 | BILLBOARDMODE_Z | |
  13959. * | 7 | BILLBOARDMODE_ALL | |
  13960. *
  13961. */
  13962. billboardMode: number;
  13963. private _preserveParentRotationForBillboard;
  13964. /**
  13965. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13966. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13967. */
  13968. preserveParentRotationForBillboard: boolean;
  13969. /**
  13970. * 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
  13971. */
  13972. scalingDeterminant: number;
  13973. private _infiniteDistance;
  13974. /**
  13975. * Gets or sets the distance of the object to max, often used by skybox
  13976. */
  13977. infiniteDistance: boolean;
  13978. /**
  13979. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13980. * By default the system will update normals to compensate
  13981. */
  13982. ignoreNonUniformScaling: boolean;
  13983. /**
  13984. * 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
  13985. */
  13986. reIntegrateRotationIntoRotationQuaternion: boolean;
  13987. /** @hidden */
  13988. _poseMatrix: Nullable<Matrix>;
  13989. /** @hidden */
  13990. _localMatrix: Matrix;
  13991. private _usePivotMatrix;
  13992. private _absolutePosition;
  13993. private _absoluteScaling;
  13994. private _absoluteRotationQuaternion;
  13995. private _pivotMatrix;
  13996. private _pivotMatrixInverse;
  13997. protected _postMultiplyPivotMatrix: boolean;
  13998. protected _isWorldMatrixFrozen: boolean;
  13999. /** @hidden */
  14000. _indexInSceneTransformNodesArray: number;
  14001. /**
  14002. * An event triggered after the world matrix is updated
  14003. */
  14004. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14005. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14006. /**
  14007. * Gets a string identifying the name of the class
  14008. * @returns "TransformNode" string
  14009. */
  14010. getClassName(): string;
  14011. /**
  14012. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14013. */
  14014. position: Vector3;
  14015. /**
  14016. * 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)).
  14017. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14018. */
  14019. rotation: Vector3;
  14020. /**
  14021. * 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)).
  14022. */
  14023. scaling: Vector3;
  14024. /**
  14025. * 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).
  14026. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14027. */
  14028. rotationQuaternion: Nullable<Quaternion>;
  14029. /**
  14030. * The forward direction of that transform in world space.
  14031. */
  14032. readonly forward: Vector3;
  14033. /**
  14034. * The up direction of that transform in world space.
  14035. */
  14036. readonly up: Vector3;
  14037. /**
  14038. * The right direction of that transform in world space.
  14039. */
  14040. readonly right: Vector3;
  14041. /**
  14042. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14043. * @param matrix the matrix to copy the pose from
  14044. * @returns this TransformNode.
  14045. */
  14046. updatePoseMatrix(matrix: Matrix): TransformNode;
  14047. /**
  14048. * Returns the mesh Pose matrix.
  14049. * @returns the pose matrix
  14050. */
  14051. getPoseMatrix(): Matrix;
  14052. /** @hidden */
  14053. _isSynchronized(): boolean;
  14054. /** @hidden */
  14055. _initCache(): void;
  14056. /**
  14057. * Flag the transform node as dirty (Forcing it to update everything)
  14058. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14059. * @returns this transform node
  14060. */
  14061. markAsDirty(property: string): TransformNode;
  14062. /**
  14063. * Returns the current mesh absolute position.
  14064. * Returns a Vector3.
  14065. */
  14066. readonly absolutePosition: Vector3;
  14067. /**
  14068. * Returns the current mesh absolute scaling.
  14069. * Returns a Vector3.
  14070. */
  14071. readonly absoluteScaling: Vector3;
  14072. /**
  14073. * Returns the current mesh absolute rotation.
  14074. * Returns a Quaternion.
  14075. */
  14076. readonly absoluteRotationQuaternion: Quaternion;
  14077. /**
  14078. * Sets a new matrix to apply before all other transformation
  14079. * @param matrix defines the transform matrix
  14080. * @returns the current TransformNode
  14081. */
  14082. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14083. /**
  14084. * Sets a new pivot matrix to the current node
  14085. * @param matrix defines the new pivot matrix to use
  14086. * @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
  14087. * @returns the current TransformNode
  14088. */
  14089. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14090. /**
  14091. * Returns the mesh pivot matrix.
  14092. * Default : Identity.
  14093. * @returns the matrix
  14094. */
  14095. getPivotMatrix(): Matrix;
  14096. /**
  14097. * Prevents the World matrix to be computed any longer.
  14098. * @returns the TransformNode.
  14099. */
  14100. freezeWorldMatrix(): TransformNode;
  14101. /**
  14102. * Allows back the World matrix computation.
  14103. * @returns the TransformNode.
  14104. */
  14105. unfreezeWorldMatrix(): this;
  14106. /**
  14107. * True if the World matrix has been frozen.
  14108. */
  14109. readonly isWorldMatrixFrozen: boolean;
  14110. /**
  14111. * Retuns the mesh absolute position in the World.
  14112. * @returns a Vector3.
  14113. */
  14114. getAbsolutePosition(): Vector3;
  14115. /**
  14116. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14117. * @param absolutePosition the absolute position to set
  14118. * @returns the TransformNode.
  14119. */
  14120. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14121. /**
  14122. * Sets the mesh position in its local space.
  14123. * @param vector3 the position to set in localspace
  14124. * @returns the TransformNode.
  14125. */
  14126. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14127. /**
  14128. * Returns the mesh position in the local space from the current World matrix values.
  14129. * @returns a new Vector3.
  14130. */
  14131. getPositionExpressedInLocalSpace(): Vector3;
  14132. /**
  14133. * Translates the mesh along the passed Vector3 in its local space.
  14134. * @param vector3 the distance to translate in localspace
  14135. * @returns the TransformNode.
  14136. */
  14137. locallyTranslate(vector3: Vector3): TransformNode;
  14138. private static _lookAtVectorCache;
  14139. /**
  14140. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14141. * @param targetPoint the position (must be in same space as current mesh) to look at
  14142. * @param yawCor optional yaw (y-axis) correction in radians
  14143. * @param pitchCor optional pitch (x-axis) correction in radians
  14144. * @param rollCor optional roll (z-axis) correction in radians
  14145. * @param space the choosen space of the target
  14146. * @returns the TransformNode.
  14147. */
  14148. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14149. /**
  14150. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14151. * This Vector3 is expressed in the World space.
  14152. * @param localAxis axis to rotate
  14153. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14154. */
  14155. getDirection(localAxis: Vector3): Vector3;
  14156. /**
  14157. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14158. * localAxis is expressed in the mesh local space.
  14159. * result is computed in the Wordl space from the mesh World matrix.
  14160. * @param localAxis axis to rotate
  14161. * @param result the resulting transformnode
  14162. * @returns this TransformNode.
  14163. */
  14164. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14165. /**
  14166. * Sets this transform node rotation to the given local axis.
  14167. * @param localAxis the axis in local space
  14168. * @param yawCor optional yaw (y-axis) correction in radians
  14169. * @param pitchCor optional pitch (x-axis) correction in radians
  14170. * @param rollCor optional roll (z-axis) correction in radians
  14171. * @returns this TransformNode
  14172. */
  14173. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14174. /**
  14175. * Sets a new pivot point to the current node
  14176. * @param point defines the new pivot point to use
  14177. * @param space defines if the point is in world or local space (local by default)
  14178. * @returns the current TransformNode
  14179. */
  14180. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14181. /**
  14182. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14183. * @returns the pivot point
  14184. */
  14185. getPivotPoint(): Vector3;
  14186. /**
  14187. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14188. * @param result the vector3 to store the result
  14189. * @returns this TransformNode.
  14190. */
  14191. getPivotPointToRef(result: Vector3): TransformNode;
  14192. /**
  14193. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14194. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14195. */
  14196. getAbsolutePivotPoint(): Vector3;
  14197. /**
  14198. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14199. * @param result vector3 to store the result
  14200. * @returns this TransformNode.
  14201. */
  14202. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14203. /**
  14204. * Defines the passed node as the parent of the current node.
  14205. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14206. * @see https://doc.babylonjs.com/how_to/parenting
  14207. * @param node the node ot set as the parent
  14208. * @returns this TransformNode.
  14209. */
  14210. setParent(node: Nullable<Node>): TransformNode;
  14211. private _nonUniformScaling;
  14212. /**
  14213. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14214. */
  14215. readonly nonUniformScaling: boolean;
  14216. /** @hidden */
  14217. _updateNonUniformScalingState(value: boolean): boolean;
  14218. /**
  14219. * Attach the current TransformNode to another TransformNode associated with a bone
  14220. * @param bone Bone affecting the TransformNode
  14221. * @param affectedTransformNode TransformNode associated with the bone
  14222. * @returns this object
  14223. */
  14224. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14225. /**
  14226. * Detach the transform node if its associated with a bone
  14227. * @returns this object
  14228. */
  14229. detachFromBone(): TransformNode;
  14230. private static _rotationAxisCache;
  14231. /**
  14232. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14233. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14234. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14235. * The passed axis is also normalized.
  14236. * @param axis the axis to rotate around
  14237. * @param amount the amount to rotate in radians
  14238. * @param space Space to rotate in (Default: local)
  14239. * @returns the TransformNode.
  14240. */
  14241. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14242. /**
  14243. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14244. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14245. * The passed axis is also normalized. .
  14246. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14247. * @param point the point to rotate around
  14248. * @param axis the axis to rotate around
  14249. * @param amount the amount to rotate in radians
  14250. * @returns the TransformNode
  14251. */
  14252. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14253. /**
  14254. * Translates the mesh along the axis vector for the passed distance in the given space.
  14255. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14256. * @param axis the axis to translate in
  14257. * @param distance the distance to translate
  14258. * @param space Space to rotate in (Default: local)
  14259. * @returns the TransformNode.
  14260. */
  14261. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14262. /**
  14263. * Adds a rotation step to the mesh current rotation.
  14264. * x, y, z are Euler angles expressed in radians.
  14265. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14266. * This means this rotation is made in the mesh local space only.
  14267. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14268. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14269. * ```javascript
  14270. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14271. * ```
  14272. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14273. * 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.
  14274. * @param x Rotation to add
  14275. * @param y Rotation to add
  14276. * @param z Rotation to add
  14277. * @returns the TransformNode.
  14278. */
  14279. addRotation(x: number, y: number, z: number): TransformNode;
  14280. /**
  14281. * @hidden
  14282. */
  14283. protected _getEffectiveParent(): Nullable<Node>;
  14284. /**
  14285. * Computes the world matrix of the node
  14286. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14287. * @returns the world matrix
  14288. */
  14289. computeWorldMatrix(force?: boolean): Matrix;
  14290. protected _afterComputeWorldMatrix(): void;
  14291. /**
  14292. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14293. * @param func callback function to add
  14294. *
  14295. * @returns the TransformNode.
  14296. */
  14297. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14298. /**
  14299. * Removes a registered callback function.
  14300. * @param func callback function to remove
  14301. * @returns the TransformNode.
  14302. */
  14303. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14304. /**
  14305. * Gets the position of the current mesh in camera space
  14306. * @param camera defines the camera to use
  14307. * @returns a position
  14308. */
  14309. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14310. /**
  14311. * Returns the distance from the mesh to the active camera
  14312. * @param camera defines the camera to use
  14313. * @returns the distance
  14314. */
  14315. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14316. /**
  14317. * Clone the current transform node
  14318. * @param name Name of the new clone
  14319. * @param newParent New parent for the clone
  14320. * @param doNotCloneChildren Do not clone children hierarchy
  14321. * @returns the new transform node
  14322. */
  14323. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14324. /**
  14325. * Serializes the objects information.
  14326. * @param currentSerializationObject defines the object to serialize in
  14327. * @returns the serialized object
  14328. */
  14329. serialize(currentSerializationObject?: any): any;
  14330. /**
  14331. * Returns a new TransformNode object parsed from the source provided.
  14332. * @param parsedTransformNode is the source.
  14333. * @param scene the scne the object belongs to
  14334. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14335. * @returns a new TransformNode object parsed from the source provided.
  14336. */
  14337. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14338. /**
  14339. * Get all child-transformNodes of this node
  14340. * @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
  14341. * @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
  14342. * @returns an array of TransformNode
  14343. */
  14344. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14345. /**
  14346. * Releases resources associated with this transform node.
  14347. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14348. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14349. */
  14350. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14351. /**
  14352. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14353. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14354. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14355. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14356. * @returns the current mesh
  14357. */
  14358. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14359. private _syncAbsoluteScalingAndRotation;
  14360. }
  14361. }
  14362. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14363. import { Observable } from "babylonjs/Misc/observable";
  14364. import { Nullable } from "babylonjs/types";
  14365. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14366. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14368. import { Ray } from "babylonjs/Culling/ray";
  14369. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14370. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14371. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14372. /**
  14373. * Defines the types of pose enabled controllers that are supported
  14374. */
  14375. export enum PoseEnabledControllerType {
  14376. /**
  14377. * HTC Vive
  14378. */
  14379. VIVE = 0,
  14380. /**
  14381. * Oculus Rift
  14382. */
  14383. OCULUS = 1,
  14384. /**
  14385. * Windows mixed reality
  14386. */
  14387. WINDOWS = 2,
  14388. /**
  14389. * Samsung gear VR
  14390. */
  14391. GEAR_VR = 3,
  14392. /**
  14393. * Google Daydream
  14394. */
  14395. DAYDREAM = 4,
  14396. /**
  14397. * Generic
  14398. */
  14399. GENERIC = 5
  14400. }
  14401. /**
  14402. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14403. */
  14404. export interface MutableGamepadButton {
  14405. /**
  14406. * Value of the button/trigger
  14407. */
  14408. value: number;
  14409. /**
  14410. * If the button/trigger is currently touched
  14411. */
  14412. touched: boolean;
  14413. /**
  14414. * If the button/trigger is currently pressed
  14415. */
  14416. pressed: boolean;
  14417. }
  14418. /**
  14419. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14420. * @hidden
  14421. */
  14422. export interface ExtendedGamepadButton extends GamepadButton {
  14423. /**
  14424. * If the button/trigger is currently pressed
  14425. */
  14426. readonly pressed: boolean;
  14427. /**
  14428. * If the button/trigger is currently touched
  14429. */
  14430. readonly touched: boolean;
  14431. /**
  14432. * Value of the button/trigger
  14433. */
  14434. readonly value: number;
  14435. }
  14436. /** @hidden */
  14437. export interface _GamePadFactory {
  14438. /**
  14439. * Returns wether or not the current gamepad can be created for this type of controller.
  14440. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14441. * @returns true if it can be created, otherwise false
  14442. */
  14443. canCreate(gamepadInfo: any): boolean;
  14444. /**
  14445. * Creates a new instance of the Gamepad.
  14446. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14447. * @returns the new gamepad instance
  14448. */
  14449. create(gamepadInfo: any): Gamepad;
  14450. }
  14451. /**
  14452. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14453. */
  14454. export class PoseEnabledControllerHelper {
  14455. /** @hidden */
  14456. static _ControllerFactories: _GamePadFactory[];
  14457. /** @hidden */
  14458. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14459. /**
  14460. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14461. * @param vrGamepad the gamepad to initialized
  14462. * @returns a vr controller of the type the gamepad identified as
  14463. */
  14464. static InitiateController(vrGamepad: any): Gamepad;
  14465. }
  14466. /**
  14467. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14468. */
  14469. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14470. /**
  14471. * If the controller is used in a webXR session
  14472. */
  14473. isXR: boolean;
  14474. private _deviceRoomPosition;
  14475. private _deviceRoomRotationQuaternion;
  14476. /**
  14477. * The device position in babylon space
  14478. */
  14479. devicePosition: Vector3;
  14480. /**
  14481. * The device rotation in babylon space
  14482. */
  14483. deviceRotationQuaternion: Quaternion;
  14484. /**
  14485. * The scale factor of the device in babylon space
  14486. */
  14487. deviceScaleFactor: number;
  14488. /**
  14489. * (Likely devicePosition should be used instead) The device position in its room space
  14490. */
  14491. position: Vector3;
  14492. /**
  14493. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14494. */
  14495. rotationQuaternion: Quaternion;
  14496. /**
  14497. * The type of controller (Eg. Windows mixed reality)
  14498. */
  14499. controllerType: PoseEnabledControllerType;
  14500. protected _calculatedPosition: Vector3;
  14501. private _calculatedRotation;
  14502. /**
  14503. * The raw pose from the device
  14504. */
  14505. rawPose: DevicePose;
  14506. private _trackPosition;
  14507. private _maxRotationDistFromHeadset;
  14508. private _draggedRoomRotation;
  14509. /**
  14510. * @hidden
  14511. */
  14512. _disableTrackPosition(fixedPosition: Vector3): void;
  14513. /**
  14514. * Internal, the mesh attached to the controller
  14515. * @hidden
  14516. */
  14517. _mesh: Nullable<AbstractMesh>;
  14518. private _poseControlledCamera;
  14519. private _leftHandSystemQuaternion;
  14520. /**
  14521. * Internal, matrix used to convert room space to babylon space
  14522. * @hidden
  14523. */
  14524. _deviceToWorld: Matrix;
  14525. /**
  14526. * Node to be used when casting a ray from the controller
  14527. * @hidden
  14528. */
  14529. _pointingPoseNode: Nullable<TransformNode>;
  14530. /**
  14531. * Name of the child mesh that can be used to cast a ray from the controller
  14532. */
  14533. static readonly POINTING_POSE: string;
  14534. /**
  14535. * Creates a new PoseEnabledController from a gamepad
  14536. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14537. */
  14538. constructor(browserGamepad: any);
  14539. private _workingMatrix;
  14540. /**
  14541. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14542. */
  14543. update(): void;
  14544. /**
  14545. * Updates only the pose device and mesh without doing any button event checking
  14546. */
  14547. protected _updatePoseAndMesh(): void;
  14548. /**
  14549. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14550. * @param poseData raw pose fromthe device
  14551. */
  14552. updateFromDevice(poseData: DevicePose): void;
  14553. /**
  14554. * @hidden
  14555. */
  14556. _meshAttachedObservable: Observable<AbstractMesh>;
  14557. /**
  14558. * Attaches a mesh to the controller
  14559. * @param mesh the mesh to be attached
  14560. */
  14561. attachToMesh(mesh: AbstractMesh): void;
  14562. /**
  14563. * Attaches the controllers mesh to a camera
  14564. * @param camera the camera the mesh should be attached to
  14565. */
  14566. attachToPoseControlledCamera(camera: TargetCamera): void;
  14567. /**
  14568. * Disposes of the controller
  14569. */
  14570. dispose(): void;
  14571. /**
  14572. * The mesh that is attached to the controller
  14573. */
  14574. readonly mesh: Nullable<AbstractMesh>;
  14575. /**
  14576. * Gets the ray of the controller in the direction the controller is pointing
  14577. * @param length the length the resulting ray should be
  14578. * @returns a ray in the direction the controller is pointing
  14579. */
  14580. getForwardRay(length?: number): Ray;
  14581. }
  14582. }
  14583. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14584. import { Observable } from "babylonjs/Misc/observable";
  14585. import { Scene } from "babylonjs/scene";
  14586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14587. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14588. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14589. /**
  14590. * Defines the WebVRController object that represents controllers tracked in 3D space
  14591. */
  14592. export abstract class WebVRController extends PoseEnabledController {
  14593. /**
  14594. * Internal, the default controller model for the controller
  14595. */
  14596. protected _defaultModel: AbstractMesh;
  14597. /**
  14598. * Fired when the trigger state has changed
  14599. */
  14600. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14601. /**
  14602. * Fired when the main button state has changed
  14603. */
  14604. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14605. /**
  14606. * Fired when the secondary button state has changed
  14607. */
  14608. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14609. /**
  14610. * Fired when the pad state has changed
  14611. */
  14612. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14613. /**
  14614. * Fired when controllers stick values have changed
  14615. */
  14616. onPadValuesChangedObservable: Observable<StickValues>;
  14617. /**
  14618. * Array of button availible on the controller
  14619. */
  14620. protected _buttons: Array<MutableGamepadButton>;
  14621. private _onButtonStateChange;
  14622. /**
  14623. * Fired when a controller button's state has changed
  14624. * @param callback the callback containing the button that was modified
  14625. */
  14626. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14627. /**
  14628. * X and Y axis corresponding to the controllers joystick
  14629. */
  14630. pad: StickValues;
  14631. /**
  14632. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14633. */
  14634. hand: string;
  14635. /**
  14636. * The default controller model for the controller
  14637. */
  14638. readonly defaultModel: AbstractMesh;
  14639. /**
  14640. * Creates a new WebVRController from a gamepad
  14641. * @param vrGamepad the gamepad that the WebVRController should be created from
  14642. */
  14643. constructor(vrGamepad: any);
  14644. /**
  14645. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14646. */
  14647. update(): void;
  14648. /**
  14649. * Function to be called when a button is modified
  14650. */
  14651. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14652. /**
  14653. * Loads a mesh and attaches it to the controller
  14654. * @param scene the scene the mesh should be added to
  14655. * @param meshLoaded callback for when the mesh has been loaded
  14656. */
  14657. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14658. private _setButtonValue;
  14659. private _changes;
  14660. private _checkChanges;
  14661. /**
  14662. * Disposes of th webVRCOntroller
  14663. */
  14664. dispose(): void;
  14665. }
  14666. }
  14667. declare module "babylonjs/Lights/hemisphericLight" {
  14668. import { Nullable } from "babylonjs/types";
  14669. import { Scene } from "babylonjs/scene";
  14670. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14671. import { Color3 } from "babylonjs/Maths/math.color";
  14672. import { Effect } from "babylonjs/Materials/effect";
  14673. import { Light } from "babylonjs/Lights/light";
  14674. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14675. /**
  14676. * The HemisphericLight simulates the ambient environment light,
  14677. * so the passed direction is the light reflection direction, not the incoming direction.
  14678. */
  14679. export class HemisphericLight extends Light {
  14680. /**
  14681. * The groundColor is the light in the opposite direction to the one specified during creation.
  14682. * 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.
  14683. */
  14684. groundColor: Color3;
  14685. /**
  14686. * The light reflection direction, not the incoming direction.
  14687. */
  14688. direction: Vector3;
  14689. /**
  14690. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14691. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14692. * The HemisphericLight can't cast shadows.
  14693. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14694. * @param name The friendly name of the light
  14695. * @param direction The direction of the light reflection
  14696. * @param scene The scene the light belongs to
  14697. */
  14698. constructor(name: string, direction: Vector3, scene: Scene);
  14699. protected _buildUniformLayout(): void;
  14700. /**
  14701. * Returns the string "HemisphericLight".
  14702. * @return The class name
  14703. */
  14704. getClassName(): string;
  14705. /**
  14706. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14707. * Returns the updated direction.
  14708. * @param target The target the direction should point to
  14709. * @return The computed direction
  14710. */
  14711. setDirectionToTarget(target: Vector3): Vector3;
  14712. /**
  14713. * Returns the shadow generator associated to the light.
  14714. * @returns Always null for hemispheric lights because it does not support shadows.
  14715. */
  14716. getShadowGenerator(): Nullable<IShadowGenerator>;
  14717. /**
  14718. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14719. * @param effect The effect to update
  14720. * @param lightIndex The index of the light in the effect to update
  14721. * @returns The hemispheric light
  14722. */
  14723. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14724. /**
  14725. * Computes the world matrix of the node
  14726. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14727. * @param useWasUpdatedFlag defines a reserved property
  14728. * @returns the world matrix
  14729. */
  14730. computeWorldMatrix(): Matrix;
  14731. /**
  14732. * Returns the integer 3.
  14733. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14734. */
  14735. getTypeID(): number;
  14736. /**
  14737. * Prepares the list of defines specific to the light type.
  14738. * @param defines the list of defines
  14739. * @param lightIndex defines the index of the light for the effect
  14740. */
  14741. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14742. }
  14743. }
  14744. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14745. /** @hidden */
  14746. export var vrMultiviewToSingleviewPixelShader: {
  14747. name: string;
  14748. shader: string;
  14749. };
  14750. }
  14751. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14752. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14753. import { Scene } from "babylonjs/scene";
  14754. /**
  14755. * Renders to multiple views with a single draw call
  14756. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14757. */
  14758. export class MultiviewRenderTarget extends RenderTargetTexture {
  14759. /**
  14760. * Creates a multiview render target
  14761. * @param scene scene used with the render target
  14762. * @param size the size of the render target (used for each view)
  14763. */
  14764. constructor(scene: Scene, size?: number | {
  14765. width: number;
  14766. height: number;
  14767. } | {
  14768. ratio: number;
  14769. });
  14770. /**
  14771. * @hidden
  14772. * @param faceIndex the face index, if its a cube texture
  14773. */
  14774. _bindFrameBuffer(faceIndex?: number): void;
  14775. /**
  14776. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14777. * @returns the view count
  14778. */
  14779. getViewCount(): number;
  14780. }
  14781. }
  14782. declare module "babylonjs/Maths/math.frustum" {
  14783. import { Matrix } from "babylonjs/Maths/math.vector";
  14784. import { DeepImmutable } from "babylonjs/types";
  14785. import { Plane } from "babylonjs/Maths/math.plane";
  14786. /**
  14787. * Reprasents a camera frustum
  14788. */
  14789. export class Frustum {
  14790. /**
  14791. * Gets the planes representing the frustum
  14792. * @param transform matrix to be applied to the returned planes
  14793. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14794. */
  14795. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14796. /**
  14797. * Gets the near frustum plane transformed by the transform matrix
  14798. * @param transform transformation matrix to be applied to the resulting frustum plane
  14799. * @param frustumPlane the resuling frustum plane
  14800. */
  14801. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14802. /**
  14803. * Gets the far frustum plane transformed by the transform matrix
  14804. * @param transform transformation matrix to be applied to the resulting frustum plane
  14805. * @param frustumPlane the resuling frustum plane
  14806. */
  14807. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14808. /**
  14809. * Gets the left frustum plane transformed by the transform matrix
  14810. * @param transform transformation matrix to be applied to the resulting frustum plane
  14811. * @param frustumPlane the resuling frustum plane
  14812. */
  14813. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14814. /**
  14815. * Gets the right frustum plane transformed by the transform matrix
  14816. * @param transform transformation matrix to be applied to the resulting frustum plane
  14817. * @param frustumPlane the resuling frustum plane
  14818. */
  14819. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14820. /**
  14821. * Gets the top frustum plane transformed by the transform matrix
  14822. * @param transform transformation matrix to be applied to the resulting frustum plane
  14823. * @param frustumPlane the resuling frustum plane
  14824. */
  14825. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14826. /**
  14827. * Gets the bottom frustum plane transformed by the transform matrix
  14828. * @param transform transformation matrix to be applied to the resulting frustum plane
  14829. * @param frustumPlane the resuling frustum plane
  14830. */
  14831. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14832. /**
  14833. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14834. * @param transform transformation matrix to be applied to the resulting frustum planes
  14835. * @param frustumPlanes the resuling frustum planes
  14836. */
  14837. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14838. }
  14839. }
  14840. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14841. import { Camera } from "babylonjs/Cameras/camera";
  14842. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14843. import { Nullable } from "babylonjs/types";
  14844. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14845. import { Matrix } from "babylonjs/Maths/math.vector";
  14846. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14847. module "babylonjs/Engines/engine" {
  14848. interface Engine {
  14849. /**
  14850. * Creates a new multiview render target
  14851. * @param width defines the width of the texture
  14852. * @param height defines the height of the texture
  14853. * @returns the created multiview texture
  14854. */
  14855. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14856. /**
  14857. * Binds a multiview framebuffer to be drawn to
  14858. * @param multiviewTexture texture to bind
  14859. */
  14860. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14861. }
  14862. }
  14863. module "babylonjs/Cameras/camera" {
  14864. interface Camera {
  14865. /**
  14866. * @hidden
  14867. * 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)
  14868. */
  14869. _useMultiviewToSingleView: boolean;
  14870. /**
  14871. * @hidden
  14872. * 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)
  14873. */
  14874. _multiviewTexture: Nullable<RenderTargetTexture>;
  14875. /**
  14876. * @hidden
  14877. * ensures the multiview texture of the camera exists and has the specified width/height
  14878. * @param width height to set on the multiview texture
  14879. * @param height width to set on the multiview texture
  14880. */
  14881. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14882. }
  14883. }
  14884. module "babylonjs/scene" {
  14885. interface Scene {
  14886. /** @hidden */
  14887. _transformMatrixR: Matrix;
  14888. /** @hidden */
  14889. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14890. /** @hidden */
  14891. _createMultiviewUbo(): void;
  14892. /** @hidden */
  14893. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14894. /** @hidden */
  14895. _renderMultiviewToSingleView(camera: Camera): void;
  14896. }
  14897. }
  14898. }
  14899. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  14900. import { Camera } from "babylonjs/Cameras/camera";
  14901. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14902. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  14903. import "babylonjs/Engines/Extensions/engine.multiview";
  14904. /**
  14905. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14906. * This will not be used for webXR as it supports displaying texture arrays directly
  14907. */
  14908. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14909. /**
  14910. * Initializes a VRMultiviewToSingleview
  14911. * @param name name of the post process
  14912. * @param camera camera to be applied to
  14913. * @param scaleFactor scaling factor to the size of the output texture
  14914. */
  14915. constructor(name: string, camera: Camera, scaleFactor: number);
  14916. }
  14917. }
  14918. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  14919. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  14920. import { Nullable } from "babylonjs/types";
  14921. import { Size } from "babylonjs/Maths/math.size";
  14922. import { Observable } from "babylonjs/Misc/observable";
  14923. module "babylonjs/Engines/engine" {
  14924. interface Engine {
  14925. /** @hidden */
  14926. _vrDisplay: any;
  14927. /** @hidden */
  14928. _vrSupported: boolean;
  14929. /** @hidden */
  14930. _oldSize: Size;
  14931. /** @hidden */
  14932. _oldHardwareScaleFactor: number;
  14933. /** @hidden */
  14934. _vrExclusivePointerMode: boolean;
  14935. /** @hidden */
  14936. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14937. /** @hidden */
  14938. _onVRDisplayPointerRestricted: () => void;
  14939. /** @hidden */
  14940. _onVRDisplayPointerUnrestricted: () => void;
  14941. /** @hidden */
  14942. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14943. /** @hidden */
  14944. _onVrDisplayDisconnect: Nullable<() => void>;
  14945. /** @hidden */
  14946. _onVrDisplayPresentChange: Nullable<() => void>;
  14947. /**
  14948. * Observable signaled when VR display mode changes
  14949. */
  14950. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14951. /**
  14952. * Observable signaled when VR request present is complete
  14953. */
  14954. onVRRequestPresentComplete: Observable<boolean>;
  14955. /**
  14956. * Observable signaled when VR request present starts
  14957. */
  14958. onVRRequestPresentStart: Observable<Engine>;
  14959. /**
  14960. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14961. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14962. */
  14963. isInVRExclusivePointerMode: boolean;
  14964. /**
  14965. * Gets a boolean indicating if a webVR device was detected
  14966. * @returns true if a webVR device was detected
  14967. */
  14968. isVRDevicePresent(): boolean;
  14969. /**
  14970. * Gets the current webVR device
  14971. * @returns the current webVR device (or null)
  14972. */
  14973. getVRDevice(): any;
  14974. /**
  14975. * Initializes a webVR display and starts listening to display change events
  14976. * The onVRDisplayChangedObservable will be notified upon these changes
  14977. * @returns A promise containing a VRDisplay and if vr is supported
  14978. */
  14979. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14980. /** @hidden */
  14981. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14982. /**
  14983. * Call this function to switch to webVR mode
  14984. * Will do nothing if webVR is not supported or if there is no webVR device
  14985. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14986. */
  14987. enableVR(): void;
  14988. /** @hidden */
  14989. _onVRFullScreenTriggered(): void;
  14990. }
  14991. }
  14992. }
  14993. declare module "babylonjs/Cameras/VR/webVRCamera" {
  14994. import { Nullable } from "babylonjs/types";
  14995. import { Observable } from "babylonjs/Misc/observable";
  14996. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  14997. import { Scene } from "babylonjs/scene";
  14998. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14999. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15000. import { Node } from "babylonjs/node";
  15001. import { Ray } from "babylonjs/Culling/ray";
  15002. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15003. import "babylonjs/Engines/Extensions/engine.webVR";
  15004. /**
  15005. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15006. * IMPORTANT!! The data is right-hand data.
  15007. * @export
  15008. * @interface DevicePose
  15009. */
  15010. export interface DevicePose {
  15011. /**
  15012. * The position of the device, values in array are [x,y,z].
  15013. */
  15014. readonly position: Nullable<Float32Array>;
  15015. /**
  15016. * The linearVelocity of the device, values in array are [x,y,z].
  15017. */
  15018. readonly linearVelocity: Nullable<Float32Array>;
  15019. /**
  15020. * The linearAcceleration of the device, values in array are [x,y,z].
  15021. */
  15022. readonly linearAcceleration: Nullable<Float32Array>;
  15023. /**
  15024. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15025. */
  15026. readonly orientation: Nullable<Float32Array>;
  15027. /**
  15028. * The angularVelocity of the device, values in array are [x,y,z].
  15029. */
  15030. readonly angularVelocity: Nullable<Float32Array>;
  15031. /**
  15032. * The angularAcceleration of the device, values in array are [x,y,z].
  15033. */
  15034. readonly angularAcceleration: Nullable<Float32Array>;
  15035. }
  15036. /**
  15037. * Interface representing a pose controlled object in Babylon.
  15038. * A pose controlled object has both regular pose values as well as pose values
  15039. * from an external device such as a VR head mounted display
  15040. */
  15041. export interface PoseControlled {
  15042. /**
  15043. * The position of the object in babylon space.
  15044. */
  15045. position: Vector3;
  15046. /**
  15047. * The rotation quaternion of the object in babylon space.
  15048. */
  15049. rotationQuaternion: Quaternion;
  15050. /**
  15051. * The position of the device in babylon space.
  15052. */
  15053. devicePosition?: Vector3;
  15054. /**
  15055. * The rotation quaternion of the device in babylon space.
  15056. */
  15057. deviceRotationQuaternion: Quaternion;
  15058. /**
  15059. * The raw pose coming from the device.
  15060. */
  15061. rawPose: Nullable<DevicePose>;
  15062. /**
  15063. * The scale of the device to be used when translating from device space to babylon space.
  15064. */
  15065. deviceScaleFactor: number;
  15066. /**
  15067. * Updates the poseControlled values based on the input device pose.
  15068. * @param poseData the pose data to update the object with
  15069. */
  15070. updateFromDevice(poseData: DevicePose): void;
  15071. }
  15072. /**
  15073. * Set of options to customize the webVRCamera
  15074. */
  15075. export interface WebVROptions {
  15076. /**
  15077. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15078. */
  15079. trackPosition?: boolean;
  15080. /**
  15081. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15082. */
  15083. positionScale?: number;
  15084. /**
  15085. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15086. */
  15087. displayName?: string;
  15088. /**
  15089. * Should the native controller meshes be initialized. (default: true)
  15090. */
  15091. controllerMeshes?: boolean;
  15092. /**
  15093. * Creating a default HemiLight only on controllers. (default: true)
  15094. */
  15095. defaultLightingOnControllers?: boolean;
  15096. /**
  15097. * If you don't want to use the default VR button of the helper. (default: false)
  15098. */
  15099. useCustomVRButton?: boolean;
  15100. /**
  15101. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15102. */
  15103. customVRButton?: HTMLButtonElement;
  15104. /**
  15105. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15106. */
  15107. rayLength?: number;
  15108. /**
  15109. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15110. */
  15111. defaultHeight?: number;
  15112. /**
  15113. * If multiview should be used if availible (default: false)
  15114. */
  15115. useMultiview?: boolean;
  15116. }
  15117. /**
  15118. * This represents a WebVR camera.
  15119. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15120. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15121. */
  15122. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15123. private webVROptions;
  15124. /**
  15125. * @hidden
  15126. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15127. */
  15128. _vrDevice: any;
  15129. /**
  15130. * The rawPose of the vrDevice.
  15131. */
  15132. rawPose: Nullable<DevicePose>;
  15133. private _onVREnabled;
  15134. private _specsVersion;
  15135. private _attached;
  15136. private _frameData;
  15137. protected _descendants: Array<Node>;
  15138. private _deviceRoomPosition;
  15139. /** @hidden */
  15140. _deviceRoomRotationQuaternion: Quaternion;
  15141. private _standingMatrix;
  15142. /**
  15143. * Represents device position in babylon space.
  15144. */
  15145. devicePosition: Vector3;
  15146. /**
  15147. * Represents device rotation in babylon space.
  15148. */
  15149. deviceRotationQuaternion: Quaternion;
  15150. /**
  15151. * The scale of the device to be used when translating from device space to babylon space.
  15152. */
  15153. deviceScaleFactor: number;
  15154. private _deviceToWorld;
  15155. private _worldToDevice;
  15156. /**
  15157. * References to the webVR controllers for the vrDevice.
  15158. */
  15159. controllers: Array<WebVRController>;
  15160. /**
  15161. * Emits an event when a controller is attached.
  15162. */
  15163. onControllersAttachedObservable: Observable<WebVRController[]>;
  15164. /**
  15165. * Emits an event when a controller's mesh has been loaded;
  15166. */
  15167. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15168. /**
  15169. * Emits an event when the HMD's pose has been updated.
  15170. */
  15171. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15172. private _poseSet;
  15173. /**
  15174. * If the rig cameras be used as parent instead of this camera.
  15175. */
  15176. rigParenting: boolean;
  15177. private _lightOnControllers;
  15178. private _defaultHeight?;
  15179. /**
  15180. * Instantiates a WebVRFreeCamera.
  15181. * @param name The name of the WebVRFreeCamera
  15182. * @param position The starting anchor position for the camera
  15183. * @param scene The scene the camera belongs to
  15184. * @param webVROptions a set of customizable options for the webVRCamera
  15185. */
  15186. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15187. /**
  15188. * Gets the device distance from the ground in meters.
  15189. * @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.
  15190. */
  15191. deviceDistanceToRoomGround(): number;
  15192. /**
  15193. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15194. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15195. */
  15196. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15197. /**
  15198. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15199. * @returns A promise with a boolean set to if the standing matrix is supported.
  15200. */
  15201. useStandingMatrixAsync(): Promise<boolean>;
  15202. /**
  15203. * Disposes the camera
  15204. */
  15205. dispose(): void;
  15206. /**
  15207. * Gets a vrController by name.
  15208. * @param name The name of the controller to retreive
  15209. * @returns the controller matching the name specified or null if not found
  15210. */
  15211. getControllerByName(name: string): Nullable<WebVRController>;
  15212. private _leftController;
  15213. /**
  15214. * The controller corresponding to the users left hand.
  15215. */
  15216. readonly leftController: Nullable<WebVRController>;
  15217. private _rightController;
  15218. /**
  15219. * The controller corresponding to the users right hand.
  15220. */
  15221. readonly rightController: Nullable<WebVRController>;
  15222. /**
  15223. * Casts a ray forward from the vrCamera's gaze.
  15224. * @param length Length of the ray (default: 100)
  15225. * @returns the ray corresponding to the gaze
  15226. */
  15227. getForwardRay(length?: number): Ray;
  15228. /**
  15229. * @hidden
  15230. * Updates the camera based on device's frame data
  15231. */
  15232. _checkInputs(): void;
  15233. /**
  15234. * Updates the poseControlled values based on the input device pose.
  15235. * @param poseData Pose coming from the device
  15236. */
  15237. updateFromDevice(poseData: DevicePose): void;
  15238. private _htmlElementAttached;
  15239. private _detachIfAttached;
  15240. /**
  15241. * WebVR's attach control will start broadcasting frames to the device.
  15242. * Note that in certain browsers (chrome for example) this function must be called
  15243. * within a user-interaction callback. Example:
  15244. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15245. *
  15246. * @param element html element to attach the vrDevice to
  15247. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15248. */
  15249. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15250. /**
  15251. * Detaches the camera from the html element and disables VR
  15252. *
  15253. * @param element html element to detach from
  15254. */
  15255. detachControl(element: HTMLElement): void;
  15256. /**
  15257. * @returns the name of this class
  15258. */
  15259. getClassName(): string;
  15260. /**
  15261. * Calls resetPose on the vrDisplay
  15262. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15263. */
  15264. resetToCurrentRotation(): void;
  15265. /**
  15266. * @hidden
  15267. * Updates the rig cameras (left and right eye)
  15268. */
  15269. _updateRigCameras(): void;
  15270. private _workingVector;
  15271. private _oneVector;
  15272. private _workingMatrix;
  15273. private updateCacheCalled;
  15274. private _correctPositionIfNotTrackPosition;
  15275. /**
  15276. * @hidden
  15277. * Updates the cached values of the camera
  15278. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15279. */
  15280. _updateCache(ignoreParentClass?: boolean): void;
  15281. /**
  15282. * @hidden
  15283. * Get current device position in babylon world
  15284. */
  15285. _computeDevicePosition(): void;
  15286. /**
  15287. * Updates the current device position and rotation in the babylon world
  15288. */
  15289. update(): void;
  15290. /**
  15291. * @hidden
  15292. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15293. * @returns an identity matrix
  15294. */
  15295. _getViewMatrix(): Matrix;
  15296. private _tmpMatrix;
  15297. /**
  15298. * This function is called by the two RIG cameras.
  15299. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15300. * @hidden
  15301. */
  15302. _getWebVRViewMatrix(): Matrix;
  15303. /** @hidden */
  15304. _getWebVRProjectionMatrix(): Matrix;
  15305. private _onGamepadConnectedObserver;
  15306. private _onGamepadDisconnectedObserver;
  15307. private _updateCacheWhenTrackingDisabledObserver;
  15308. /**
  15309. * Initializes the controllers and their meshes
  15310. */
  15311. initControllers(): void;
  15312. }
  15313. }
  15314. declare module "babylonjs/PostProcesses/postProcess" {
  15315. import { Nullable } from "babylonjs/types";
  15316. import { SmartArray } from "babylonjs/Misc/smartArray";
  15317. import { Observable } from "babylonjs/Misc/observable";
  15318. import { Vector2 } from "babylonjs/Maths/math.vector";
  15319. import { Camera } from "babylonjs/Cameras/camera";
  15320. import { Effect } from "babylonjs/Materials/effect";
  15321. import "babylonjs/Shaders/postprocess.vertex";
  15322. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15323. import { Engine } from "babylonjs/Engines/engine";
  15324. import { Color4 } from "babylonjs/Maths/math.color";
  15325. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15326. /**
  15327. * Size options for a post process
  15328. */
  15329. export type PostProcessOptions = {
  15330. width: number;
  15331. height: number;
  15332. };
  15333. /**
  15334. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15335. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15336. */
  15337. export class PostProcess {
  15338. /** Name of the PostProcess. */
  15339. name: string;
  15340. /**
  15341. * Gets or sets the unique id of the post process
  15342. */
  15343. uniqueId: number;
  15344. /**
  15345. * Width of the texture to apply the post process on
  15346. */
  15347. width: number;
  15348. /**
  15349. * Height of the texture to apply the post process on
  15350. */
  15351. height: number;
  15352. /**
  15353. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15354. * @hidden
  15355. */
  15356. _outputTexture: Nullable<InternalTexture>;
  15357. /**
  15358. * Sampling mode used by the shader
  15359. * See https://doc.babylonjs.com/classes/3.1/texture
  15360. */
  15361. renderTargetSamplingMode: number;
  15362. /**
  15363. * Clear color to use when screen clearing
  15364. */
  15365. clearColor: Color4;
  15366. /**
  15367. * If the buffer needs to be cleared before applying the post process. (default: true)
  15368. * Should be set to false if shader will overwrite all previous pixels.
  15369. */
  15370. autoClear: boolean;
  15371. /**
  15372. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15373. */
  15374. alphaMode: number;
  15375. /**
  15376. * Sets the setAlphaBlendConstants of the babylon engine
  15377. */
  15378. alphaConstants: Color4;
  15379. /**
  15380. * Animations to be used for the post processing
  15381. */
  15382. animations: import("babylonjs/Animations/animation").Animation[];
  15383. /**
  15384. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15385. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15386. */
  15387. enablePixelPerfectMode: boolean;
  15388. /**
  15389. * Force the postprocess to be applied without taking in account viewport
  15390. */
  15391. forceFullscreenViewport: boolean;
  15392. /**
  15393. * List of inspectable custom properties (used by the Inspector)
  15394. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15395. */
  15396. inspectableCustomProperties: IInspectable[];
  15397. /**
  15398. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15399. *
  15400. * | Value | Type | Description |
  15401. * | ----- | ----------------------------------- | ----------- |
  15402. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15403. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15404. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15405. *
  15406. */
  15407. scaleMode: number;
  15408. /**
  15409. * Force textures to be a power of two (default: false)
  15410. */
  15411. alwaysForcePOT: boolean;
  15412. private _samples;
  15413. /**
  15414. * Number of sample textures (default: 1)
  15415. */
  15416. samples: number;
  15417. /**
  15418. * Modify the scale of the post process to be the same as the viewport (default: false)
  15419. */
  15420. adaptScaleToCurrentViewport: boolean;
  15421. private _camera;
  15422. private _scene;
  15423. private _engine;
  15424. private _options;
  15425. private _reusable;
  15426. private _textureType;
  15427. /**
  15428. * Smart array of input and output textures for the post process.
  15429. * @hidden
  15430. */
  15431. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15432. /**
  15433. * The index in _textures that corresponds to the output texture.
  15434. * @hidden
  15435. */
  15436. _currentRenderTextureInd: number;
  15437. private _effect;
  15438. private _samplers;
  15439. private _fragmentUrl;
  15440. private _vertexUrl;
  15441. private _parameters;
  15442. private _scaleRatio;
  15443. protected _indexParameters: any;
  15444. private _shareOutputWithPostProcess;
  15445. private _texelSize;
  15446. private _forcedOutputTexture;
  15447. /**
  15448. * Returns the fragment url or shader name used in the post process.
  15449. * @returns the fragment url or name in the shader store.
  15450. */
  15451. getEffectName(): string;
  15452. /**
  15453. * An event triggered when the postprocess is activated.
  15454. */
  15455. onActivateObservable: Observable<Camera>;
  15456. private _onActivateObserver;
  15457. /**
  15458. * A function that is added to the onActivateObservable
  15459. */
  15460. onActivate: Nullable<(camera: Camera) => void>;
  15461. /**
  15462. * An event triggered when the postprocess changes its size.
  15463. */
  15464. onSizeChangedObservable: Observable<PostProcess>;
  15465. private _onSizeChangedObserver;
  15466. /**
  15467. * A function that is added to the onSizeChangedObservable
  15468. */
  15469. onSizeChanged: (postProcess: PostProcess) => void;
  15470. /**
  15471. * An event triggered when the postprocess applies its effect.
  15472. */
  15473. onApplyObservable: Observable<Effect>;
  15474. private _onApplyObserver;
  15475. /**
  15476. * A function that is added to the onApplyObservable
  15477. */
  15478. onApply: (effect: Effect) => void;
  15479. /**
  15480. * An event triggered before rendering the postprocess
  15481. */
  15482. onBeforeRenderObservable: Observable<Effect>;
  15483. private _onBeforeRenderObserver;
  15484. /**
  15485. * A function that is added to the onBeforeRenderObservable
  15486. */
  15487. onBeforeRender: (effect: Effect) => void;
  15488. /**
  15489. * An event triggered after rendering the postprocess
  15490. */
  15491. onAfterRenderObservable: Observable<Effect>;
  15492. private _onAfterRenderObserver;
  15493. /**
  15494. * A function that is added to the onAfterRenderObservable
  15495. */
  15496. onAfterRender: (efect: Effect) => void;
  15497. /**
  15498. * 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
  15499. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15500. */
  15501. inputTexture: InternalTexture;
  15502. /**
  15503. * Gets the camera which post process is applied to.
  15504. * @returns The camera the post process is applied to.
  15505. */
  15506. getCamera(): Camera;
  15507. /**
  15508. * Gets the texel size of the postprocess.
  15509. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15510. */
  15511. readonly texelSize: Vector2;
  15512. /**
  15513. * Creates a new instance PostProcess
  15514. * @param name The name of the PostProcess.
  15515. * @param fragmentUrl The url of the fragment shader to be used.
  15516. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15517. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15518. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15519. * @param camera The camera to apply the render pass to.
  15520. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15521. * @param engine The engine which the post process will be applied. (default: current engine)
  15522. * @param reusable If the post process can be reused on the same frame. (default: false)
  15523. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15524. * @param textureType Type of textures used when performing the post process. (default: 0)
  15525. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15526. * @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
  15527. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15528. */
  15529. constructor(
  15530. /** Name of the PostProcess. */
  15531. 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);
  15532. /**
  15533. * Gets a string idenfifying the name of the class
  15534. * @returns "PostProcess" string
  15535. */
  15536. getClassName(): string;
  15537. /**
  15538. * Gets the engine which this post process belongs to.
  15539. * @returns The engine the post process was enabled with.
  15540. */
  15541. getEngine(): Engine;
  15542. /**
  15543. * The effect that is created when initializing the post process.
  15544. * @returns The created effect corresponding the the postprocess.
  15545. */
  15546. getEffect(): Effect;
  15547. /**
  15548. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15549. * @param postProcess The post process to share the output with.
  15550. * @returns This post process.
  15551. */
  15552. shareOutputWith(postProcess: PostProcess): PostProcess;
  15553. /**
  15554. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15555. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15556. */
  15557. useOwnOutput(): void;
  15558. /**
  15559. * Updates the effect with the current post process compile time values and recompiles the shader.
  15560. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15561. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15562. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15563. * @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
  15564. * @param onCompiled Called when the shader has been compiled.
  15565. * @param onError Called if there is an error when compiling a shader.
  15566. */
  15567. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15568. /**
  15569. * The post process is reusable if it can be used multiple times within one frame.
  15570. * @returns If the post process is reusable
  15571. */
  15572. isReusable(): boolean;
  15573. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15574. markTextureDirty(): void;
  15575. /**
  15576. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15577. * 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.
  15578. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15579. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15580. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15581. * @returns The target texture that was bound to be written to.
  15582. */
  15583. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15584. /**
  15585. * If the post process is supported.
  15586. */
  15587. readonly isSupported: boolean;
  15588. /**
  15589. * The aspect ratio of the output texture.
  15590. */
  15591. readonly aspectRatio: number;
  15592. /**
  15593. * Get a value indicating if the post-process is ready to be used
  15594. * @returns true if the post-process is ready (shader is compiled)
  15595. */
  15596. isReady(): boolean;
  15597. /**
  15598. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15599. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15600. */
  15601. apply(): Nullable<Effect>;
  15602. private _disposeTextures;
  15603. /**
  15604. * Disposes the post process.
  15605. * @param camera The camera to dispose the post process on.
  15606. */
  15607. dispose(camera?: Camera): void;
  15608. }
  15609. }
  15610. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15611. /** @hidden */
  15612. export var kernelBlurVaryingDeclaration: {
  15613. name: string;
  15614. shader: string;
  15615. };
  15616. }
  15617. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15618. /** @hidden */
  15619. export var kernelBlurFragment: {
  15620. name: string;
  15621. shader: string;
  15622. };
  15623. }
  15624. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15625. /** @hidden */
  15626. export var kernelBlurFragment2: {
  15627. name: string;
  15628. shader: string;
  15629. };
  15630. }
  15631. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15632. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15633. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15634. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15635. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15636. /** @hidden */
  15637. export var kernelBlurPixelShader: {
  15638. name: string;
  15639. shader: string;
  15640. };
  15641. }
  15642. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15643. /** @hidden */
  15644. export var kernelBlurVertex: {
  15645. name: string;
  15646. shader: string;
  15647. };
  15648. }
  15649. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15650. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15651. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15652. /** @hidden */
  15653. export var kernelBlurVertexShader: {
  15654. name: string;
  15655. shader: string;
  15656. };
  15657. }
  15658. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15659. import { Vector2 } from "babylonjs/Maths/math.vector";
  15660. import { Nullable } from "babylonjs/types";
  15661. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15662. import { Camera } from "babylonjs/Cameras/camera";
  15663. import { Effect } from "babylonjs/Materials/effect";
  15664. import { Engine } from "babylonjs/Engines/engine";
  15665. import "babylonjs/Shaders/kernelBlur.fragment";
  15666. import "babylonjs/Shaders/kernelBlur.vertex";
  15667. /**
  15668. * The Blur Post Process which blurs an image based on a kernel and direction.
  15669. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15670. */
  15671. export class BlurPostProcess extends PostProcess {
  15672. /** The direction in which to blur the image. */
  15673. direction: Vector2;
  15674. private blockCompilation;
  15675. protected _kernel: number;
  15676. protected _idealKernel: number;
  15677. protected _packedFloat: boolean;
  15678. private _staticDefines;
  15679. /**
  15680. * Sets the length in pixels of the blur sample region
  15681. */
  15682. /**
  15683. * Gets the length in pixels of the blur sample region
  15684. */
  15685. kernel: number;
  15686. /**
  15687. * Sets wether or not the blur needs to unpack/repack floats
  15688. */
  15689. /**
  15690. * Gets wether or not the blur is unpacking/repacking floats
  15691. */
  15692. packedFloat: boolean;
  15693. /**
  15694. * Creates a new instance BlurPostProcess
  15695. * @param name The name of the effect.
  15696. * @param direction The direction in which to blur the image.
  15697. * @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.
  15698. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15699. * @param camera The camera to apply the render pass to.
  15700. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15701. * @param engine The engine which the post process will be applied. (default: current engine)
  15702. * @param reusable If the post process can be reused on the same frame. (default: false)
  15703. * @param textureType Type of textures used when performing the post process. (default: 0)
  15704. * @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)
  15705. */
  15706. constructor(name: string,
  15707. /** The direction in which to blur the image. */
  15708. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15709. /**
  15710. * Updates the effect with the current post process compile time values and recompiles the shader.
  15711. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15712. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15713. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15714. * @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
  15715. * @param onCompiled Called when the shader has been compiled.
  15716. * @param onError Called if there is an error when compiling a shader.
  15717. */
  15718. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15719. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15720. /**
  15721. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15722. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15723. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15724. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15725. * The gaps between physical kernels are compensated for in the weighting of the samples
  15726. * @param idealKernel Ideal blur kernel.
  15727. * @return Nearest best kernel.
  15728. */
  15729. protected _nearestBestKernel(idealKernel: number): number;
  15730. /**
  15731. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15732. * @param x The point on the Gaussian distribution to sample.
  15733. * @return the value of the Gaussian function at x.
  15734. */
  15735. protected _gaussianWeight(x: number): number;
  15736. /**
  15737. * Generates a string that can be used as a floating point number in GLSL.
  15738. * @param x Value to print.
  15739. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15740. * @return GLSL float string.
  15741. */
  15742. protected _glslFloat(x: number, decimalFigures?: number): string;
  15743. }
  15744. }
  15745. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15746. import { Scene } from "babylonjs/scene";
  15747. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15748. import { Plane } from "babylonjs/Maths/math.plane";
  15749. /**
  15750. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15751. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15752. * You can then easily use it as a reflectionTexture on a flat surface.
  15753. * In case the surface is not a plane, please consider relying on reflection probes.
  15754. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15755. */
  15756. export class MirrorTexture extends RenderTargetTexture {
  15757. private scene;
  15758. /**
  15759. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15760. * 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.
  15761. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15762. */
  15763. mirrorPlane: Plane;
  15764. /**
  15765. * Define the blur ratio used to blur the reflection if needed.
  15766. */
  15767. blurRatio: number;
  15768. /**
  15769. * Define the adaptive blur kernel used to blur the reflection if needed.
  15770. * This will autocompute the closest best match for the `blurKernel`
  15771. */
  15772. adaptiveBlurKernel: number;
  15773. /**
  15774. * Define the blur kernel used to blur the reflection if needed.
  15775. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15776. */
  15777. blurKernel: number;
  15778. /**
  15779. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15780. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15781. */
  15782. blurKernelX: number;
  15783. /**
  15784. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15785. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15786. */
  15787. blurKernelY: number;
  15788. private _autoComputeBlurKernel;
  15789. protected _onRatioRescale(): void;
  15790. private _updateGammaSpace;
  15791. private _imageProcessingConfigChangeObserver;
  15792. private _transformMatrix;
  15793. private _mirrorMatrix;
  15794. private _savedViewMatrix;
  15795. private _blurX;
  15796. private _blurY;
  15797. private _adaptiveBlurKernel;
  15798. private _blurKernelX;
  15799. private _blurKernelY;
  15800. private _blurRatio;
  15801. /**
  15802. * Instantiates a Mirror Texture.
  15803. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15804. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15805. * You can then easily use it as a reflectionTexture on a flat surface.
  15806. * In case the surface is not a plane, please consider relying on reflection probes.
  15807. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15808. * @param name
  15809. * @param size
  15810. * @param scene
  15811. * @param generateMipMaps
  15812. * @param type
  15813. * @param samplingMode
  15814. * @param generateDepthBuffer
  15815. */
  15816. constructor(name: string, size: number | {
  15817. width: number;
  15818. height: number;
  15819. } | {
  15820. ratio: number;
  15821. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15822. private _preparePostProcesses;
  15823. /**
  15824. * Clone the mirror texture.
  15825. * @returns the cloned texture
  15826. */
  15827. clone(): MirrorTexture;
  15828. /**
  15829. * Serialize the texture to a JSON representation you could use in Parse later on
  15830. * @returns the serialized JSON representation
  15831. */
  15832. serialize(): any;
  15833. /**
  15834. * Dispose the texture and release its associated resources.
  15835. */
  15836. dispose(): void;
  15837. }
  15838. }
  15839. declare module "babylonjs/Materials/Textures/texture" {
  15840. import { Observable } from "babylonjs/Misc/observable";
  15841. import { Nullable } from "babylonjs/types";
  15842. import { Scene } from "babylonjs/scene";
  15843. import { Matrix } from "babylonjs/Maths/math.vector";
  15844. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15845. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15846. import { Engine } from "babylonjs/Engines/engine";
  15847. /**
  15848. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15849. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15850. */
  15851. export class Texture extends BaseTexture {
  15852. /** @hidden */
  15853. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15854. /** @hidden */
  15855. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15856. /** @hidden */
  15857. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15858. /** nearest is mag = nearest and min = nearest and mip = linear */
  15859. static readonly NEAREST_SAMPLINGMODE: number;
  15860. /** nearest is mag = nearest and min = nearest and mip = linear */
  15861. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15862. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15863. static readonly BILINEAR_SAMPLINGMODE: number;
  15864. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15865. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15866. /** Trilinear is mag = linear and min = linear and mip = linear */
  15867. static readonly TRILINEAR_SAMPLINGMODE: number;
  15868. /** Trilinear is mag = linear and min = linear and mip = linear */
  15869. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15870. /** mag = nearest and min = nearest and mip = nearest */
  15871. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15872. /** mag = nearest and min = linear and mip = nearest */
  15873. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15874. /** mag = nearest and min = linear and mip = linear */
  15875. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15876. /** mag = nearest and min = linear and mip = none */
  15877. static readonly NEAREST_LINEAR: number;
  15878. /** mag = nearest and min = nearest and mip = none */
  15879. static readonly NEAREST_NEAREST: number;
  15880. /** mag = linear and min = nearest and mip = nearest */
  15881. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15882. /** mag = linear and min = nearest and mip = linear */
  15883. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15884. /** mag = linear and min = linear and mip = none */
  15885. static readonly LINEAR_LINEAR: number;
  15886. /** mag = linear and min = nearest and mip = none */
  15887. static readonly LINEAR_NEAREST: number;
  15888. /** Explicit coordinates mode */
  15889. static readonly EXPLICIT_MODE: number;
  15890. /** Spherical coordinates mode */
  15891. static readonly SPHERICAL_MODE: number;
  15892. /** Planar coordinates mode */
  15893. static readonly PLANAR_MODE: number;
  15894. /** Cubic coordinates mode */
  15895. static readonly CUBIC_MODE: number;
  15896. /** Projection coordinates mode */
  15897. static readonly PROJECTION_MODE: number;
  15898. /** Inverse Cubic coordinates mode */
  15899. static readonly SKYBOX_MODE: number;
  15900. /** Inverse Cubic coordinates mode */
  15901. static readonly INVCUBIC_MODE: number;
  15902. /** Equirectangular coordinates mode */
  15903. static readonly EQUIRECTANGULAR_MODE: number;
  15904. /** Equirectangular Fixed coordinates mode */
  15905. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15906. /** Equirectangular Fixed Mirrored coordinates mode */
  15907. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15908. /** Texture is not repeating outside of 0..1 UVs */
  15909. static readonly CLAMP_ADDRESSMODE: number;
  15910. /** Texture is repeating outside of 0..1 UVs */
  15911. static readonly WRAP_ADDRESSMODE: number;
  15912. /** Texture is repeating and mirrored */
  15913. static readonly MIRROR_ADDRESSMODE: number;
  15914. /**
  15915. * 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
  15916. */
  15917. static UseSerializedUrlIfAny: boolean;
  15918. /**
  15919. * Define the url of the texture.
  15920. */
  15921. url: Nullable<string>;
  15922. /**
  15923. * Define an offset on the texture to offset the u coordinates of the UVs
  15924. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15925. */
  15926. uOffset: number;
  15927. /**
  15928. * Define an offset on the texture to offset the v coordinates of the UVs
  15929. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15930. */
  15931. vOffset: number;
  15932. /**
  15933. * Define an offset on the texture to scale the u coordinates of the UVs
  15934. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15935. */
  15936. uScale: number;
  15937. /**
  15938. * Define an offset on the texture to scale the v coordinates of the UVs
  15939. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15940. */
  15941. vScale: number;
  15942. /**
  15943. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15944. * @see http://doc.babylonjs.com/how_to/more_materials
  15945. */
  15946. uAng: number;
  15947. /**
  15948. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15949. * @see http://doc.babylonjs.com/how_to/more_materials
  15950. */
  15951. vAng: number;
  15952. /**
  15953. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15954. * @see http://doc.babylonjs.com/how_to/more_materials
  15955. */
  15956. wAng: number;
  15957. /**
  15958. * Defines the center of rotation (U)
  15959. */
  15960. uRotationCenter: number;
  15961. /**
  15962. * Defines the center of rotation (V)
  15963. */
  15964. vRotationCenter: number;
  15965. /**
  15966. * Defines the center of rotation (W)
  15967. */
  15968. wRotationCenter: number;
  15969. /**
  15970. * Are mip maps generated for this texture or not.
  15971. */
  15972. readonly noMipmap: boolean;
  15973. /**
  15974. * List of inspectable custom properties (used by the Inspector)
  15975. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15976. */
  15977. inspectableCustomProperties: Nullable<IInspectable[]>;
  15978. private _noMipmap;
  15979. /** @hidden */
  15980. _invertY: boolean;
  15981. private _rowGenerationMatrix;
  15982. private _cachedTextureMatrix;
  15983. private _projectionModeMatrix;
  15984. private _t0;
  15985. private _t1;
  15986. private _t2;
  15987. private _cachedUOffset;
  15988. private _cachedVOffset;
  15989. private _cachedUScale;
  15990. private _cachedVScale;
  15991. private _cachedUAng;
  15992. private _cachedVAng;
  15993. private _cachedWAng;
  15994. private _cachedProjectionMatrixId;
  15995. private _cachedCoordinatesMode;
  15996. /** @hidden */
  15997. protected _initialSamplingMode: number;
  15998. /** @hidden */
  15999. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  16000. private _deleteBuffer;
  16001. protected _format: Nullable<number>;
  16002. private _delayedOnLoad;
  16003. private _delayedOnError;
  16004. /**
  16005. * Observable triggered once the texture has been loaded.
  16006. */
  16007. onLoadObservable: Observable<Texture>;
  16008. protected _isBlocking: boolean;
  16009. /**
  16010. * Is the texture preventing material to render while loading.
  16011. * If false, a default texture will be used instead of the loading one during the preparation step.
  16012. */
  16013. isBlocking: boolean;
  16014. /**
  16015. * Get the current sampling mode associated with the texture.
  16016. */
  16017. readonly samplingMode: number;
  16018. /**
  16019. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16020. */
  16021. readonly invertY: boolean;
  16022. /**
  16023. * Instantiates a new texture.
  16024. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16025. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16026. * @param url define the url of the picture to load as a texture
  16027. * @param scene define the scene or engine the texture will belong to
  16028. * @param noMipmap define if the texture will require mip maps or not
  16029. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16030. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16031. * @param onLoad define a callback triggered when the texture has been loaded
  16032. * @param onError define a callback triggered when an error occurred during the loading session
  16033. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16034. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16035. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16036. */
  16037. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  16038. /**
  16039. * Update the url (and optional buffer) of this texture if url was null during construction.
  16040. * @param url the url of the texture
  16041. * @param buffer the buffer of the texture (defaults to null)
  16042. * @param onLoad callback called when the texture is loaded (defaults to null)
  16043. */
  16044. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16045. /**
  16046. * Finish the loading sequence of a texture flagged as delayed load.
  16047. * @hidden
  16048. */
  16049. delayLoad(): void;
  16050. private _prepareRowForTextureGeneration;
  16051. /**
  16052. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16053. * @returns the transform matrix of the texture.
  16054. */
  16055. getTextureMatrix(): Matrix;
  16056. /**
  16057. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16058. * @returns The reflection texture transform
  16059. */
  16060. getReflectionTextureMatrix(): Matrix;
  16061. /**
  16062. * Clones the texture.
  16063. * @returns the cloned texture
  16064. */
  16065. clone(): Texture;
  16066. /**
  16067. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16068. * @returns The JSON representation of the texture
  16069. */
  16070. serialize(): any;
  16071. /**
  16072. * Get the current class name of the texture useful for serialization or dynamic coding.
  16073. * @returns "Texture"
  16074. */
  16075. getClassName(): string;
  16076. /**
  16077. * Dispose the texture and release its associated resources.
  16078. */
  16079. dispose(): void;
  16080. /**
  16081. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16082. * @param parsedTexture Define the JSON representation of the texture
  16083. * @param scene Define the scene the parsed texture should be instantiated in
  16084. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16085. * @returns The parsed texture if successful
  16086. */
  16087. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16088. /**
  16089. * Creates a texture from its base 64 representation.
  16090. * @param data Define the base64 payload without the data: prefix
  16091. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16092. * @param scene Define the scene the texture should belong to
  16093. * @param noMipmap Forces the texture to not create mip map information if true
  16094. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16095. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16096. * @param onLoad define a callback triggered when the texture has been loaded
  16097. * @param onError define a callback triggered when an error occurred during the loading session
  16098. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16099. * @returns the created texture
  16100. */
  16101. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16102. /**
  16103. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16104. * @param data Define the base64 payload without the data: prefix
  16105. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16106. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16107. * @param scene Define the scene the texture should belong to
  16108. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16109. * @param noMipmap Forces the texture to not create mip map information if true
  16110. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16111. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16112. * @param onLoad define a callback triggered when the texture has been loaded
  16113. * @param onError define a callback triggered when an error occurred during the loading session
  16114. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16115. * @returns the created texture
  16116. */
  16117. 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;
  16118. }
  16119. }
  16120. declare module "babylonjs/PostProcesses/postProcessManager" {
  16121. import { Nullable } from "babylonjs/types";
  16122. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16123. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16124. import { Scene } from "babylonjs/scene";
  16125. /**
  16126. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16127. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16128. */
  16129. export class PostProcessManager {
  16130. private _scene;
  16131. private _indexBuffer;
  16132. private _vertexBuffers;
  16133. /**
  16134. * Creates a new instance PostProcess
  16135. * @param scene The scene that the post process is associated with.
  16136. */
  16137. constructor(scene: Scene);
  16138. private _prepareBuffers;
  16139. private _buildIndexBuffer;
  16140. /**
  16141. * Rebuilds the vertex buffers of the manager.
  16142. * @hidden
  16143. */
  16144. _rebuild(): void;
  16145. /**
  16146. * Prepares a frame to be run through a post process.
  16147. * @param sourceTexture The input texture to the post procesess. (default: null)
  16148. * @param postProcesses An array of post processes to be run. (default: null)
  16149. * @returns True if the post processes were able to be run.
  16150. * @hidden
  16151. */
  16152. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16153. /**
  16154. * Manually render a set of post processes to a texture.
  16155. * @param postProcesses An array of post processes to be run.
  16156. * @param targetTexture The target texture to render to.
  16157. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16158. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16159. * @param lodLevel defines which lod of the texture to render to
  16160. */
  16161. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16162. /**
  16163. * Finalize the result of the output of the postprocesses.
  16164. * @param doNotPresent If true the result will not be displayed to the screen.
  16165. * @param targetTexture The target texture to render to.
  16166. * @param faceIndex The index of the face to bind the target texture to.
  16167. * @param postProcesses The array of post processes to render.
  16168. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16169. * @hidden
  16170. */
  16171. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16172. /**
  16173. * Disposes of the post process manager.
  16174. */
  16175. dispose(): void;
  16176. }
  16177. }
  16178. declare module "babylonjs/Misc/gradients" {
  16179. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16180. /** Interface used by value gradients (color, factor, ...) */
  16181. export interface IValueGradient {
  16182. /**
  16183. * Gets or sets the gradient value (between 0 and 1)
  16184. */
  16185. gradient: number;
  16186. }
  16187. /** Class used to store color4 gradient */
  16188. export class ColorGradient implements IValueGradient {
  16189. /**
  16190. * Gets or sets the gradient value (between 0 and 1)
  16191. */
  16192. gradient: number;
  16193. /**
  16194. * Gets or sets first associated color
  16195. */
  16196. color1: Color4;
  16197. /**
  16198. * Gets or sets second associated color
  16199. */
  16200. color2?: Color4;
  16201. /**
  16202. * Will get a color picked randomly between color1 and color2.
  16203. * If color2 is undefined then color1 will be used
  16204. * @param result defines the target Color4 to store the result in
  16205. */
  16206. getColorToRef(result: Color4): void;
  16207. }
  16208. /** Class used to store color 3 gradient */
  16209. export class Color3Gradient implements IValueGradient {
  16210. /**
  16211. * Gets or sets the gradient value (between 0 and 1)
  16212. */
  16213. gradient: number;
  16214. /**
  16215. * Gets or sets the associated color
  16216. */
  16217. color: Color3;
  16218. }
  16219. /** Class used to store factor gradient */
  16220. export class FactorGradient implements IValueGradient {
  16221. /**
  16222. * Gets or sets the gradient value (between 0 and 1)
  16223. */
  16224. gradient: number;
  16225. /**
  16226. * Gets or sets first associated factor
  16227. */
  16228. factor1: number;
  16229. /**
  16230. * Gets or sets second associated factor
  16231. */
  16232. factor2?: number;
  16233. /**
  16234. * Will get a number picked randomly between factor1 and factor2.
  16235. * If factor2 is undefined then factor1 will be used
  16236. * @returns the picked number
  16237. */
  16238. getFactor(): number;
  16239. }
  16240. /**
  16241. * Helper used to simplify some generic gradient tasks
  16242. */
  16243. export class GradientHelper {
  16244. /**
  16245. * Gets the current gradient from an array of IValueGradient
  16246. * @param ratio defines the current ratio to get
  16247. * @param gradients defines the array of IValueGradient
  16248. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16249. */
  16250. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16251. }
  16252. }
  16253. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16254. import { Scene } from "babylonjs/scene";
  16255. import { ISceneComponent } from "babylonjs/sceneComponent";
  16256. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16257. module "babylonjs/abstractScene" {
  16258. interface AbstractScene {
  16259. /**
  16260. * The list of procedural textures added to the scene
  16261. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16262. */
  16263. proceduralTextures: Array<ProceduralTexture>;
  16264. }
  16265. }
  16266. /**
  16267. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16268. * in a given scene.
  16269. */
  16270. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16271. /**
  16272. * The component name helpfull to identify the component in the list of scene components.
  16273. */
  16274. readonly name: string;
  16275. /**
  16276. * The scene the component belongs to.
  16277. */
  16278. scene: Scene;
  16279. /**
  16280. * Creates a new instance of the component for the given scene
  16281. * @param scene Defines the scene to register the component in
  16282. */
  16283. constructor(scene: Scene);
  16284. /**
  16285. * Registers the component in a given scene
  16286. */
  16287. register(): void;
  16288. /**
  16289. * Rebuilds the elements related to this component in case of
  16290. * context lost for instance.
  16291. */
  16292. rebuild(): void;
  16293. /**
  16294. * Disposes the component and the associated ressources.
  16295. */
  16296. dispose(): void;
  16297. private _beforeClear;
  16298. }
  16299. }
  16300. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16301. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16302. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16303. module "babylonjs/Engines/engine" {
  16304. interface Engine {
  16305. /**
  16306. * Creates a new render target cube texture
  16307. * @param size defines the size of the texture
  16308. * @param options defines the options used to create the texture
  16309. * @returns a new render target cube texture stored in an InternalTexture
  16310. */
  16311. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16312. }
  16313. }
  16314. }
  16315. declare module "babylonjs/Shaders/procedural.vertex" {
  16316. /** @hidden */
  16317. export var proceduralVertexShader: {
  16318. name: string;
  16319. shader: string;
  16320. };
  16321. }
  16322. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16323. import { Observable } from "babylonjs/Misc/observable";
  16324. import { Nullable } from "babylonjs/types";
  16325. import { Scene } from "babylonjs/scene";
  16326. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16327. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16328. import { Effect } from "babylonjs/Materials/effect";
  16329. import { Texture } from "babylonjs/Materials/Textures/texture";
  16330. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16331. import "babylonjs/Shaders/procedural.vertex";
  16332. /**
  16333. * 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.
  16334. * This is the base class of any Procedural texture and contains most of the shareable code.
  16335. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16336. */
  16337. export class ProceduralTexture extends Texture {
  16338. isCube: boolean;
  16339. /**
  16340. * Define if the texture is enabled or not (disabled texture will not render)
  16341. */
  16342. isEnabled: boolean;
  16343. /**
  16344. * Define if the texture must be cleared before rendering (default is true)
  16345. */
  16346. autoClear: boolean;
  16347. /**
  16348. * Callback called when the texture is generated
  16349. */
  16350. onGenerated: () => void;
  16351. /**
  16352. * Event raised when the texture is generated
  16353. */
  16354. onGeneratedObservable: Observable<ProceduralTexture>;
  16355. /** @hidden */
  16356. _generateMipMaps: boolean;
  16357. /** @hidden **/
  16358. _effect: Effect;
  16359. /** @hidden */
  16360. _textures: {
  16361. [key: string]: Texture;
  16362. };
  16363. private _size;
  16364. private _currentRefreshId;
  16365. private _refreshRate;
  16366. private _vertexBuffers;
  16367. private _indexBuffer;
  16368. private _uniforms;
  16369. private _samplers;
  16370. private _fragment;
  16371. private _floats;
  16372. private _ints;
  16373. private _floatsArrays;
  16374. private _colors3;
  16375. private _colors4;
  16376. private _vectors2;
  16377. private _vectors3;
  16378. private _matrices;
  16379. private _fallbackTexture;
  16380. private _fallbackTextureUsed;
  16381. private _engine;
  16382. private _cachedDefines;
  16383. private _contentUpdateId;
  16384. private _contentData;
  16385. /**
  16386. * Instantiates a new procedural texture.
  16387. * 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.
  16388. * This is the base class of any Procedural texture and contains most of the shareable code.
  16389. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16390. * @param name Define the name of the texture
  16391. * @param size Define the size of the texture to create
  16392. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16393. * @param scene Define the scene the texture belongs to
  16394. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16395. * @param generateMipMaps Define if the texture should creates mip maps or not
  16396. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16397. */
  16398. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16399. /**
  16400. * The effect that is created when initializing the post process.
  16401. * @returns The created effect corresponding the the postprocess.
  16402. */
  16403. getEffect(): Effect;
  16404. /**
  16405. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16406. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16407. */
  16408. getContent(): Nullable<ArrayBufferView>;
  16409. private _createIndexBuffer;
  16410. /** @hidden */
  16411. _rebuild(): void;
  16412. /**
  16413. * Resets the texture in order to recreate its associated resources.
  16414. * This can be called in case of context loss
  16415. */
  16416. reset(): void;
  16417. protected _getDefines(): string;
  16418. /**
  16419. * Is the texture ready to be used ? (rendered at least once)
  16420. * @returns true if ready, otherwise, false.
  16421. */
  16422. isReady(): boolean;
  16423. /**
  16424. * Resets the refresh counter of the texture and start bak from scratch.
  16425. * Could be useful to regenerate the texture if it is setup to render only once.
  16426. */
  16427. resetRefreshCounter(): void;
  16428. /**
  16429. * Set the fragment shader to use in order to render the texture.
  16430. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16431. */
  16432. setFragment(fragment: any): void;
  16433. /**
  16434. * Define the refresh rate of the texture or the rendering frequency.
  16435. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16436. */
  16437. refreshRate: number;
  16438. /** @hidden */
  16439. _shouldRender(): boolean;
  16440. /**
  16441. * Get the size the texture is rendering at.
  16442. * @returns the size (texture is always squared)
  16443. */
  16444. getRenderSize(): number;
  16445. /**
  16446. * Resize the texture to new value.
  16447. * @param size Define the new size the texture should have
  16448. * @param generateMipMaps Define whether the new texture should create mip maps
  16449. */
  16450. resize(size: number, generateMipMaps: boolean): void;
  16451. private _checkUniform;
  16452. /**
  16453. * Set a texture in the shader program used to render.
  16454. * @param name Define the name of the uniform samplers as defined in the shader
  16455. * @param texture Define the texture to bind to this sampler
  16456. * @return the texture itself allowing "fluent" like uniform updates
  16457. */
  16458. setTexture(name: string, texture: Texture): ProceduralTexture;
  16459. /**
  16460. * Set a float in the shader.
  16461. * @param name Define the name of the uniform as defined in the shader
  16462. * @param value Define the value to give to the uniform
  16463. * @return the texture itself allowing "fluent" like uniform updates
  16464. */
  16465. setFloat(name: string, value: number): ProceduralTexture;
  16466. /**
  16467. * Set a int in the shader.
  16468. * @param name Define the name of the uniform as defined in the shader
  16469. * @param value Define the value to give to the uniform
  16470. * @return the texture itself allowing "fluent" like uniform updates
  16471. */
  16472. setInt(name: string, value: number): ProceduralTexture;
  16473. /**
  16474. * Set an array of floats in the shader.
  16475. * @param name Define the name of the uniform as defined in the shader
  16476. * @param value Define the value to give to the uniform
  16477. * @return the texture itself allowing "fluent" like uniform updates
  16478. */
  16479. setFloats(name: string, value: number[]): ProceduralTexture;
  16480. /**
  16481. * Set a vec3 in the shader from a Color3.
  16482. * @param name Define the name of the uniform as defined in the shader
  16483. * @param value Define the value to give to the uniform
  16484. * @return the texture itself allowing "fluent" like uniform updates
  16485. */
  16486. setColor3(name: string, value: Color3): ProceduralTexture;
  16487. /**
  16488. * Set a vec4 in the shader from a Color4.
  16489. * @param name Define the name of the uniform as defined in the shader
  16490. * @param value Define the value to give to the uniform
  16491. * @return the texture itself allowing "fluent" like uniform updates
  16492. */
  16493. setColor4(name: string, value: Color4): ProceduralTexture;
  16494. /**
  16495. * Set a vec2 in the shader from a Vector2.
  16496. * @param name Define the name of the uniform as defined in the shader
  16497. * @param value Define the value to give to the uniform
  16498. * @return the texture itself allowing "fluent" like uniform updates
  16499. */
  16500. setVector2(name: string, value: Vector2): ProceduralTexture;
  16501. /**
  16502. * Set a vec3 in the shader from a Vector3.
  16503. * @param name Define the name of the uniform as defined in the shader
  16504. * @param value Define the value to give to the uniform
  16505. * @return the texture itself allowing "fluent" like uniform updates
  16506. */
  16507. setVector3(name: string, value: Vector3): ProceduralTexture;
  16508. /**
  16509. * Set a mat4 in the shader from a MAtrix.
  16510. * @param name Define the name of the uniform as defined in the shader
  16511. * @param value Define the value to give to the uniform
  16512. * @return the texture itself allowing "fluent" like uniform updates
  16513. */
  16514. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16515. /**
  16516. * Render the texture to its associated render target.
  16517. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16518. */
  16519. render(useCameraPostProcess?: boolean): void;
  16520. /**
  16521. * Clone the texture.
  16522. * @returns the cloned texture
  16523. */
  16524. clone(): ProceduralTexture;
  16525. /**
  16526. * Dispose the texture and release its asoociated resources.
  16527. */
  16528. dispose(): void;
  16529. }
  16530. }
  16531. declare module "babylonjs/Particles/baseParticleSystem" {
  16532. import { Nullable } from "babylonjs/types";
  16533. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16534. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16535. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16536. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16537. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16538. import { Scene } from "babylonjs/scene";
  16539. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16540. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16541. import { Texture } from "babylonjs/Materials/Textures/texture";
  16542. import { Color4 } from "babylonjs/Maths/math.color";
  16543. import { Animation } from "babylonjs/Animations/animation";
  16544. /**
  16545. * This represents the base class for particle system in Babylon.
  16546. * 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.
  16547. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16548. * @example https://doc.babylonjs.com/babylon101/particles
  16549. */
  16550. export class BaseParticleSystem {
  16551. /**
  16552. * Source color is added to the destination color without alpha affecting the result
  16553. */
  16554. static BLENDMODE_ONEONE: number;
  16555. /**
  16556. * Blend current color and particle color using particle’s alpha
  16557. */
  16558. static BLENDMODE_STANDARD: number;
  16559. /**
  16560. * Add current color and particle color multiplied by particle’s alpha
  16561. */
  16562. static BLENDMODE_ADD: number;
  16563. /**
  16564. * Multiply current color with particle color
  16565. */
  16566. static BLENDMODE_MULTIPLY: number;
  16567. /**
  16568. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16569. */
  16570. static BLENDMODE_MULTIPLYADD: number;
  16571. /**
  16572. * List of animations used by the particle system.
  16573. */
  16574. animations: Animation[];
  16575. /**
  16576. * The id of the Particle system.
  16577. */
  16578. id: string;
  16579. /**
  16580. * The friendly name of the Particle system.
  16581. */
  16582. name: string;
  16583. /**
  16584. * The rendering group used by the Particle system to chose when to render.
  16585. */
  16586. renderingGroupId: number;
  16587. /**
  16588. * The emitter represents the Mesh or position we are attaching the particle system to.
  16589. */
  16590. emitter: Nullable<AbstractMesh | Vector3>;
  16591. /**
  16592. * The maximum number of particles to emit per frame
  16593. */
  16594. emitRate: number;
  16595. /**
  16596. * If you want to launch only a few particles at once, that can be done, as well.
  16597. */
  16598. manualEmitCount: number;
  16599. /**
  16600. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16601. */
  16602. updateSpeed: number;
  16603. /**
  16604. * The amount of time the particle system is running (depends of the overall update speed).
  16605. */
  16606. targetStopDuration: number;
  16607. /**
  16608. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16609. */
  16610. disposeOnStop: boolean;
  16611. /**
  16612. * Minimum power of emitting particles.
  16613. */
  16614. minEmitPower: number;
  16615. /**
  16616. * Maximum power of emitting particles.
  16617. */
  16618. maxEmitPower: number;
  16619. /**
  16620. * Minimum life time of emitting particles.
  16621. */
  16622. minLifeTime: number;
  16623. /**
  16624. * Maximum life time of emitting particles.
  16625. */
  16626. maxLifeTime: number;
  16627. /**
  16628. * Minimum Size of emitting particles.
  16629. */
  16630. minSize: number;
  16631. /**
  16632. * Maximum Size of emitting particles.
  16633. */
  16634. maxSize: number;
  16635. /**
  16636. * Minimum scale of emitting particles on X axis.
  16637. */
  16638. minScaleX: number;
  16639. /**
  16640. * Maximum scale of emitting particles on X axis.
  16641. */
  16642. maxScaleX: number;
  16643. /**
  16644. * Minimum scale of emitting particles on Y axis.
  16645. */
  16646. minScaleY: number;
  16647. /**
  16648. * Maximum scale of emitting particles on Y axis.
  16649. */
  16650. maxScaleY: number;
  16651. /**
  16652. * Gets or sets the minimal initial rotation in radians.
  16653. */
  16654. minInitialRotation: number;
  16655. /**
  16656. * Gets or sets the maximal initial rotation in radians.
  16657. */
  16658. maxInitialRotation: number;
  16659. /**
  16660. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16661. */
  16662. minAngularSpeed: number;
  16663. /**
  16664. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16665. */
  16666. maxAngularSpeed: number;
  16667. /**
  16668. * The texture used to render each particle. (this can be a spritesheet)
  16669. */
  16670. particleTexture: Nullable<Texture>;
  16671. /**
  16672. * The layer mask we are rendering the particles through.
  16673. */
  16674. layerMask: number;
  16675. /**
  16676. * This can help using your own shader to render the particle system.
  16677. * The according effect will be created
  16678. */
  16679. customShader: any;
  16680. /**
  16681. * By default particle system starts as soon as they are created. This prevents the
  16682. * automatic start to happen and let you decide when to start emitting particles.
  16683. */
  16684. preventAutoStart: boolean;
  16685. private _noiseTexture;
  16686. /**
  16687. * Gets or sets a texture used to add random noise to particle positions
  16688. */
  16689. noiseTexture: Nullable<ProceduralTexture>;
  16690. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16691. noiseStrength: Vector3;
  16692. /**
  16693. * Callback triggered when the particle animation is ending.
  16694. */
  16695. onAnimationEnd: Nullable<() => void>;
  16696. /**
  16697. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16698. */
  16699. blendMode: number;
  16700. /**
  16701. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16702. * to override the particles.
  16703. */
  16704. forceDepthWrite: boolean;
  16705. /** 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 */
  16706. preWarmCycles: number;
  16707. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16708. preWarmStepOffset: number;
  16709. /**
  16710. * 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)
  16711. */
  16712. spriteCellChangeSpeed: number;
  16713. /**
  16714. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16715. */
  16716. startSpriteCellID: number;
  16717. /**
  16718. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16719. */
  16720. endSpriteCellID: number;
  16721. /**
  16722. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16723. */
  16724. spriteCellWidth: number;
  16725. /**
  16726. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16727. */
  16728. spriteCellHeight: number;
  16729. /**
  16730. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16731. */
  16732. spriteRandomStartCell: boolean;
  16733. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16734. translationPivot: Vector2;
  16735. /** @hidden */
  16736. protected _isAnimationSheetEnabled: boolean;
  16737. /**
  16738. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16739. */
  16740. beginAnimationOnStart: boolean;
  16741. /**
  16742. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16743. */
  16744. beginAnimationFrom: number;
  16745. /**
  16746. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16747. */
  16748. beginAnimationTo: number;
  16749. /**
  16750. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16751. */
  16752. beginAnimationLoop: boolean;
  16753. /**
  16754. * Gets or sets a world offset applied to all particles
  16755. */
  16756. worldOffset: Vector3;
  16757. /**
  16758. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16759. */
  16760. isAnimationSheetEnabled: boolean;
  16761. /**
  16762. * Get hosting scene
  16763. * @returns the scene
  16764. */
  16765. getScene(): Scene;
  16766. /**
  16767. * You can use gravity if you want to give an orientation to your particles.
  16768. */
  16769. gravity: Vector3;
  16770. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16771. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16772. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16773. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16774. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16775. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16776. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16777. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16778. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16779. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16780. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16781. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16782. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16783. /**
  16784. * Defines the delay in milliseconds before starting the system (0 by default)
  16785. */
  16786. startDelay: number;
  16787. /**
  16788. * Gets the current list of drag gradients.
  16789. * You must use addDragGradient and removeDragGradient to udpate this list
  16790. * @returns the list of drag gradients
  16791. */
  16792. getDragGradients(): Nullable<Array<FactorGradient>>;
  16793. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16794. limitVelocityDamping: number;
  16795. /**
  16796. * Gets the current list of limit velocity gradients.
  16797. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16798. * @returns the list of limit velocity gradients
  16799. */
  16800. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16801. /**
  16802. * Gets the current list of color gradients.
  16803. * You must use addColorGradient and removeColorGradient to udpate this list
  16804. * @returns the list of color gradients
  16805. */
  16806. getColorGradients(): Nullable<Array<ColorGradient>>;
  16807. /**
  16808. * Gets the current list of size gradients.
  16809. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16810. * @returns the list of size gradients
  16811. */
  16812. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16813. /**
  16814. * Gets the current list of color remap gradients.
  16815. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16816. * @returns the list of color remap gradients
  16817. */
  16818. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16819. /**
  16820. * Gets the current list of alpha remap gradients.
  16821. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16822. * @returns the list of alpha remap gradients
  16823. */
  16824. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16825. /**
  16826. * Gets the current list of life time gradients.
  16827. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16828. * @returns the list of life time gradients
  16829. */
  16830. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16831. /**
  16832. * Gets the current list of angular speed gradients.
  16833. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16834. * @returns the list of angular speed gradients
  16835. */
  16836. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16837. /**
  16838. * Gets the current list of velocity gradients.
  16839. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16840. * @returns the list of velocity gradients
  16841. */
  16842. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16843. /**
  16844. * Gets the current list of start size gradients.
  16845. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16846. * @returns the list of start size gradients
  16847. */
  16848. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16849. /**
  16850. * Gets the current list of emit rate gradients.
  16851. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16852. * @returns the list of emit rate gradients
  16853. */
  16854. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16855. /**
  16856. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16857. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16858. */
  16859. direction1: Vector3;
  16860. /**
  16861. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16862. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16863. */
  16864. direction2: Vector3;
  16865. /**
  16866. * 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.
  16867. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16868. */
  16869. minEmitBox: Vector3;
  16870. /**
  16871. * 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.
  16872. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16873. */
  16874. maxEmitBox: Vector3;
  16875. /**
  16876. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16877. */
  16878. color1: Color4;
  16879. /**
  16880. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16881. */
  16882. color2: Color4;
  16883. /**
  16884. * Color the particle will have at the end of its lifetime
  16885. */
  16886. colorDead: Color4;
  16887. /**
  16888. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16889. */
  16890. textureMask: Color4;
  16891. /**
  16892. * The particle emitter type defines the emitter used by the particle system.
  16893. * It can be for example box, sphere, or cone...
  16894. */
  16895. particleEmitterType: IParticleEmitterType;
  16896. /** @hidden */
  16897. _isSubEmitter: boolean;
  16898. /**
  16899. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16900. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16901. */
  16902. billboardMode: number;
  16903. protected _isBillboardBased: boolean;
  16904. /**
  16905. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16906. */
  16907. isBillboardBased: boolean;
  16908. /**
  16909. * The scene the particle system belongs to.
  16910. */
  16911. protected _scene: Scene;
  16912. /**
  16913. * Local cache of defines for image processing.
  16914. */
  16915. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16916. /**
  16917. * Default configuration related to image processing available in the standard Material.
  16918. */
  16919. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16920. /**
  16921. * Gets the image processing configuration used either in this material.
  16922. */
  16923. /**
  16924. * Sets the Default image processing configuration used either in the this material.
  16925. *
  16926. * If sets to null, the scene one is in use.
  16927. */
  16928. imageProcessingConfiguration: ImageProcessingConfiguration;
  16929. /**
  16930. * Attaches a new image processing configuration to the Standard Material.
  16931. * @param configuration
  16932. */
  16933. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16934. /** @hidden */
  16935. protected _reset(): void;
  16936. /** @hidden */
  16937. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16938. /**
  16939. * Instantiates a particle system.
  16940. * 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.
  16941. * @param name The name of the particle system
  16942. */
  16943. constructor(name: string);
  16944. /**
  16945. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16946. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16947. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16948. * @returns the emitter
  16949. */
  16950. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16951. /**
  16952. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16953. * @param radius The radius of the hemisphere to emit from
  16954. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16955. * @returns the emitter
  16956. */
  16957. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16958. /**
  16959. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16960. * @param radius The radius of the sphere to emit from
  16961. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16962. * @returns the emitter
  16963. */
  16964. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16965. /**
  16966. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16967. * @param radius The radius of the sphere to emit from
  16968. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16969. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16970. * @returns the emitter
  16971. */
  16972. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16973. /**
  16974. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16975. * @param radius The radius of the emission cylinder
  16976. * @param height The height of the emission cylinder
  16977. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16978. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16979. * @returns the emitter
  16980. */
  16981. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16982. /**
  16983. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16984. * @param radius The radius of the cylinder to emit from
  16985. * @param height The height of the emission cylinder
  16986. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16987. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16988. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16989. * @returns the emitter
  16990. */
  16991. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16992. /**
  16993. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16994. * @param radius The radius of the cone to emit from
  16995. * @param angle The base angle of the cone
  16996. * @returns the emitter
  16997. */
  16998. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16999. /**
  17000. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17001. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17002. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17003. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17004. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17005. * @returns the emitter
  17006. */
  17007. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17008. }
  17009. }
  17010. declare module "babylonjs/Particles/subEmitter" {
  17011. import { Scene } from "babylonjs/scene";
  17012. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17013. /**
  17014. * Type of sub emitter
  17015. */
  17016. export enum SubEmitterType {
  17017. /**
  17018. * Attached to the particle over it's lifetime
  17019. */
  17020. ATTACHED = 0,
  17021. /**
  17022. * Created when the particle dies
  17023. */
  17024. END = 1
  17025. }
  17026. /**
  17027. * Sub emitter class used to emit particles from an existing particle
  17028. */
  17029. export class SubEmitter {
  17030. /**
  17031. * the particle system to be used by the sub emitter
  17032. */
  17033. particleSystem: ParticleSystem;
  17034. /**
  17035. * Type of the submitter (Default: END)
  17036. */
  17037. type: SubEmitterType;
  17038. /**
  17039. * 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)
  17040. * Note: This only is supported when using an emitter of type Mesh
  17041. */
  17042. inheritDirection: boolean;
  17043. /**
  17044. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17045. */
  17046. inheritedVelocityAmount: number;
  17047. /**
  17048. * Creates a sub emitter
  17049. * @param particleSystem the particle system to be used by the sub emitter
  17050. */
  17051. constructor(
  17052. /**
  17053. * the particle system to be used by the sub emitter
  17054. */
  17055. particleSystem: ParticleSystem);
  17056. /**
  17057. * Clones the sub emitter
  17058. * @returns the cloned sub emitter
  17059. */
  17060. clone(): SubEmitter;
  17061. /**
  17062. * Serialize current object to a JSON object
  17063. * @returns the serialized object
  17064. */
  17065. serialize(): any;
  17066. /** @hidden */
  17067. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17068. /**
  17069. * Creates a new SubEmitter from a serialized JSON version
  17070. * @param serializationObject defines the JSON object to read from
  17071. * @param scene defines the hosting scene
  17072. * @param rootUrl defines the rootUrl for data loading
  17073. * @returns a new SubEmitter
  17074. */
  17075. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17076. /** Release associated resources */
  17077. dispose(): void;
  17078. }
  17079. }
  17080. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17081. /** @hidden */
  17082. export var clipPlaneFragmentDeclaration: {
  17083. name: string;
  17084. shader: string;
  17085. };
  17086. }
  17087. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17088. /** @hidden */
  17089. export var imageProcessingDeclaration: {
  17090. name: string;
  17091. shader: string;
  17092. };
  17093. }
  17094. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17095. /** @hidden */
  17096. export var imageProcessingFunctions: {
  17097. name: string;
  17098. shader: string;
  17099. };
  17100. }
  17101. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17102. /** @hidden */
  17103. export var clipPlaneFragment: {
  17104. name: string;
  17105. shader: string;
  17106. };
  17107. }
  17108. declare module "babylonjs/Shaders/particles.fragment" {
  17109. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17110. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17111. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17112. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17113. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17114. /** @hidden */
  17115. export var particlesPixelShader: {
  17116. name: string;
  17117. shader: string;
  17118. };
  17119. }
  17120. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17121. /** @hidden */
  17122. export var clipPlaneVertexDeclaration: {
  17123. name: string;
  17124. shader: string;
  17125. };
  17126. }
  17127. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17128. /** @hidden */
  17129. export var clipPlaneVertex: {
  17130. name: string;
  17131. shader: string;
  17132. };
  17133. }
  17134. declare module "babylonjs/Shaders/particles.vertex" {
  17135. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17136. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17137. /** @hidden */
  17138. export var particlesVertexShader: {
  17139. name: string;
  17140. shader: string;
  17141. };
  17142. }
  17143. declare module "babylonjs/Particles/particleSystem" {
  17144. import { Nullable } from "babylonjs/types";
  17145. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17146. import { Observable } from "babylonjs/Misc/observable";
  17147. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17148. import { Effect } from "babylonjs/Materials/effect";
  17149. import { Scene, IDisposable } from "babylonjs/scene";
  17150. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17151. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17152. import { Particle } from "babylonjs/Particles/particle";
  17153. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17154. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17155. import "babylonjs/Shaders/particles.fragment";
  17156. import "babylonjs/Shaders/particles.vertex";
  17157. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17158. /**
  17159. * This represents a particle system in Babylon.
  17160. * 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.
  17161. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17162. * @example https://doc.babylonjs.com/babylon101/particles
  17163. */
  17164. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17165. /**
  17166. * Billboard mode will only apply to Y axis
  17167. */
  17168. static readonly BILLBOARDMODE_Y: number;
  17169. /**
  17170. * Billboard mode will apply to all axes
  17171. */
  17172. static readonly BILLBOARDMODE_ALL: number;
  17173. /**
  17174. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17175. */
  17176. static readonly BILLBOARDMODE_STRETCHED: number;
  17177. /**
  17178. * This function can be defined to provide custom update for active particles.
  17179. * This function will be called instead of regular update (age, position, color, etc.).
  17180. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17181. */
  17182. updateFunction: (particles: Particle[]) => void;
  17183. private _emitterWorldMatrix;
  17184. /**
  17185. * This function can be defined to specify initial direction for every new particle.
  17186. * It by default use the emitterType defined function
  17187. */
  17188. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17189. /**
  17190. * This function can be defined to specify initial position for every new particle.
  17191. * It by default use the emitterType defined function
  17192. */
  17193. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17194. /**
  17195. * @hidden
  17196. */
  17197. _inheritedVelocityOffset: Vector3;
  17198. /**
  17199. * An event triggered when the system is disposed
  17200. */
  17201. onDisposeObservable: Observable<ParticleSystem>;
  17202. private _onDisposeObserver;
  17203. /**
  17204. * Sets a callback that will be triggered when the system is disposed
  17205. */
  17206. onDispose: () => void;
  17207. private _particles;
  17208. private _epsilon;
  17209. private _capacity;
  17210. private _stockParticles;
  17211. private _newPartsExcess;
  17212. private _vertexData;
  17213. private _vertexBuffer;
  17214. private _vertexBuffers;
  17215. private _spriteBuffer;
  17216. private _indexBuffer;
  17217. private _effect;
  17218. private _customEffect;
  17219. private _cachedDefines;
  17220. private _scaledColorStep;
  17221. private _colorDiff;
  17222. private _scaledDirection;
  17223. private _scaledGravity;
  17224. private _currentRenderId;
  17225. private _alive;
  17226. private _useInstancing;
  17227. private _started;
  17228. private _stopped;
  17229. private _actualFrame;
  17230. private _scaledUpdateSpeed;
  17231. private _vertexBufferSize;
  17232. /** @hidden */
  17233. _currentEmitRateGradient: Nullable<FactorGradient>;
  17234. /** @hidden */
  17235. _currentEmitRate1: number;
  17236. /** @hidden */
  17237. _currentEmitRate2: number;
  17238. /** @hidden */
  17239. _currentStartSizeGradient: Nullable<FactorGradient>;
  17240. /** @hidden */
  17241. _currentStartSize1: number;
  17242. /** @hidden */
  17243. _currentStartSize2: number;
  17244. private readonly _rawTextureWidth;
  17245. private _rampGradientsTexture;
  17246. private _useRampGradients;
  17247. /** Gets or sets a boolean indicating that ramp gradients must be used
  17248. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17249. */
  17250. useRampGradients: boolean;
  17251. /**
  17252. * 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.
  17253. * 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: [])
  17254. */
  17255. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17256. private _subEmitters;
  17257. /**
  17258. * @hidden
  17259. * If the particle systems emitter should be disposed when the particle system is disposed
  17260. */
  17261. _disposeEmitterOnDispose: boolean;
  17262. /**
  17263. * The current active Sub-systems, this property is used by the root particle system only.
  17264. */
  17265. activeSubSystems: Array<ParticleSystem>;
  17266. private _rootParticleSystem;
  17267. /**
  17268. * Gets the current list of active particles
  17269. */
  17270. readonly particles: Particle[];
  17271. /**
  17272. * Returns the string "ParticleSystem"
  17273. * @returns a string containing the class name
  17274. */
  17275. getClassName(): string;
  17276. /**
  17277. * Instantiates a particle system.
  17278. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17279. * @param name The name of the particle system
  17280. * @param capacity The max number of particles alive at the same time
  17281. * @param scene The scene the particle system belongs to
  17282. * @param customEffect a custom effect used to change the way particles are rendered by default
  17283. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17284. * @param epsilon Offset used to render the particles
  17285. */
  17286. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17287. private _addFactorGradient;
  17288. private _removeFactorGradient;
  17289. /**
  17290. * Adds a new life time gradient
  17291. * @param gradient defines the gradient to use (between 0 and 1)
  17292. * @param factor defines the life time factor to affect to the specified gradient
  17293. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17294. * @returns the current particle system
  17295. */
  17296. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17297. /**
  17298. * Remove a specific life time gradient
  17299. * @param gradient defines the gradient to remove
  17300. * @returns the current particle system
  17301. */
  17302. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17303. /**
  17304. * Adds a new size gradient
  17305. * @param gradient defines the gradient to use (between 0 and 1)
  17306. * @param factor defines the size factor to affect to the specified gradient
  17307. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17308. * @returns the current particle system
  17309. */
  17310. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17311. /**
  17312. * Remove a specific size gradient
  17313. * @param gradient defines the gradient to remove
  17314. * @returns the current particle system
  17315. */
  17316. removeSizeGradient(gradient: number): IParticleSystem;
  17317. /**
  17318. * Adds a new color remap gradient
  17319. * @param gradient defines the gradient to use (between 0 and 1)
  17320. * @param min defines the color remap minimal range
  17321. * @param max defines the color remap maximal range
  17322. * @returns the current particle system
  17323. */
  17324. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17325. /**
  17326. * Remove a specific color remap gradient
  17327. * @param gradient defines the gradient to remove
  17328. * @returns the current particle system
  17329. */
  17330. removeColorRemapGradient(gradient: number): IParticleSystem;
  17331. /**
  17332. * Adds a new alpha remap gradient
  17333. * @param gradient defines the gradient to use (between 0 and 1)
  17334. * @param min defines the alpha remap minimal range
  17335. * @param max defines the alpha remap maximal range
  17336. * @returns the current particle system
  17337. */
  17338. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17339. /**
  17340. * Remove a specific alpha remap gradient
  17341. * @param gradient defines the gradient to remove
  17342. * @returns the current particle system
  17343. */
  17344. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17345. /**
  17346. * Adds a new angular speed gradient
  17347. * @param gradient defines the gradient to use (between 0 and 1)
  17348. * @param factor defines the angular speed to affect to the specified gradient
  17349. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17350. * @returns the current particle system
  17351. */
  17352. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17353. /**
  17354. * Remove a specific angular speed gradient
  17355. * @param gradient defines the gradient to remove
  17356. * @returns the current particle system
  17357. */
  17358. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17359. /**
  17360. * Adds a new velocity gradient
  17361. * @param gradient defines the gradient to use (between 0 and 1)
  17362. * @param factor defines the velocity to affect to the specified gradient
  17363. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17364. * @returns the current particle system
  17365. */
  17366. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17367. /**
  17368. * Remove a specific velocity gradient
  17369. * @param gradient defines the gradient to remove
  17370. * @returns the current particle system
  17371. */
  17372. removeVelocityGradient(gradient: number): IParticleSystem;
  17373. /**
  17374. * Adds a new limit velocity gradient
  17375. * @param gradient defines the gradient to use (between 0 and 1)
  17376. * @param factor defines the limit velocity value to affect to the specified gradient
  17377. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17378. * @returns the current particle system
  17379. */
  17380. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17381. /**
  17382. * Remove a specific limit velocity gradient
  17383. * @param gradient defines the gradient to remove
  17384. * @returns the current particle system
  17385. */
  17386. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17387. /**
  17388. * Adds a new drag gradient
  17389. * @param gradient defines the gradient to use (between 0 and 1)
  17390. * @param factor defines the drag value to affect to the specified gradient
  17391. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17392. * @returns the current particle system
  17393. */
  17394. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17395. /**
  17396. * Remove a specific drag gradient
  17397. * @param gradient defines the gradient to remove
  17398. * @returns the current particle system
  17399. */
  17400. removeDragGradient(gradient: number): IParticleSystem;
  17401. /**
  17402. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17403. * @param gradient defines the gradient to use (between 0 and 1)
  17404. * @param factor defines the emit rate value to affect to the specified gradient
  17405. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17406. * @returns the current particle system
  17407. */
  17408. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17409. /**
  17410. * Remove a specific emit rate gradient
  17411. * @param gradient defines the gradient to remove
  17412. * @returns the current particle system
  17413. */
  17414. removeEmitRateGradient(gradient: number): IParticleSystem;
  17415. /**
  17416. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17417. * @param gradient defines the gradient to use (between 0 and 1)
  17418. * @param factor defines the start size value to affect to the specified gradient
  17419. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17420. * @returns the current particle system
  17421. */
  17422. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17423. /**
  17424. * Remove a specific start size gradient
  17425. * @param gradient defines the gradient to remove
  17426. * @returns the current particle system
  17427. */
  17428. removeStartSizeGradient(gradient: number): IParticleSystem;
  17429. private _createRampGradientTexture;
  17430. /**
  17431. * Gets the current list of ramp gradients.
  17432. * You must use addRampGradient and removeRampGradient to udpate this list
  17433. * @returns the list of ramp gradients
  17434. */
  17435. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17436. /**
  17437. * Adds a new ramp gradient used to remap particle colors
  17438. * @param gradient defines the gradient to use (between 0 and 1)
  17439. * @param color defines the color to affect to the specified gradient
  17440. * @returns the current particle system
  17441. */
  17442. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17443. /**
  17444. * Remove a specific ramp gradient
  17445. * @param gradient defines the gradient to remove
  17446. * @returns the current particle system
  17447. */
  17448. removeRampGradient(gradient: number): ParticleSystem;
  17449. /**
  17450. * Adds a new color gradient
  17451. * @param gradient defines the gradient to use (between 0 and 1)
  17452. * @param color1 defines the color to affect to the specified gradient
  17453. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17454. * @returns this particle system
  17455. */
  17456. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17457. /**
  17458. * Remove a specific color gradient
  17459. * @param gradient defines the gradient to remove
  17460. * @returns this particle system
  17461. */
  17462. removeColorGradient(gradient: number): IParticleSystem;
  17463. private _fetchR;
  17464. protected _reset(): void;
  17465. private _resetEffect;
  17466. private _createVertexBuffers;
  17467. private _createIndexBuffer;
  17468. /**
  17469. * Gets the maximum number of particles active at the same time.
  17470. * @returns The max number of active particles.
  17471. */
  17472. getCapacity(): number;
  17473. /**
  17474. * Gets whether there are still active particles in the system.
  17475. * @returns True if it is alive, otherwise false.
  17476. */
  17477. isAlive(): boolean;
  17478. /**
  17479. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17480. * @returns True if it has been started, otherwise false.
  17481. */
  17482. isStarted(): boolean;
  17483. private _prepareSubEmitterInternalArray;
  17484. /**
  17485. * Starts the particle system and begins to emit
  17486. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17487. */
  17488. start(delay?: number): void;
  17489. /**
  17490. * Stops the particle system.
  17491. * @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.
  17492. */
  17493. stop(stopSubEmitters?: boolean): void;
  17494. /**
  17495. * Remove all active particles
  17496. */
  17497. reset(): void;
  17498. /**
  17499. * @hidden (for internal use only)
  17500. */
  17501. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17502. /**
  17503. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17504. * Its lifetime will start back at 0.
  17505. */
  17506. recycleParticle: (particle: Particle) => void;
  17507. private _stopSubEmitters;
  17508. private _createParticle;
  17509. private _removeFromRoot;
  17510. private _emitFromParticle;
  17511. private _update;
  17512. /** @hidden */
  17513. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17514. /** @hidden */
  17515. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17516. /** @hidden */
  17517. private _getEffect;
  17518. /**
  17519. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17520. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17521. */
  17522. animate(preWarmOnly?: boolean): void;
  17523. private _appendParticleVertices;
  17524. /**
  17525. * Rebuilds the particle system.
  17526. */
  17527. rebuild(): void;
  17528. /**
  17529. * Is this system ready to be used/rendered
  17530. * @return true if the system is ready
  17531. */
  17532. isReady(): boolean;
  17533. private _render;
  17534. /**
  17535. * Renders the particle system in its current state.
  17536. * @returns the current number of particles
  17537. */
  17538. render(): number;
  17539. /**
  17540. * Disposes the particle system and free the associated resources
  17541. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17542. */
  17543. dispose(disposeTexture?: boolean): void;
  17544. /**
  17545. * Clones the particle system.
  17546. * @param name The name of the cloned object
  17547. * @param newEmitter The new emitter to use
  17548. * @returns the cloned particle system
  17549. */
  17550. clone(name: string, newEmitter: any): ParticleSystem;
  17551. /**
  17552. * Serializes the particle system to a JSON object.
  17553. * @returns the JSON object
  17554. */
  17555. serialize(): any;
  17556. /** @hidden */
  17557. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17558. /** @hidden */
  17559. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17560. /**
  17561. * Parses a JSON object to create a particle system.
  17562. * @param parsedParticleSystem The JSON object to parse
  17563. * @param scene The scene to create the particle system in
  17564. * @param rootUrl The root url to use to load external dependencies like texture
  17565. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17566. * @returns the Parsed particle system
  17567. */
  17568. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17569. }
  17570. }
  17571. declare module "babylonjs/Particles/particle" {
  17572. import { Nullable } from "babylonjs/types";
  17573. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17574. import { Color4 } from "babylonjs/Maths/math.color";
  17575. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17576. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17577. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17578. /**
  17579. * A particle represents one of the element emitted by a particle system.
  17580. * This is mainly define by its coordinates, direction, velocity and age.
  17581. */
  17582. export class Particle {
  17583. /**
  17584. * The particle system the particle belongs to.
  17585. */
  17586. particleSystem: ParticleSystem;
  17587. private static _Count;
  17588. /**
  17589. * Unique ID of the particle
  17590. */
  17591. id: number;
  17592. /**
  17593. * The world position of the particle in the scene.
  17594. */
  17595. position: Vector3;
  17596. /**
  17597. * The world direction of the particle in the scene.
  17598. */
  17599. direction: Vector3;
  17600. /**
  17601. * The color of the particle.
  17602. */
  17603. color: Color4;
  17604. /**
  17605. * The color change of the particle per step.
  17606. */
  17607. colorStep: Color4;
  17608. /**
  17609. * Defines how long will the life of the particle be.
  17610. */
  17611. lifeTime: number;
  17612. /**
  17613. * The current age of the particle.
  17614. */
  17615. age: number;
  17616. /**
  17617. * The current size of the particle.
  17618. */
  17619. size: number;
  17620. /**
  17621. * The current scale of the particle.
  17622. */
  17623. scale: Vector2;
  17624. /**
  17625. * The current angle of the particle.
  17626. */
  17627. angle: number;
  17628. /**
  17629. * Defines how fast is the angle changing.
  17630. */
  17631. angularSpeed: number;
  17632. /**
  17633. * Defines the cell index used by the particle to be rendered from a sprite.
  17634. */
  17635. cellIndex: number;
  17636. /**
  17637. * The information required to support color remapping
  17638. */
  17639. remapData: Vector4;
  17640. /** @hidden */
  17641. _randomCellOffset?: number;
  17642. /** @hidden */
  17643. _initialDirection: Nullable<Vector3>;
  17644. /** @hidden */
  17645. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17646. /** @hidden */
  17647. _initialStartSpriteCellID: number;
  17648. /** @hidden */
  17649. _initialEndSpriteCellID: number;
  17650. /** @hidden */
  17651. _currentColorGradient: Nullable<ColorGradient>;
  17652. /** @hidden */
  17653. _currentColor1: Color4;
  17654. /** @hidden */
  17655. _currentColor2: Color4;
  17656. /** @hidden */
  17657. _currentSizeGradient: Nullable<FactorGradient>;
  17658. /** @hidden */
  17659. _currentSize1: number;
  17660. /** @hidden */
  17661. _currentSize2: number;
  17662. /** @hidden */
  17663. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17664. /** @hidden */
  17665. _currentAngularSpeed1: number;
  17666. /** @hidden */
  17667. _currentAngularSpeed2: number;
  17668. /** @hidden */
  17669. _currentVelocityGradient: Nullable<FactorGradient>;
  17670. /** @hidden */
  17671. _currentVelocity1: number;
  17672. /** @hidden */
  17673. _currentVelocity2: number;
  17674. /** @hidden */
  17675. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17676. /** @hidden */
  17677. _currentLimitVelocity1: number;
  17678. /** @hidden */
  17679. _currentLimitVelocity2: number;
  17680. /** @hidden */
  17681. _currentDragGradient: Nullable<FactorGradient>;
  17682. /** @hidden */
  17683. _currentDrag1: number;
  17684. /** @hidden */
  17685. _currentDrag2: number;
  17686. /** @hidden */
  17687. _randomNoiseCoordinates1: Vector3;
  17688. /** @hidden */
  17689. _randomNoiseCoordinates2: Vector3;
  17690. /**
  17691. * Creates a new instance Particle
  17692. * @param particleSystem the particle system the particle belongs to
  17693. */
  17694. constructor(
  17695. /**
  17696. * The particle system the particle belongs to.
  17697. */
  17698. particleSystem: ParticleSystem);
  17699. private updateCellInfoFromSystem;
  17700. /**
  17701. * Defines how the sprite cell index is updated for the particle
  17702. */
  17703. updateCellIndex(): void;
  17704. /** @hidden */
  17705. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17706. /** @hidden */
  17707. _inheritParticleInfoToSubEmitters(): void;
  17708. /** @hidden */
  17709. _reset(): void;
  17710. /**
  17711. * Copy the properties of particle to another one.
  17712. * @param other the particle to copy the information to.
  17713. */
  17714. copyTo(other: Particle): void;
  17715. }
  17716. }
  17717. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17718. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17719. import { Effect } from "babylonjs/Materials/effect";
  17720. import { Particle } from "babylonjs/Particles/particle";
  17721. /**
  17722. * Particle emitter represents a volume emitting particles.
  17723. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17724. */
  17725. export interface IParticleEmitterType {
  17726. /**
  17727. * Called by the particle System when the direction is computed for the created particle.
  17728. * @param worldMatrix is the world matrix of the particle system
  17729. * @param directionToUpdate is the direction vector to update with the result
  17730. * @param particle is the particle we are computed the direction for
  17731. */
  17732. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17733. /**
  17734. * Called by the particle System when the position is computed for the created particle.
  17735. * @param worldMatrix is the world matrix of the particle system
  17736. * @param positionToUpdate is the position vector to update with the result
  17737. * @param particle is the particle we are computed the position for
  17738. */
  17739. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17740. /**
  17741. * Clones the current emitter and returns a copy of it
  17742. * @returns the new emitter
  17743. */
  17744. clone(): IParticleEmitterType;
  17745. /**
  17746. * Called by the GPUParticleSystem to setup the update shader
  17747. * @param effect defines the update shader
  17748. */
  17749. applyToShader(effect: Effect): void;
  17750. /**
  17751. * Returns a string to use to update the GPU particles update shader
  17752. * @returns the effect defines string
  17753. */
  17754. getEffectDefines(): string;
  17755. /**
  17756. * Returns a string representing the class name
  17757. * @returns a string containing the class name
  17758. */
  17759. getClassName(): string;
  17760. /**
  17761. * Serializes the particle system to a JSON object.
  17762. * @returns the JSON object
  17763. */
  17764. serialize(): any;
  17765. /**
  17766. * Parse properties from a JSON object
  17767. * @param serializationObject defines the JSON object
  17768. */
  17769. parse(serializationObject: any): void;
  17770. }
  17771. }
  17772. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  17773. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17774. import { Effect } from "babylonjs/Materials/effect";
  17775. import { Particle } from "babylonjs/Particles/particle";
  17776. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17777. /**
  17778. * Particle emitter emitting particles from the inside of a box.
  17779. * It emits the particles randomly between 2 given directions.
  17780. */
  17781. export class BoxParticleEmitter implements IParticleEmitterType {
  17782. /**
  17783. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17784. */
  17785. direction1: Vector3;
  17786. /**
  17787. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17788. */
  17789. direction2: Vector3;
  17790. /**
  17791. * 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.
  17792. */
  17793. minEmitBox: Vector3;
  17794. /**
  17795. * 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.
  17796. */
  17797. maxEmitBox: Vector3;
  17798. /**
  17799. * Creates a new instance BoxParticleEmitter
  17800. */
  17801. constructor();
  17802. /**
  17803. * Called by the particle System when the direction is computed for the created particle.
  17804. * @param worldMatrix is the world matrix of the particle system
  17805. * @param directionToUpdate is the direction vector to update with the result
  17806. * @param particle is the particle we are computed the direction for
  17807. */
  17808. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17809. /**
  17810. * Called by the particle System when the position is computed for the created particle.
  17811. * @param worldMatrix is the world matrix of the particle system
  17812. * @param positionToUpdate is the position vector to update with the result
  17813. * @param particle is the particle we are computed the position for
  17814. */
  17815. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17816. /**
  17817. * Clones the current emitter and returns a copy of it
  17818. * @returns the new emitter
  17819. */
  17820. clone(): BoxParticleEmitter;
  17821. /**
  17822. * Called by the GPUParticleSystem to setup the update shader
  17823. * @param effect defines the update shader
  17824. */
  17825. applyToShader(effect: Effect): void;
  17826. /**
  17827. * Returns a string to use to update the GPU particles update shader
  17828. * @returns a string containng the defines string
  17829. */
  17830. getEffectDefines(): string;
  17831. /**
  17832. * Returns the string "BoxParticleEmitter"
  17833. * @returns a string containing the class name
  17834. */
  17835. getClassName(): string;
  17836. /**
  17837. * Serializes the particle system to a JSON object.
  17838. * @returns the JSON object
  17839. */
  17840. serialize(): any;
  17841. /**
  17842. * Parse properties from a JSON object
  17843. * @param serializationObject defines the JSON object
  17844. */
  17845. parse(serializationObject: any): void;
  17846. }
  17847. }
  17848. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  17849. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17850. import { Effect } from "babylonjs/Materials/effect";
  17851. import { Particle } from "babylonjs/Particles/particle";
  17852. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17853. /**
  17854. * Particle emitter emitting particles from the inside of a cone.
  17855. * It emits the particles alongside the cone volume from the base to the particle.
  17856. * The emission direction might be randomized.
  17857. */
  17858. export class ConeParticleEmitter implements IParticleEmitterType {
  17859. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17860. directionRandomizer: number;
  17861. private _radius;
  17862. private _angle;
  17863. private _height;
  17864. /**
  17865. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17866. */
  17867. radiusRange: number;
  17868. /**
  17869. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17870. */
  17871. heightRange: number;
  17872. /**
  17873. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17874. */
  17875. emitFromSpawnPointOnly: boolean;
  17876. /**
  17877. * Gets or sets the radius of the emission cone
  17878. */
  17879. radius: number;
  17880. /**
  17881. * Gets or sets the angle of the emission cone
  17882. */
  17883. angle: number;
  17884. private _buildHeight;
  17885. /**
  17886. * Creates a new instance ConeParticleEmitter
  17887. * @param radius the radius of the emission cone (1 by default)
  17888. * @param angle the cone base angle (PI by default)
  17889. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17890. */
  17891. constructor(radius?: number, angle?: number,
  17892. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17893. directionRandomizer?: number);
  17894. /**
  17895. * Called by the particle System when the direction is computed for the created particle.
  17896. * @param worldMatrix is the world matrix of the particle system
  17897. * @param directionToUpdate is the direction vector to update with the result
  17898. * @param particle is the particle we are computed the direction for
  17899. */
  17900. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17901. /**
  17902. * Called by the particle System when the position is computed for the created particle.
  17903. * @param worldMatrix is the world matrix of the particle system
  17904. * @param positionToUpdate is the position vector to update with the result
  17905. * @param particle is the particle we are computed the position for
  17906. */
  17907. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17908. /**
  17909. * Clones the current emitter and returns a copy of it
  17910. * @returns the new emitter
  17911. */
  17912. clone(): ConeParticleEmitter;
  17913. /**
  17914. * Called by the GPUParticleSystem to setup the update shader
  17915. * @param effect defines the update shader
  17916. */
  17917. applyToShader(effect: Effect): void;
  17918. /**
  17919. * Returns a string to use to update the GPU particles update shader
  17920. * @returns a string containng the defines string
  17921. */
  17922. getEffectDefines(): string;
  17923. /**
  17924. * Returns the string "ConeParticleEmitter"
  17925. * @returns a string containing the class name
  17926. */
  17927. getClassName(): string;
  17928. /**
  17929. * Serializes the particle system to a JSON object.
  17930. * @returns the JSON object
  17931. */
  17932. serialize(): any;
  17933. /**
  17934. * Parse properties from a JSON object
  17935. * @param serializationObject defines the JSON object
  17936. */
  17937. parse(serializationObject: any): void;
  17938. }
  17939. }
  17940. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  17941. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17942. import { Effect } from "babylonjs/Materials/effect";
  17943. import { Particle } from "babylonjs/Particles/particle";
  17944. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17945. /**
  17946. * Particle emitter emitting particles from the inside of a cylinder.
  17947. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17948. */
  17949. export class CylinderParticleEmitter implements IParticleEmitterType {
  17950. /**
  17951. * The radius of the emission cylinder.
  17952. */
  17953. radius: number;
  17954. /**
  17955. * The height of the emission cylinder.
  17956. */
  17957. height: number;
  17958. /**
  17959. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17960. */
  17961. radiusRange: number;
  17962. /**
  17963. * How much to randomize the particle direction [0-1].
  17964. */
  17965. directionRandomizer: number;
  17966. /**
  17967. * Creates a new instance CylinderParticleEmitter
  17968. * @param radius the radius of the emission cylinder (1 by default)
  17969. * @param height the height of the emission cylinder (1 by default)
  17970. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17971. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17972. */
  17973. constructor(
  17974. /**
  17975. * The radius of the emission cylinder.
  17976. */
  17977. radius?: number,
  17978. /**
  17979. * The height of the emission cylinder.
  17980. */
  17981. height?: number,
  17982. /**
  17983. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17984. */
  17985. radiusRange?: number,
  17986. /**
  17987. * How much to randomize the particle direction [0-1].
  17988. */
  17989. directionRandomizer?: number);
  17990. /**
  17991. * Called by the particle System when the direction is computed for the created particle.
  17992. * @param worldMatrix is the world matrix of the particle system
  17993. * @param directionToUpdate is the direction vector to update with the result
  17994. * @param particle is the particle we are computed the direction for
  17995. */
  17996. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17997. /**
  17998. * Called by the particle System when the position is computed for the created particle.
  17999. * @param worldMatrix is the world matrix of the particle system
  18000. * @param positionToUpdate is the position vector to update with the result
  18001. * @param particle is the particle we are computed the position for
  18002. */
  18003. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18004. /**
  18005. * Clones the current emitter and returns a copy of it
  18006. * @returns the new emitter
  18007. */
  18008. clone(): CylinderParticleEmitter;
  18009. /**
  18010. * Called by the GPUParticleSystem to setup the update shader
  18011. * @param effect defines the update shader
  18012. */
  18013. applyToShader(effect: Effect): void;
  18014. /**
  18015. * Returns a string to use to update the GPU particles update shader
  18016. * @returns a string containng the defines string
  18017. */
  18018. getEffectDefines(): string;
  18019. /**
  18020. * Returns the string "CylinderParticleEmitter"
  18021. * @returns a string containing the class name
  18022. */
  18023. getClassName(): string;
  18024. /**
  18025. * Serializes the particle system to a JSON object.
  18026. * @returns the JSON object
  18027. */
  18028. serialize(): any;
  18029. /**
  18030. * Parse properties from a JSON object
  18031. * @param serializationObject defines the JSON object
  18032. */
  18033. parse(serializationObject: any): void;
  18034. }
  18035. /**
  18036. * Particle emitter emitting particles from the inside of a cylinder.
  18037. * It emits the particles randomly between two vectors.
  18038. */
  18039. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18040. /**
  18041. * The min limit of the emission direction.
  18042. */
  18043. direction1: Vector3;
  18044. /**
  18045. * The max limit of the emission direction.
  18046. */
  18047. direction2: Vector3;
  18048. /**
  18049. * Creates a new instance CylinderDirectedParticleEmitter
  18050. * @param radius the radius of the emission cylinder (1 by default)
  18051. * @param height the height of the emission cylinder (1 by default)
  18052. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18053. * @param direction1 the min limit of the emission direction (up vector by default)
  18054. * @param direction2 the max limit of the emission direction (up vector by default)
  18055. */
  18056. constructor(radius?: number, height?: number, radiusRange?: number,
  18057. /**
  18058. * The min limit of the emission direction.
  18059. */
  18060. direction1?: Vector3,
  18061. /**
  18062. * The max limit of the emission direction.
  18063. */
  18064. direction2?: Vector3);
  18065. /**
  18066. * Called by the particle System when the direction is computed for the created particle.
  18067. * @param worldMatrix is the world matrix of the particle system
  18068. * @param directionToUpdate is the direction vector to update with the result
  18069. * @param particle is the particle we are computed the direction for
  18070. */
  18071. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18072. /**
  18073. * Clones the current emitter and returns a copy of it
  18074. * @returns the new emitter
  18075. */
  18076. clone(): CylinderDirectedParticleEmitter;
  18077. /**
  18078. * Called by the GPUParticleSystem to setup the update shader
  18079. * @param effect defines the update shader
  18080. */
  18081. applyToShader(effect: Effect): void;
  18082. /**
  18083. * Returns a string to use to update the GPU particles update shader
  18084. * @returns a string containng the defines string
  18085. */
  18086. getEffectDefines(): string;
  18087. /**
  18088. * Returns the string "CylinderDirectedParticleEmitter"
  18089. * @returns a string containing the class name
  18090. */
  18091. getClassName(): string;
  18092. /**
  18093. * Serializes the particle system to a JSON object.
  18094. * @returns the JSON object
  18095. */
  18096. serialize(): any;
  18097. /**
  18098. * Parse properties from a JSON object
  18099. * @param serializationObject defines the JSON object
  18100. */
  18101. parse(serializationObject: any): void;
  18102. }
  18103. }
  18104. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18105. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18106. import { Effect } from "babylonjs/Materials/effect";
  18107. import { Particle } from "babylonjs/Particles/particle";
  18108. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18109. /**
  18110. * Particle emitter emitting particles from the inside of a hemisphere.
  18111. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18112. */
  18113. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18114. /**
  18115. * The radius of the emission hemisphere.
  18116. */
  18117. radius: number;
  18118. /**
  18119. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18120. */
  18121. radiusRange: number;
  18122. /**
  18123. * How much to randomize the particle direction [0-1].
  18124. */
  18125. directionRandomizer: number;
  18126. /**
  18127. * Creates a new instance HemisphericParticleEmitter
  18128. * @param radius the radius of the emission hemisphere (1 by default)
  18129. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18130. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18131. */
  18132. constructor(
  18133. /**
  18134. * The radius of the emission hemisphere.
  18135. */
  18136. radius?: number,
  18137. /**
  18138. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18139. */
  18140. radiusRange?: number,
  18141. /**
  18142. * How much to randomize the particle direction [0-1].
  18143. */
  18144. directionRandomizer?: number);
  18145. /**
  18146. * Called by the particle System when the direction is computed for the created particle.
  18147. * @param worldMatrix is the world matrix of the particle system
  18148. * @param directionToUpdate is the direction vector to update with the result
  18149. * @param particle is the particle we are computed the direction for
  18150. */
  18151. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18152. /**
  18153. * Called by the particle System when the position is computed for the created particle.
  18154. * @param worldMatrix is the world matrix of the particle system
  18155. * @param positionToUpdate is the position vector to update with the result
  18156. * @param particle is the particle we are computed the position for
  18157. */
  18158. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18159. /**
  18160. * Clones the current emitter and returns a copy of it
  18161. * @returns the new emitter
  18162. */
  18163. clone(): HemisphericParticleEmitter;
  18164. /**
  18165. * Called by the GPUParticleSystem to setup the update shader
  18166. * @param effect defines the update shader
  18167. */
  18168. applyToShader(effect: Effect): void;
  18169. /**
  18170. * Returns a string to use to update the GPU particles update shader
  18171. * @returns a string containng the defines string
  18172. */
  18173. getEffectDefines(): string;
  18174. /**
  18175. * Returns the string "HemisphericParticleEmitter"
  18176. * @returns a string containing the class name
  18177. */
  18178. getClassName(): string;
  18179. /**
  18180. * Serializes the particle system to a JSON object.
  18181. * @returns the JSON object
  18182. */
  18183. serialize(): any;
  18184. /**
  18185. * Parse properties from a JSON object
  18186. * @param serializationObject defines the JSON object
  18187. */
  18188. parse(serializationObject: any): void;
  18189. }
  18190. }
  18191. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18192. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18193. import { Effect } from "babylonjs/Materials/effect";
  18194. import { Particle } from "babylonjs/Particles/particle";
  18195. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18196. /**
  18197. * Particle emitter emitting particles from a point.
  18198. * It emits the particles randomly between 2 given directions.
  18199. */
  18200. export class PointParticleEmitter implements IParticleEmitterType {
  18201. /**
  18202. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18203. */
  18204. direction1: Vector3;
  18205. /**
  18206. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18207. */
  18208. direction2: Vector3;
  18209. /**
  18210. * Creates a new instance PointParticleEmitter
  18211. */
  18212. constructor();
  18213. /**
  18214. * Called by the particle System when the direction is computed for the created particle.
  18215. * @param worldMatrix is the world matrix of the particle system
  18216. * @param directionToUpdate is the direction vector to update with the result
  18217. * @param particle is the particle we are computed the direction for
  18218. */
  18219. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18220. /**
  18221. * Called by the particle System when the position is computed for the created particle.
  18222. * @param worldMatrix is the world matrix of the particle system
  18223. * @param positionToUpdate is the position vector to update with the result
  18224. * @param particle is the particle we are computed the position for
  18225. */
  18226. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18227. /**
  18228. * Clones the current emitter and returns a copy of it
  18229. * @returns the new emitter
  18230. */
  18231. clone(): PointParticleEmitter;
  18232. /**
  18233. * Called by the GPUParticleSystem to setup the update shader
  18234. * @param effect defines the update shader
  18235. */
  18236. applyToShader(effect: Effect): void;
  18237. /**
  18238. * Returns a string to use to update the GPU particles update shader
  18239. * @returns a string containng the defines string
  18240. */
  18241. getEffectDefines(): string;
  18242. /**
  18243. * Returns the string "PointParticleEmitter"
  18244. * @returns a string containing the class name
  18245. */
  18246. getClassName(): string;
  18247. /**
  18248. * Serializes the particle system to a JSON object.
  18249. * @returns the JSON object
  18250. */
  18251. serialize(): any;
  18252. /**
  18253. * Parse properties from a JSON object
  18254. * @param serializationObject defines the JSON object
  18255. */
  18256. parse(serializationObject: any): void;
  18257. }
  18258. }
  18259. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18260. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18261. import { Effect } from "babylonjs/Materials/effect";
  18262. import { Particle } from "babylonjs/Particles/particle";
  18263. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18264. /**
  18265. * Particle emitter emitting particles from the inside of a sphere.
  18266. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18267. */
  18268. export class SphereParticleEmitter implements IParticleEmitterType {
  18269. /**
  18270. * The radius of the emission sphere.
  18271. */
  18272. radius: number;
  18273. /**
  18274. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18275. */
  18276. radiusRange: number;
  18277. /**
  18278. * How much to randomize the particle direction [0-1].
  18279. */
  18280. directionRandomizer: number;
  18281. /**
  18282. * Creates a new instance SphereParticleEmitter
  18283. * @param radius the radius of the emission sphere (1 by default)
  18284. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18285. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18286. */
  18287. constructor(
  18288. /**
  18289. * The radius of the emission sphere.
  18290. */
  18291. radius?: number,
  18292. /**
  18293. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18294. */
  18295. radiusRange?: number,
  18296. /**
  18297. * How much to randomize the particle direction [0-1].
  18298. */
  18299. directionRandomizer?: number);
  18300. /**
  18301. * Called by the particle System when the direction is computed for the created particle.
  18302. * @param worldMatrix is the world matrix of the particle system
  18303. * @param directionToUpdate is the direction vector to update with the result
  18304. * @param particle is the particle we are computed the direction for
  18305. */
  18306. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18307. /**
  18308. * Called by the particle System when the position is computed for the created particle.
  18309. * @param worldMatrix is the world matrix of the particle system
  18310. * @param positionToUpdate is the position vector to update with the result
  18311. * @param particle is the particle we are computed the position for
  18312. */
  18313. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18314. /**
  18315. * Clones the current emitter and returns a copy of it
  18316. * @returns the new emitter
  18317. */
  18318. clone(): SphereParticleEmitter;
  18319. /**
  18320. * Called by the GPUParticleSystem to setup the update shader
  18321. * @param effect defines the update shader
  18322. */
  18323. applyToShader(effect: Effect): void;
  18324. /**
  18325. * Returns a string to use to update the GPU particles update shader
  18326. * @returns a string containng the defines string
  18327. */
  18328. getEffectDefines(): string;
  18329. /**
  18330. * Returns the string "SphereParticleEmitter"
  18331. * @returns a string containing the class name
  18332. */
  18333. getClassName(): string;
  18334. /**
  18335. * Serializes the particle system to a JSON object.
  18336. * @returns the JSON object
  18337. */
  18338. serialize(): any;
  18339. /**
  18340. * Parse properties from a JSON object
  18341. * @param serializationObject defines the JSON object
  18342. */
  18343. parse(serializationObject: any): void;
  18344. }
  18345. /**
  18346. * Particle emitter emitting particles from the inside of a sphere.
  18347. * It emits the particles randomly between two vectors.
  18348. */
  18349. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18350. /**
  18351. * The min limit of the emission direction.
  18352. */
  18353. direction1: Vector3;
  18354. /**
  18355. * The max limit of the emission direction.
  18356. */
  18357. direction2: Vector3;
  18358. /**
  18359. * Creates a new instance SphereDirectedParticleEmitter
  18360. * @param radius the radius of the emission sphere (1 by default)
  18361. * @param direction1 the min limit of the emission direction (up vector by default)
  18362. * @param direction2 the max limit of the emission direction (up vector by default)
  18363. */
  18364. constructor(radius?: number,
  18365. /**
  18366. * The min limit of the emission direction.
  18367. */
  18368. direction1?: Vector3,
  18369. /**
  18370. * The max limit of the emission direction.
  18371. */
  18372. direction2?: Vector3);
  18373. /**
  18374. * Called by the particle System when the direction is computed for the created particle.
  18375. * @param worldMatrix is the world matrix of the particle system
  18376. * @param directionToUpdate is the direction vector to update with the result
  18377. * @param particle is the particle we are computed the direction for
  18378. */
  18379. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18380. /**
  18381. * Clones the current emitter and returns a copy of it
  18382. * @returns the new emitter
  18383. */
  18384. clone(): SphereDirectedParticleEmitter;
  18385. /**
  18386. * Called by the GPUParticleSystem to setup the update shader
  18387. * @param effect defines the update shader
  18388. */
  18389. applyToShader(effect: Effect): void;
  18390. /**
  18391. * Returns a string to use to update the GPU particles update shader
  18392. * @returns a string containng the defines string
  18393. */
  18394. getEffectDefines(): string;
  18395. /**
  18396. * Returns the string "SphereDirectedParticleEmitter"
  18397. * @returns a string containing the class name
  18398. */
  18399. getClassName(): string;
  18400. /**
  18401. * Serializes the particle system to a JSON object.
  18402. * @returns the JSON object
  18403. */
  18404. serialize(): any;
  18405. /**
  18406. * Parse properties from a JSON object
  18407. * @param serializationObject defines the JSON object
  18408. */
  18409. parse(serializationObject: any): void;
  18410. }
  18411. }
  18412. declare module "babylonjs/Particles/EmitterTypes/index" {
  18413. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18414. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18415. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18416. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18417. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18418. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18419. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18420. }
  18421. declare module "babylonjs/Particles/IParticleSystem" {
  18422. import { Nullable } from "babylonjs/types";
  18423. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18424. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18425. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18426. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18427. import { Texture } from "babylonjs/Materials/Textures/texture";
  18428. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18429. import { Scene } from "babylonjs/scene";
  18430. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18431. import { Animation } from "babylonjs/Animations/animation";
  18432. /**
  18433. * Interface representing a particle system in Babylon.js.
  18434. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18435. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18436. */
  18437. export interface IParticleSystem {
  18438. /**
  18439. * List of animations used by the particle system.
  18440. */
  18441. animations: Animation[];
  18442. /**
  18443. * The id of the Particle system.
  18444. */
  18445. id: string;
  18446. /**
  18447. * The name of the Particle system.
  18448. */
  18449. name: string;
  18450. /**
  18451. * The emitter represents the Mesh or position we are attaching the particle system to.
  18452. */
  18453. emitter: Nullable<AbstractMesh | Vector3>;
  18454. /**
  18455. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18456. */
  18457. isBillboardBased: boolean;
  18458. /**
  18459. * The rendering group used by the Particle system to chose when to render.
  18460. */
  18461. renderingGroupId: number;
  18462. /**
  18463. * The layer mask we are rendering the particles through.
  18464. */
  18465. layerMask: number;
  18466. /**
  18467. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18468. */
  18469. updateSpeed: number;
  18470. /**
  18471. * The amount of time the particle system is running (depends of the overall update speed).
  18472. */
  18473. targetStopDuration: number;
  18474. /**
  18475. * The texture used to render each particle. (this can be a spritesheet)
  18476. */
  18477. particleTexture: Nullable<Texture>;
  18478. /**
  18479. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18480. */
  18481. blendMode: number;
  18482. /**
  18483. * Minimum life time of emitting particles.
  18484. */
  18485. minLifeTime: number;
  18486. /**
  18487. * Maximum life time of emitting particles.
  18488. */
  18489. maxLifeTime: number;
  18490. /**
  18491. * Minimum Size of emitting particles.
  18492. */
  18493. minSize: number;
  18494. /**
  18495. * Maximum Size of emitting particles.
  18496. */
  18497. maxSize: number;
  18498. /**
  18499. * Minimum scale of emitting particles on X axis.
  18500. */
  18501. minScaleX: number;
  18502. /**
  18503. * Maximum scale of emitting particles on X axis.
  18504. */
  18505. maxScaleX: number;
  18506. /**
  18507. * Minimum scale of emitting particles on Y axis.
  18508. */
  18509. minScaleY: number;
  18510. /**
  18511. * Maximum scale of emitting particles on Y axis.
  18512. */
  18513. maxScaleY: number;
  18514. /**
  18515. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18516. */
  18517. color1: Color4;
  18518. /**
  18519. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18520. */
  18521. color2: Color4;
  18522. /**
  18523. * Color the particle will have at the end of its lifetime.
  18524. */
  18525. colorDead: Color4;
  18526. /**
  18527. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18528. */
  18529. emitRate: number;
  18530. /**
  18531. * You can use gravity if you want to give an orientation to your particles.
  18532. */
  18533. gravity: Vector3;
  18534. /**
  18535. * Minimum power of emitting particles.
  18536. */
  18537. minEmitPower: number;
  18538. /**
  18539. * Maximum power of emitting particles.
  18540. */
  18541. maxEmitPower: number;
  18542. /**
  18543. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18544. */
  18545. minAngularSpeed: number;
  18546. /**
  18547. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18548. */
  18549. maxAngularSpeed: number;
  18550. /**
  18551. * Gets or sets the minimal initial rotation in radians.
  18552. */
  18553. minInitialRotation: number;
  18554. /**
  18555. * Gets or sets the maximal initial rotation in radians.
  18556. */
  18557. maxInitialRotation: number;
  18558. /**
  18559. * The particle emitter type defines the emitter used by the particle system.
  18560. * It can be for example box, sphere, or cone...
  18561. */
  18562. particleEmitterType: Nullable<IParticleEmitterType>;
  18563. /**
  18564. * Defines the delay in milliseconds before starting the system (0 by default)
  18565. */
  18566. startDelay: number;
  18567. /**
  18568. * 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
  18569. */
  18570. preWarmCycles: number;
  18571. /**
  18572. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18573. */
  18574. preWarmStepOffset: number;
  18575. /**
  18576. * 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)
  18577. */
  18578. spriteCellChangeSpeed: number;
  18579. /**
  18580. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18581. */
  18582. startSpriteCellID: number;
  18583. /**
  18584. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18585. */
  18586. endSpriteCellID: number;
  18587. /**
  18588. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18589. */
  18590. spriteCellWidth: number;
  18591. /**
  18592. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18593. */
  18594. spriteCellHeight: number;
  18595. /**
  18596. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18597. */
  18598. spriteRandomStartCell: boolean;
  18599. /**
  18600. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18601. */
  18602. isAnimationSheetEnabled: boolean;
  18603. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18604. translationPivot: Vector2;
  18605. /**
  18606. * Gets or sets a texture used to add random noise to particle positions
  18607. */
  18608. noiseTexture: Nullable<BaseTexture>;
  18609. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18610. noiseStrength: Vector3;
  18611. /**
  18612. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18613. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18614. */
  18615. billboardMode: number;
  18616. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18617. limitVelocityDamping: number;
  18618. /**
  18619. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18620. */
  18621. beginAnimationOnStart: boolean;
  18622. /**
  18623. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18624. */
  18625. beginAnimationFrom: number;
  18626. /**
  18627. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18628. */
  18629. beginAnimationTo: number;
  18630. /**
  18631. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18632. */
  18633. beginAnimationLoop: boolean;
  18634. /**
  18635. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18636. */
  18637. disposeOnStop: boolean;
  18638. /**
  18639. * Gets the maximum number of particles active at the same time.
  18640. * @returns The max number of active particles.
  18641. */
  18642. getCapacity(): number;
  18643. /**
  18644. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18645. * @returns True if it has been started, otherwise false.
  18646. */
  18647. isStarted(): boolean;
  18648. /**
  18649. * Animates the particle system for this frame.
  18650. */
  18651. animate(): void;
  18652. /**
  18653. * Renders the particle system in its current state.
  18654. * @returns the current number of particles
  18655. */
  18656. render(): number;
  18657. /**
  18658. * Dispose the particle system and frees its associated resources.
  18659. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18660. */
  18661. dispose(disposeTexture?: boolean): void;
  18662. /**
  18663. * Clones the particle system.
  18664. * @param name The name of the cloned object
  18665. * @param newEmitter The new emitter to use
  18666. * @returns the cloned particle system
  18667. */
  18668. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18669. /**
  18670. * Serializes the particle system to a JSON object.
  18671. * @returns the JSON object
  18672. */
  18673. serialize(): any;
  18674. /**
  18675. * Rebuild the particle system
  18676. */
  18677. rebuild(): void;
  18678. /**
  18679. * Starts the particle system and begins to emit
  18680. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18681. */
  18682. start(delay?: number): void;
  18683. /**
  18684. * Stops the particle system.
  18685. */
  18686. stop(): void;
  18687. /**
  18688. * Remove all active particles
  18689. */
  18690. reset(): void;
  18691. /**
  18692. * Is this system ready to be used/rendered
  18693. * @return true if the system is ready
  18694. */
  18695. isReady(): boolean;
  18696. /**
  18697. * Adds a new color gradient
  18698. * @param gradient defines the gradient to use (between 0 and 1)
  18699. * @param color1 defines the color to affect to the specified gradient
  18700. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18701. * @returns the current particle system
  18702. */
  18703. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18704. /**
  18705. * Remove a specific color gradient
  18706. * @param gradient defines the gradient to remove
  18707. * @returns the current particle system
  18708. */
  18709. removeColorGradient(gradient: number): IParticleSystem;
  18710. /**
  18711. * Adds a new size gradient
  18712. * @param gradient defines the gradient to use (between 0 and 1)
  18713. * @param factor defines the size factor to affect to the specified gradient
  18714. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18715. * @returns the current particle system
  18716. */
  18717. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18718. /**
  18719. * Remove a specific size gradient
  18720. * @param gradient defines the gradient to remove
  18721. * @returns the current particle system
  18722. */
  18723. removeSizeGradient(gradient: number): IParticleSystem;
  18724. /**
  18725. * Gets the current list of color gradients.
  18726. * You must use addColorGradient and removeColorGradient to udpate this list
  18727. * @returns the list of color gradients
  18728. */
  18729. getColorGradients(): Nullable<Array<ColorGradient>>;
  18730. /**
  18731. * Gets the current list of size gradients.
  18732. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18733. * @returns the list of size gradients
  18734. */
  18735. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18736. /**
  18737. * Gets the current list of angular speed gradients.
  18738. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18739. * @returns the list of angular speed gradients
  18740. */
  18741. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18742. /**
  18743. * Adds a new angular speed gradient
  18744. * @param gradient defines the gradient to use (between 0 and 1)
  18745. * @param factor defines the angular speed to affect to the specified gradient
  18746. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18747. * @returns the current particle system
  18748. */
  18749. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18750. /**
  18751. * Remove a specific angular speed gradient
  18752. * @param gradient defines the gradient to remove
  18753. * @returns the current particle system
  18754. */
  18755. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18756. /**
  18757. * Gets the current list of velocity gradients.
  18758. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18759. * @returns the list of velocity gradients
  18760. */
  18761. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18762. /**
  18763. * Adds a new velocity gradient
  18764. * @param gradient defines the gradient to use (between 0 and 1)
  18765. * @param factor defines the velocity to affect to the specified gradient
  18766. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18767. * @returns the current particle system
  18768. */
  18769. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18770. /**
  18771. * Remove a specific velocity gradient
  18772. * @param gradient defines the gradient to remove
  18773. * @returns the current particle system
  18774. */
  18775. removeVelocityGradient(gradient: number): IParticleSystem;
  18776. /**
  18777. * Gets the current list of limit velocity gradients.
  18778. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18779. * @returns the list of limit velocity gradients
  18780. */
  18781. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18782. /**
  18783. * Adds a new limit velocity gradient
  18784. * @param gradient defines the gradient to use (between 0 and 1)
  18785. * @param factor defines the limit velocity to affect to the specified gradient
  18786. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18787. * @returns the current particle system
  18788. */
  18789. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18790. /**
  18791. * Remove a specific limit velocity gradient
  18792. * @param gradient defines the gradient to remove
  18793. * @returns the current particle system
  18794. */
  18795. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18796. /**
  18797. * Adds a new drag gradient
  18798. * @param gradient defines the gradient to use (between 0 and 1)
  18799. * @param factor defines the drag to affect to the specified gradient
  18800. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18801. * @returns the current particle system
  18802. */
  18803. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18804. /**
  18805. * Remove a specific drag gradient
  18806. * @param gradient defines the gradient to remove
  18807. * @returns the current particle system
  18808. */
  18809. removeDragGradient(gradient: number): IParticleSystem;
  18810. /**
  18811. * Gets the current list of drag gradients.
  18812. * You must use addDragGradient and removeDragGradient to udpate this list
  18813. * @returns the list of drag gradients
  18814. */
  18815. getDragGradients(): Nullable<Array<FactorGradient>>;
  18816. /**
  18817. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18818. * @param gradient defines the gradient to use (between 0 and 1)
  18819. * @param factor defines the emit rate to affect to the specified gradient
  18820. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18821. * @returns the current particle system
  18822. */
  18823. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18824. /**
  18825. * Remove a specific emit rate gradient
  18826. * @param gradient defines the gradient to remove
  18827. * @returns the current particle system
  18828. */
  18829. removeEmitRateGradient(gradient: number): IParticleSystem;
  18830. /**
  18831. * Gets the current list of emit rate gradients.
  18832. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18833. * @returns the list of emit rate gradients
  18834. */
  18835. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18836. /**
  18837. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18838. * @param gradient defines the gradient to use (between 0 and 1)
  18839. * @param factor defines the start size to affect to the specified gradient
  18840. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18841. * @returns the current particle system
  18842. */
  18843. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18844. /**
  18845. * Remove a specific start size gradient
  18846. * @param gradient defines the gradient to remove
  18847. * @returns the current particle system
  18848. */
  18849. removeStartSizeGradient(gradient: number): IParticleSystem;
  18850. /**
  18851. * Gets the current list of start size gradients.
  18852. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18853. * @returns the list of start size gradients
  18854. */
  18855. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18856. /**
  18857. * Adds a new life time gradient
  18858. * @param gradient defines the gradient to use (between 0 and 1)
  18859. * @param factor defines the life time factor to affect to the specified gradient
  18860. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18861. * @returns the current particle system
  18862. */
  18863. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18864. /**
  18865. * Remove a specific life time gradient
  18866. * @param gradient defines the gradient to remove
  18867. * @returns the current particle system
  18868. */
  18869. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18870. /**
  18871. * Gets the current list of life time gradients.
  18872. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18873. * @returns the list of life time gradients
  18874. */
  18875. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18876. /**
  18877. * Gets the current list of color gradients.
  18878. * You must use addColorGradient and removeColorGradient to udpate this list
  18879. * @returns the list of color gradients
  18880. */
  18881. getColorGradients(): Nullable<Array<ColorGradient>>;
  18882. /**
  18883. * Adds a new ramp gradient used to remap particle colors
  18884. * @param gradient defines the gradient to use (between 0 and 1)
  18885. * @param color defines the color to affect to the specified gradient
  18886. * @returns the current particle system
  18887. */
  18888. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18889. /**
  18890. * Gets the current list of ramp gradients.
  18891. * You must use addRampGradient and removeRampGradient to udpate this list
  18892. * @returns the list of ramp gradients
  18893. */
  18894. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18895. /** Gets or sets a boolean indicating that ramp gradients must be used
  18896. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18897. */
  18898. useRampGradients: boolean;
  18899. /**
  18900. * Adds a new color remap gradient
  18901. * @param gradient defines the gradient to use (between 0 and 1)
  18902. * @param min defines the color remap minimal range
  18903. * @param max defines the color remap maximal range
  18904. * @returns the current particle system
  18905. */
  18906. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18907. /**
  18908. * Gets the current list of color remap gradients.
  18909. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18910. * @returns the list of color remap gradients
  18911. */
  18912. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18913. /**
  18914. * Adds a new alpha remap gradient
  18915. * @param gradient defines the gradient to use (between 0 and 1)
  18916. * @param min defines the alpha remap minimal range
  18917. * @param max defines the alpha remap maximal range
  18918. * @returns the current particle system
  18919. */
  18920. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18921. /**
  18922. * Gets the current list of alpha remap gradients.
  18923. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18924. * @returns the list of alpha remap gradients
  18925. */
  18926. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18927. /**
  18928. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18929. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18930. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18931. * @returns the emitter
  18932. */
  18933. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18934. /**
  18935. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18936. * @param radius The radius of the hemisphere to emit from
  18937. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18938. * @returns the emitter
  18939. */
  18940. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18941. /**
  18942. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18943. * @param radius The radius of the sphere to emit from
  18944. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18945. * @returns the emitter
  18946. */
  18947. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18948. /**
  18949. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18950. * @param radius The radius of the sphere to emit from
  18951. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18952. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18953. * @returns the emitter
  18954. */
  18955. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18956. /**
  18957. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18958. * @param radius The radius of the emission cylinder
  18959. * @param height The height of the emission cylinder
  18960. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18961. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18962. * @returns the emitter
  18963. */
  18964. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18965. /**
  18966. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18967. * @param radius The radius of the cylinder to emit from
  18968. * @param height The height of the emission cylinder
  18969. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18970. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18971. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18972. * @returns the emitter
  18973. */
  18974. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18975. /**
  18976. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18977. * @param radius The radius of the cone to emit from
  18978. * @param angle The base angle of the cone
  18979. * @returns the emitter
  18980. */
  18981. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18982. /**
  18983. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18984. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18985. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18986. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18987. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18988. * @returns the emitter
  18989. */
  18990. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18991. /**
  18992. * Get hosting scene
  18993. * @returns the scene
  18994. */
  18995. getScene(): Scene;
  18996. }
  18997. }
  18998. declare module "babylonjs/Meshes/instancedMesh" {
  18999. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19000. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19001. import { Camera } from "babylonjs/Cameras/camera";
  19002. import { Node } from "babylonjs/node";
  19003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19004. import { Mesh } from "babylonjs/Meshes/mesh";
  19005. import { Material } from "babylonjs/Materials/material";
  19006. import { Skeleton } from "babylonjs/Bones/skeleton";
  19007. import { Light } from "babylonjs/Lights/light";
  19008. /**
  19009. * Creates an instance based on a source mesh.
  19010. */
  19011. export class InstancedMesh extends AbstractMesh {
  19012. private _sourceMesh;
  19013. private _currentLOD;
  19014. /** @hidden */
  19015. _indexInSourceMeshInstanceArray: number;
  19016. constructor(name: string, source: Mesh);
  19017. /**
  19018. * Returns the string "InstancedMesh".
  19019. */
  19020. getClassName(): string;
  19021. /** Gets the list of lights affecting that mesh */
  19022. readonly lightSources: Light[];
  19023. _resyncLightSources(): void;
  19024. _resyncLighSource(light: Light): void;
  19025. _removeLightSource(light: Light): void;
  19026. /**
  19027. * If the source mesh receives shadows
  19028. */
  19029. readonly receiveShadows: boolean;
  19030. /**
  19031. * The material of the source mesh
  19032. */
  19033. readonly material: Nullable<Material>;
  19034. /**
  19035. * Visibility of the source mesh
  19036. */
  19037. readonly visibility: number;
  19038. /**
  19039. * Skeleton of the source mesh
  19040. */
  19041. readonly skeleton: Nullable<Skeleton>;
  19042. /**
  19043. * Rendering ground id of the source mesh
  19044. */
  19045. renderingGroupId: number;
  19046. /**
  19047. * Returns the total number of vertices (integer).
  19048. */
  19049. getTotalVertices(): number;
  19050. /**
  19051. * Returns a positive integer : the total number of indices in this mesh geometry.
  19052. * @returns the numner of indices or zero if the mesh has no geometry.
  19053. */
  19054. getTotalIndices(): number;
  19055. /**
  19056. * The source mesh of the instance
  19057. */
  19058. readonly sourceMesh: Mesh;
  19059. /**
  19060. * Is this node ready to be used/rendered
  19061. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19062. * @return {boolean} is it ready
  19063. */
  19064. isReady(completeCheck?: boolean): boolean;
  19065. /**
  19066. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19067. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19068. * @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.
  19069. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19070. */
  19071. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19072. /**
  19073. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19074. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19075. * The `data` are either a numeric array either a Float32Array.
  19076. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19077. * 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).
  19078. * Note that a new underlying VertexBuffer object is created each call.
  19079. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19080. *
  19081. * Possible `kind` values :
  19082. * - VertexBuffer.PositionKind
  19083. * - VertexBuffer.UVKind
  19084. * - VertexBuffer.UV2Kind
  19085. * - VertexBuffer.UV3Kind
  19086. * - VertexBuffer.UV4Kind
  19087. * - VertexBuffer.UV5Kind
  19088. * - VertexBuffer.UV6Kind
  19089. * - VertexBuffer.ColorKind
  19090. * - VertexBuffer.MatricesIndicesKind
  19091. * - VertexBuffer.MatricesIndicesExtraKind
  19092. * - VertexBuffer.MatricesWeightsKind
  19093. * - VertexBuffer.MatricesWeightsExtraKind
  19094. *
  19095. * Returns the Mesh.
  19096. */
  19097. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  19098. /**
  19099. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19100. * If the mesh has no geometry, it is simply returned as it is.
  19101. * The `data` are either a numeric array either a Float32Array.
  19102. * No new underlying VertexBuffer object is created.
  19103. * 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.
  19104. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19105. *
  19106. * Possible `kind` values :
  19107. * - VertexBuffer.PositionKind
  19108. * - VertexBuffer.UVKind
  19109. * - VertexBuffer.UV2Kind
  19110. * - VertexBuffer.UV3Kind
  19111. * - VertexBuffer.UV4Kind
  19112. * - VertexBuffer.UV5Kind
  19113. * - VertexBuffer.UV6Kind
  19114. * - VertexBuffer.ColorKind
  19115. * - VertexBuffer.MatricesIndicesKind
  19116. * - VertexBuffer.MatricesIndicesExtraKind
  19117. * - VertexBuffer.MatricesWeightsKind
  19118. * - VertexBuffer.MatricesWeightsExtraKind
  19119. *
  19120. * Returns the Mesh.
  19121. */
  19122. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19123. /**
  19124. * Sets the mesh indices.
  19125. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19126. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19127. * This method creates a new index buffer each call.
  19128. * Returns the Mesh.
  19129. */
  19130. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19131. /**
  19132. * Boolean : True if the mesh owns the requested kind of data.
  19133. */
  19134. isVerticesDataPresent(kind: string): boolean;
  19135. /**
  19136. * Returns an array of indices (IndicesArray).
  19137. */
  19138. getIndices(): Nullable<IndicesArray>;
  19139. readonly _positions: Nullable<Vector3[]>;
  19140. /**
  19141. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19142. * This means the mesh underlying bounding box and sphere are recomputed.
  19143. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19144. * @returns the current mesh
  19145. */
  19146. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19147. /** @hidden */
  19148. _preActivate(): InstancedMesh;
  19149. /** @hidden */
  19150. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19151. /** @hidden */
  19152. _postActivate(): void;
  19153. getWorldMatrix(): Matrix;
  19154. readonly isAnInstance: boolean;
  19155. /**
  19156. * Returns the current associated LOD AbstractMesh.
  19157. */
  19158. getLOD(camera: Camera): AbstractMesh;
  19159. /** @hidden */
  19160. _syncSubMeshes(): InstancedMesh;
  19161. /** @hidden */
  19162. _generatePointsArray(): boolean;
  19163. /**
  19164. * Creates a new InstancedMesh from the current mesh.
  19165. * - name (string) : the cloned mesh name
  19166. * - newParent (optional Node) : the optional Node to parent the clone to.
  19167. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19168. *
  19169. * Returns the clone.
  19170. */
  19171. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  19172. /**
  19173. * Disposes the InstancedMesh.
  19174. * Returns nothing.
  19175. */
  19176. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19177. }
  19178. }
  19179. declare module "babylonjs/Materials/shaderMaterial" {
  19180. import { Scene } from "babylonjs/scene";
  19181. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19183. import { Mesh } from "babylonjs/Meshes/mesh";
  19184. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19185. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19186. import { Texture } from "babylonjs/Materials/Textures/texture";
  19187. import { Material } from "babylonjs/Materials/material";
  19188. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19189. /**
  19190. * Defines the options associated with the creation of a shader material.
  19191. */
  19192. export interface IShaderMaterialOptions {
  19193. /**
  19194. * Does the material work in alpha blend mode
  19195. */
  19196. needAlphaBlending: boolean;
  19197. /**
  19198. * Does the material work in alpha test mode
  19199. */
  19200. needAlphaTesting: boolean;
  19201. /**
  19202. * The list of attribute names used in the shader
  19203. */
  19204. attributes: string[];
  19205. /**
  19206. * The list of unifrom names used in the shader
  19207. */
  19208. uniforms: string[];
  19209. /**
  19210. * The list of UBO names used in the shader
  19211. */
  19212. uniformBuffers: string[];
  19213. /**
  19214. * The list of sampler names used in the shader
  19215. */
  19216. samplers: string[];
  19217. /**
  19218. * The list of defines used in the shader
  19219. */
  19220. defines: string[];
  19221. }
  19222. /**
  19223. * 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.
  19224. *
  19225. * This returned material effects how the mesh will look based on the code in the shaders.
  19226. *
  19227. * @see http://doc.babylonjs.com/how_to/shader_material
  19228. */
  19229. export class ShaderMaterial extends Material {
  19230. private _shaderPath;
  19231. private _options;
  19232. private _textures;
  19233. private _textureArrays;
  19234. private _floats;
  19235. private _ints;
  19236. private _floatsArrays;
  19237. private _colors3;
  19238. private _colors3Arrays;
  19239. private _colors4;
  19240. private _colors4Arrays;
  19241. private _vectors2;
  19242. private _vectors3;
  19243. private _vectors4;
  19244. private _matrices;
  19245. private _matrices3x3;
  19246. private _matrices2x2;
  19247. private _vectors2Arrays;
  19248. private _vectors3Arrays;
  19249. private _vectors4Arrays;
  19250. private _cachedWorldViewMatrix;
  19251. private _cachedWorldViewProjectionMatrix;
  19252. private _renderId;
  19253. /**
  19254. * Instantiate a new shader material.
  19255. * 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.
  19256. * This returned material effects how the mesh will look based on the code in the shaders.
  19257. * @see http://doc.babylonjs.com/how_to/shader_material
  19258. * @param name Define the name of the material in the scene
  19259. * @param scene Define the scene the material belongs to
  19260. * @param shaderPath Defines the route to the shader code in one of three ways:
  19261. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19262. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  19263. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19264. * @param options Define the options used to create the shader
  19265. */
  19266. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19267. /**
  19268. * Gets the options used to compile the shader.
  19269. * They can be modified to trigger a new compilation
  19270. */
  19271. readonly options: IShaderMaterialOptions;
  19272. /**
  19273. * Gets the current class name of the material e.g. "ShaderMaterial"
  19274. * Mainly use in serialization.
  19275. * @returns the class name
  19276. */
  19277. getClassName(): string;
  19278. /**
  19279. * Specifies if the material will require alpha blending
  19280. * @returns a boolean specifying if alpha blending is needed
  19281. */
  19282. needAlphaBlending(): boolean;
  19283. /**
  19284. * Specifies if this material should be rendered in alpha test mode
  19285. * @returns a boolean specifying if an alpha test is needed.
  19286. */
  19287. needAlphaTesting(): boolean;
  19288. private _checkUniform;
  19289. /**
  19290. * Set a texture in the shader.
  19291. * @param name Define the name of the uniform samplers as defined in the shader
  19292. * @param texture Define the texture to bind to this sampler
  19293. * @return the material itself allowing "fluent" like uniform updates
  19294. */
  19295. setTexture(name: string, texture: Texture): ShaderMaterial;
  19296. /**
  19297. * Set a texture array in the shader.
  19298. * @param name Define the name of the uniform sampler array as defined in the shader
  19299. * @param textures Define the list of textures to bind to this sampler
  19300. * @return the material itself allowing "fluent" like uniform updates
  19301. */
  19302. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19303. /**
  19304. * Set a float in the shader.
  19305. * @param name Define the name of the uniform as defined in the shader
  19306. * @param value Define the value to give to the uniform
  19307. * @return the material itself allowing "fluent" like uniform updates
  19308. */
  19309. setFloat(name: string, value: number): ShaderMaterial;
  19310. /**
  19311. * Set a int in the shader.
  19312. * @param name Define the name of the uniform as defined in the shader
  19313. * @param value Define the value to give to the uniform
  19314. * @return the material itself allowing "fluent" like uniform updates
  19315. */
  19316. setInt(name: string, value: number): ShaderMaterial;
  19317. /**
  19318. * Set an array of floats in the shader.
  19319. * @param name Define the name of the uniform as defined in the shader
  19320. * @param value Define the value to give to the uniform
  19321. * @return the material itself allowing "fluent" like uniform updates
  19322. */
  19323. setFloats(name: string, value: number[]): ShaderMaterial;
  19324. /**
  19325. * Set a vec3 in the shader from a Color3.
  19326. * @param name Define the name of the uniform as defined in the shader
  19327. * @param value Define the value to give to the uniform
  19328. * @return the material itself allowing "fluent" like uniform updates
  19329. */
  19330. setColor3(name: string, value: Color3): ShaderMaterial;
  19331. /**
  19332. * Set a vec3 array in the shader from a Color3 array.
  19333. * @param name Define the name of the uniform as defined in the shader
  19334. * @param value Define the value to give to the uniform
  19335. * @return the material itself allowing "fluent" like uniform updates
  19336. */
  19337. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19338. /**
  19339. * Set a vec4 in the shader from a Color4.
  19340. * @param name Define the name of the uniform as defined in the shader
  19341. * @param value Define the value to give to the uniform
  19342. * @return the material itself allowing "fluent" like uniform updates
  19343. */
  19344. setColor4(name: string, value: Color4): ShaderMaterial;
  19345. /**
  19346. * Set a vec4 array in the shader from a Color4 array.
  19347. * @param name Define the name of the uniform as defined in the shader
  19348. * @param value Define the value to give to the uniform
  19349. * @return the material itself allowing "fluent" like uniform updates
  19350. */
  19351. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19352. /**
  19353. * Set a vec2 in the shader from a Vector2.
  19354. * @param name Define the name of the uniform as defined in the shader
  19355. * @param value Define the value to give to the uniform
  19356. * @return the material itself allowing "fluent" like uniform updates
  19357. */
  19358. setVector2(name: string, value: Vector2): ShaderMaterial;
  19359. /**
  19360. * Set a vec3 in the shader from a Vector3.
  19361. * @param name Define the name of the uniform as defined in the shader
  19362. * @param value Define the value to give to the uniform
  19363. * @return the material itself allowing "fluent" like uniform updates
  19364. */
  19365. setVector3(name: string, value: Vector3): ShaderMaterial;
  19366. /**
  19367. * Set a vec4 in the shader from a Vector4.
  19368. * @param name Define the name of the uniform as defined in the shader
  19369. * @param value Define the value to give to the uniform
  19370. * @return the material itself allowing "fluent" like uniform updates
  19371. */
  19372. setVector4(name: string, value: Vector4): ShaderMaterial;
  19373. /**
  19374. * Set a mat4 in the shader from a Matrix.
  19375. * @param name Define the name of the uniform as defined in the shader
  19376. * @param value Define the value to give to the uniform
  19377. * @return the material itself allowing "fluent" like uniform updates
  19378. */
  19379. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19380. /**
  19381. * Set a mat3 in the shader from a Float32Array.
  19382. * @param name Define the name of the uniform as defined in the shader
  19383. * @param value Define the value to give to the uniform
  19384. * @return the material itself allowing "fluent" like uniform updates
  19385. */
  19386. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19387. /**
  19388. * Set a mat2 in the shader from a Float32Array.
  19389. * @param name Define the name of the uniform as defined in the shader
  19390. * @param value Define the value to give to the uniform
  19391. * @return the material itself allowing "fluent" like uniform updates
  19392. */
  19393. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19394. /**
  19395. * Set a vec2 array in the shader from a number array.
  19396. * @param name Define the name of the uniform as defined in the shader
  19397. * @param value Define the value to give to the uniform
  19398. * @return the material itself allowing "fluent" like uniform updates
  19399. */
  19400. setArray2(name: string, value: number[]): ShaderMaterial;
  19401. /**
  19402. * Set a vec3 array in the shader from a number array.
  19403. * @param name Define the name of the uniform as defined in the shader
  19404. * @param value Define the value to give to the uniform
  19405. * @return the material itself allowing "fluent" like uniform updates
  19406. */
  19407. setArray3(name: string, value: number[]): ShaderMaterial;
  19408. /**
  19409. * Set a vec4 array in the shader from a number array.
  19410. * @param name Define the name of the uniform as defined in the shader
  19411. * @param value Define the value to give to the uniform
  19412. * @return the material itself allowing "fluent" like uniform updates
  19413. */
  19414. setArray4(name: string, value: number[]): ShaderMaterial;
  19415. private _checkCache;
  19416. /**
  19417. * Specifies that the submesh is ready to be used
  19418. * @param mesh defines the mesh to check
  19419. * @param subMesh defines which submesh to check
  19420. * @param useInstances specifies that instances should be used
  19421. * @returns a boolean indicating that the submesh is ready or not
  19422. */
  19423. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19424. /**
  19425. * Checks if the material is ready to render the requested mesh
  19426. * @param mesh Define the mesh to render
  19427. * @param useInstances Define whether or not the material is used with instances
  19428. * @returns true if ready, otherwise false
  19429. */
  19430. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19431. /**
  19432. * Binds the world matrix to the material
  19433. * @param world defines the world transformation matrix
  19434. */
  19435. bindOnlyWorldMatrix(world: Matrix): void;
  19436. /**
  19437. * Binds the material to the mesh
  19438. * @param world defines the world transformation matrix
  19439. * @param mesh defines the mesh to bind the material to
  19440. */
  19441. bind(world: Matrix, mesh?: Mesh): void;
  19442. /**
  19443. * Gets the active textures from the material
  19444. * @returns an array of textures
  19445. */
  19446. getActiveTextures(): BaseTexture[];
  19447. /**
  19448. * Specifies if the material uses a texture
  19449. * @param texture defines the texture to check against the material
  19450. * @returns a boolean specifying if the material uses the texture
  19451. */
  19452. hasTexture(texture: BaseTexture): boolean;
  19453. /**
  19454. * Makes a duplicate of the material, and gives it a new name
  19455. * @param name defines the new name for the duplicated material
  19456. * @returns the cloned material
  19457. */
  19458. clone(name: string): ShaderMaterial;
  19459. /**
  19460. * Disposes the material
  19461. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19462. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19463. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19464. */
  19465. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19466. /**
  19467. * Serializes this material in a JSON representation
  19468. * @returns the serialized material object
  19469. */
  19470. serialize(): any;
  19471. /**
  19472. * Creates a shader material from parsed shader material data
  19473. * @param source defines the JSON represnetation of the material
  19474. * @param scene defines the hosting scene
  19475. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19476. * @returns a new material
  19477. */
  19478. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19479. }
  19480. }
  19481. declare module "babylonjs/Shaders/color.fragment" {
  19482. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19483. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19484. /** @hidden */
  19485. export var colorPixelShader: {
  19486. name: string;
  19487. shader: string;
  19488. };
  19489. }
  19490. declare module "babylonjs/Shaders/color.vertex" {
  19491. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19492. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19493. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19494. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19495. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19496. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19497. /** @hidden */
  19498. export var colorVertexShader: {
  19499. name: string;
  19500. shader: string;
  19501. };
  19502. }
  19503. declare module "babylonjs/Meshes/linesMesh" {
  19504. import { Nullable } from "babylonjs/types";
  19505. import { Scene } from "babylonjs/scene";
  19506. import { Color3 } from "babylonjs/Maths/math.color";
  19507. import { Node } from "babylonjs/node";
  19508. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19509. import { Mesh } from "babylonjs/Meshes/mesh";
  19510. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19511. import { Effect } from "babylonjs/Materials/effect";
  19512. import { Material } from "babylonjs/Materials/material";
  19513. import "babylonjs/Shaders/color.fragment";
  19514. import "babylonjs/Shaders/color.vertex";
  19515. /**
  19516. * Line mesh
  19517. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19518. */
  19519. export class LinesMesh extends Mesh {
  19520. /**
  19521. * If vertex color should be applied to the mesh
  19522. */
  19523. readonly useVertexColor?: boolean | undefined;
  19524. /**
  19525. * If vertex alpha should be applied to the mesh
  19526. */
  19527. readonly useVertexAlpha?: boolean | undefined;
  19528. /**
  19529. * Color of the line (Default: White)
  19530. */
  19531. color: Color3;
  19532. /**
  19533. * Alpha of the line (Default: 1)
  19534. */
  19535. alpha: number;
  19536. /**
  19537. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19538. * This margin is expressed in world space coordinates, so its value may vary.
  19539. * Default value is 0.1
  19540. */
  19541. intersectionThreshold: number;
  19542. private _colorShader;
  19543. private color4;
  19544. /**
  19545. * Creates a new LinesMesh
  19546. * @param name defines the name
  19547. * @param scene defines the hosting scene
  19548. * @param parent defines the parent mesh if any
  19549. * @param source defines the optional source LinesMesh used to clone data from
  19550. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19551. * When false, achieved by calling a clone(), also passing False.
  19552. * This will make creation of children, recursive.
  19553. * @param useVertexColor defines if this LinesMesh supports vertex color
  19554. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19555. */
  19556. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  19557. /**
  19558. * If vertex color should be applied to the mesh
  19559. */
  19560. useVertexColor?: boolean | undefined,
  19561. /**
  19562. * If vertex alpha should be applied to the mesh
  19563. */
  19564. useVertexAlpha?: boolean | undefined);
  19565. private _addClipPlaneDefine;
  19566. private _removeClipPlaneDefine;
  19567. isReady(): boolean;
  19568. /**
  19569. * Returns the string "LineMesh"
  19570. */
  19571. getClassName(): string;
  19572. /**
  19573. * @hidden
  19574. */
  19575. /**
  19576. * @hidden
  19577. */
  19578. material: Material;
  19579. /**
  19580. * @hidden
  19581. */
  19582. readonly checkCollisions: boolean;
  19583. /** @hidden */
  19584. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  19585. /** @hidden */
  19586. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  19587. /**
  19588. * Disposes of the line mesh
  19589. * @param doNotRecurse If children should be disposed
  19590. */
  19591. dispose(doNotRecurse?: boolean): void;
  19592. /**
  19593. * Returns a new LineMesh object cloned from the current one.
  19594. */
  19595. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  19596. /**
  19597. * Creates a new InstancedLinesMesh object from the mesh model.
  19598. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19599. * @param name defines the name of the new instance
  19600. * @returns a new InstancedLinesMesh
  19601. */
  19602. createInstance(name: string): InstancedLinesMesh;
  19603. }
  19604. /**
  19605. * Creates an instance based on a source LinesMesh
  19606. */
  19607. export class InstancedLinesMesh extends InstancedMesh {
  19608. /**
  19609. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19610. * This margin is expressed in world space coordinates, so its value may vary.
  19611. * Initilized with the intersectionThreshold value of the source LinesMesh
  19612. */
  19613. intersectionThreshold: number;
  19614. constructor(name: string, source: LinesMesh);
  19615. /**
  19616. * Returns the string "InstancedLinesMesh".
  19617. */
  19618. getClassName(): string;
  19619. }
  19620. }
  19621. declare module "babylonjs/Shaders/line.fragment" {
  19622. /** @hidden */
  19623. export var linePixelShader: {
  19624. name: string;
  19625. shader: string;
  19626. };
  19627. }
  19628. declare module "babylonjs/Shaders/line.vertex" {
  19629. /** @hidden */
  19630. export var lineVertexShader: {
  19631. name: string;
  19632. shader: string;
  19633. };
  19634. }
  19635. declare module "babylonjs/Rendering/edgesRenderer" {
  19636. import { Nullable } from "babylonjs/types";
  19637. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19639. import { Vector3 } from "babylonjs/Maths/math.vector";
  19640. import { IDisposable } from "babylonjs/scene";
  19641. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19642. import "babylonjs/Shaders/line.fragment";
  19643. import "babylonjs/Shaders/line.vertex";
  19644. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19645. module "babylonjs/Meshes/abstractMesh" {
  19646. interface AbstractMesh {
  19647. /**
  19648. * Gets the edgesRenderer associated with the mesh
  19649. */
  19650. edgesRenderer: Nullable<EdgesRenderer>;
  19651. }
  19652. }
  19653. module "babylonjs/Meshes/linesMesh" {
  19654. interface LinesMesh {
  19655. /**
  19656. * Enables the edge rendering mode on the mesh.
  19657. * This mode makes the mesh edges visible
  19658. * @param epsilon defines the maximal distance between two angles to detect a face
  19659. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19660. * @returns the currentAbstractMesh
  19661. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19662. */
  19663. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19664. }
  19665. }
  19666. module "babylonjs/Meshes/linesMesh" {
  19667. interface InstancedLinesMesh {
  19668. /**
  19669. * Enables the edge rendering mode on the mesh.
  19670. * This mode makes the mesh edges visible
  19671. * @param epsilon defines the maximal distance between two angles to detect a face
  19672. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19673. * @returns the current InstancedLinesMesh
  19674. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19675. */
  19676. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19677. }
  19678. }
  19679. /**
  19680. * Defines the minimum contract an Edges renderer should follow.
  19681. */
  19682. export interface IEdgesRenderer extends IDisposable {
  19683. /**
  19684. * Gets or sets a boolean indicating if the edgesRenderer is active
  19685. */
  19686. isEnabled: boolean;
  19687. /**
  19688. * Renders the edges of the attached mesh,
  19689. */
  19690. render(): void;
  19691. /**
  19692. * Checks wether or not the edges renderer is ready to render.
  19693. * @return true if ready, otherwise false.
  19694. */
  19695. isReady(): boolean;
  19696. }
  19697. /**
  19698. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19699. */
  19700. export class EdgesRenderer implements IEdgesRenderer {
  19701. /**
  19702. * Define the size of the edges with an orthographic camera
  19703. */
  19704. edgesWidthScalerForOrthographic: number;
  19705. /**
  19706. * Define the size of the edges with a perspective camera
  19707. */
  19708. edgesWidthScalerForPerspective: number;
  19709. protected _source: AbstractMesh;
  19710. protected _linesPositions: number[];
  19711. protected _linesNormals: number[];
  19712. protected _linesIndices: number[];
  19713. protected _epsilon: number;
  19714. protected _indicesCount: number;
  19715. protected _lineShader: ShaderMaterial;
  19716. protected _ib: DataBuffer;
  19717. protected _buffers: {
  19718. [key: string]: Nullable<VertexBuffer>;
  19719. };
  19720. protected _checkVerticesInsteadOfIndices: boolean;
  19721. private _meshRebuildObserver;
  19722. private _meshDisposeObserver;
  19723. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19724. isEnabled: boolean;
  19725. /**
  19726. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19727. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19728. * @param source Mesh used to create edges
  19729. * @param epsilon sum of angles in adjacency to check for edge
  19730. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19731. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19732. */
  19733. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19734. protected _prepareRessources(): void;
  19735. /** @hidden */
  19736. _rebuild(): void;
  19737. /**
  19738. * Releases the required resources for the edges renderer
  19739. */
  19740. dispose(): void;
  19741. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19742. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19743. /**
  19744. * Checks if the pair of p0 and p1 is en edge
  19745. * @param faceIndex
  19746. * @param edge
  19747. * @param faceNormals
  19748. * @param p0
  19749. * @param p1
  19750. * @private
  19751. */
  19752. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19753. /**
  19754. * push line into the position, normal and index buffer
  19755. * @protected
  19756. */
  19757. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19758. /**
  19759. * Generates lines edges from adjacencjes
  19760. * @private
  19761. */
  19762. _generateEdgesLines(): void;
  19763. /**
  19764. * Checks wether or not the edges renderer is ready to render.
  19765. * @return true if ready, otherwise false.
  19766. */
  19767. isReady(): boolean;
  19768. /**
  19769. * Renders the edges of the attached mesh,
  19770. */
  19771. render(): void;
  19772. }
  19773. /**
  19774. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19775. */
  19776. export class LineEdgesRenderer extends EdgesRenderer {
  19777. /**
  19778. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19779. * @param source LineMesh used to generate edges
  19780. * @param epsilon not important (specified angle for edge detection)
  19781. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19782. */
  19783. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19784. /**
  19785. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19786. */
  19787. _generateEdgesLines(): void;
  19788. }
  19789. }
  19790. declare module "babylonjs/Rendering/renderingGroup" {
  19791. import { SmartArray } from "babylonjs/Misc/smartArray";
  19792. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19794. import { Nullable } from "babylonjs/types";
  19795. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19796. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  19797. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19798. import { Material } from "babylonjs/Materials/material";
  19799. import { Scene } from "babylonjs/scene";
  19800. /**
  19801. * This represents the object necessary to create a rendering group.
  19802. * This is exclusively used and created by the rendering manager.
  19803. * To modify the behavior, you use the available helpers in your scene or meshes.
  19804. * @hidden
  19805. */
  19806. export class RenderingGroup {
  19807. index: number;
  19808. private static _zeroVector;
  19809. private _scene;
  19810. private _opaqueSubMeshes;
  19811. private _transparentSubMeshes;
  19812. private _alphaTestSubMeshes;
  19813. private _depthOnlySubMeshes;
  19814. private _particleSystems;
  19815. private _spriteManagers;
  19816. private _opaqueSortCompareFn;
  19817. private _alphaTestSortCompareFn;
  19818. private _transparentSortCompareFn;
  19819. private _renderOpaque;
  19820. private _renderAlphaTest;
  19821. private _renderTransparent;
  19822. /** @hidden */
  19823. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19824. onBeforeTransparentRendering: () => void;
  19825. /**
  19826. * Set the opaque sort comparison function.
  19827. * If null the sub meshes will be render in the order they were created
  19828. */
  19829. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19830. /**
  19831. * Set the alpha test sort comparison function.
  19832. * If null the sub meshes will be render in the order they were created
  19833. */
  19834. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19835. /**
  19836. * Set the transparent sort comparison function.
  19837. * If null the sub meshes will be render in the order they were created
  19838. */
  19839. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19840. /**
  19841. * Creates a new rendering group.
  19842. * @param index The rendering group index
  19843. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19844. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19845. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19846. */
  19847. 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>);
  19848. /**
  19849. * Render all the sub meshes contained in the group.
  19850. * @param customRenderFunction Used to override the default render behaviour of the group.
  19851. * @returns true if rendered some submeshes.
  19852. */
  19853. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19854. /**
  19855. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19856. * @param subMeshes The submeshes to render
  19857. */
  19858. private renderOpaqueSorted;
  19859. /**
  19860. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19861. * @param subMeshes The submeshes to render
  19862. */
  19863. private renderAlphaTestSorted;
  19864. /**
  19865. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19866. * @param subMeshes The submeshes to render
  19867. */
  19868. private renderTransparentSorted;
  19869. /**
  19870. * Renders the submeshes in a specified order.
  19871. * @param subMeshes The submeshes to sort before render
  19872. * @param sortCompareFn The comparison function use to sort
  19873. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19874. * @param transparent Specifies to activate blending if true
  19875. */
  19876. private static renderSorted;
  19877. /**
  19878. * Renders the submeshes in the order they were dispatched (no sort applied).
  19879. * @param subMeshes The submeshes to render
  19880. */
  19881. private static renderUnsorted;
  19882. /**
  19883. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19884. * are rendered back to front if in the same alpha index.
  19885. *
  19886. * @param a The first submesh
  19887. * @param b The second submesh
  19888. * @returns The result of the comparison
  19889. */
  19890. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19891. /**
  19892. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19893. * are rendered back to front.
  19894. *
  19895. * @param a The first submesh
  19896. * @param b The second submesh
  19897. * @returns The result of the comparison
  19898. */
  19899. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19900. /**
  19901. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19902. * are rendered front to back (prevent overdraw).
  19903. *
  19904. * @param a The first submesh
  19905. * @param b The second submesh
  19906. * @returns The result of the comparison
  19907. */
  19908. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19909. /**
  19910. * Resets the different lists of submeshes to prepare a new frame.
  19911. */
  19912. prepare(): void;
  19913. dispose(): void;
  19914. /**
  19915. * Inserts the submesh in its correct queue depending on its material.
  19916. * @param subMesh The submesh to dispatch
  19917. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19918. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19919. */
  19920. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19921. dispatchSprites(spriteManager: ISpriteManager): void;
  19922. dispatchParticles(particleSystem: IParticleSystem): void;
  19923. private _renderParticles;
  19924. private _renderSprites;
  19925. }
  19926. }
  19927. declare module "babylonjs/Rendering/renderingManager" {
  19928. import { Nullable } from "babylonjs/types";
  19929. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19930. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19931. import { SmartArray } from "babylonjs/Misc/smartArray";
  19932. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19933. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19934. import { Material } from "babylonjs/Materials/material";
  19935. import { Scene } from "babylonjs/scene";
  19936. import { Camera } from "babylonjs/Cameras/camera";
  19937. /**
  19938. * Interface describing the different options available in the rendering manager
  19939. * regarding Auto Clear between groups.
  19940. */
  19941. export interface IRenderingManagerAutoClearSetup {
  19942. /**
  19943. * Defines whether or not autoclear is enable.
  19944. */
  19945. autoClear: boolean;
  19946. /**
  19947. * Defines whether or not to autoclear the depth buffer.
  19948. */
  19949. depth: boolean;
  19950. /**
  19951. * Defines whether or not to autoclear the stencil buffer.
  19952. */
  19953. stencil: boolean;
  19954. }
  19955. /**
  19956. * This class is used by the onRenderingGroupObservable
  19957. */
  19958. export class RenderingGroupInfo {
  19959. /**
  19960. * The Scene that being rendered
  19961. */
  19962. scene: Scene;
  19963. /**
  19964. * The camera currently used for the rendering pass
  19965. */
  19966. camera: Nullable<Camera>;
  19967. /**
  19968. * The ID of the renderingGroup being processed
  19969. */
  19970. renderingGroupId: number;
  19971. }
  19972. /**
  19973. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19974. * It is enable to manage the different groups as well as the different necessary sort functions.
  19975. * This should not be used directly aside of the few static configurations
  19976. */
  19977. export class RenderingManager {
  19978. /**
  19979. * The max id used for rendering groups (not included)
  19980. */
  19981. static MAX_RENDERINGGROUPS: number;
  19982. /**
  19983. * The min id used for rendering groups (included)
  19984. */
  19985. static MIN_RENDERINGGROUPS: number;
  19986. /**
  19987. * Used to globally prevent autoclearing scenes.
  19988. */
  19989. static AUTOCLEAR: boolean;
  19990. /**
  19991. * @hidden
  19992. */
  19993. _useSceneAutoClearSetup: boolean;
  19994. private _scene;
  19995. private _renderingGroups;
  19996. private _depthStencilBufferAlreadyCleaned;
  19997. private _autoClearDepthStencil;
  19998. private _customOpaqueSortCompareFn;
  19999. private _customAlphaTestSortCompareFn;
  20000. private _customTransparentSortCompareFn;
  20001. private _renderingGroupInfo;
  20002. /**
  20003. * Instantiates a new rendering group for a particular scene
  20004. * @param scene Defines the scene the groups belongs to
  20005. */
  20006. constructor(scene: Scene);
  20007. private _clearDepthStencilBuffer;
  20008. /**
  20009. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20010. * @hidden
  20011. */
  20012. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20013. /**
  20014. * Resets the different information of the group to prepare a new frame
  20015. * @hidden
  20016. */
  20017. reset(): void;
  20018. /**
  20019. * Dispose and release the group and its associated resources.
  20020. * @hidden
  20021. */
  20022. dispose(): void;
  20023. /**
  20024. * Clear the info related to rendering groups preventing retention points during dispose.
  20025. */
  20026. freeRenderingGroups(): void;
  20027. private _prepareRenderingGroup;
  20028. /**
  20029. * Add a sprite manager to the rendering manager in order to render it this frame.
  20030. * @param spriteManager Define the sprite manager to render
  20031. */
  20032. dispatchSprites(spriteManager: ISpriteManager): void;
  20033. /**
  20034. * Add a particle system to the rendering manager in order to render it this frame.
  20035. * @param particleSystem Define the particle system to render
  20036. */
  20037. dispatchParticles(particleSystem: IParticleSystem): void;
  20038. /**
  20039. * Add a submesh to the manager in order to render it this frame
  20040. * @param subMesh The submesh to dispatch
  20041. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20042. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20043. */
  20044. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20045. /**
  20046. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20047. * This allowed control for front to back rendering or reversly depending of the special needs.
  20048. *
  20049. * @param renderingGroupId The rendering group id corresponding to its index
  20050. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20051. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20052. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20053. */
  20054. 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;
  20055. /**
  20056. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20057. *
  20058. * @param renderingGroupId The rendering group id corresponding to its index
  20059. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20060. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20061. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20062. */
  20063. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20064. /**
  20065. * Gets the current auto clear configuration for one rendering group of the rendering
  20066. * manager.
  20067. * @param index the rendering group index to get the information for
  20068. * @returns The auto clear setup for the requested rendering group
  20069. */
  20070. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20071. }
  20072. }
  20073. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20074. import { Observable } from "babylonjs/Misc/observable";
  20075. import { SmartArray } from "babylonjs/Misc/smartArray";
  20076. import { Nullable } from "babylonjs/types";
  20077. import { Camera } from "babylonjs/Cameras/camera";
  20078. import { Scene } from "babylonjs/scene";
  20079. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20080. import { Color4 } from "babylonjs/Maths/math.color";
  20081. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20082. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20083. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20084. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20085. import { Texture } from "babylonjs/Materials/Textures/texture";
  20086. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20087. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20088. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20089. import { Engine } from "babylonjs/Engines/engine";
  20090. /**
  20091. * This Helps creating a texture that will be created from a camera in your scene.
  20092. * It is basically a dynamic texture that could be used to create special effects for instance.
  20093. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20094. */
  20095. export class RenderTargetTexture extends Texture {
  20096. isCube: boolean;
  20097. /**
  20098. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20099. */
  20100. static readonly REFRESHRATE_RENDER_ONCE: number;
  20101. /**
  20102. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20103. */
  20104. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20105. /**
  20106. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20107. * the central point of your effect and can save a lot of performances.
  20108. */
  20109. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20110. /**
  20111. * Use this predicate to dynamically define the list of mesh you want to render.
  20112. * If set, the renderList property will be overwritten.
  20113. */
  20114. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20115. private _renderList;
  20116. /**
  20117. * Use this list to define the list of mesh you want to render.
  20118. */
  20119. renderList: Nullable<Array<AbstractMesh>>;
  20120. private _hookArray;
  20121. /**
  20122. * Define if particles should be rendered in your texture.
  20123. */
  20124. renderParticles: boolean;
  20125. /**
  20126. * Define if sprites should be rendered in your texture.
  20127. */
  20128. renderSprites: boolean;
  20129. /**
  20130. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20131. */
  20132. coordinatesMode: number;
  20133. /**
  20134. * Define the camera used to render the texture.
  20135. */
  20136. activeCamera: Nullable<Camera>;
  20137. /**
  20138. * Override the render function of the texture with your own one.
  20139. */
  20140. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20141. /**
  20142. * Define if camera post processes should be use while rendering the texture.
  20143. */
  20144. useCameraPostProcesses: boolean;
  20145. /**
  20146. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20147. */
  20148. ignoreCameraViewport: boolean;
  20149. private _postProcessManager;
  20150. private _postProcesses;
  20151. private _resizeObserver;
  20152. /**
  20153. * An event triggered when the texture is unbind.
  20154. */
  20155. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20156. /**
  20157. * An event triggered when the texture is unbind.
  20158. */
  20159. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20160. private _onAfterUnbindObserver;
  20161. /**
  20162. * Set a after unbind callback in the texture.
  20163. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20164. */
  20165. onAfterUnbind: () => void;
  20166. /**
  20167. * An event triggered before rendering the texture
  20168. */
  20169. onBeforeRenderObservable: Observable<number>;
  20170. private _onBeforeRenderObserver;
  20171. /**
  20172. * Set a before render callback in the texture.
  20173. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20174. */
  20175. onBeforeRender: (faceIndex: number) => void;
  20176. /**
  20177. * An event triggered after rendering the texture
  20178. */
  20179. onAfterRenderObservable: Observable<number>;
  20180. private _onAfterRenderObserver;
  20181. /**
  20182. * Set a after render callback in the texture.
  20183. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20184. */
  20185. onAfterRender: (faceIndex: number) => void;
  20186. /**
  20187. * An event triggered after the texture clear
  20188. */
  20189. onClearObservable: Observable<Engine>;
  20190. private _onClearObserver;
  20191. /**
  20192. * Set a clear callback in the texture.
  20193. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20194. */
  20195. onClear: (Engine: Engine) => void;
  20196. /**
  20197. * Define the clear color of the Render Target if it should be different from the scene.
  20198. */
  20199. clearColor: Color4;
  20200. protected _size: number | {
  20201. width: number;
  20202. height: number;
  20203. };
  20204. protected _initialSizeParameter: number | {
  20205. width: number;
  20206. height: number;
  20207. } | {
  20208. ratio: number;
  20209. };
  20210. protected _sizeRatio: Nullable<number>;
  20211. /** @hidden */
  20212. _generateMipMaps: boolean;
  20213. protected _renderingManager: RenderingManager;
  20214. /** @hidden */
  20215. _waitingRenderList: string[];
  20216. protected _doNotChangeAspectRatio: boolean;
  20217. protected _currentRefreshId: number;
  20218. protected _refreshRate: number;
  20219. protected _textureMatrix: Matrix;
  20220. protected _samples: number;
  20221. protected _renderTargetOptions: RenderTargetCreationOptions;
  20222. /**
  20223. * Gets render target creation options that were used.
  20224. */
  20225. readonly renderTargetOptions: RenderTargetCreationOptions;
  20226. protected _engine: Engine;
  20227. protected _onRatioRescale(): void;
  20228. /**
  20229. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20230. * It must define where the camera used to render the texture is set
  20231. */
  20232. boundingBoxPosition: Vector3;
  20233. private _boundingBoxSize;
  20234. /**
  20235. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20236. * When defined, the cubemap will switch to local mode
  20237. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20238. * @example https://www.babylonjs-playground.com/#RNASML
  20239. */
  20240. boundingBoxSize: Vector3;
  20241. /**
  20242. * In case the RTT has been created with a depth texture, get the associated
  20243. * depth texture.
  20244. * Otherwise, return null.
  20245. */
  20246. depthStencilTexture: Nullable<InternalTexture>;
  20247. /**
  20248. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20249. * or used a shadow, depth texture...
  20250. * @param name The friendly name of the texture
  20251. * @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)
  20252. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20253. * @param generateMipMaps True if mip maps need to be generated after render.
  20254. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20255. * @param type The type of the buffer in the RTT (int, half float, float...)
  20256. * @param isCube True if a cube texture needs to be created
  20257. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20258. * @param generateDepthBuffer True to generate a depth buffer
  20259. * @param generateStencilBuffer True to generate a stencil buffer
  20260. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20261. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20262. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20263. */
  20264. constructor(name: string, size: number | {
  20265. width: number;
  20266. height: number;
  20267. } | {
  20268. ratio: number;
  20269. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20270. /**
  20271. * Creates a depth stencil texture.
  20272. * This is only available in WebGL 2 or with the depth texture extension available.
  20273. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20274. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20275. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20276. */
  20277. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20278. private _processSizeParameter;
  20279. /**
  20280. * Define the number of samples to use in case of MSAA.
  20281. * It defaults to one meaning no MSAA has been enabled.
  20282. */
  20283. samples: number;
  20284. /**
  20285. * Resets the refresh counter of the texture and start bak from scratch.
  20286. * Could be useful to regenerate the texture if it is setup to render only once.
  20287. */
  20288. resetRefreshCounter(): void;
  20289. /**
  20290. * Define the refresh rate of the texture or the rendering frequency.
  20291. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20292. */
  20293. refreshRate: number;
  20294. /**
  20295. * Adds a post process to the render target rendering passes.
  20296. * @param postProcess define the post process to add
  20297. */
  20298. addPostProcess(postProcess: PostProcess): void;
  20299. /**
  20300. * Clear all the post processes attached to the render target
  20301. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20302. */
  20303. clearPostProcesses(dispose?: boolean): void;
  20304. /**
  20305. * Remove one of the post process from the list of attached post processes to the texture
  20306. * @param postProcess define the post process to remove from the list
  20307. */
  20308. removePostProcess(postProcess: PostProcess): void;
  20309. /** @hidden */
  20310. _shouldRender(): boolean;
  20311. /**
  20312. * Gets the actual render size of the texture.
  20313. * @returns the width of the render size
  20314. */
  20315. getRenderSize(): number;
  20316. /**
  20317. * Gets the actual render width of the texture.
  20318. * @returns the width of the render size
  20319. */
  20320. getRenderWidth(): number;
  20321. /**
  20322. * Gets the actual render height of the texture.
  20323. * @returns the height of the render size
  20324. */
  20325. getRenderHeight(): number;
  20326. /**
  20327. * Get if the texture can be rescaled or not.
  20328. */
  20329. readonly canRescale: boolean;
  20330. /**
  20331. * Resize the texture using a ratio.
  20332. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20333. */
  20334. scale(ratio: number): void;
  20335. /**
  20336. * Get the texture reflection matrix used to rotate/transform the reflection.
  20337. * @returns the reflection matrix
  20338. */
  20339. getReflectionTextureMatrix(): Matrix;
  20340. /**
  20341. * Resize the texture to a new desired size.
  20342. * Be carrefull as it will recreate all the data in the new texture.
  20343. * @param size Define the new size. It can be:
  20344. * - a number for squared texture,
  20345. * - an object containing { width: number, height: number }
  20346. * - or an object containing a ratio { ratio: number }
  20347. */
  20348. resize(size: number | {
  20349. width: number;
  20350. height: number;
  20351. } | {
  20352. ratio: number;
  20353. }): void;
  20354. /**
  20355. * Renders all the objects from the render list into the texture.
  20356. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20357. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20358. */
  20359. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20360. private _bestReflectionRenderTargetDimension;
  20361. /**
  20362. * @hidden
  20363. * @param faceIndex face index to bind to if this is a cubetexture
  20364. */
  20365. _bindFrameBuffer(faceIndex?: number): void;
  20366. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20367. private renderToTarget;
  20368. /**
  20369. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20370. * This allowed control for front to back rendering or reversly depending of the special needs.
  20371. *
  20372. * @param renderingGroupId The rendering group id corresponding to its index
  20373. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20374. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20375. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20376. */
  20377. 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;
  20378. /**
  20379. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20380. *
  20381. * @param renderingGroupId The rendering group id corresponding to its index
  20382. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20383. */
  20384. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20385. /**
  20386. * Clones the texture.
  20387. * @returns the cloned texture
  20388. */
  20389. clone(): RenderTargetTexture;
  20390. /**
  20391. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20392. * @returns The JSON representation of the texture
  20393. */
  20394. serialize(): any;
  20395. /**
  20396. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20397. */
  20398. disposeFramebufferObjects(): void;
  20399. /**
  20400. * Dispose the texture and release its associated resources.
  20401. */
  20402. dispose(): void;
  20403. /** @hidden */
  20404. _rebuild(): void;
  20405. /**
  20406. * Clear the info related to rendering groups preventing retention point in material dispose.
  20407. */
  20408. freeRenderingGroups(): void;
  20409. /**
  20410. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20411. * @returns the view count
  20412. */
  20413. getViewCount(): number;
  20414. }
  20415. }
  20416. declare module "babylonjs/Materials/material" {
  20417. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20418. import { SmartArray } from "babylonjs/Misc/smartArray";
  20419. import { Observable } from "babylonjs/Misc/observable";
  20420. import { Nullable } from "babylonjs/types";
  20421. import { Scene } from "babylonjs/scene";
  20422. import { Matrix } from "babylonjs/Maths/math.vector";
  20423. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20424. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20425. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20426. import { Effect } from "babylonjs/Materials/effect";
  20427. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20428. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20429. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20430. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20431. import { Mesh } from "babylonjs/Meshes/mesh";
  20432. import { Animation } from "babylonjs/Animations/animation";
  20433. /**
  20434. * Base class for the main features of a material in Babylon.js
  20435. */
  20436. export class Material implements IAnimatable {
  20437. /**
  20438. * Returns the triangle fill mode
  20439. */
  20440. static readonly TriangleFillMode: number;
  20441. /**
  20442. * Returns the wireframe mode
  20443. */
  20444. static readonly WireFrameFillMode: number;
  20445. /**
  20446. * Returns the point fill mode
  20447. */
  20448. static readonly PointFillMode: number;
  20449. /**
  20450. * Returns the point list draw mode
  20451. */
  20452. static readonly PointListDrawMode: number;
  20453. /**
  20454. * Returns the line list draw mode
  20455. */
  20456. static readonly LineListDrawMode: number;
  20457. /**
  20458. * Returns the line loop draw mode
  20459. */
  20460. static readonly LineLoopDrawMode: number;
  20461. /**
  20462. * Returns the line strip draw mode
  20463. */
  20464. static readonly LineStripDrawMode: number;
  20465. /**
  20466. * Returns the triangle strip draw mode
  20467. */
  20468. static readonly TriangleStripDrawMode: number;
  20469. /**
  20470. * Returns the triangle fan draw mode
  20471. */
  20472. static readonly TriangleFanDrawMode: number;
  20473. /**
  20474. * Stores the clock-wise side orientation
  20475. */
  20476. static readonly ClockWiseSideOrientation: number;
  20477. /**
  20478. * Stores the counter clock-wise side orientation
  20479. */
  20480. static readonly CounterClockWiseSideOrientation: number;
  20481. /**
  20482. * The dirty texture flag value
  20483. */
  20484. static readonly TextureDirtyFlag: number;
  20485. /**
  20486. * The dirty light flag value
  20487. */
  20488. static readonly LightDirtyFlag: number;
  20489. /**
  20490. * The dirty fresnel flag value
  20491. */
  20492. static readonly FresnelDirtyFlag: number;
  20493. /**
  20494. * The dirty attribute flag value
  20495. */
  20496. static readonly AttributesDirtyFlag: number;
  20497. /**
  20498. * The dirty misc flag value
  20499. */
  20500. static readonly MiscDirtyFlag: number;
  20501. /**
  20502. * The all dirty flag value
  20503. */
  20504. static readonly AllDirtyFlag: number;
  20505. /**
  20506. * The ID of the material
  20507. */
  20508. id: string;
  20509. /**
  20510. * Gets or sets the unique id of the material
  20511. */
  20512. uniqueId: number;
  20513. /**
  20514. * The name of the material
  20515. */
  20516. name: string;
  20517. /**
  20518. * Gets or sets user defined metadata
  20519. */
  20520. metadata: any;
  20521. /**
  20522. * For internal use only. Please do not use.
  20523. */
  20524. reservedDataStore: any;
  20525. /**
  20526. * Specifies if the ready state should be checked on each call
  20527. */
  20528. checkReadyOnEveryCall: boolean;
  20529. /**
  20530. * Specifies if the ready state should be checked once
  20531. */
  20532. checkReadyOnlyOnce: boolean;
  20533. /**
  20534. * The state of the material
  20535. */
  20536. state: string;
  20537. /**
  20538. * The alpha value of the material
  20539. */
  20540. protected _alpha: number;
  20541. /**
  20542. * List of inspectable custom properties (used by the Inspector)
  20543. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20544. */
  20545. inspectableCustomProperties: IInspectable[];
  20546. /**
  20547. * Sets the alpha value of the material
  20548. */
  20549. /**
  20550. * Gets the alpha value of the material
  20551. */
  20552. alpha: number;
  20553. /**
  20554. * Specifies if back face culling is enabled
  20555. */
  20556. protected _backFaceCulling: boolean;
  20557. /**
  20558. * Sets the back-face culling state
  20559. */
  20560. /**
  20561. * Gets the back-face culling state
  20562. */
  20563. backFaceCulling: boolean;
  20564. /**
  20565. * Stores the value for side orientation
  20566. */
  20567. sideOrientation: number;
  20568. /**
  20569. * Callback triggered when the material is compiled
  20570. */
  20571. onCompiled: Nullable<(effect: Effect) => void>;
  20572. /**
  20573. * Callback triggered when an error occurs
  20574. */
  20575. onError: Nullable<(effect: Effect, errors: string) => void>;
  20576. /**
  20577. * Callback triggered to get the render target textures
  20578. */
  20579. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20580. /**
  20581. * Gets a boolean indicating that current material needs to register RTT
  20582. */
  20583. readonly hasRenderTargetTextures: boolean;
  20584. /**
  20585. * Specifies if the material should be serialized
  20586. */
  20587. doNotSerialize: boolean;
  20588. /**
  20589. * @hidden
  20590. */
  20591. _storeEffectOnSubMeshes: boolean;
  20592. /**
  20593. * Stores the animations for the material
  20594. */
  20595. animations: Nullable<Array<Animation>>;
  20596. /**
  20597. * An event triggered when the material is disposed
  20598. */
  20599. onDisposeObservable: Observable<Material>;
  20600. /**
  20601. * An observer which watches for dispose events
  20602. */
  20603. private _onDisposeObserver;
  20604. private _onUnBindObservable;
  20605. /**
  20606. * Called during a dispose event
  20607. */
  20608. onDispose: () => void;
  20609. private _onBindObservable;
  20610. /**
  20611. * An event triggered when the material is bound
  20612. */
  20613. readonly onBindObservable: Observable<AbstractMesh>;
  20614. /**
  20615. * An observer which watches for bind events
  20616. */
  20617. private _onBindObserver;
  20618. /**
  20619. * Called during a bind event
  20620. */
  20621. onBind: (Mesh: AbstractMesh) => void;
  20622. /**
  20623. * An event triggered when the material is unbound
  20624. */
  20625. readonly onUnBindObservable: Observable<Material>;
  20626. /**
  20627. * Stores the value of the alpha mode
  20628. */
  20629. private _alphaMode;
  20630. /**
  20631. * Sets the value of the alpha mode.
  20632. *
  20633. * | Value | Type | Description |
  20634. * | --- | --- | --- |
  20635. * | 0 | ALPHA_DISABLE | |
  20636. * | 1 | ALPHA_ADD | |
  20637. * | 2 | ALPHA_COMBINE | |
  20638. * | 3 | ALPHA_SUBTRACT | |
  20639. * | 4 | ALPHA_MULTIPLY | |
  20640. * | 5 | ALPHA_MAXIMIZED | |
  20641. * | 6 | ALPHA_ONEONE | |
  20642. * | 7 | ALPHA_PREMULTIPLIED | |
  20643. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20644. * | 9 | ALPHA_INTERPOLATE | |
  20645. * | 10 | ALPHA_SCREENMODE | |
  20646. *
  20647. */
  20648. /**
  20649. * Gets the value of the alpha mode
  20650. */
  20651. alphaMode: number;
  20652. /**
  20653. * Stores the state of the need depth pre-pass value
  20654. */
  20655. private _needDepthPrePass;
  20656. /**
  20657. * Sets the need depth pre-pass value
  20658. */
  20659. /**
  20660. * Gets the depth pre-pass value
  20661. */
  20662. needDepthPrePass: boolean;
  20663. /**
  20664. * Specifies if depth writing should be disabled
  20665. */
  20666. disableDepthWrite: boolean;
  20667. /**
  20668. * Specifies if depth writing should be forced
  20669. */
  20670. forceDepthWrite: boolean;
  20671. /**
  20672. * Specifies if there should be a separate pass for culling
  20673. */
  20674. separateCullingPass: boolean;
  20675. /**
  20676. * Stores the state specifing if fog should be enabled
  20677. */
  20678. private _fogEnabled;
  20679. /**
  20680. * Sets the state for enabling fog
  20681. */
  20682. /**
  20683. * Gets the value of the fog enabled state
  20684. */
  20685. fogEnabled: boolean;
  20686. /**
  20687. * Stores the size of points
  20688. */
  20689. pointSize: number;
  20690. /**
  20691. * Stores the z offset value
  20692. */
  20693. zOffset: number;
  20694. /**
  20695. * Gets a value specifying if wireframe mode is enabled
  20696. */
  20697. /**
  20698. * Sets the state of wireframe mode
  20699. */
  20700. wireframe: boolean;
  20701. /**
  20702. * Gets the value specifying if point clouds are enabled
  20703. */
  20704. /**
  20705. * Sets the state of point cloud mode
  20706. */
  20707. pointsCloud: boolean;
  20708. /**
  20709. * Gets the material fill mode
  20710. */
  20711. /**
  20712. * Sets the material fill mode
  20713. */
  20714. fillMode: number;
  20715. /**
  20716. * @hidden
  20717. * Stores the effects for the material
  20718. */
  20719. _effect: Nullable<Effect>;
  20720. /**
  20721. * @hidden
  20722. * Specifies if the material was previously ready
  20723. */
  20724. _wasPreviouslyReady: boolean;
  20725. /**
  20726. * Specifies if uniform buffers should be used
  20727. */
  20728. private _useUBO;
  20729. /**
  20730. * Stores a reference to the scene
  20731. */
  20732. private _scene;
  20733. /**
  20734. * Stores the fill mode state
  20735. */
  20736. private _fillMode;
  20737. /**
  20738. * Specifies if the depth write state should be cached
  20739. */
  20740. private _cachedDepthWriteState;
  20741. /**
  20742. * Stores the uniform buffer
  20743. */
  20744. protected _uniformBuffer: UniformBuffer;
  20745. /** @hidden */
  20746. _indexInSceneMaterialArray: number;
  20747. /** @hidden */
  20748. meshMap: Nullable<{
  20749. [id: string]: AbstractMesh | undefined;
  20750. }>;
  20751. /**
  20752. * Creates a material instance
  20753. * @param name defines the name of the material
  20754. * @param scene defines the scene to reference
  20755. * @param doNotAdd specifies if the material should be added to the scene
  20756. */
  20757. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20758. /**
  20759. * Returns a string representation of the current material
  20760. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20761. * @returns a string with material information
  20762. */
  20763. toString(fullDetails?: boolean): string;
  20764. /**
  20765. * Gets the class name of the material
  20766. * @returns a string with the class name of the material
  20767. */
  20768. getClassName(): string;
  20769. /**
  20770. * Specifies if updates for the material been locked
  20771. */
  20772. readonly isFrozen: boolean;
  20773. /**
  20774. * Locks updates for the material
  20775. */
  20776. freeze(): void;
  20777. /**
  20778. * Unlocks updates for the material
  20779. */
  20780. unfreeze(): void;
  20781. /**
  20782. * Specifies if the material is ready to be used
  20783. * @param mesh defines the mesh to check
  20784. * @param useInstances specifies if instances should be used
  20785. * @returns a boolean indicating if the material is ready to be used
  20786. */
  20787. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20788. /**
  20789. * Specifies that the submesh is ready to be used
  20790. * @param mesh defines the mesh to check
  20791. * @param subMesh defines which submesh to check
  20792. * @param useInstances specifies that instances should be used
  20793. * @returns a boolean indicating that the submesh is ready or not
  20794. */
  20795. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20796. /**
  20797. * Returns the material effect
  20798. * @returns the effect associated with the material
  20799. */
  20800. getEffect(): Nullable<Effect>;
  20801. /**
  20802. * Returns the current scene
  20803. * @returns a Scene
  20804. */
  20805. getScene(): Scene;
  20806. /**
  20807. * Specifies if the material will require alpha blending
  20808. * @returns a boolean specifying if alpha blending is needed
  20809. */
  20810. needAlphaBlending(): boolean;
  20811. /**
  20812. * Specifies if the mesh will require alpha blending
  20813. * @param mesh defines the mesh to check
  20814. * @returns a boolean specifying if alpha blending is needed for the mesh
  20815. */
  20816. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20817. /**
  20818. * Specifies if this material should be rendered in alpha test mode
  20819. * @returns a boolean specifying if an alpha test is needed.
  20820. */
  20821. needAlphaTesting(): boolean;
  20822. /**
  20823. * Gets the texture used for the alpha test
  20824. * @returns the texture to use for alpha testing
  20825. */
  20826. getAlphaTestTexture(): Nullable<BaseTexture>;
  20827. /**
  20828. * Marks the material to indicate that it needs to be re-calculated
  20829. */
  20830. markDirty(): void;
  20831. /** @hidden */
  20832. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20833. /**
  20834. * Binds the material to the mesh
  20835. * @param world defines the world transformation matrix
  20836. * @param mesh defines the mesh to bind the material to
  20837. */
  20838. bind(world: Matrix, mesh?: Mesh): void;
  20839. /**
  20840. * Binds the submesh to the material
  20841. * @param world defines the world transformation matrix
  20842. * @param mesh defines the mesh containing the submesh
  20843. * @param subMesh defines the submesh to bind the material to
  20844. */
  20845. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20846. /**
  20847. * Binds the world matrix to the material
  20848. * @param world defines the world transformation matrix
  20849. */
  20850. bindOnlyWorldMatrix(world: Matrix): void;
  20851. /**
  20852. * Binds the scene's uniform buffer to the effect.
  20853. * @param effect defines the effect to bind to the scene uniform buffer
  20854. * @param sceneUbo defines the uniform buffer storing scene data
  20855. */
  20856. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20857. /**
  20858. * Binds the view matrix to the effect
  20859. * @param effect defines the effect to bind the view matrix to
  20860. */
  20861. bindView(effect: Effect): void;
  20862. /**
  20863. * Binds the view projection matrix to the effect
  20864. * @param effect defines the effect to bind the view projection matrix to
  20865. */
  20866. bindViewProjection(effect: Effect): void;
  20867. /**
  20868. * Specifies if material alpha testing should be turned on for the mesh
  20869. * @param mesh defines the mesh to check
  20870. */
  20871. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20872. /**
  20873. * Processes to execute after binding the material to a mesh
  20874. * @param mesh defines the rendered mesh
  20875. */
  20876. protected _afterBind(mesh?: Mesh): void;
  20877. /**
  20878. * Unbinds the material from the mesh
  20879. */
  20880. unbind(): void;
  20881. /**
  20882. * Gets the active textures from the material
  20883. * @returns an array of textures
  20884. */
  20885. getActiveTextures(): BaseTexture[];
  20886. /**
  20887. * Specifies if the material uses a texture
  20888. * @param texture defines the texture to check against the material
  20889. * @returns a boolean specifying if the material uses the texture
  20890. */
  20891. hasTexture(texture: BaseTexture): boolean;
  20892. /**
  20893. * Makes a duplicate of the material, and gives it a new name
  20894. * @param name defines the new name for the duplicated material
  20895. * @returns the cloned material
  20896. */
  20897. clone(name: string): Nullable<Material>;
  20898. /**
  20899. * Gets the meshes bound to the material
  20900. * @returns an array of meshes bound to the material
  20901. */
  20902. getBindedMeshes(): AbstractMesh[];
  20903. /**
  20904. * Force shader compilation
  20905. * @param mesh defines the mesh associated with this material
  20906. * @param onCompiled defines a function to execute once the material is compiled
  20907. * @param options defines the options to configure the compilation
  20908. */
  20909. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20910. clipPlane: boolean;
  20911. }>): void;
  20912. /**
  20913. * Force shader compilation
  20914. * @param mesh defines the mesh that will use this material
  20915. * @param options defines additional options for compiling the shaders
  20916. * @returns a promise that resolves when the compilation completes
  20917. */
  20918. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20919. clipPlane: boolean;
  20920. }>): Promise<void>;
  20921. private static readonly _AllDirtyCallBack;
  20922. private static readonly _ImageProcessingDirtyCallBack;
  20923. private static readonly _TextureDirtyCallBack;
  20924. private static readonly _FresnelDirtyCallBack;
  20925. private static readonly _MiscDirtyCallBack;
  20926. private static readonly _LightsDirtyCallBack;
  20927. private static readonly _AttributeDirtyCallBack;
  20928. private static _FresnelAndMiscDirtyCallBack;
  20929. private static _TextureAndMiscDirtyCallBack;
  20930. private static readonly _DirtyCallbackArray;
  20931. private static readonly _RunDirtyCallBacks;
  20932. /**
  20933. * Marks a define in the material to indicate that it needs to be re-computed
  20934. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20935. */
  20936. markAsDirty(flag: number): void;
  20937. /**
  20938. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20939. * @param func defines a function which checks material defines against the submeshes
  20940. */
  20941. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20942. /**
  20943. * Indicates that we need to re-calculated for all submeshes
  20944. */
  20945. protected _markAllSubMeshesAsAllDirty(): void;
  20946. /**
  20947. * Indicates that image processing needs to be re-calculated for all submeshes
  20948. */
  20949. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20950. /**
  20951. * Indicates that textures need to be re-calculated for all submeshes
  20952. */
  20953. protected _markAllSubMeshesAsTexturesDirty(): void;
  20954. /**
  20955. * Indicates that fresnel needs to be re-calculated for all submeshes
  20956. */
  20957. protected _markAllSubMeshesAsFresnelDirty(): void;
  20958. /**
  20959. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20960. */
  20961. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20962. /**
  20963. * Indicates that lights need to be re-calculated for all submeshes
  20964. */
  20965. protected _markAllSubMeshesAsLightsDirty(): void;
  20966. /**
  20967. * Indicates that attributes need to be re-calculated for all submeshes
  20968. */
  20969. protected _markAllSubMeshesAsAttributesDirty(): void;
  20970. /**
  20971. * Indicates that misc needs to be re-calculated for all submeshes
  20972. */
  20973. protected _markAllSubMeshesAsMiscDirty(): void;
  20974. /**
  20975. * Indicates that textures and misc need to be re-calculated for all submeshes
  20976. */
  20977. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20978. /**
  20979. * Disposes the material
  20980. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20981. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20982. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20983. */
  20984. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20985. /** @hidden */
  20986. private releaseVertexArrayObject;
  20987. /**
  20988. * Serializes this material
  20989. * @returns the serialized material object
  20990. */
  20991. serialize(): any;
  20992. /**
  20993. * Creates a material from parsed material data
  20994. * @param parsedMaterial defines parsed material data
  20995. * @param scene defines the hosting scene
  20996. * @param rootUrl defines the root URL to use to load textures
  20997. * @returns a new material
  20998. */
  20999. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21000. }
  21001. }
  21002. declare module "babylonjs/Materials/multiMaterial" {
  21003. import { Nullable } from "babylonjs/types";
  21004. import { Scene } from "babylonjs/scene";
  21005. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21006. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21007. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21008. import { Material } from "babylonjs/Materials/material";
  21009. /**
  21010. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21011. * separate meshes. This can be use to improve performances.
  21012. * @see http://doc.babylonjs.com/how_to/multi_materials
  21013. */
  21014. export class MultiMaterial extends Material {
  21015. private _subMaterials;
  21016. /**
  21017. * Gets or Sets the list of Materials used within the multi material.
  21018. * They need to be ordered according to the submeshes order in the associated mesh
  21019. */
  21020. subMaterials: Nullable<Material>[];
  21021. /**
  21022. * Function used to align with Node.getChildren()
  21023. * @returns the list of Materials used within the multi material
  21024. */
  21025. getChildren(): Nullable<Material>[];
  21026. /**
  21027. * Instantiates a new Multi Material
  21028. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21029. * separate meshes. This can be use to improve performances.
  21030. * @see http://doc.babylonjs.com/how_to/multi_materials
  21031. * @param name Define the name in the scene
  21032. * @param scene Define the scene the material belongs to
  21033. */
  21034. constructor(name: string, scene: Scene);
  21035. private _hookArray;
  21036. /**
  21037. * Get one of the submaterial by its index in the submaterials array
  21038. * @param index The index to look the sub material at
  21039. * @returns The Material if the index has been defined
  21040. */
  21041. getSubMaterial(index: number): Nullable<Material>;
  21042. /**
  21043. * Get the list of active textures for the whole sub materials list.
  21044. * @returns All the textures that will be used during the rendering
  21045. */
  21046. getActiveTextures(): BaseTexture[];
  21047. /**
  21048. * Gets the current class name of the material e.g. "MultiMaterial"
  21049. * Mainly use in serialization.
  21050. * @returns the class name
  21051. */
  21052. getClassName(): string;
  21053. /**
  21054. * Checks if the material is ready to render the requested sub mesh
  21055. * @param mesh Define the mesh the submesh belongs to
  21056. * @param subMesh Define the sub mesh to look readyness for
  21057. * @param useInstances Define whether or not the material is used with instances
  21058. * @returns true if ready, otherwise false
  21059. */
  21060. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21061. /**
  21062. * Clones the current material and its related sub materials
  21063. * @param name Define the name of the newly cloned material
  21064. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21065. * @returns the cloned material
  21066. */
  21067. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21068. /**
  21069. * Serializes the materials into a JSON representation.
  21070. * @returns the JSON representation
  21071. */
  21072. serialize(): any;
  21073. /**
  21074. * Dispose the material and release its associated resources
  21075. * @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)
  21076. * @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)
  21077. * @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)
  21078. */
  21079. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21080. /**
  21081. * Creates a MultiMaterial from parsed MultiMaterial data.
  21082. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21083. * @param scene defines the hosting scene
  21084. * @returns a new MultiMaterial
  21085. */
  21086. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21087. }
  21088. }
  21089. declare module "babylonjs/Meshes/subMesh" {
  21090. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21091. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21092. import { Engine } from "babylonjs/Engines/engine";
  21093. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21094. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21095. import { Effect } from "babylonjs/Materials/effect";
  21096. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21097. import { Plane } from "babylonjs/Maths/math.plane";
  21098. import { Collider } from "babylonjs/Collisions/collider";
  21099. import { Material } from "babylonjs/Materials/material";
  21100. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21101. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21102. import { Mesh } from "babylonjs/Meshes/mesh";
  21103. import { Ray } from "babylonjs/Culling/ray";
  21104. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21105. /**
  21106. * Base class for submeshes
  21107. */
  21108. export class BaseSubMesh {
  21109. /** @hidden */
  21110. _materialDefines: Nullable<MaterialDefines>;
  21111. /** @hidden */
  21112. _materialEffect: Nullable<Effect>;
  21113. /**
  21114. * Gets associated effect
  21115. */
  21116. readonly effect: Nullable<Effect>;
  21117. /**
  21118. * Sets associated effect (effect used to render this submesh)
  21119. * @param effect defines the effect to associate with
  21120. * @param defines defines the set of defines used to compile this effect
  21121. */
  21122. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21123. }
  21124. /**
  21125. * Defines a subdivision inside a mesh
  21126. */
  21127. export class SubMesh extends BaseSubMesh implements ICullable {
  21128. /** the material index to use */
  21129. materialIndex: number;
  21130. /** vertex index start */
  21131. verticesStart: number;
  21132. /** vertices count */
  21133. verticesCount: number;
  21134. /** index start */
  21135. indexStart: number;
  21136. /** indices count */
  21137. indexCount: number;
  21138. /** @hidden */
  21139. _linesIndexCount: number;
  21140. private _mesh;
  21141. private _renderingMesh;
  21142. private _boundingInfo;
  21143. private _linesIndexBuffer;
  21144. /** @hidden */
  21145. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21146. /** @hidden */
  21147. _trianglePlanes: Plane[];
  21148. /** @hidden */
  21149. _lastColliderTransformMatrix: Nullable<Matrix>;
  21150. /** @hidden */
  21151. _renderId: number;
  21152. /** @hidden */
  21153. _alphaIndex: number;
  21154. /** @hidden */
  21155. _distanceToCamera: number;
  21156. /** @hidden */
  21157. _id: number;
  21158. private _currentMaterial;
  21159. /**
  21160. * Add a new submesh to a mesh
  21161. * @param materialIndex defines the material index to use
  21162. * @param verticesStart defines vertex index start
  21163. * @param verticesCount defines vertices count
  21164. * @param indexStart defines index start
  21165. * @param indexCount defines indices count
  21166. * @param mesh defines the parent mesh
  21167. * @param renderingMesh defines an optional rendering mesh
  21168. * @param createBoundingBox defines if bounding box should be created for this submesh
  21169. * @returns the new submesh
  21170. */
  21171. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21172. /**
  21173. * Creates a new submesh
  21174. * @param materialIndex defines the material index to use
  21175. * @param verticesStart defines vertex index start
  21176. * @param verticesCount defines vertices count
  21177. * @param indexStart defines index start
  21178. * @param indexCount defines indices count
  21179. * @param mesh defines the parent mesh
  21180. * @param renderingMesh defines an optional rendering mesh
  21181. * @param createBoundingBox defines if bounding box should be created for this submesh
  21182. */
  21183. constructor(
  21184. /** the material index to use */
  21185. materialIndex: number,
  21186. /** vertex index start */
  21187. verticesStart: number,
  21188. /** vertices count */
  21189. verticesCount: number,
  21190. /** index start */
  21191. indexStart: number,
  21192. /** indices count */
  21193. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21194. /**
  21195. * Returns true if this submesh covers the entire parent mesh
  21196. * @ignorenaming
  21197. */
  21198. readonly IsGlobal: boolean;
  21199. /**
  21200. * Returns the submesh BoudingInfo object
  21201. * @returns current bounding info (or mesh's one if the submesh is global)
  21202. */
  21203. getBoundingInfo(): BoundingInfo;
  21204. /**
  21205. * Sets the submesh BoundingInfo
  21206. * @param boundingInfo defines the new bounding info to use
  21207. * @returns the SubMesh
  21208. */
  21209. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21210. /**
  21211. * Returns the mesh of the current submesh
  21212. * @return the parent mesh
  21213. */
  21214. getMesh(): AbstractMesh;
  21215. /**
  21216. * Returns the rendering mesh of the submesh
  21217. * @returns the rendering mesh (could be different from parent mesh)
  21218. */
  21219. getRenderingMesh(): Mesh;
  21220. /**
  21221. * Returns the submesh material
  21222. * @returns null or the current material
  21223. */
  21224. getMaterial(): Nullable<Material>;
  21225. /**
  21226. * Sets a new updated BoundingInfo object to the submesh
  21227. * @param data defines an optional position array to use to determine the bounding info
  21228. * @returns the SubMesh
  21229. */
  21230. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21231. /** @hidden */
  21232. _checkCollision(collider: Collider): boolean;
  21233. /**
  21234. * Updates the submesh BoundingInfo
  21235. * @param world defines the world matrix to use to update the bounding info
  21236. * @returns the submesh
  21237. */
  21238. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21239. /**
  21240. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21241. * @param frustumPlanes defines the frustum planes
  21242. * @returns true if the submesh is intersecting with the frustum
  21243. */
  21244. isInFrustum(frustumPlanes: Plane[]): boolean;
  21245. /**
  21246. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21247. * @param frustumPlanes defines the frustum planes
  21248. * @returns true if the submesh is inside the frustum
  21249. */
  21250. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21251. /**
  21252. * Renders the submesh
  21253. * @param enableAlphaMode defines if alpha needs to be used
  21254. * @returns the submesh
  21255. */
  21256. render(enableAlphaMode: boolean): SubMesh;
  21257. /**
  21258. * @hidden
  21259. */
  21260. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21261. /**
  21262. * Checks if the submesh intersects with a ray
  21263. * @param ray defines the ray to test
  21264. * @returns true is the passed ray intersects the submesh bounding box
  21265. */
  21266. canIntersects(ray: Ray): boolean;
  21267. /**
  21268. * Intersects current submesh with a ray
  21269. * @param ray defines the ray to test
  21270. * @param positions defines mesh's positions array
  21271. * @param indices defines mesh's indices array
  21272. * @param fastCheck defines if only bounding info should be used
  21273. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21274. * @returns intersection info or null if no intersection
  21275. */
  21276. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21277. /** @hidden */
  21278. private _intersectLines;
  21279. /** @hidden */
  21280. private _intersectUnIndexedLines;
  21281. /** @hidden */
  21282. private _intersectTriangles;
  21283. /** @hidden */
  21284. private _intersectUnIndexedTriangles;
  21285. /** @hidden */
  21286. _rebuild(): void;
  21287. /**
  21288. * Creates a new submesh from the passed mesh
  21289. * @param newMesh defines the new hosting mesh
  21290. * @param newRenderingMesh defines an optional rendering mesh
  21291. * @returns the new submesh
  21292. */
  21293. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21294. /**
  21295. * Release associated resources
  21296. */
  21297. dispose(): void;
  21298. /**
  21299. * Gets the class name
  21300. * @returns the string "SubMesh".
  21301. */
  21302. getClassName(): string;
  21303. /**
  21304. * Creates a new submesh from indices data
  21305. * @param materialIndex the index of the main mesh material
  21306. * @param startIndex the index where to start the copy in the mesh indices array
  21307. * @param indexCount the number of indices to copy then from the startIndex
  21308. * @param mesh the main mesh to create the submesh from
  21309. * @param renderingMesh the optional rendering mesh
  21310. * @returns a new submesh
  21311. */
  21312. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21313. }
  21314. }
  21315. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21316. /**
  21317. * Class used to represent data loading progression
  21318. */
  21319. export class SceneLoaderFlags {
  21320. private static _ForceFullSceneLoadingForIncremental;
  21321. private static _ShowLoadingScreen;
  21322. private static _CleanBoneMatrixWeights;
  21323. private static _loggingLevel;
  21324. /**
  21325. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21326. */
  21327. static ForceFullSceneLoadingForIncremental: boolean;
  21328. /**
  21329. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21330. */
  21331. static ShowLoadingScreen: boolean;
  21332. /**
  21333. * Defines the current logging level (while loading the scene)
  21334. * @ignorenaming
  21335. */
  21336. static loggingLevel: number;
  21337. /**
  21338. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21339. */
  21340. static CleanBoneMatrixWeights: boolean;
  21341. }
  21342. }
  21343. declare module "babylonjs/Meshes/geometry" {
  21344. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21345. import { Scene } from "babylonjs/scene";
  21346. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21347. import { Engine } from "babylonjs/Engines/engine";
  21348. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21349. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21350. import { Effect } from "babylonjs/Materials/effect";
  21351. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21352. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21353. import { Mesh } from "babylonjs/Meshes/mesh";
  21354. /**
  21355. * Class used to store geometry data (vertex buffers + index buffer)
  21356. */
  21357. export class Geometry implements IGetSetVerticesData {
  21358. /**
  21359. * Gets or sets the ID of the geometry
  21360. */
  21361. id: string;
  21362. /**
  21363. * Gets or sets the unique ID of the geometry
  21364. */
  21365. uniqueId: number;
  21366. /**
  21367. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21368. */
  21369. delayLoadState: number;
  21370. /**
  21371. * Gets the file containing the data to load when running in delay load state
  21372. */
  21373. delayLoadingFile: Nullable<string>;
  21374. /**
  21375. * Callback called when the geometry is updated
  21376. */
  21377. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21378. private _scene;
  21379. private _engine;
  21380. private _meshes;
  21381. private _totalVertices;
  21382. /** @hidden */
  21383. _indices: IndicesArray;
  21384. /** @hidden */
  21385. _vertexBuffers: {
  21386. [key: string]: VertexBuffer;
  21387. };
  21388. private _isDisposed;
  21389. private _extend;
  21390. private _boundingBias;
  21391. /** @hidden */
  21392. _delayInfo: Array<string>;
  21393. private _indexBuffer;
  21394. private _indexBufferIsUpdatable;
  21395. /** @hidden */
  21396. _boundingInfo: Nullable<BoundingInfo>;
  21397. /** @hidden */
  21398. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21399. /** @hidden */
  21400. _softwareSkinningFrameId: number;
  21401. private _vertexArrayObjects;
  21402. private _updatable;
  21403. /** @hidden */
  21404. _positions: Nullable<Vector3[]>;
  21405. /**
  21406. * 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
  21407. */
  21408. /**
  21409. * 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
  21410. */
  21411. boundingBias: Vector2;
  21412. /**
  21413. * Static function used to attach a new empty geometry to a mesh
  21414. * @param mesh defines the mesh to attach the geometry to
  21415. * @returns the new Geometry
  21416. */
  21417. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21418. /**
  21419. * Creates a new geometry
  21420. * @param id defines the unique ID
  21421. * @param scene defines the hosting scene
  21422. * @param vertexData defines the VertexData used to get geometry data
  21423. * @param updatable defines if geometry must be updatable (false by default)
  21424. * @param mesh defines the mesh that will be associated with the geometry
  21425. */
  21426. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21427. /**
  21428. * Gets the current extend of the geometry
  21429. */
  21430. readonly extend: {
  21431. minimum: Vector3;
  21432. maximum: Vector3;
  21433. };
  21434. /**
  21435. * Gets the hosting scene
  21436. * @returns the hosting Scene
  21437. */
  21438. getScene(): Scene;
  21439. /**
  21440. * Gets the hosting engine
  21441. * @returns the hosting Engine
  21442. */
  21443. getEngine(): Engine;
  21444. /**
  21445. * Defines if the geometry is ready to use
  21446. * @returns true if the geometry is ready to be used
  21447. */
  21448. isReady(): boolean;
  21449. /**
  21450. * Gets a value indicating that the geometry should not be serialized
  21451. */
  21452. readonly doNotSerialize: boolean;
  21453. /** @hidden */
  21454. _rebuild(): void;
  21455. /**
  21456. * Affects all geometry data in one call
  21457. * @param vertexData defines the geometry data
  21458. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21459. */
  21460. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21461. /**
  21462. * Set specific vertex data
  21463. * @param kind defines the data kind (Position, normal, etc...)
  21464. * @param data defines the vertex data to use
  21465. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21466. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21467. */
  21468. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21469. /**
  21470. * Removes a specific vertex data
  21471. * @param kind defines the data kind (Position, normal, etc...)
  21472. */
  21473. removeVerticesData(kind: string): void;
  21474. /**
  21475. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21476. * @param buffer defines the vertex buffer to use
  21477. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21478. */
  21479. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21480. /**
  21481. * Update a specific vertex buffer
  21482. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21483. * It will do nothing if the buffer is not updatable
  21484. * @param kind defines the data kind (Position, normal, etc...)
  21485. * @param data defines the data to use
  21486. * @param offset defines the offset in the target buffer where to store the data
  21487. * @param useBytes set to true if the offset is in bytes
  21488. */
  21489. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21490. /**
  21491. * Update a specific vertex buffer
  21492. * This function will create a new buffer if the current one is not updatable
  21493. * @param kind defines the data kind (Position, normal, etc...)
  21494. * @param data defines the data to use
  21495. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21496. */
  21497. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21498. private _updateBoundingInfo;
  21499. /** @hidden */
  21500. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21501. /**
  21502. * Gets total number of vertices
  21503. * @returns the total number of vertices
  21504. */
  21505. getTotalVertices(): number;
  21506. /**
  21507. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21508. * @param kind defines the data kind (Position, normal, etc...)
  21509. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21510. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21511. * @returns a float array containing vertex data
  21512. */
  21513. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21514. /**
  21515. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21516. * @param kind defines the data kind (Position, normal, etc...)
  21517. * @returns true if the vertex buffer with the specified kind is updatable
  21518. */
  21519. isVertexBufferUpdatable(kind: string): boolean;
  21520. /**
  21521. * Gets a specific vertex buffer
  21522. * @param kind defines the data kind (Position, normal, etc...)
  21523. * @returns a VertexBuffer
  21524. */
  21525. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21526. /**
  21527. * Returns all vertex buffers
  21528. * @return an object holding all vertex buffers indexed by kind
  21529. */
  21530. getVertexBuffers(): Nullable<{
  21531. [key: string]: VertexBuffer;
  21532. }>;
  21533. /**
  21534. * Gets a boolean indicating if specific vertex buffer is present
  21535. * @param kind defines the data kind (Position, normal, etc...)
  21536. * @returns true if data is present
  21537. */
  21538. isVerticesDataPresent(kind: string): boolean;
  21539. /**
  21540. * Gets a list of all attached data kinds (Position, normal, etc...)
  21541. * @returns a list of string containing all kinds
  21542. */
  21543. getVerticesDataKinds(): string[];
  21544. /**
  21545. * Update index buffer
  21546. * @param indices defines the indices to store in the index buffer
  21547. * @param offset defines the offset in the target buffer where to store the data
  21548. * @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)
  21549. */
  21550. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21551. /**
  21552. * Creates a new index buffer
  21553. * @param indices defines the indices to store in the index buffer
  21554. * @param totalVertices defines the total number of vertices (could be null)
  21555. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21556. */
  21557. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21558. /**
  21559. * Return the total number of indices
  21560. * @returns the total number of indices
  21561. */
  21562. getTotalIndices(): number;
  21563. /**
  21564. * Gets the index buffer array
  21565. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21566. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21567. * @returns the index buffer array
  21568. */
  21569. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21570. /**
  21571. * Gets the index buffer
  21572. * @return the index buffer
  21573. */
  21574. getIndexBuffer(): Nullable<DataBuffer>;
  21575. /** @hidden */
  21576. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21577. /**
  21578. * Release the associated resources for a specific mesh
  21579. * @param mesh defines the source mesh
  21580. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21581. */
  21582. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21583. /**
  21584. * Apply current geometry to a given mesh
  21585. * @param mesh defines the mesh to apply geometry to
  21586. */
  21587. applyToMesh(mesh: Mesh): void;
  21588. private _updateExtend;
  21589. private _applyToMesh;
  21590. private notifyUpdate;
  21591. /**
  21592. * Load the geometry if it was flagged as delay loaded
  21593. * @param scene defines the hosting scene
  21594. * @param onLoaded defines a callback called when the geometry is loaded
  21595. */
  21596. load(scene: Scene, onLoaded?: () => void): void;
  21597. private _queueLoad;
  21598. /**
  21599. * Invert the geometry to move from a right handed system to a left handed one.
  21600. */
  21601. toLeftHanded(): void;
  21602. /** @hidden */
  21603. _resetPointsArrayCache(): void;
  21604. /** @hidden */
  21605. _generatePointsArray(): boolean;
  21606. /**
  21607. * Gets a value indicating if the geometry is disposed
  21608. * @returns true if the geometry was disposed
  21609. */
  21610. isDisposed(): boolean;
  21611. private _disposeVertexArrayObjects;
  21612. /**
  21613. * Free all associated resources
  21614. */
  21615. dispose(): void;
  21616. /**
  21617. * Clone the current geometry into a new geometry
  21618. * @param id defines the unique ID of the new geometry
  21619. * @returns a new geometry object
  21620. */
  21621. copy(id: string): Geometry;
  21622. /**
  21623. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21624. * @return a JSON representation of the current geometry data (without the vertices data)
  21625. */
  21626. serialize(): any;
  21627. private toNumberArray;
  21628. /**
  21629. * Serialize all vertices data into a JSON oject
  21630. * @returns a JSON representation of the current geometry data
  21631. */
  21632. serializeVerticeData(): any;
  21633. /**
  21634. * Extracts a clone of a mesh geometry
  21635. * @param mesh defines the source mesh
  21636. * @param id defines the unique ID of the new geometry object
  21637. * @returns the new geometry object
  21638. */
  21639. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21640. /**
  21641. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21642. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21643. * Be aware Math.random() could cause collisions, but:
  21644. * "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"
  21645. * @returns a string containing a new GUID
  21646. */
  21647. static RandomId(): string;
  21648. /** @hidden */
  21649. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21650. private static _CleanMatricesWeights;
  21651. /**
  21652. * Create a new geometry from persisted data (Using .babylon file format)
  21653. * @param parsedVertexData defines the persisted data
  21654. * @param scene defines the hosting scene
  21655. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21656. * @returns the new geometry object
  21657. */
  21658. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21659. }
  21660. }
  21661. declare module "babylonjs/Meshes/mesh.vertexData" {
  21662. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21663. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21664. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21665. import { Geometry } from "babylonjs/Meshes/geometry";
  21666. import { Mesh } from "babylonjs/Meshes/mesh";
  21667. /**
  21668. * Define an interface for all classes that will get and set the data on vertices
  21669. */
  21670. export interface IGetSetVerticesData {
  21671. /**
  21672. * Gets a boolean indicating if specific vertex data is present
  21673. * @param kind defines the vertex data kind to use
  21674. * @returns true is data kind is present
  21675. */
  21676. isVerticesDataPresent(kind: string): boolean;
  21677. /**
  21678. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21679. * @param kind defines the data kind (Position, normal, etc...)
  21680. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21681. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21682. * @returns a float array containing vertex data
  21683. */
  21684. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21685. /**
  21686. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21687. * @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.
  21688. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21689. * @returns the indices array or an empty array if the mesh has no geometry
  21690. */
  21691. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21692. /**
  21693. * Set specific vertex data
  21694. * @param kind defines the data kind (Position, normal, etc...)
  21695. * @param data defines the vertex data to use
  21696. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21697. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21698. */
  21699. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21700. /**
  21701. * Update a specific associated vertex buffer
  21702. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21703. * - VertexBuffer.PositionKind
  21704. * - VertexBuffer.UVKind
  21705. * - VertexBuffer.UV2Kind
  21706. * - VertexBuffer.UV3Kind
  21707. * - VertexBuffer.UV4Kind
  21708. * - VertexBuffer.UV5Kind
  21709. * - VertexBuffer.UV6Kind
  21710. * - VertexBuffer.ColorKind
  21711. * - VertexBuffer.MatricesIndicesKind
  21712. * - VertexBuffer.MatricesIndicesExtraKind
  21713. * - VertexBuffer.MatricesWeightsKind
  21714. * - VertexBuffer.MatricesWeightsExtraKind
  21715. * @param data defines the data source
  21716. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21717. * @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)
  21718. */
  21719. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21720. /**
  21721. * Creates a new index buffer
  21722. * @param indices defines the indices to store in the index buffer
  21723. * @param totalVertices defines the total number of vertices (could be null)
  21724. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21725. */
  21726. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21727. }
  21728. /**
  21729. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21730. */
  21731. export class VertexData {
  21732. /**
  21733. * Mesh side orientation : usually the external or front surface
  21734. */
  21735. static readonly FRONTSIDE: number;
  21736. /**
  21737. * Mesh side orientation : usually the internal or back surface
  21738. */
  21739. static readonly BACKSIDE: number;
  21740. /**
  21741. * Mesh side orientation : both internal and external or front and back surfaces
  21742. */
  21743. static readonly DOUBLESIDE: number;
  21744. /**
  21745. * Mesh side orientation : by default, `FRONTSIDE`
  21746. */
  21747. static readonly DEFAULTSIDE: number;
  21748. /**
  21749. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21750. */
  21751. positions: Nullable<FloatArray>;
  21752. /**
  21753. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21754. */
  21755. normals: Nullable<FloatArray>;
  21756. /**
  21757. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21758. */
  21759. tangents: Nullable<FloatArray>;
  21760. /**
  21761. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21762. */
  21763. uvs: Nullable<FloatArray>;
  21764. /**
  21765. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21766. */
  21767. uvs2: Nullable<FloatArray>;
  21768. /**
  21769. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21770. */
  21771. uvs3: Nullable<FloatArray>;
  21772. /**
  21773. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21774. */
  21775. uvs4: Nullable<FloatArray>;
  21776. /**
  21777. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21778. */
  21779. uvs5: Nullable<FloatArray>;
  21780. /**
  21781. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21782. */
  21783. uvs6: Nullable<FloatArray>;
  21784. /**
  21785. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21786. */
  21787. colors: Nullable<FloatArray>;
  21788. /**
  21789. * 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).
  21790. */
  21791. matricesIndices: Nullable<FloatArray>;
  21792. /**
  21793. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21794. */
  21795. matricesWeights: Nullable<FloatArray>;
  21796. /**
  21797. * An array extending the number of possible indices
  21798. */
  21799. matricesIndicesExtra: Nullable<FloatArray>;
  21800. /**
  21801. * An array extending the number of possible weights when the number of indices is extended
  21802. */
  21803. matricesWeightsExtra: Nullable<FloatArray>;
  21804. /**
  21805. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21806. */
  21807. indices: Nullable<IndicesArray>;
  21808. /**
  21809. * Uses the passed data array to set the set the values for the specified kind of data
  21810. * @param data a linear array of floating numbers
  21811. * @param kind the type of data that is being set, eg positions, colors etc
  21812. */
  21813. set(data: FloatArray, kind: string): void;
  21814. /**
  21815. * Associates the vertexData to the passed Mesh.
  21816. * Sets it as updatable or not (default `false`)
  21817. * @param mesh the mesh the vertexData is applied to
  21818. * @param updatable when used and having the value true allows new data to update the vertexData
  21819. * @returns the VertexData
  21820. */
  21821. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21822. /**
  21823. * Associates the vertexData to the passed Geometry.
  21824. * Sets it as updatable or not (default `false`)
  21825. * @param geometry the geometry the vertexData is applied to
  21826. * @param updatable when used and having the value true allows new data to update the vertexData
  21827. * @returns VertexData
  21828. */
  21829. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21830. /**
  21831. * Updates the associated mesh
  21832. * @param mesh the mesh to be updated
  21833. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21834. * @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
  21835. * @returns VertexData
  21836. */
  21837. updateMesh(mesh: Mesh): VertexData;
  21838. /**
  21839. * Updates the associated geometry
  21840. * @param geometry the geometry to be updated
  21841. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21842. * @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
  21843. * @returns VertexData.
  21844. */
  21845. updateGeometry(geometry: Geometry): VertexData;
  21846. private _applyTo;
  21847. private _update;
  21848. /**
  21849. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21850. * @param matrix the transforming matrix
  21851. * @returns the VertexData
  21852. */
  21853. transform(matrix: Matrix): VertexData;
  21854. /**
  21855. * Merges the passed VertexData into the current one
  21856. * @param other the VertexData to be merged into the current one
  21857. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21858. * @returns the modified VertexData
  21859. */
  21860. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21861. private _mergeElement;
  21862. private _validate;
  21863. /**
  21864. * Serializes the VertexData
  21865. * @returns a serialized object
  21866. */
  21867. serialize(): any;
  21868. /**
  21869. * Extracts the vertexData from a mesh
  21870. * @param mesh the mesh from which to extract the VertexData
  21871. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21872. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21873. * @returns the object VertexData associated to the passed mesh
  21874. */
  21875. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21876. /**
  21877. * Extracts the vertexData from the geometry
  21878. * @param geometry the geometry from which to extract the VertexData
  21879. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21880. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21881. * @returns the object VertexData associated to the passed mesh
  21882. */
  21883. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21884. private static _ExtractFrom;
  21885. /**
  21886. * Creates the VertexData for a Ribbon
  21887. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21888. * * pathArray array of paths, each of which an array of successive Vector3
  21889. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21890. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21891. * * 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
  21892. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21893. * * 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)
  21894. * * 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)
  21895. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21896. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21897. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21898. * @returns the VertexData of the ribbon
  21899. */
  21900. static CreateRibbon(options: {
  21901. pathArray: Vector3[][];
  21902. closeArray?: boolean;
  21903. closePath?: boolean;
  21904. offset?: number;
  21905. sideOrientation?: number;
  21906. frontUVs?: Vector4;
  21907. backUVs?: Vector4;
  21908. invertUV?: boolean;
  21909. uvs?: Vector2[];
  21910. colors?: Color4[];
  21911. }): VertexData;
  21912. /**
  21913. * Creates the VertexData for a box
  21914. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21915. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21916. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21917. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21918. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21919. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21920. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21921. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21922. * * 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)
  21923. * * 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)
  21924. * @returns the VertexData of the box
  21925. */
  21926. static CreateBox(options: {
  21927. size?: number;
  21928. width?: number;
  21929. height?: number;
  21930. depth?: number;
  21931. faceUV?: Vector4[];
  21932. faceColors?: Color4[];
  21933. sideOrientation?: number;
  21934. frontUVs?: Vector4;
  21935. backUVs?: Vector4;
  21936. }): VertexData;
  21937. /**
  21938. * Creates the VertexData for a tiled box
  21939. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21940. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21941. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21942. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21943. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21944. * @returns the VertexData of the box
  21945. */
  21946. static CreateTiledBox(options: {
  21947. pattern?: number;
  21948. width?: number;
  21949. height?: number;
  21950. depth?: number;
  21951. tileSize?: number;
  21952. tileWidth?: number;
  21953. tileHeight?: number;
  21954. alignHorizontal?: number;
  21955. alignVertical?: number;
  21956. faceUV?: Vector4[];
  21957. faceColors?: Color4[];
  21958. sideOrientation?: number;
  21959. }): VertexData;
  21960. /**
  21961. * Creates the VertexData for a tiled plane
  21962. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21963. * * pattern a limited pattern arrangement depending on the number
  21964. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21965. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21966. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21967. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21968. * * 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)
  21969. * * 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)
  21970. * @returns the VertexData of the tiled plane
  21971. */
  21972. static CreateTiledPlane(options: {
  21973. pattern?: number;
  21974. tileSize?: number;
  21975. tileWidth?: number;
  21976. tileHeight?: number;
  21977. size?: number;
  21978. width?: number;
  21979. height?: number;
  21980. alignHorizontal?: number;
  21981. alignVertical?: number;
  21982. sideOrientation?: number;
  21983. frontUVs?: Vector4;
  21984. backUVs?: Vector4;
  21985. }): VertexData;
  21986. /**
  21987. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21988. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21989. * * segments sets the number of horizontal strips optional, default 32
  21990. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21991. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21992. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21993. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21994. * * 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
  21995. * * 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
  21996. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21997. * * 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)
  21998. * * 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)
  21999. * @returns the VertexData of the ellipsoid
  22000. */
  22001. static CreateSphere(options: {
  22002. segments?: number;
  22003. diameter?: number;
  22004. diameterX?: number;
  22005. diameterY?: number;
  22006. diameterZ?: number;
  22007. arc?: number;
  22008. slice?: number;
  22009. sideOrientation?: number;
  22010. frontUVs?: Vector4;
  22011. backUVs?: Vector4;
  22012. }): VertexData;
  22013. /**
  22014. * Creates the VertexData for a cylinder, cone or prism
  22015. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22016. * * height sets the height (y direction) of the cylinder, optional, default 2
  22017. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22018. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22019. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22020. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22021. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22022. * * 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
  22023. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22024. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22025. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22026. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22027. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22028. * * 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)
  22029. * * 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)
  22030. * @returns the VertexData of the cylinder, cone or prism
  22031. */
  22032. static CreateCylinder(options: {
  22033. height?: number;
  22034. diameterTop?: number;
  22035. diameterBottom?: number;
  22036. diameter?: number;
  22037. tessellation?: number;
  22038. subdivisions?: number;
  22039. arc?: number;
  22040. faceColors?: Color4[];
  22041. faceUV?: Vector4[];
  22042. hasRings?: boolean;
  22043. enclose?: boolean;
  22044. sideOrientation?: number;
  22045. frontUVs?: Vector4;
  22046. backUVs?: Vector4;
  22047. }): VertexData;
  22048. /**
  22049. * Creates the VertexData for a torus
  22050. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22051. * * diameter the diameter of the torus, optional default 1
  22052. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22053. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22054. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22055. * * 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)
  22056. * * 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)
  22057. * @returns the VertexData of the torus
  22058. */
  22059. static CreateTorus(options: {
  22060. diameter?: number;
  22061. thickness?: number;
  22062. tessellation?: number;
  22063. sideOrientation?: number;
  22064. frontUVs?: Vector4;
  22065. backUVs?: Vector4;
  22066. }): VertexData;
  22067. /**
  22068. * Creates the VertexData of the LineSystem
  22069. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22070. * - lines an array of lines, each line being an array of successive Vector3
  22071. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22072. * @returns the VertexData of the LineSystem
  22073. */
  22074. static CreateLineSystem(options: {
  22075. lines: Vector3[][];
  22076. colors?: Nullable<Color4[][]>;
  22077. }): VertexData;
  22078. /**
  22079. * Create the VertexData for a DashedLines
  22080. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22081. * - points an array successive Vector3
  22082. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22083. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22084. * - dashNb the intended total number of dashes, optional, default 200
  22085. * @returns the VertexData for the DashedLines
  22086. */
  22087. static CreateDashedLines(options: {
  22088. points: Vector3[];
  22089. dashSize?: number;
  22090. gapSize?: number;
  22091. dashNb?: number;
  22092. }): VertexData;
  22093. /**
  22094. * Creates the VertexData for a Ground
  22095. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22096. * - width the width (x direction) of the ground, optional, default 1
  22097. * - height the height (z direction) of the ground, optional, default 1
  22098. * - subdivisions the number of subdivisions per side, optional, default 1
  22099. * @returns the VertexData of the Ground
  22100. */
  22101. static CreateGround(options: {
  22102. width?: number;
  22103. height?: number;
  22104. subdivisions?: number;
  22105. subdivisionsX?: number;
  22106. subdivisionsY?: number;
  22107. }): VertexData;
  22108. /**
  22109. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22110. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22111. * * xmin the ground minimum X coordinate, optional, default -1
  22112. * * zmin the ground minimum Z coordinate, optional, default -1
  22113. * * xmax the ground maximum X coordinate, optional, default 1
  22114. * * zmax the ground maximum Z coordinate, optional, default 1
  22115. * * 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}
  22116. * * 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}
  22117. * @returns the VertexData of the TiledGround
  22118. */
  22119. static CreateTiledGround(options: {
  22120. xmin: number;
  22121. zmin: number;
  22122. xmax: number;
  22123. zmax: number;
  22124. subdivisions?: {
  22125. w: number;
  22126. h: number;
  22127. };
  22128. precision?: {
  22129. w: number;
  22130. h: number;
  22131. };
  22132. }): VertexData;
  22133. /**
  22134. * Creates the VertexData of the Ground designed from a heightmap
  22135. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22136. * * width the width (x direction) of the ground
  22137. * * height the height (z direction) of the ground
  22138. * * subdivisions the number of subdivisions per side
  22139. * * minHeight the minimum altitude on the ground, optional, default 0
  22140. * * maxHeight the maximum altitude on the ground, optional default 1
  22141. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22142. * * buffer the array holding the image color data
  22143. * * bufferWidth the width of image
  22144. * * bufferHeight the height of image
  22145. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22146. * @returns the VertexData of the Ground designed from a heightmap
  22147. */
  22148. static CreateGroundFromHeightMap(options: {
  22149. width: number;
  22150. height: number;
  22151. subdivisions: number;
  22152. minHeight: number;
  22153. maxHeight: number;
  22154. colorFilter: Color3;
  22155. buffer: Uint8Array;
  22156. bufferWidth: number;
  22157. bufferHeight: number;
  22158. alphaFilter: number;
  22159. }): VertexData;
  22160. /**
  22161. * Creates the VertexData for a Plane
  22162. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22163. * * size sets the width and height of the plane to the value of size, optional default 1
  22164. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22165. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22166. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22167. * * 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)
  22168. * * 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)
  22169. * @returns the VertexData of the box
  22170. */
  22171. static CreatePlane(options: {
  22172. size?: number;
  22173. width?: number;
  22174. height?: number;
  22175. sideOrientation?: number;
  22176. frontUVs?: Vector4;
  22177. backUVs?: Vector4;
  22178. }): VertexData;
  22179. /**
  22180. * Creates the VertexData of the Disc or regular Polygon
  22181. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22182. * * radius the radius of the disc, optional default 0.5
  22183. * * tessellation the number of polygon sides, optional, default 64
  22184. * * 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
  22185. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22186. * * 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)
  22187. * * 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)
  22188. * @returns the VertexData of the box
  22189. */
  22190. static CreateDisc(options: {
  22191. radius?: number;
  22192. tessellation?: number;
  22193. arc?: number;
  22194. sideOrientation?: number;
  22195. frontUVs?: Vector4;
  22196. backUVs?: Vector4;
  22197. }): VertexData;
  22198. /**
  22199. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22200. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22201. * @param polygon a mesh built from polygonTriangulation.build()
  22202. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22203. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22204. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22205. * @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)
  22206. * @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)
  22207. * @returns the VertexData of the Polygon
  22208. */
  22209. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22210. /**
  22211. * Creates the VertexData of the IcoSphere
  22212. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22213. * * radius the radius of the IcoSphere, optional default 1
  22214. * * radiusX allows stretching in the x direction, optional, default radius
  22215. * * radiusY allows stretching in the y direction, optional, default radius
  22216. * * radiusZ allows stretching in the z direction, optional, default radius
  22217. * * flat when true creates a flat shaded mesh, optional, default true
  22218. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22219. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22220. * * 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)
  22221. * * 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)
  22222. * @returns the VertexData of the IcoSphere
  22223. */
  22224. static CreateIcoSphere(options: {
  22225. radius?: number;
  22226. radiusX?: number;
  22227. radiusY?: number;
  22228. radiusZ?: number;
  22229. flat?: boolean;
  22230. subdivisions?: number;
  22231. sideOrientation?: number;
  22232. frontUVs?: Vector4;
  22233. backUVs?: Vector4;
  22234. }): VertexData;
  22235. /**
  22236. * Creates the VertexData for a Polyhedron
  22237. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22238. * * type provided types are:
  22239. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22240. * * 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)
  22241. * * size the size of the IcoSphere, optional default 1
  22242. * * sizeX allows stretching in the x direction, optional, default size
  22243. * * sizeY allows stretching in the y direction, optional, default size
  22244. * * sizeZ allows stretching in the z direction, optional, default size
  22245. * * 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
  22246. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22247. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22248. * * flat when true creates a flat shaded mesh, optional, default true
  22249. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22250. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22251. * * 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)
  22252. * * 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)
  22253. * @returns the VertexData of the Polyhedron
  22254. */
  22255. static CreatePolyhedron(options: {
  22256. type?: number;
  22257. size?: number;
  22258. sizeX?: number;
  22259. sizeY?: number;
  22260. sizeZ?: number;
  22261. custom?: any;
  22262. faceUV?: Vector4[];
  22263. faceColors?: Color4[];
  22264. flat?: boolean;
  22265. sideOrientation?: number;
  22266. frontUVs?: Vector4;
  22267. backUVs?: Vector4;
  22268. }): VertexData;
  22269. /**
  22270. * Creates the VertexData for a TorusKnot
  22271. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22272. * * radius the radius of the torus knot, optional, default 2
  22273. * * tube the thickness of the tube, optional, default 0.5
  22274. * * radialSegments the number of sides on each tube segments, optional, default 32
  22275. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22276. * * p the number of windings around the z axis, optional, default 2
  22277. * * q the number of windings around the x axis, optional, default 3
  22278. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22279. * * 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)
  22280. * * 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)
  22281. * @returns the VertexData of the Torus Knot
  22282. */
  22283. static CreateTorusKnot(options: {
  22284. radius?: number;
  22285. tube?: number;
  22286. radialSegments?: number;
  22287. tubularSegments?: number;
  22288. p?: number;
  22289. q?: number;
  22290. sideOrientation?: number;
  22291. frontUVs?: Vector4;
  22292. backUVs?: Vector4;
  22293. }): VertexData;
  22294. /**
  22295. * Compute normals for given positions and indices
  22296. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22297. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22298. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22299. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22300. * * facetNormals : optional array of facet normals (vector3)
  22301. * * facetPositions : optional array of facet positions (vector3)
  22302. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22303. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22304. * * bInfo : optional bounding info, required for facetPartitioning computation
  22305. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22306. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22307. * * useRightHandedSystem: optional boolean to for right handed system computation
  22308. * * depthSort : optional boolean to enable the facet depth sort computation
  22309. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22310. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22311. */
  22312. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22313. facetNormals?: any;
  22314. facetPositions?: any;
  22315. facetPartitioning?: any;
  22316. ratio?: number;
  22317. bInfo?: any;
  22318. bbSize?: Vector3;
  22319. subDiv?: any;
  22320. useRightHandedSystem?: boolean;
  22321. depthSort?: boolean;
  22322. distanceTo?: Vector3;
  22323. depthSortedFacets?: any;
  22324. }): void;
  22325. /** @hidden */
  22326. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22327. /**
  22328. * Applies VertexData created from the imported parameters to the geometry
  22329. * @param parsedVertexData the parsed data from an imported file
  22330. * @param geometry the geometry to apply the VertexData to
  22331. */
  22332. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22333. }
  22334. }
  22335. declare module "babylonjs/Morph/morphTarget" {
  22336. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22337. import { Observable } from "babylonjs/Misc/observable";
  22338. import { Nullable, FloatArray } from "babylonjs/types";
  22339. import { Scene } from "babylonjs/scene";
  22340. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22341. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22342. /**
  22343. * Defines a target to use with MorphTargetManager
  22344. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22345. */
  22346. export class MorphTarget implements IAnimatable {
  22347. /** defines the name of the target */
  22348. name: string;
  22349. /**
  22350. * Gets or sets the list of animations
  22351. */
  22352. animations: import("babylonjs/Animations/animation").Animation[];
  22353. private _scene;
  22354. private _positions;
  22355. private _normals;
  22356. private _tangents;
  22357. private _uvs;
  22358. private _influence;
  22359. /**
  22360. * Observable raised when the influence changes
  22361. */
  22362. onInfluenceChanged: Observable<boolean>;
  22363. /** @hidden */
  22364. _onDataLayoutChanged: Observable<void>;
  22365. /**
  22366. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22367. */
  22368. influence: number;
  22369. /**
  22370. * Gets or sets the id of the morph Target
  22371. */
  22372. id: string;
  22373. private _animationPropertiesOverride;
  22374. /**
  22375. * Gets or sets the animation properties override
  22376. */
  22377. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22378. /**
  22379. * Creates a new MorphTarget
  22380. * @param name defines the name of the target
  22381. * @param influence defines the influence to use
  22382. * @param scene defines the scene the morphtarget belongs to
  22383. */
  22384. constructor(
  22385. /** defines the name of the target */
  22386. name: string, influence?: number, scene?: Nullable<Scene>);
  22387. /**
  22388. * Gets a boolean defining if the target contains position data
  22389. */
  22390. readonly hasPositions: boolean;
  22391. /**
  22392. * Gets a boolean defining if the target contains normal data
  22393. */
  22394. readonly hasNormals: boolean;
  22395. /**
  22396. * Gets a boolean defining if the target contains tangent data
  22397. */
  22398. readonly hasTangents: boolean;
  22399. /**
  22400. * Gets a boolean defining if the target contains texture coordinates data
  22401. */
  22402. readonly hasUVs: boolean;
  22403. /**
  22404. * Affects position data to this target
  22405. * @param data defines the position data to use
  22406. */
  22407. setPositions(data: Nullable<FloatArray>): void;
  22408. /**
  22409. * Gets the position data stored in this target
  22410. * @returns a FloatArray containing the position data (or null if not present)
  22411. */
  22412. getPositions(): Nullable<FloatArray>;
  22413. /**
  22414. * Affects normal data to this target
  22415. * @param data defines the normal data to use
  22416. */
  22417. setNormals(data: Nullable<FloatArray>): void;
  22418. /**
  22419. * Gets the normal data stored in this target
  22420. * @returns a FloatArray containing the normal data (or null if not present)
  22421. */
  22422. getNormals(): Nullable<FloatArray>;
  22423. /**
  22424. * Affects tangent data to this target
  22425. * @param data defines the tangent data to use
  22426. */
  22427. setTangents(data: Nullable<FloatArray>): void;
  22428. /**
  22429. * Gets the tangent data stored in this target
  22430. * @returns a FloatArray containing the tangent data (or null if not present)
  22431. */
  22432. getTangents(): Nullable<FloatArray>;
  22433. /**
  22434. * Affects texture coordinates data to this target
  22435. * @param data defines the texture coordinates data to use
  22436. */
  22437. setUVs(data: Nullable<FloatArray>): void;
  22438. /**
  22439. * Gets the texture coordinates data stored in this target
  22440. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22441. */
  22442. getUVs(): Nullable<FloatArray>;
  22443. /**
  22444. * Serializes the current target into a Serialization object
  22445. * @returns the serialized object
  22446. */
  22447. serialize(): any;
  22448. /**
  22449. * Returns the string "MorphTarget"
  22450. * @returns "MorphTarget"
  22451. */
  22452. getClassName(): string;
  22453. /**
  22454. * Creates a new target from serialized data
  22455. * @param serializationObject defines the serialized data to use
  22456. * @returns a new MorphTarget
  22457. */
  22458. static Parse(serializationObject: any): MorphTarget;
  22459. /**
  22460. * Creates a MorphTarget from mesh data
  22461. * @param mesh defines the source mesh
  22462. * @param name defines the name to use for the new target
  22463. * @param influence defines the influence to attach to the target
  22464. * @returns a new MorphTarget
  22465. */
  22466. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22467. }
  22468. }
  22469. declare module "babylonjs/Morph/morphTargetManager" {
  22470. import { Nullable } from "babylonjs/types";
  22471. import { Scene } from "babylonjs/scene";
  22472. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22473. /**
  22474. * This class is used to deform meshes using morphing between different targets
  22475. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22476. */
  22477. export class MorphTargetManager {
  22478. private _targets;
  22479. private _targetInfluenceChangedObservers;
  22480. private _targetDataLayoutChangedObservers;
  22481. private _activeTargets;
  22482. private _scene;
  22483. private _influences;
  22484. private _supportsNormals;
  22485. private _supportsTangents;
  22486. private _supportsUVs;
  22487. private _vertexCount;
  22488. private _uniqueId;
  22489. private _tempInfluences;
  22490. /**
  22491. * Gets or sets a boolean indicating if normals must be morphed
  22492. */
  22493. enableNormalMorphing: boolean;
  22494. /**
  22495. * Gets or sets a boolean indicating if tangents must be morphed
  22496. */
  22497. enableTangentMorphing: boolean;
  22498. /**
  22499. * Gets or sets a boolean indicating if UV must be morphed
  22500. */
  22501. enableUVMorphing: boolean;
  22502. /**
  22503. * Creates a new MorphTargetManager
  22504. * @param scene defines the current scene
  22505. */
  22506. constructor(scene?: Nullable<Scene>);
  22507. /**
  22508. * Gets the unique ID of this manager
  22509. */
  22510. readonly uniqueId: number;
  22511. /**
  22512. * Gets the number of vertices handled by this manager
  22513. */
  22514. readonly vertexCount: number;
  22515. /**
  22516. * Gets a boolean indicating if this manager supports morphing of normals
  22517. */
  22518. readonly supportsNormals: boolean;
  22519. /**
  22520. * Gets a boolean indicating if this manager supports morphing of tangents
  22521. */
  22522. readonly supportsTangents: boolean;
  22523. /**
  22524. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22525. */
  22526. readonly supportsUVs: boolean;
  22527. /**
  22528. * Gets the number of targets stored in this manager
  22529. */
  22530. readonly numTargets: number;
  22531. /**
  22532. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22533. */
  22534. readonly numInfluencers: number;
  22535. /**
  22536. * Gets the list of influences (one per target)
  22537. */
  22538. readonly influences: Float32Array;
  22539. /**
  22540. * Gets the active target at specified index. An active target is a target with an influence > 0
  22541. * @param index defines the index to check
  22542. * @returns the requested target
  22543. */
  22544. getActiveTarget(index: number): MorphTarget;
  22545. /**
  22546. * Gets the target at specified index
  22547. * @param index defines the index to check
  22548. * @returns the requested target
  22549. */
  22550. getTarget(index: number): MorphTarget;
  22551. /**
  22552. * Add a new target to this manager
  22553. * @param target defines the target to add
  22554. */
  22555. addTarget(target: MorphTarget): void;
  22556. /**
  22557. * Removes a target from the manager
  22558. * @param target defines the target to remove
  22559. */
  22560. removeTarget(target: MorphTarget): void;
  22561. /**
  22562. * Serializes the current manager into a Serialization object
  22563. * @returns the serialized object
  22564. */
  22565. serialize(): any;
  22566. private _syncActiveTargets;
  22567. /**
  22568. * Syncrhonize the targets with all the meshes using this morph target manager
  22569. */
  22570. synchronize(): void;
  22571. /**
  22572. * Creates a new MorphTargetManager from serialized data
  22573. * @param serializationObject defines the serialized data
  22574. * @param scene defines the hosting scene
  22575. * @returns the new MorphTargetManager
  22576. */
  22577. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22578. }
  22579. }
  22580. declare module "babylonjs/Meshes/meshLODLevel" {
  22581. import { Mesh } from "babylonjs/Meshes/mesh";
  22582. import { Nullable } from "babylonjs/types";
  22583. /**
  22584. * Class used to represent a specific level of detail of a mesh
  22585. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22586. */
  22587. export class MeshLODLevel {
  22588. /** Defines the distance where this level should star being displayed */
  22589. distance: number;
  22590. /** Defines the mesh to use to render this level */
  22591. mesh: Nullable<Mesh>;
  22592. /**
  22593. * Creates a new LOD level
  22594. * @param distance defines the distance where this level should star being displayed
  22595. * @param mesh defines the mesh to use to render this level
  22596. */
  22597. constructor(
  22598. /** Defines the distance where this level should star being displayed */
  22599. distance: number,
  22600. /** Defines the mesh to use to render this level */
  22601. mesh: Nullable<Mesh>);
  22602. }
  22603. }
  22604. declare module "babylonjs/Meshes/groundMesh" {
  22605. import { Scene } from "babylonjs/scene";
  22606. import { Vector3 } from "babylonjs/Maths/math.vector";
  22607. import { Mesh } from "babylonjs/Meshes/mesh";
  22608. /**
  22609. * Mesh representing the gorund
  22610. */
  22611. export class GroundMesh extends Mesh {
  22612. /** If octree should be generated */
  22613. generateOctree: boolean;
  22614. private _heightQuads;
  22615. /** @hidden */
  22616. _subdivisionsX: number;
  22617. /** @hidden */
  22618. _subdivisionsY: number;
  22619. /** @hidden */
  22620. _width: number;
  22621. /** @hidden */
  22622. _height: number;
  22623. /** @hidden */
  22624. _minX: number;
  22625. /** @hidden */
  22626. _maxX: number;
  22627. /** @hidden */
  22628. _minZ: number;
  22629. /** @hidden */
  22630. _maxZ: number;
  22631. constructor(name: string, scene: Scene);
  22632. /**
  22633. * "GroundMesh"
  22634. * @returns "GroundMesh"
  22635. */
  22636. getClassName(): string;
  22637. /**
  22638. * The minimum of x and y subdivisions
  22639. */
  22640. readonly subdivisions: number;
  22641. /**
  22642. * X subdivisions
  22643. */
  22644. readonly subdivisionsX: number;
  22645. /**
  22646. * Y subdivisions
  22647. */
  22648. readonly subdivisionsY: number;
  22649. /**
  22650. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22651. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22652. * @param chunksCount the number of subdivisions for x and y
  22653. * @param octreeBlocksSize (Default: 32)
  22654. */
  22655. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22656. /**
  22657. * Returns a height (y) value in the Worl system :
  22658. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22659. * @param x x coordinate
  22660. * @param z z coordinate
  22661. * @returns the ground y position if (x, z) are outside the ground surface.
  22662. */
  22663. getHeightAtCoordinates(x: number, z: number): number;
  22664. /**
  22665. * Returns a normalized vector (Vector3) orthogonal to the ground
  22666. * at the ground coordinates (x, z) expressed in the World system.
  22667. * @param x x coordinate
  22668. * @param z z coordinate
  22669. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22670. */
  22671. getNormalAtCoordinates(x: number, z: number): Vector3;
  22672. /**
  22673. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22674. * at the ground coordinates (x, z) expressed in the World system.
  22675. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22676. * @param x x coordinate
  22677. * @param z z coordinate
  22678. * @param ref vector to store the result
  22679. * @returns the GroundMesh.
  22680. */
  22681. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22682. /**
  22683. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22684. * if the ground has been updated.
  22685. * This can be used in the render loop.
  22686. * @returns the GroundMesh.
  22687. */
  22688. updateCoordinateHeights(): GroundMesh;
  22689. private _getFacetAt;
  22690. private _initHeightQuads;
  22691. private _computeHeightQuads;
  22692. /**
  22693. * Serializes this ground mesh
  22694. * @param serializationObject object to write serialization to
  22695. */
  22696. serialize(serializationObject: any): void;
  22697. /**
  22698. * Parses a serialized ground mesh
  22699. * @param parsedMesh the serialized mesh
  22700. * @param scene the scene to create the ground mesh in
  22701. * @returns the created ground mesh
  22702. */
  22703. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22704. }
  22705. }
  22706. declare module "babylonjs/Physics/physicsJoint" {
  22707. import { Vector3 } from "babylonjs/Maths/math.vector";
  22708. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22709. /**
  22710. * Interface for Physics-Joint data
  22711. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22712. */
  22713. export interface PhysicsJointData {
  22714. /**
  22715. * The main pivot of the joint
  22716. */
  22717. mainPivot?: Vector3;
  22718. /**
  22719. * The connected pivot of the joint
  22720. */
  22721. connectedPivot?: Vector3;
  22722. /**
  22723. * The main axis of the joint
  22724. */
  22725. mainAxis?: Vector3;
  22726. /**
  22727. * The connected axis of the joint
  22728. */
  22729. connectedAxis?: Vector3;
  22730. /**
  22731. * The collision of the joint
  22732. */
  22733. collision?: boolean;
  22734. /**
  22735. * Native Oimo/Cannon/Energy data
  22736. */
  22737. nativeParams?: any;
  22738. }
  22739. /**
  22740. * This is a holder class for the physics joint created by the physics plugin
  22741. * It holds a set of functions to control the underlying joint
  22742. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22743. */
  22744. export class PhysicsJoint {
  22745. /**
  22746. * The type of the physics joint
  22747. */
  22748. type: number;
  22749. /**
  22750. * The data for the physics joint
  22751. */
  22752. jointData: PhysicsJointData;
  22753. private _physicsJoint;
  22754. protected _physicsPlugin: IPhysicsEnginePlugin;
  22755. /**
  22756. * Initializes the physics joint
  22757. * @param type The type of the physics joint
  22758. * @param jointData The data for the physics joint
  22759. */
  22760. constructor(
  22761. /**
  22762. * The type of the physics joint
  22763. */
  22764. type: number,
  22765. /**
  22766. * The data for the physics joint
  22767. */
  22768. jointData: PhysicsJointData);
  22769. /**
  22770. * Gets the physics joint
  22771. */
  22772. /**
  22773. * Sets the physics joint
  22774. */
  22775. physicsJoint: any;
  22776. /**
  22777. * Sets the physics plugin
  22778. */
  22779. physicsPlugin: IPhysicsEnginePlugin;
  22780. /**
  22781. * Execute a function that is physics-plugin specific.
  22782. * @param {Function} func the function that will be executed.
  22783. * It accepts two parameters: the physics world and the physics joint
  22784. */
  22785. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22786. /**
  22787. * Distance-Joint type
  22788. */
  22789. static DistanceJoint: number;
  22790. /**
  22791. * Hinge-Joint type
  22792. */
  22793. static HingeJoint: number;
  22794. /**
  22795. * Ball-and-Socket joint type
  22796. */
  22797. static BallAndSocketJoint: number;
  22798. /**
  22799. * Wheel-Joint type
  22800. */
  22801. static WheelJoint: number;
  22802. /**
  22803. * Slider-Joint type
  22804. */
  22805. static SliderJoint: number;
  22806. /**
  22807. * Prismatic-Joint type
  22808. */
  22809. static PrismaticJoint: number;
  22810. /**
  22811. * Universal-Joint type
  22812. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22813. */
  22814. static UniversalJoint: number;
  22815. /**
  22816. * Hinge-Joint 2 type
  22817. */
  22818. static Hinge2Joint: number;
  22819. /**
  22820. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22821. */
  22822. static PointToPointJoint: number;
  22823. /**
  22824. * Spring-Joint type
  22825. */
  22826. static SpringJoint: number;
  22827. /**
  22828. * Lock-Joint type
  22829. */
  22830. static LockJoint: number;
  22831. }
  22832. /**
  22833. * A class representing a physics distance joint
  22834. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22835. */
  22836. export class DistanceJoint extends PhysicsJoint {
  22837. /**
  22838. *
  22839. * @param jointData The data for the Distance-Joint
  22840. */
  22841. constructor(jointData: DistanceJointData);
  22842. /**
  22843. * Update the predefined distance.
  22844. * @param maxDistance The maximum preferred distance
  22845. * @param minDistance The minimum preferred distance
  22846. */
  22847. updateDistance(maxDistance: number, minDistance?: number): void;
  22848. }
  22849. /**
  22850. * Represents a Motor-Enabled Joint
  22851. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22852. */
  22853. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22854. /**
  22855. * Initializes the Motor-Enabled Joint
  22856. * @param type The type of the joint
  22857. * @param jointData The physica joint data for the joint
  22858. */
  22859. constructor(type: number, jointData: PhysicsJointData);
  22860. /**
  22861. * Set the motor values.
  22862. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22863. * @param force the force to apply
  22864. * @param maxForce max force for this motor.
  22865. */
  22866. setMotor(force?: number, maxForce?: number): void;
  22867. /**
  22868. * Set the motor's limits.
  22869. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22870. * @param upperLimit The upper limit of the motor
  22871. * @param lowerLimit The lower limit of the motor
  22872. */
  22873. setLimit(upperLimit: number, lowerLimit?: number): void;
  22874. }
  22875. /**
  22876. * This class represents a single physics Hinge-Joint
  22877. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22878. */
  22879. export class HingeJoint extends MotorEnabledJoint {
  22880. /**
  22881. * Initializes the Hinge-Joint
  22882. * @param jointData The joint data for the Hinge-Joint
  22883. */
  22884. constructor(jointData: PhysicsJointData);
  22885. /**
  22886. * Set the motor values.
  22887. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22888. * @param {number} force the force to apply
  22889. * @param {number} maxForce max force for this motor.
  22890. */
  22891. setMotor(force?: number, maxForce?: number): void;
  22892. /**
  22893. * Set the motor's limits.
  22894. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22895. * @param upperLimit The upper limit of the motor
  22896. * @param lowerLimit The lower limit of the motor
  22897. */
  22898. setLimit(upperLimit: number, lowerLimit?: number): void;
  22899. }
  22900. /**
  22901. * This class represents a dual hinge physics joint (same as wheel joint)
  22902. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22903. */
  22904. export class Hinge2Joint extends MotorEnabledJoint {
  22905. /**
  22906. * Initializes the Hinge2-Joint
  22907. * @param jointData The joint data for the Hinge2-Joint
  22908. */
  22909. constructor(jointData: PhysicsJointData);
  22910. /**
  22911. * Set the motor values.
  22912. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22913. * @param {number} targetSpeed the speed the motor is to reach
  22914. * @param {number} maxForce max force for this motor.
  22915. * @param {motorIndex} the motor's index, 0 or 1.
  22916. */
  22917. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22918. /**
  22919. * Set the motor limits.
  22920. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22921. * @param {number} upperLimit the upper limit
  22922. * @param {number} lowerLimit lower limit
  22923. * @param {motorIndex} the motor's index, 0 or 1.
  22924. */
  22925. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22926. }
  22927. /**
  22928. * Interface for a motor enabled joint
  22929. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22930. */
  22931. export interface IMotorEnabledJoint {
  22932. /**
  22933. * Physics joint
  22934. */
  22935. physicsJoint: any;
  22936. /**
  22937. * Sets the motor of the motor-enabled joint
  22938. * @param force The force of the motor
  22939. * @param maxForce The maximum force of the motor
  22940. * @param motorIndex The index of the motor
  22941. */
  22942. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22943. /**
  22944. * Sets the limit of the motor
  22945. * @param upperLimit The upper limit of the motor
  22946. * @param lowerLimit The lower limit of the motor
  22947. * @param motorIndex The index of the motor
  22948. */
  22949. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22950. }
  22951. /**
  22952. * Joint data for a Distance-Joint
  22953. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22954. */
  22955. export interface DistanceJointData extends PhysicsJointData {
  22956. /**
  22957. * Max distance the 2 joint objects can be apart
  22958. */
  22959. maxDistance: number;
  22960. }
  22961. /**
  22962. * Joint data from a spring joint
  22963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22964. */
  22965. export interface SpringJointData extends PhysicsJointData {
  22966. /**
  22967. * Length of the spring
  22968. */
  22969. length: number;
  22970. /**
  22971. * Stiffness of the spring
  22972. */
  22973. stiffness: number;
  22974. /**
  22975. * Damping of the spring
  22976. */
  22977. damping: number;
  22978. /** this callback will be called when applying the force to the impostors. */
  22979. forceApplicationCallback: () => void;
  22980. }
  22981. }
  22982. declare module "babylonjs/Physics/physicsRaycastResult" {
  22983. import { Vector3 } from "babylonjs/Maths/math.vector";
  22984. /**
  22985. * Holds the data for the raycast result
  22986. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22987. */
  22988. export class PhysicsRaycastResult {
  22989. private _hasHit;
  22990. private _hitDistance;
  22991. private _hitNormalWorld;
  22992. private _hitPointWorld;
  22993. private _rayFromWorld;
  22994. private _rayToWorld;
  22995. /**
  22996. * Gets if there was a hit
  22997. */
  22998. readonly hasHit: boolean;
  22999. /**
  23000. * Gets the distance from the hit
  23001. */
  23002. readonly hitDistance: number;
  23003. /**
  23004. * Gets the hit normal/direction in the world
  23005. */
  23006. readonly hitNormalWorld: Vector3;
  23007. /**
  23008. * Gets the hit point in the world
  23009. */
  23010. readonly hitPointWorld: Vector3;
  23011. /**
  23012. * Gets the ray "start point" of the ray in the world
  23013. */
  23014. readonly rayFromWorld: Vector3;
  23015. /**
  23016. * Gets the ray "end point" of the ray in the world
  23017. */
  23018. readonly rayToWorld: Vector3;
  23019. /**
  23020. * Sets the hit data (normal & point in world space)
  23021. * @param hitNormalWorld defines the normal in world space
  23022. * @param hitPointWorld defines the point in world space
  23023. */
  23024. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23025. /**
  23026. * Sets the distance from the start point to the hit point
  23027. * @param distance
  23028. */
  23029. setHitDistance(distance: number): void;
  23030. /**
  23031. * Calculates the distance manually
  23032. */
  23033. calculateHitDistance(): void;
  23034. /**
  23035. * Resets all the values to default
  23036. * @param from The from point on world space
  23037. * @param to The to point on world space
  23038. */
  23039. reset(from?: Vector3, to?: Vector3): void;
  23040. }
  23041. /**
  23042. * Interface for the size containing width and height
  23043. */
  23044. interface IXYZ {
  23045. /**
  23046. * X
  23047. */
  23048. x: number;
  23049. /**
  23050. * Y
  23051. */
  23052. y: number;
  23053. /**
  23054. * Z
  23055. */
  23056. z: number;
  23057. }
  23058. }
  23059. declare module "babylonjs/Physics/IPhysicsEngine" {
  23060. import { Nullable } from "babylonjs/types";
  23061. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23063. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23064. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23065. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23066. /**
  23067. * Interface used to describe a physics joint
  23068. */
  23069. export interface PhysicsImpostorJoint {
  23070. /** Defines the main impostor to which the joint is linked */
  23071. mainImpostor: PhysicsImpostor;
  23072. /** Defines the impostor that is connected to the main impostor using this joint */
  23073. connectedImpostor: PhysicsImpostor;
  23074. /** Defines the joint itself */
  23075. joint: PhysicsJoint;
  23076. }
  23077. /** @hidden */
  23078. export interface IPhysicsEnginePlugin {
  23079. world: any;
  23080. name: string;
  23081. setGravity(gravity: Vector3): void;
  23082. setTimeStep(timeStep: number): void;
  23083. getTimeStep(): number;
  23084. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23085. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23086. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23087. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23088. removePhysicsBody(impostor: PhysicsImpostor): void;
  23089. generateJoint(joint: PhysicsImpostorJoint): void;
  23090. removeJoint(joint: PhysicsImpostorJoint): void;
  23091. isSupported(): boolean;
  23092. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23093. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23094. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23095. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23096. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23097. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23098. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23099. getBodyMass(impostor: PhysicsImpostor): number;
  23100. getBodyFriction(impostor: PhysicsImpostor): number;
  23101. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23102. getBodyRestitution(impostor: PhysicsImpostor): number;
  23103. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23104. getBodyPressure?(impostor: PhysicsImpostor): number;
  23105. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23106. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23107. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23108. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23109. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23110. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23111. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23112. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23113. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23114. sleepBody(impostor: PhysicsImpostor): void;
  23115. wakeUpBody(impostor: PhysicsImpostor): void;
  23116. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23117. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23118. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23119. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23120. getRadius(impostor: PhysicsImpostor): number;
  23121. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23122. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23123. dispose(): void;
  23124. }
  23125. /**
  23126. * Interface used to define a physics engine
  23127. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23128. */
  23129. export interface IPhysicsEngine {
  23130. /**
  23131. * Gets the gravity vector used by the simulation
  23132. */
  23133. gravity: Vector3;
  23134. /**
  23135. * Sets the gravity vector used by the simulation
  23136. * @param gravity defines the gravity vector to use
  23137. */
  23138. setGravity(gravity: Vector3): void;
  23139. /**
  23140. * Set the time step of the physics engine.
  23141. * Default is 1/60.
  23142. * To slow it down, enter 1/600 for example.
  23143. * To speed it up, 1/30
  23144. * @param newTimeStep the new timestep to apply to this world.
  23145. */
  23146. setTimeStep(newTimeStep: number): void;
  23147. /**
  23148. * Get the time step of the physics engine.
  23149. * @returns the current time step
  23150. */
  23151. getTimeStep(): number;
  23152. /**
  23153. * Release all resources
  23154. */
  23155. dispose(): void;
  23156. /**
  23157. * Gets the name of the current physics plugin
  23158. * @returns the name of the plugin
  23159. */
  23160. getPhysicsPluginName(): string;
  23161. /**
  23162. * Adding a new impostor for the impostor tracking.
  23163. * This will be done by the impostor itself.
  23164. * @param impostor the impostor to add
  23165. */
  23166. addImpostor(impostor: PhysicsImpostor): void;
  23167. /**
  23168. * Remove an impostor from the engine.
  23169. * This impostor and its mesh will not longer be updated by the physics engine.
  23170. * @param impostor the impostor to remove
  23171. */
  23172. removeImpostor(impostor: PhysicsImpostor): void;
  23173. /**
  23174. * Add a joint to the physics engine
  23175. * @param mainImpostor defines the main impostor to which the joint is added.
  23176. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23177. * @param joint defines the joint that will connect both impostors.
  23178. */
  23179. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23180. /**
  23181. * Removes a joint from the simulation
  23182. * @param mainImpostor defines the impostor used with the joint
  23183. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23184. * @param joint defines the joint to remove
  23185. */
  23186. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23187. /**
  23188. * Gets the current plugin used to run the simulation
  23189. * @returns current plugin
  23190. */
  23191. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23192. /**
  23193. * Gets the list of physic impostors
  23194. * @returns an array of PhysicsImpostor
  23195. */
  23196. getImpostors(): Array<PhysicsImpostor>;
  23197. /**
  23198. * Gets the impostor for a physics enabled object
  23199. * @param object defines the object impersonated by the impostor
  23200. * @returns the PhysicsImpostor or null if not found
  23201. */
  23202. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23203. /**
  23204. * Gets the impostor for a physics body object
  23205. * @param body defines physics body used by the impostor
  23206. * @returns the PhysicsImpostor or null if not found
  23207. */
  23208. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23209. /**
  23210. * Does a raycast in the physics world
  23211. * @param from when should the ray start?
  23212. * @param to when should the ray end?
  23213. * @returns PhysicsRaycastResult
  23214. */
  23215. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23216. /**
  23217. * Called by the scene. No need to call it.
  23218. * @param delta defines the timespam between frames
  23219. */
  23220. _step(delta: number): void;
  23221. }
  23222. }
  23223. declare module "babylonjs/Physics/physicsImpostor" {
  23224. import { Nullable, IndicesArray } from "babylonjs/types";
  23225. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23226. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23227. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23228. import { Scene } from "babylonjs/scene";
  23229. import { Bone } from "babylonjs/Bones/bone";
  23230. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23231. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23232. import { Space } from "babylonjs/Maths/math.axis";
  23233. /**
  23234. * The interface for the physics imposter parameters
  23235. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23236. */
  23237. export interface PhysicsImpostorParameters {
  23238. /**
  23239. * The mass of the physics imposter
  23240. */
  23241. mass: number;
  23242. /**
  23243. * The friction of the physics imposter
  23244. */
  23245. friction?: number;
  23246. /**
  23247. * The coefficient of restitution of the physics imposter
  23248. */
  23249. restitution?: number;
  23250. /**
  23251. * The native options of the physics imposter
  23252. */
  23253. nativeOptions?: any;
  23254. /**
  23255. * Specifies if the parent should be ignored
  23256. */
  23257. ignoreParent?: boolean;
  23258. /**
  23259. * Specifies if bi-directional transformations should be disabled
  23260. */
  23261. disableBidirectionalTransformation?: boolean;
  23262. /**
  23263. * The pressure inside the physics imposter, soft object only
  23264. */
  23265. pressure?: number;
  23266. /**
  23267. * The stiffness the physics imposter, soft object only
  23268. */
  23269. stiffness?: number;
  23270. /**
  23271. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23272. */
  23273. velocityIterations?: number;
  23274. /**
  23275. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23276. */
  23277. positionIterations?: number;
  23278. /**
  23279. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23280. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23281. * Add to fix multiple points
  23282. */
  23283. fixedPoints?: number;
  23284. /**
  23285. * The collision margin around a soft object
  23286. */
  23287. margin?: number;
  23288. /**
  23289. * The collision margin around a soft object
  23290. */
  23291. damping?: number;
  23292. /**
  23293. * The path for a rope based on an extrusion
  23294. */
  23295. path?: any;
  23296. /**
  23297. * The shape of an extrusion used for a rope based on an extrusion
  23298. */
  23299. shape?: any;
  23300. }
  23301. /**
  23302. * Interface for a physics-enabled object
  23303. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23304. */
  23305. export interface IPhysicsEnabledObject {
  23306. /**
  23307. * The position of the physics-enabled object
  23308. */
  23309. position: Vector3;
  23310. /**
  23311. * The rotation of the physics-enabled object
  23312. */
  23313. rotationQuaternion: Nullable<Quaternion>;
  23314. /**
  23315. * The scale of the physics-enabled object
  23316. */
  23317. scaling: Vector3;
  23318. /**
  23319. * The rotation of the physics-enabled object
  23320. */
  23321. rotation?: Vector3;
  23322. /**
  23323. * The parent of the physics-enabled object
  23324. */
  23325. parent?: any;
  23326. /**
  23327. * The bounding info of the physics-enabled object
  23328. * @returns The bounding info of the physics-enabled object
  23329. */
  23330. getBoundingInfo(): BoundingInfo;
  23331. /**
  23332. * Computes the world matrix
  23333. * @param force Specifies if the world matrix should be computed by force
  23334. * @returns A world matrix
  23335. */
  23336. computeWorldMatrix(force: boolean): Matrix;
  23337. /**
  23338. * Gets the world matrix
  23339. * @returns A world matrix
  23340. */
  23341. getWorldMatrix?(): Matrix;
  23342. /**
  23343. * Gets the child meshes
  23344. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23345. * @returns An array of abstract meshes
  23346. */
  23347. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23348. /**
  23349. * Gets the vertex data
  23350. * @param kind The type of vertex data
  23351. * @returns A nullable array of numbers, or a float32 array
  23352. */
  23353. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23354. /**
  23355. * Gets the indices from the mesh
  23356. * @returns A nullable array of index arrays
  23357. */
  23358. getIndices?(): Nullable<IndicesArray>;
  23359. /**
  23360. * Gets the scene from the mesh
  23361. * @returns the indices array or null
  23362. */
  23363. getScene?(): Scene;
  23364. /**
  23365. * Gets the absolute position from the mesh
  23366. * @returns the absolute position
  23367. */
  23368. getAbsolutePosition(): Vector3;
  23369. /**
  23370. * Gets the absolute pivot point from the mesh
  23371. * @returns the absolute pivot point
  23372. */
  23373. getAbsolutePivotPoint(): Vector3;
  23374. /**
  23375. * Rotates the mesh
  23376. * @param axis The axis of rotation
  23377. * @param amount The amount of rotation
  23378. * @param space The space of the rotation
  23379. * @returns The rotation transform node
  23380. */
  23381. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23382. /**
  23383. * Translates the mesh
  23384. * @param axis The axis of translation
  23385. * @param distance The distance of translation
  23386. * @param space The space of the translation
  23387. * @returns The transform node
  23388. */
  23389. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23390. /**
  23391. * Sets the absolute position of the mesh
  23392. * @param absolutePosition The absolute position of the mesh
  23393. * @returns The transform node
  23394. */
  23395. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23396. /**
  23397. * Gets the class name of the mesh
  23398. * @returns The class name
  23399. */
  23400. getClassName(): string;
  23401. }
  23402. /**
  23403. * Represents a physics imposter
  23404. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23405. */
  23406. export class PhysicsImpostor {
  23407. /**
  23408. * The physics-enabled object used as the physics imposter
  23409. */
  23410. object: IPhysicsEnabledObject;
  23411. /**
  23412. * The type of the physics imposter
  23413. */
  23414. type: number;
  23415. private _options;
  23416. private _scene?;
  23417. /**
  23418. * The default object size of the imposter
  23419. */
  23420. static DEFAULT_OBJECT_SIZE: Vector3;
  23421. /**
  23422. * The identity quaternion of the imposter
  23423. */
  23424. static IDENTITY_QUATERNION: Quaternion;
  23425. /** @hidden */
  23426. _pluginData: any;
  23427. private _physicsEngine;
  23428. private _physicsBody;
  23429. private _bodyUpdateRequired;
  23430. private _onBeforePhysicsStepCallbacks;
  23431. private _onAfterPhysicsStepCallbacks;
  23432. /** @hidden */
  23433. _onPhysicsCollideCallbacks: Array<{
  23434. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23435. otherImpostors: Array<PhysicsImpostor>;
  23436. }>;
  23437. private _deltaPosition;
  23438. private _deltaRotation;
  23439. private _deltaRotationConjugated;
  23440. /** @hidden */
  23441. _isFromLine: boolean;
  23442. private _parent;
  23443. private _isDisposed;
  23444. private static _tmpVecs;
  23445. private static _tmpQuat;
  23446. /**
  23447. * Specifies if the physics imposter is disposed
  23448. */
  23449. readonly isDisposed: boolean;
  23450. /**
  23451. * Gets the mass of the physics imposter
  23452. */
  23453. mass: number;
  23454. /**
  23455. * Gets the coefficient of friction
  23456. */
  23457. /**
  23458. * Sets the coefficient of friction
  23459. */
  23460. friction: number;
  23461. /**
  23462. * Gets the coefficient of restitution
  23463. */
  23464. /**
  23465. * Sets the coefficient of restitution
  23466. */
  23467. restitution: number;
  23468. /**
  23469. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23470. */
  23471. /**
  23472. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23473. */
  23474. pressure: number;
  23475. /**
  23476. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23477. */
  23478. /**
  23479. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23480. */
  23481. stiffness: number;
  23482. /**
  23483. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23484. */
  23485. /**
  23486. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23487. */
  23488. velocityIterations: number;
  23489. /**
  23490. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23491. */
  23492. /**
  23493. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23494. */
  23495. positionIterations: number;
  23496. /**
  23497. * The unique id of the physics imposter
  23498. * set by the physics engine when adding this impostor to the array
  23499. */
  23500. uniqueId: number;
  23501. /**
  23502. * @hidden
  23503. */
  23504. soft: boolean;
  23505. /**
  23506. * @hidden
  23507. */
  23508. segments: number;
  23509. private _joints;
  23510. /**
  23511. * Initializes the physics imposter
  23512. * @param object The physics-enabled object used as the physics imposter
  23513. * @param type The type of the physics imposter
  23514. * @param _options The options for the physics imposter
  23515. * @param _scene The Babylon scene
  23516. */
  23517. constructor(
  23518. /**
  23519. * The physics-enabled object used as the physics imposter
  23520. */
  23521. object: IPhysicsEnabledObject,
  23522. /**
  23523. * The type of the physics imposter
  23524. */
  23525. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23526. /**
  23527. * This function will completly initialize this impostor.
  23528. * It will create a new body - but only if this mesh has no parent.
  23529. * If it has, this impostor will not be used other than to define the impostor
  23530. * of the child mesh.
  23531. * @hidden
  23532. */
  23533. _init(): void;
  23534. private _getPhysicsParent;
  23535. /**
  23536. * Should a new body be generated.
  23537. * @returns boolean specifying if body initialization is required
  23538. */
  23539. isBodyInitRequired(): boolean;
  23540. /**
  23541. * Sets the updated scaling
  23542. * @param updated Specifies if the scaling is updated
  23543. */
  23544. setScalingUpdated(): void;
  23545. /**
  23546. * Force a regeneration of this or the parent's impostor's body.
  23547. * Use under cautious - This will remove all joints already implemented.
  23548. */
  23549. forceUpdate(): void;
  23550. /**
  23551. * Gets the body that holds this impostor. Either its own, or its parent.
  23552. */
  23553. /**
  23554. * Set the physics body. Used mainly by the physics engine/plugin
  23555. */
  23556. physicsBody: any;
  23557. /**
  23558. * Get the parent of the physics imposter
  23559. * @returns Physics imposter or null
  23560. */
  23561. /**
  23562. * Sets the parent of the physics imposter
  23563. */
  23564. parent: Nullable<PhysicsImpostor>;
  23565. /**
  23566. * Resets the update flags
  23567. */
  23568. resetUpdateFlags(): void;
  23569. /**
  23570. * Gets the object extend size
  23571. * @returns the object extend size
  23572. */
  23573. getObjectExtendSize(): Vector3;
  23574. /**
  23575. * Gets the object center
  23576. * @returns The object center
  23577. */
  23578. getObjectCenter(): Vector3;
  23579. /**
  23580. * Get a specific parametes from the options parameter
  23581. * @param paramName The object parameter name
  23582. * @returns The object parameter
  23583. */
  23584. getParam(paramName: string): any;
  23585. /**
  23586. * Sets a specific parameter in the options given to the physics plugin
  23587. * @param paramName The parameter name
  23588. * @param value The value of the parameter
  23589. */
  23590. setParam(paramName: string, value: number): void;
  23591. /**
  23592. * Specifically change the body's mass option. Won't recreate the physics body object
  23593. * @param mass The mass of the physics imposter
  23594. */
  23595. setMass(mass: number): void;
  23596. /**
  23597. * Gets the linear velocity
  23598. * @returns linear velocity or null
  23599. */
  23600. getLinearVelocity(): Nullable<Vector3>;
  23601. /**
  23602. * Sets the linear velocity
  23603. * @param velocity linear velocity or null
  23604. */
  23605. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23606. /**
  23607. * Gets the angular velocity
  23608. * @returns angular velocity or null
  23609. */
  23610. getAngularVelocity(): Nullable<Vector3>;
  23611. /**
  23612. * Sets the angular velocity
  23613. * @param velocity The velocity or null
  23614. */
  23615. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23616. /**
  23617. * Execute a function with the physics plugin native code
  23618. * Provide a function the will have two variables - the world object and the physics body object
  23619. * @param func The function to execute with the physics plugin native code
  23620. */
  23621. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23622. /**
  23623. * Register a function that will be executed before the physics world is stepping forward
  23624. * @param func The function to execute before the physics world is stepped forward
  23625. */
  23626. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23627. /**
  23628. * Unregister a function that will be executed before the physics world is stepping forward
  23629. * @param func The function to execute before the physics world is stepped forward
  23630. */
  23631. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23632. /**
  23633. * Register a function that will be executed after the physics step
  23634. * @param func The function to execute after physics step
  23635. */
  23636. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23637. /**
  23638. * Unregisters a function that will be executed after the physics step
  23639. * @param func The function to execute after physics step
  23640. */
  23641. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23642. /**
  23643. * register a function that will be executed when this impostor collides against a different body
  23644. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23645. * @param func Callback that is executed on collision
  23646. */
  23647. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23648. /**
  23649. * Unregisters the physics imposter on contact
  23650. * @param collideAgainst The physics object to collide against
  23651. * @param func Callback to execute on collision
  23652. */
  23653. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23654. private _tmpQuat;
  23655. private _tmpQuat2;
  23656. /**
  23657. * Get the parent rotation
  23658. * @returns The parent rotation
  23659. */
  23660. getParentsRotation(): Quaternion;
  23661. /**
  23662. * this function is executed by the physics engine.
  23663. */
  23664. beforeStep: () => void;
  23665. /**
  23666. * this function is executed by the physics engine
  23667. */
  23668. afterStep: () => void;
  23669. /**
  23670. * Legacy collision detection event support
  23671. */
  23672. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23673. /**
  23674. * event and body object due to cannon's event-based architecture.
  23675. */
  23676. onCollide: (e: {
  23677. body: any;
  23678. }) => void;
  23679. /**
  23680. * Apply a force
  23681. * @param force The force to apply
  23682. * @param contactPoint The contact point for the force
  23683. * @returns The physics imposter
  23684. */
  23685. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23686. /**
  23687. * Apply an impulse
  23688. * @param force The impulse force
  23689. * @param contactPoint The contact point for the impulse force
  23690. * @returns The physics imposter
  23691. */
  23692. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23693. /**
  23694. * A help function to create a joint
  23695. * @param otherImpostor A physics imposter used to create a joint
  23696. * @param jointType The type of joint
  23697. * @param jointData The data for the joint
  23698. * @returns The physics imposter
  23699. */
  23700. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23701. /**
  23702. * Add a joint to this impostor with a different impostor
  23703. * @param otherImpostor A physics imposter used to add a joint
  23704. * @param joint The joint to add
  23705. * @returns The physics imposter
  23706. */
  23707. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23708. /**
  23709. * Add an anchor to a cloth impostor
  23710. * @param otherImpostor rigid impostor to anchor to
  23711. * @param width ratio across width from 0 to 1
  23712. * @param height ratio up height from 0 to 1
  23713. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23714. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23715. * @returns impostor the soft imposter
  23716. */
  23717. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23718. /**
  23719. * Add a hook to a rope impostor
  23720. * @param otherImpostor rigid impostor to anchor to
  23721. * @param length ratio across rope from 0 to 1
  23722. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23723. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23724. * @returns impostor the rope imposter
  23725. */
  23726. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23727. /**
  23728. * Will keep this body still, in a sleep mode.
  23729. * @returns the physics imposter
  23730. */
  23731. sleep(): PhysicsImpostor;
  23732. /**
  23733. * Wake the body up.
  23734. * @returns The physics imposter
  23735. */
  23736. wakeUp(): PhysicsImpostor;
  23737. /**
  23738. * Clones the physics imposter
  23739. * @param newObject The physics imposter clones to this physics-enabled object
  23740. * @returns A nullable physics imposter
  23741. */
  23742. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23743. /**
  23744. * Disposes the physics imposter
  23745. */
  23746. dispose(): void;
  23747. /**
  23748. * Sets the delta position
  23749. * @param position The delta position amount
  23750. */
  23751. setDeltaPosition(position: Vector3): void;
  23752. /**
  23753. * Sets the delta rotation
  23754. * @param rotation The delta rotation amount
  23755. */
  23756. setDeltaRotation(rotation: Quaternion): void;
  23757. /**
  23758. * Gets the box size of the physics imposter and stores the result in the input parameter
  23759. * @param result Stores the box size
  23760. * @returns The physics imposter
  23761. */
  23762. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23763. /**
  23764. * Gets the radius of the physics imposter
  23765. * @returns Radius of the physics imposter
  23766. */
  23767. getRadius(): number;
  23768. /**
  23769. * Sync a bone with this impostor
  23770. * @param bone The bone to sync to the impostor.
  23771. * @param boneMesh The mesh that the bone is influencing.
  23772. * @param jointPivot The pivot of the joint / bone in local space.
  23773. * @param distToJoint Optional distance from the impostor to the joint.
  23774. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23775. */
  23776. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23777. /**
  23778. * Sync impostor to a bone
  23779. * @param bone The bone that the impostor will be synced to.
  23780. * @param boneMesh The mesh that the bone is influencing.
  23781. * @param jointPivot The pivot of the joint / bone in local space.
  23782. * @param distToJoint Optional distance from the impostor to the joint.
  23783. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23784. * @param boneAxis Optional vector3 axis the bone is aligned with
  23785. */
  23786. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23787. /**
  23788. * No-Imposter type
  23789. */
  23790. static NoImpostor: number;
  23791. /**
  23792. * Sphere-Imposter type
  23793. */
  23794. static SphereImpostor: number;
  23795. /**
  23796. * Box-Imposter type
  23797. */
  23798. static BoxImpostor: number;
  23799. /**
  23800. * Plane-Imposter type
  23801. */
  23802. static PlaneImpostor: number;
  23803. /**
  23804. * Mesh-imposter type
  23805. */
  23806. static MeshImpostor: number;
  23807. /**
  23808. * Capsule-Impostor type (Ammo.js plugin only)
  23809. */
  23810. static CapsuleImpostor: number;
  23811. /**
  23812. * Cylinder-Imposter type
  23813. */
  23814. static CylinderImpostor: number;
  23815. /**
  23816. * Particle-Imposter type
  23817. */
  23818. static ParticleImpostor: number;
  23819. /**
  23820. * Heightmap-Imposter type
  23821. */
  23822. static HeightmapImpostor: number;
  23823. /**
  23824. * ConvexHull-Impostor type (Ammo.js plugin only)
  23825. */
  23826. static ConvexHullImpostor: number;
  23827. /**
  23828. * Rope-Imposter type
  23829. */
  23830. static RopeImpostor: number;
  23831. /**
  23832. * Cloth-Imposter type
  23833. */
  23834. static ClothImpostor: number;
  23835. /**
  23836. * Softbody-Imposter type
  23837. */
  23838. static SoftbodyImpostor: number;
  23839. }
  23840. }
  23841. declare module "babylonjs/Meshes/mesh" {
  23842. import { Observable } from "babylonjs/Misc/observable";
  23843. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23844. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23845. import { Camera } from "babylonjs/Cameras/camera";
  23846. import { Scene } from "babylonjs/scene";
  23847. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  23848. import { Color4 } from "babylonjs/Maths/math.color";
  23849. import { Engine } from "babylonjs/Engines/engine";
  23850. import { Node } from "babylonjs/node";
  23851. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23852. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23853. import { Buffer } from "babylonjs/Meshes/buffer";
  23854. import { Geometry } from "babylonjs/Meshes/geometry";
  23855. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23856. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23857. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  23858. import { Effect } from "babylonjs/Materials/effect";
  23859. import { Material } from "babylonjs/Materials/material";
  23860. import { Skeleton } from "babylonjs/Bones/skeleton";
  23861. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  23862. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  23863. import { Path3D } from "babylonjs/Maths/math.path";
  23864. import { Plane } from "babylonjs/Maths/math.plane";
  23865. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  23866. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  23867. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  23868. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23869. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  23870. /**
  23871. * @hidden
  23872. **/
  23873. export class _CreationDataStorage {
  23874. closePath?: boolean;
  23875. closeArray?: boolean;
  23876. idx: number[];
  23877. dashSize: number;
  23878. gapSize: number;
  23879. path3D: Path3D;
  23880. pathArray: Vector3[][];
  23881. arc: number;
  23882. radius: number;
  23883. cap: number;
  23884. tessellation: number;
  23885. }
  23886. /**
  23887. * @hidden
  23888. **/
  23889. class _InstanceDataStorage {
  23890. visibleInstances: any;
  23891. batchCache: _InstancesBatch;
  23892. instancesBufferSize: number;
  23893. instancesBuffer: Nullable<Buffer>;
  23894. instancesData: Float32Array;
  23895. overridenInstanceCount: number;
  23896. isFrozen: boolean;
  23897. previousBatch: Nullable<_InstancesBatch>;
  23898. hardwareInstancedRendering: boolean;
  23899. sideOrientation: number;
  23900. }
  23901. /**
  23902. * @hidden
  23903. **/
  23904. export class _InstancesBatch {
  23905. mustReturn: boolean;
  23906. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  23907. renderSelf: boolean[];
  23908. hardwareInstancedRendering: boolean[];
  23909. }
  23910. /**
  23911. * Class used to represent renderable models
  23912. */
  23913. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23914. /**
  23915. * Mesh side orientation : usually the external or front surface
  23916. */
  23917. static readonly FRONTSIDE: number;
  23918. /**
  23919. * Mesh side orientation : usually the internal or back surface
  23920. */
  23921. static readonly BACKSIDE: number;
  23922. /**
  23923. * Mesh side orientation : both internal and external or front and back surfaces
  23924. */
  23925. static readonly DOUBLESIDE: number;
  23926. /**
  23927. * Mesh side orientation : by default, `FRONTSIDE`
  23928. */
  23929. static readonly DEFAULTSIDE: number;
  23930. /**
  23931. * Mesh cap setting : no cap
  23932. */
  23933. static readonly NO_CAP: number;
  23934. /**
  23935. * Mesh cap setting : one cap at the beginning of the mesh
  23936. */
  23937. static readonly CAP_START: number;
  23938. /**
  23939. * Mesh cap setting : one cap at the end of the mesh
  23940. */
  23941. static readonly CAP_END: number;
  23942. /**
  23943. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23944. */
  23945. static readonly CAP_ALL: number;
  23946. /**
  23947. * Mesh pattern setting : no flip or rotate
  23948. */
  23949. static readonly NO_FLIP: number;
  23950. /**
  23951. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23952. */
  23953. static readonly FLIP_TILE: number;
  23954. /**
  23955. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23956. */
  23957. static readonly ROTATE_TILE: number;
  23958. /**
  23959. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23960. */
  23961. static readonly FLIP_ROW: number;
  23962. /**
  23963. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23964. */
  23965. static readonly ROTATE_ROW: number;
  23966. /**
  23967. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23968. */
  23969. static readonly FLIP_N_ROTATE_TILE: number;
  23970. /**
  23971. * Mesh pattern setting : rotate pattern and rotate
  23972. */
  23973. static readonly FLIP_N_ROTATE_ROW: number;
  23974. /**
  23975. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23976. */
  23977. static readonly CENTER: number;
  23978. /**
  23979. * Mesh tile positioning : part tiles on left
  23980. */
  23981. static readonly LEFT: number;
  23982. /**
  23983. * Mesh tile positioning : part tiles on right
  23984. */
  23985. static readonly RIGHT: number;
  23986. /**
  23987. * Mesh tile positioning : part tiles on top
  23988. */
  23989. static readonly TOP: number;
  23990. /**
  23991. * Mesh tile positioning : part tiles on bottom
  23992. */
  23993. static readonly BOTTOM: number;
  23994. /**
  23995. * Gets the default side orientation.
  23996. * @param orientation the orientation to value to attempt to get
  23997. * @returns the default orientation
  23998. * @hidden
  23999. */
  24000. static _GetDefaultSideOrientation(orientation?: number): number;
  24001. private _internalMeshDataInfo;
  24002. /**
  24003. * An event triggered before rendering the mesh
  24004. */
  24005. readonly onBeforeRenderObservable: Observable<Mesh>;
  24006. /**
  24007. * An event triggered before binding the mesh
  24008. */
  24009. readonly onBeforeBindObservable: Observable<Mesh>;
  24010. /**
  24011. * An event triggered after rendering the mesh
  24012. */
  24013. readonly onAfterRenderObservable: Observable<Mesh>;
  24014. /**
  24015. * An event triggered before drawing the mesh
  24016. */
  24017. readonly onBeforeDrawObservable: Observable<Mesh>;
  24018. private _onBeforeDrawObserver;
  24019. /**
  24020. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24021. */
  24022. onBeforeDraw: () => void;
  24023. /**
  24024. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24025. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24026. */
  24027. delayLoadState: number;
  24028. /**
  24029. * Gets the list of instances created from this mesh
  24030. * it is not supposed to be modified manually.
  24031. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24032. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24033. */
  24034. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24035. /**
  24036. * Gets the file containing delay loading data for this mesh
  24037. */
  24038. delayLoadingFile: string;
  24039. /** @hidden */
  24040. _binaryInfo: any;
  24041. /**
  24042. * User defined function used to change how LOD level selection is done
  24043. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24044. */
  24045. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24046. /**
  24047. * Gets or sets the morph target manager
  24048. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24049. */
  24050. morphTargetManager: Nullable<MorphTargetManager>;
  24051. /** @hidden */
  24052. _creationDataStorage: Nullable<_CreationDataStorage>;
  24053. /** @hidden */
  24054. _geometry: Nullable<Geometry>;
  24055. /** @hidden */
  24056. _delayInfo: Array<string>;
  24057. /** @hidden */
  24058. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24059. /** @hidden */
  24060. _instanceDataStorage: _InstanceDataStorage;
  24061. private _effectiveMaterial;
  24062. /** @hidden */
  24063. _shouldGenerateFlatShading: boolean;
  24064. /** @hidden */
  24065. _originalBuilderSideOrientation: number;
  24066. /**
  24067. * Use this property to change the original side orientation defined at construction time
  24068. */
  24069. overrideMaterialSideOrientation: Nullable<number>;
  24070. /**
  24071. * Gets the source mesh (the one used to clone this one from)
  24072. */
  24073. readonly source: Nullable<Mesh>;
  24074. /**
  24075. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24076. */
  24077. isUnIndexed: boolean;
  24078. /**
  24079. * @constructor
  24080. * @param name The value used by scene.getMeshByName() to do a lookup.
  24081. * @param scene The scene to add this mesh to.
  24082. * @param parent The parent of this mesh, if it has one
  24083. * @param source An optional Mesh from which geometry is shared, cloned.
  24084. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24085. * When false, achieved by calling a clone(), also passing False.
  24086. * This will make creation of children, recursive.
  24087. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24088. */
  24089. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24090. /**
  24091. * Gets the class name
  24092. * @returns the string "Mesh".
  24093. */
  24094. getClassName(): string;
  24095. /** @hidden */
  24096. readonly _isMesh: boolean;
  24097. /**
  24098. * Returns a description of this mesh
  24099. * @param fullDetails define if full details about this mesh must be used
  24100. * @returns a descriptive string representing this mesh
  24101. */
  24102. toString(fullDetails?: boolean): string;
  24103. /** @hidden */
  24104. _unBindEffect(): void;
  24105. /**
  24106. * Gets a boolean indicating if this mesh has LOD
  24107. */
  24108. readonly hasLODLevels: boolean;
  24109. /**
  24110. * Gets the list of MeshLODLevel associated with the current mesh
  24111. * @returns an array of MeshLODLevel
  24112. */
  24113. getLODLevels(): MeshLODLevel[];
  24114. private _sortLODLevels;
  24115. /**
  24116. * Add a mesh as LOD level triggered at the given distance.
  24117. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24118. * @param distance The distance from the center of the object to show this level
  24119. * @param mesh The mesh to be added as LOD level (can be null)
  24120. * @return This mesh (for chaining)
  24121. */
  24122. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24123. /**
  24124. * Returns the LOD level mesh at the passed distance or null if not found.
  24125. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24126. * @param distance The distance from the center of the object to show this level
  24127. * @returns a Mesh or `null`
  24128. */
  24129. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24130. /**
  24131. * Remove a mesh from the LOD array
  24132. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24133. * @param mesh defines the mesh to be removed
  24134. * @return This mesh (for chaining)
  24135. */
  24136. removeLODLevel(mesh: Mesh): Mesh;
  24137. /**
  24138. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24139. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24140. * @param camera defines the camera to use to compute distance
  24141. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24142. * @return This mesh (for chaining)
  24143. */
  24144. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24145. /**
  24146. * Gets the mesh internal Geometry object
  24147. */
  24148. readonly geometry: Nullable<Geometry>;
  24149. /**
  24150. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24151. * @returns the total number of vertices
  24152. */
  24153. getTotalVertices(): number;
  24154. /**
  24155. * Returns the content of an associated vertex buffer
  24156. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24157. * - VertexBuffer.PositionKind
  24158. * - VertexBuffer.UVKind
  24159. * - VertexBuffer.UV2Kind
  24160. * - VertexBuffer.UV3Kind
  24161. * - VertexBuffer.UV4Kind
  24162. * - VertexBuffer.UV5Kind
  24163. * - VertexBuffer.UV6Kind
  24164. * - VertexBuffer.ColorKind
  24165. * - VertexBuffer.MatricesIndicesKind
  24166. * - VertexBuffer.MatricesIndicesExtraKind
  24167. * - VertexBuffer.MatricesWeightsKind
  24168. * - VertexBuffer.MatricesWeightsExtraKind
  24169. * @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
  24170. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24171. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24172. */
  24173. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24174. /**
  24175. * Returns the mesh VertexBuffer object from the requested `kind`
  24176. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24177. * - VertexBuffer.PositionKind
  24178. * - VertexBuffer.NormalKind
  24179. * - VertexBuffer.UVKind
  24180. * - VertexBuffer.UV2Kind
  24181. * - VertexBuffer.UV3Kind
  24182. * - VertexBuffer.UV4Kind
  24183. * - VertexBuffer.UV5Kind
  24184. * - VertexBuffer.UV6Kind
  24185. * - VertexBuffer.ColorKind
  24186. * - VertexBuffer.MatricesIndicesKind
  24187. * - VertexBuffer.MatricesIndicesExtraKind
  24188. * - VertexBuffer.MatricesWeightsKind
  24189. * - VertexBuffer.MatricesWeightsExtraKind
  24190. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24191. */
  24192. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24193. /**
  24194. * Tests if a specific vertex buffer is associated with this mesh
  24195. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24196. * - VertexBuffer.PositionKind
  24197. * - VertexBuffer.NormalKind
  24198. * - VertexBuffer.UVKind
  24199. * - VertexBuffer.UV2Kind
  24200. * - VertexBuffer.UV3Kind
  24201. * - VertexBuffer.UV4Kind
  24202. * - VertexBuffer.UV5Kind
  24203. * - VertexBuffer.UV6Kind
  24204. * - VertexBuffer.ColorKind
  24205. * - VertexBuffer.MatricesIndicesKind
  24206. * - VertexBuffer.MatricesIndicesExtraKind
  24207. * - VertexBuffer.MatricesWeightsKind
  24208. * - VertexBuffer.MatricesWeightsExtraKind
  24209. * @returns a boolean
  24210. */
  24211. isVerticesDataPresent(kind: string): boolean;
  24212. /**
  24213. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24214. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24215. * - VertexBuffer.PositionKind
  24216. * - VertexBuffer.UVKind
  24217. * - VertexBuffer.UV2Kind
  24218. * - VertexBuffer.UV3Kind
  24219. * - VertexBuffer.UV4Kind
  24220. * - VertexBuffer.UV5Kind
  24221. * - VertexBuffer.UV6Kind
  24222. * - VertexBuffer.ColorKind
  24223. * - VertexBuffer.MatricesIndicesKind
  24224. * - VertexBuffer.MatricesIndicesExtraKind
  24225. * - VertexBuffer.MatricesWeightsKind
  24226. * - VertexBuffer.MatricesWeightsExtraKind
  24227. * @returns a boolean
  24228. */
  24229. isVertexBufferUpdatable(kind: string): boolean;
  24230. /**
  24231. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24232. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24233. * - VertexBuffer.PositionKind
  24234. * - VertexBuffer.NormalKind
  24235. * - VertexBuffer.UVKind
  24236. * - VertexBuffer.UV2Kind
  24237. * - VertexBuffer.UV3Kind
  24238. * - VertexBuffer.UV4Kind
  24239. * - VertexBuffer.UV5Kind
  24240. * - VertexBuffer.UV6Kind
  24241. * - VertexBuffer.ColorKind
  24242. * - VertexBuffer.MatricesIndicesKind
  24243. * - VertexBuffer.MatricesIndicesExtraKind
  24244. * - VertexBuffer.MatricesWeightsKind
  24245. * - VertexBuffer.MatricesWeightsExtraKind
  24246. * @returns an array of strings
  24247. */
  24248. getVerticesDataKinds(): string[];
  24249. /**
  24250. * Returns a positive integer : the total number of indices in this mesh geometry.
  24251. * @returns the numner of indices or zero if the mesh has no geometry.
  24252. */
  24253. getTotalIndices(): number;
  24254. /**
  24255. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24256. * @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.
  24257. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24258. * @returns the indices array or an empty array if the mesh has no geometry
  24259. */
  24260. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24261. readonly isBlocked: boolean;
  24262. /**
  24263. * Determine if the current mesh is ready to be rendered
  24264. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24265. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24266. * @returns true if all associated assets are ready (material, textures, shaders)
  24267. */
  24268. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24269. /**
  24270. * 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.
  24271. */
  24272. readonly areNormalsFrozen: boolean;
  24273. /**
  24274. * 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.
  24275. * @returns the current mesh
  24276. */
  24277. freezeNormals(): Mesh;
  24278. /**
  24279. * 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
  24280. * @returns the current mesh
  24281. */
  24282. unfreezeNormals(): Mesh;
  24283. /**
  24284. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24285. */
  24286. overridenInstanceCount: number;
  24287. /** @hidden */
  24288. _preActivate(): Mesh;
  24289. /** @hidden */
  24290. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24291. /** @hidden */
  24292. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24293. /**
  24294. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24295. * This means the mesh underlying bounding box and sphere are recomputed.
  24296. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24297. * @returns the current mesh
  24298. */
  24299. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24300. /** @hidden */
  24301. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24302. /**
  24303. * This function will subdivide the mesh into multiple submeshes
  24304. * @param count defines the expected number of submeshes
  24305. */
  24306. subdivide(count: number): void;
  24307. /**
  24308. * Copy a FloatArray into a specific associated vertex buffer
  24309. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24310. * - VertexBuffer.PositionKind
  24311. * - VertexBuffer.UVKind
  24312. * - VertexBuffer.UV2Kind
  24313. * - VertexBuffer.UV3Kind
  24314. * - VertexBuffer.UV4Kind
  24315. * - VertexBuffer.UV5Kind
  24316. * - VertexBuffer.UV6Kind
  24317. * - VertexBuffer.ColorKind
  24318. * - VertexBuffer.MatricesIndicesKind
  24319. * - VertexBuffer.MatricesIndicesExtraKind
  24320. * - VertexBuffer.MatricesWeightsKind
  24321. * - VertexBuffer.MatricesWeightsExtraKind
  24322. * @param data defines the data source
  24323. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24324. * @param stride defines the data stride size (can be null)
  24325. * @returns the current mesh
  24326. */
  24327. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  24328. /**
  24329. * Flags an associated vertex buffer as updatable
  24330. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24331. * - VertexBuffer.PositionKind
  24332. * - VertexBuffer.UVKind
  24333. * - VertexBuffer.UV2Kind
  24334. * - VertexBuffer.UV3Kind
  24335. * - VertexBuffer.UV4Kind
  24336. * - VertexBuffer.UV5Kind
  24337. * - VertexBuffer.UV6Kind
  24338. * - VertexBuffer.ColorKind
  24339. * - VertexBuffer.MatricesIndicesKind
  24340. * - VertexBuffer.MatricesIndicesExtraKind
  24341. * - VertexBuffer.MatricesWeightsKind
  24342. * - VertexBuffer.MatricesWeightsExtraKind
  24343. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24344. */
  24345. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24346. /**
  24347. * Sets the mesh global Vertex Buffer
  24348. * @param buffer defines the buffer to use
  24349. * @returns the current mesh
  24350. */
  24351. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24352. /**
  24353. * Update a specific associated vertex buffer
  24354. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24355. * - VertexBuffer.PositionKind
  24356. * - VertexBuffer.UVKind
  24357. * - VertexBuffer.UV2Kind
  24358. * - VertexBuffer.UV3Kind
  24359. * - VertexBuffer.UV4Kind
  24360. * - VertexBuffer.UV5Kind
  24361. * - VertexBuffer.UV6Kind
  24362. * - VertexBuffer.ColorKind
  24363. * - VertexBuffer.MatricesIndicesKind
  24364. * - VertexBuffer.MatricesIndicesExtraKind
  24365. * - VertexBuffer.MatricesWeightsKind
  24366. * - VertexBuffer.MatricesWeightsExtraKind
  24367. * @param data defines the data source
  24368. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24369. * @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)
  24370. * @returns the current mesh
  24371. */
  24372. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  24373. /**
  24374. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24375. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24376. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24377. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24378. * @returns the current mesh
  24379. */
  24380. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24381. /**
  24382. * Creates a un-shared specific occurence of the geometry for the mesh.
  24383. * @returns the current mesh
  24384. */
  24385. makeGeometryUnique(): Mesh;
  24386. /**
  24387. * Set the index buffer of this mesh
  24388. * @param indices defines the source data
  24389. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24390. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24391. * @returns the current mesh
  24392. */
  24393. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  24394. /**
  24395. * Update the current index buffer
  24396. * @param indices defines the source data
  24397. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24398. * @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)
  24399. * @returns the current mesh
  24400. */
  24401. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  24402. /**
  24403. * Invert the geometry to move from a right handed system to a left handed one.
  24404. * @returns the current mesh
  24405. */
  24406. toLeftHanded(): Mesh;
  24407. /** @hidden */
  24408. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24409. /** @hidden */
  24410. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24411. /**
  24412. * Registers for this mesh a javascript function called just before the rendering process
  24413. * @param func defines the function to call before rendering this mesh
  24414. * @returns the current mesh
  24415. */
  24416. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24417. /**
  24418. * Disposes a previously registered javascript function called before the rendering
  24419. * @param func defines the function to remove
  24420. * @returns the current mesh
  24421. */
  24422. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24423. /**
  24424. * Registers for this mesh a javascript function called just after the rendering is complete
  24425. * @param func defines the function to call after rendering this mesh
  24426. * @returns the current mesh
  24427. */
  24428. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24429. /**
  24430. * Disposes a previously registered javascript function called after the rendering.
  24431. * @param func defines the function to remove
  24432. * @returns the current mesh
  24433. */
  24434. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24435. /** @hidden */
  24436. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24437. /** @hidden */
  24438. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24439. /** @hidden */
  24440. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24441. /** @hidden */
  24442. _rebuild(): void;
  24443. /** @hidden */
  24444. _freeze(): void;
  24445. /** @hidden */
  24446. _unFreeze(): void;
  24447. /**
  24448. * 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
  24449. * @param subMesh defines the subMesh to render
  24450. * @param enableAlphaMode defines if alpha mode can be changed
  24451. * @returns the current mesh
  24452. */
  24453. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24454. private _onBeforeDraw;
  24455. /**
  24456. * Renormalize the mesh and patch it up if there are no weights
  24457. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24458. * However in the case of zero weights then we set just a single influence to 1.
  24459. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24460. */
  24461. cleanMatrixWeights(): void;
  24462. private normalizeSkinFourWeights;
  24463. private normalizeSkinWeightsAndExtra;
  24464. /**
  24465. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24466. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24467. * the user know there was an issue with importing the mesh
  24468. * @returns a validation object with skinned, valid and report string
  24469. */
  24470. validateSkinning(): {
  24471. skinned: boolean;
  24472. valid: boolean;
  24473. report: string;
  24474. };
  24475. /** @hidden */
  24476. _checkDelayState(): Mesh;
  24477. private _queueLoad;
  24478. /**
  24479. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24480. * A mesh is in the frustum if its bounding box intersects the frustum
  24481. * @param frustumPlanes defines the frustum to test
  24482. * @returns true if the mesh is in the frustum planes
  24483. */
  24484. isInFrustum(frustumPlanes: Plane[]): boolean;
  24485. /**
  24486. * Sets the mesh material by the material or multiMaterial `id` property
  24487. * @param id is a string identifying the material or the multiMaterial
  24488. * @returns the current mesh
  24489. */
  24490. setMaterialByID(id: string): Mesh;
  24491. /**
  24492. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24493. * @returns an array of IAnimatable
  24494. */
  24495. getAnimatables(): IAnimatable[];
  24496. /**
  24497. * Modifies the mesh geometry according to the passed transformation matrix.
  24498. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24499. * The mesh normals are modified using the same transformation.
  24500. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24501. * @param transform defines the transform matrix to use
  24502. * @see http://doc.babylonjs.com/resources/baking_transformations
  24503. * @returns the current mesh
  24504. */
  24505. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24506. /**
  24507. * Modifies the mesh geometry according to its own current World Matrix.
  24508. * The mesh World Matrix is then reset.
  24509. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24510. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24511. * @see http://doc.babylonjs.com/resources/baking_transformations
  24512. * @returns the current mesh
  24513. */
  24514. bakeCurrentTransformIntoVertices(): Mesh;
  24515. /** @hidden */
  24516. readonly _positions: Nullable<Vector3[]>;
  24517. /** @hidden */
  24518. _resetPointsArrayCache(): Mesh;
  24519. /** @hidden */
  24520. _generatePointsArray(): boolean;
  24521. /**
  24522. * Returns a new Mesh object generated from the current mesh properties.
  24523. * This method must not get confused with createInstance()
  24524. * @param name is a string, the name given to the new mesh
  24525. * @param newParent can be any Node object (default `null`)
  24526. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24527. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24528. * @returns a new mesh
  24529. */
  24530. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24531. /**
  24532. * Releases resources associated with this mesh.
  24533. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24534. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24535. */
  24536. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24537. /**
  24538. * Modifies the mesh geometry according to a displacement map.
  24539. * 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.
  24540. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24541. * @param url is a string, the URL from the image file is to be downloaded.
  24542. * @param minHeight is the lower limit of the displacement.
  24543. * @param maxHeight is the upper limit of the displacement.
  24544. * @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.
  24545. * @param uvOffset is an optional vector2 used to offset UV.
  24546. * @param uvScale is an optional vector2 used to scale UV.
  24547. * @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.
  24548. * @returns the Mesh.
  24549. */
  24550. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24551. /**
  24552. * Modifies the mesh geometry according to a displacementMap buffer.
  24553. * 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.
  24554. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24555. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24556. * @param heightMapWidth is the width of the buffer image.
  24557. * @param heightMapHeight is the height of the buffer image.
  24558. * @param minHeight is the lower limit of the displacement.
  24559. * @param maxHeight is the upper limit of the displacement.
  24560. * @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.
  24561. * @param uvOffset is an optional vector2 used to offset UV.
  24562. * @param uvScale is an optional vector2 used to scale UV.
  24563. * @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.
  24564. * @returns the Mesh.
  24565. */
  24566. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24567. /**
  24568. * Modify the mesh to get a flat shading rendering.
  24569. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24570. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24571. * @returns current mesh
  24572. */
  24573. convertToFlatShadedMesh(): Mesh;
  24574. /**
  24575. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24576. * In other words, more vertices, no more indices and a single bigger VBO.
  24577. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24578. * @returns current mesh
  24579. */
  24580. convertToUnIndexedMesh(): Mesh;
  24581. /**
  24582. * Inverses facet orientations.
  24583. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24584. * @param flipNormals will also inverts the normals
  24585. * @returns current mesh
  24586. */
  24587. flipFaces(flipNormals?: boolean): Mesh;
  24588. /**
  24589. * Increase the number of facets and hence vertices in a mesh
  24590. * Vertex normals are interpolated from existing vertex normals
  24591. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24592. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24593. */
  24594. increaseVertices(numberPerEdge: number): void;
  24595. /**
  24596. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24597. * This will undo any application of covertToFlatShadedMesh
  24598. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24599. */
  24600. forceSharedVertices(): void;
  24601. /** @hidden */
  24602. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24603. /** @hidden */
  24604. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24605. /**
  24606. * Creates a new InstancedMesh object from the mesh model.
  24607. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24608. * @param name defines the name of the new instance
  24609. * @returns a new InstancedMesh
  24610. */
  24611. createInstance(name: string): InstancedMesh;
  24612. /**
  24613. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24614. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24615. * @returns the current mesh
  24616. */
  24617. synchronizeInstances(): Mesh;
  24618. /**
  24619. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24620. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24621. * This should be used together with the simplification to avoid disappearing triangles.
  24622. * @param successCallback an optional success callback to be called after the optimization finished.
  24623. * @returns the current mesh
  24624. */
  24625. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24626. /**
  24627. * Serialize current mesh
  24628. * @param serializationObject defines the object which will receive the serialization data
  24629. */
  24630. serialize(serializationObject: any): void;
  24631. /** @hidden */
  24632. _syncGeometryWithMorphTargetManager(): void;
  24633. /** @hidden */
  24634. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24635. /**
  24636. * Returns a new Mesh object parsed from the source provided.
  24637. * @param parsedMesh is the source
  24638. * @param scene defines the hosting scene
  24639. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24640. * @returns a new Mesh
  24641. */
  24642. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24643. /**
  24644. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24645. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24646. * @param name defines the name of the mesh to create
  24647. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24648. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24649. * @param closePath creates a seam between the first and the last points of each path of the path array
  24650. * @param offset is taken in account only if the `pathArray` is containing a single path
  24651. * @param scene defines the hosting scene
  24652. * @param updatable defines if the mesh must be flagged as updatable
  24653. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24654. * @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)
  24655. * @returns a new Mesh
  24656. */
  24657. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24658. /**
  24659. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24660. * @param name defines the name of the mesh to create
  24661. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24662. * @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
  24663. * @param scene defines the hosting scene
  24664. * @param updatable defines if the mesh must be flagged as updatable
  24665. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24666. * @returns a new Mesh
  24667. */
  24668. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24669. /**
  24670. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24671. * @param name defines the name of the mesh to create
  24672. * @param size sets the size (float) of each box side (default 1)
  24673. * @param scene defines the hosting scene
  24674. * @param updatable defines if the mesh must be flagged as updatable
  24675. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24676. * @returns a new Mesh
  24677. */
  24678. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24679. /**
  24680. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24681. * @param name defines the name of the mesh to create
  24682. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24683. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24684. * @param scene defines the hosting scene
  24685. * @param updatable defines if the mesh must be flagged as updatable
  24686. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24687. * @returns a new Mesh
  24688. */
  24689. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24690. /**
  24691. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24692. * @param name defines the name of the mesh to create
  24693. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24694. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24695. * @param scene defines the hosting scene
  24696. * @returns a new Mesh
  24697. */
  24698. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24699. /**
  24700. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24701. * @param name defines the name of the mesh to create
  24702. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24703. * @param diameterTop set the top cap diameter (floats, default 1)
  24704. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24705. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24706. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24707. * @param scene defines the hosting scene
  24708. * @param updatable defines if the mesh must be flagged as updatable
  24709. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24710. * @returns a new Mesh
  24711. */
  24712. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24713. /**
  24714. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24715. * @param name defines the name of the mesh to create
  24716. * @param diameter sets the diameter size (float) of the torus (default 1)
  24717. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24718. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24719. * @param scene defines the hosting scene
  24720. * @param updatable defines if the mesh must be flagged as updatable
  24721. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24722. * @returns a new Mesh
  24723. */
  24724. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24725. /**
  24726. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24727. * @param name defines the name of the mesh to create
  24728. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24729. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24730. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24731. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24732. * @param p the number of windings on X axis (positive integers, default 2)
  24733. * @param q the number of windings on Y axis (positive integers, default 3)
  24734. * @param scene defines the hosting scene
  24735. * @param updatable defines if the mesh must be flagged as updatable
  24736. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24737. * @returns a new Mesh
  24738. */
  24739. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24740. /**
  24741. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24742. * @param name defines the name of the mesh to create
  24743. * @param points is an array successive Vector3
  24744. * @param scene defines the hosting scene
  24745. * @param updatable defines if the mesh must be flagged as updatable
  24746. * @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).
  24747. * @returns a new Mesh
  24748. */
  24749. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24750. /**
  24751. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24752. * @param name defines the name of the mesh to create
  24753. * @param points is an array successive Vector3
  24754. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24755. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24756. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24757. * @param scene defines the hosting scene
  24758. * @param updatable defines if the mesh must be flagged as updatable
  24759. * @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)
  24760. * @returns a new Mesh
  24761. */
  24762. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24763. /**
  24764. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24765. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24766. * 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.
  24767. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24768. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24769. * Remember you can only change the shape positions, not their number when updating a polygon.
  24770. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24771. * @param name defines the name of the mesh to create
  24772. * @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
  24773. * @param scene defines the hosting scene
  24774. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24775. * @param updatable defines if the mesh must be flagged as updatable
  24776. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24777. * @param earcutInjection can be used to inject your own earcut reference
  24778. * @returns a new Mesh
  24779. */
  24780. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24781. /**
  24782. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24783. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24784. * @param name defines the name of the mesh to create
  24785. * @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
  24786. * @param depth defines the height of extrusion
  24787. * @param scene defines the hosting scene
  24788. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24789. * @param updatable defines if the mesh must be flagged as updatable
  24790. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24791. * @param earcutInjection can be used to inject your own earcut reference
  24792. * @returns a new Mesh
  24793. */
  24794. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24795. /**
  24796. * Creates an extruded shape mesh.
  24797. * 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
  24798. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24799. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24800. * @param name defines the name of the mesh to create
  24801. * @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
  24802. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24803. * @param scale is the value to scale the shape
  24804. * @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
  24805. * @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
  24806. * @param scene defines the hosting scene
  24807. * @param updatable defines if the mesh must be flagged as updatable
  24808. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24809. * @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)
  24810. * @returns a new Mesh
  24811. */
  24812. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24813. /**
  24814. * Creates an custom extruded shape mesh.
  24815. * The custom extrusion is a parametric shape.
  24816. * It has no predefined shape. Its final shape will depend on the input parameters.
  24817. * Please consider using the same method from the MeshBuilder class instead
  24818. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24819. * @param name defines the name of the mesh to create
  24820. * @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
  24821. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24822. * @param scaleFunction is a custom Javascript function called on each path point
  24823. * @param rotationFunction is a custom Javascript function called on each path point
  24824. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24825. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24826. * @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
  24827. * @param scene defines the hosting scene
  24828. * @param updatable defines if the mesh must be flagged as updatable
  24829. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24830. * @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)
  24831. * @returns a new Mesh
  24832. */
  24833. 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;
  24834. /**
  24835. * Creates lathe mesh.
  24836. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24837. * Please consider using the same method from the MeshBuilder class instead
  24838. * @param name defines the name of the mesh to create
  24839. * @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
  24840. * @param radius is the radius value of the lathe
  24841. * @param tessellation is the side number of the lathe.
  24842. * @param scene defines the hosting scene
  24843. * @param updatable defines if the mesh must be flagged as updatable
  24844. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24845. * @returns a new Mesh
  24846. */
  24847. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24848. /**
  24849. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24850. * @param name defines the name of the mesh to create
  24851. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24852. * @param scene defines the hosting scene
  24853. * @param updatable defines if the mesh must be flagged as updatable
  24854. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24855. * @returns a new Mesh
  24856. */
  24857. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24858. /**
  24859. * Creates a ground mesh.
  24860. * Please consider using the same method from the MeshBuilder class instead
  24861. * @param name defines the name of the mesh to create
  24862. * @param width set the width of the ground
  24863. * @param height set the height of the ground
  24864. * @param subdivisions sets the number of subdivisions per side
  24865. * @param scene defines the hosting scene
  24866. * @param updatable defines if the mesh must be flagged as updatable
  24867. * @returns a new Mesh
  24868. */
  24869. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24870. /**
  24871. * Creates a tiled ground mesh.
  24872. * Please consider using the same method from the MeshBuilder class instead
  24873. * @param name defines the name of the mesh to create
  24874. * @param xmin set the ground minimum X coordinate
  24875. * @param zmin set the ground minimum Y coordinate
  24876. * @param xmax set the ground maximum X coordinate
  24877. * @param zmax set the ground maximum Z coordinate
  24878. * @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
  24879. * @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
  24880. * @param scene defines the hosting scene
  24881. * @param updatable defines if the mesh must be flagged as updatable
  24882. * @returns a new Mesh
  24883. */
  24884. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24885. w: number;
  24886. h: number;
  24887. }, precision: {
  24888. w: number;
  24889. h: number;
  24890. }, scene: Scene, updatable?: boolean): Mesh;
  24891. /**
  24892. * Creates a ground mesh from a height map.
  24893. * Please consider using the same method from the MeshBuilder class instead
  24894. * @see http://doc.babylonjs.com/babylon101/height_map
  24895. * @param name defines the name of the mesh to create
  24896. * @param url sets the URL of the height map image resource
  24897. * @param width set the ground width size
  24898. * @param height set the ground height size
  24899. * @param subdivisions sets the number of subdivision per side
  24900. * @param minHeight is the minimum altitude on the ground
  24901. * @param maxHeight is the maximum altitude on the ground
  24902. * @param scene defines the hosting scene
  24903. * @param updatable defines if the mesh must be flagged as updatable
  24904. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24905. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24906. * @returns a new Mesh
  24907. */
  24908. 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;
  24909. /**
  24910. * Creates a tube mesh.
  24911. * The tube is a parametric shape.
  24912. * It has no predefined shape. Its final shape will depend on the input parameters.
  24913. * Please consider using the same method from the MeshBuilder class instead
  24914. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24915. * @param name defines the name of the mesh to create
  24916. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24917. * @param radius sets the tube radius size
  24918. * @param tessellation is the number of sides on the tubular surface
  24919. * @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
  24920. * @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
  24921. * @param scene defines the hosting scene
  24922. * @param updatable defines if the mesh must be flagged as updatable
  24923. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24924. * @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)
  24925. * @returns a new Mesh
  24926. */
  24927. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24928. (i: number, distance: number): number;
  24929. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24930. /**
  24931. * Creates a polyhedron mesh.
  24932. * Please consider using the same method from the MeshBuilder class instead.
  24933. * * 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
  24934. * * The parameter `size` (positive float, default 1) sets the polygon size
  24935. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24936. * * 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`
  24937. * * 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
  24938. * * 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)`)
  24939. * * 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
  24940. * * 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
  24941. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24942. * * If you create a double-sided mesh, you can choose what parts of 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
  24943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24944. * @param name defines the name of the mesh to create
  24945. * @param options defines the options used to create the mesh
  24946. * @param scene defines the hosting scene
  24947. * @returns a new Mesh
  24948. */
  24949. static CreatePolyhedron(name: string, options: {
  24950. type?: number;
  24951. size?: number;
  24952. sizeX?: number;
  24953. sizeY?: number;
  24954. sizeZ?: number;
  24955. custom?: any;
  24956. faceUV?: Vector4[];
  24957. faceColors?: Color4[];
  24958. updatable?: boolean;
  24959. sideOrientation?: number;
  24960. }, scene: Scene): Mesh;
  24961. /**
  24962. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24963. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24964. * * 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`)
  24965. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24966. * * 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
  24967. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24968. * * If you create a double-sided mesh, you can choose what parts of 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
  24969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24970. * @param name defines the name of the mesh
  24971. * @param options defines the options used to create the mesh
  24972. * @param scene defines the hosting scene
  24973. * @returns a new Mesh
  24974. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24975. */
  24976. static CreateIcoSphere(name: string, options: {
  24977. radius?: number;
  24978. flat?: boolean;
  24979. subdivisions?: number;
  24980. sideOrientation?: number;
  24981. updatable?: boolean;
  24982. }, scene: Scene): Mesh;
  24983. /**
  24984. * Creates a decal mesh.
  24985. * Please consider using the same method from the MeshBuilder class instead.
  24986. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24987. * @param name defines the name of the mesh
  24988. * @param sourceMesh defines the mesh receiving the decal
  24989. * @param position sets the position of the decal in world coordinates
  24990. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24991. * @param size sets the decal scaling
  24992. * @param angle sets the angle to rotate the decal
  24993. * @returns a new Mesh
  24994. */
  24995. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24996. /**
  24997. * Prepare internal position array for software CPU skinning
  24998. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24999. */
  25000. setPositionsForCPUSkinning(): Float32Array;
  25001. /**
  25002. * Prepare internal normal array for software CPU skinning
  25003. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25004. */
  25005. setNormalsForCPUSkinning(): Float32Array;
  25006. /**
  25007. * Updates the vertex buffer by applying transformation from the bones
  25008. * @param skeleton defines the skeleton to apply to current mesh
  25009. * @returns the current mesh
  25010. */
  25011. applySkeleton(skeleton: Skeleton): Mesh;
  25012. /**
  25013. * 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
  25014. * @param meshes defines the list of meshes to scan
  25015. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25016. */
  25017. static MinMax(meshes: AbstractMesh[]): {
  25018. min: Vector3;
  25019. max: Vector3;
  25020. };
  25021. /**
  25022. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25023. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25024. * @returns a vector3
  25025. */
  25026. static Center(meshesOrMinMaxVector: {
  25027. min: Vector3;
  25028. max: Vector3;
  25029. } | AbstractMesh[]): Vector3;
  25030. /**
  25031. * Merge the array of meshes into a single mesh for performance reasons.
  25032. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25033. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25034. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25035. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25036. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25037. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25038. * @returns a new mesh
  25039. */
  25040. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25041. /** @hidden */
  25042. addInstance(instance: InstancedMesh): void;
  25043. /** @hidden */
  25044. removeInstance(instance: InstancedMesh): void;
  25045. }
  25046. }
  25047. declare module "babylonjs/Cameras/camera" {
  25048. import { SmartArray } from "babylonjs/Misc/smartArray";
  25049. import { Observable } from "babylonjs/Misc/observable";
  25050. import { Nullable } from "babylonjs/types";
  25051. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25052. import { Scene } from "babylonjs/scene";
  25053. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25054. import { Node } from "babylonjs/node";
  25055. import { Mesh } from "babylonjs/Meshes/mesh";
  25056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25057. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25058. import { Viewport } from "babylonjs/Maths/math.viewport";
  25059. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25060. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25061. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25062. import { Ray } from "babylonjs/Culling/ray";
  25063. /**
  25064. * This is the base class of all the camera used in the application.
  25065. * @see http://doc.babylonjs.com/features/cameras
  25066. */
  25067. export class Camera extends Node {
  25068. /** @hidden */
  25069. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25070. /**
  25071. * This is the default projection mode used by the cameras.
  25072. * It helps recreating a feeling of perspective and better appreciate depth.
  25073. * This is the best way to simulate real life cameras.
  25074. */
  25075. static readonly PERSPECTIVE_CAMERA: number;
  25076. /**
  25077. * This helps creating camera with an orthographic mode.
  25078. * 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.
  25079. */
  25080. static readonly ORTHOGRAPHIC_CAMERA: number;
  25081. /**
  25082. * This is the default FOV mode for perspective cameras.
  25083. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25084. */
  25085. static readonly FOVMODE_VERTICAL_FIXED: number;
  25086. /**
  25087. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25088. */
  25089. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25090. /**
  25091. * This specifies ther is no need for a camera rig.
  25092. * Basically only one eye is rendered corresponding to the camera.
  25093. */
  25094. static readonly RIG_MODE_NONE: number;
  25095. /**
  25096. * Simulates a camera Rig with one blue eye and one red eye.
  25097. * This can be use with 3d blue and red glasses.
  25098. */
  25099. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25100. /**
  25101. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25102. */
  25103. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25104. /**
  25105. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25106. */
  25107. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25108. /**
  25109. * Defines that both eyes of the camera will be rendered over under each other.
  25110. */
  25111. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25112. /**
  25113. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25114. */
  25115. static readonly RIG_MODE_VR: number;
  25116. /**
  25117. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25118. */
  25119. static readonly RIG_MODE_WEBVR: number;
  25120. /**
  25121. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25122. */
  25123. static readonly RIG_MODE_CUSTOM: number;
  25124. /**
  25125. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25126. */
  25127. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25128. /**
  25129. * Define the input manager associated with the camera.
  25130. */
  25131. inputs: CameraInputsManager<Camera>;
  25132. /** @hidden */
  25133. _position: Vector3;
  25134. /**
  25135. * Define the current local position of the camera in the scene
  25136. */
  25137. position: Vector3;
  25138. /**
  25139. * The vector the camera should consider as up.
  25140. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25141. */
  25142. upVector: Vector3;
  25143. /**
  25144. * Define the current limit on the left side for an orthographic camera
  25145. * In scene unit
  25146. */
  25147. orthoLeft: Nullable<number>;
  25148. /**
  25149. * Define the current limit on the right side for an orthographic camera
  25150. * In scene unit
  25151. */
  25152. orthoRight: Nullable<number>;
  25153. /**
  25154. * Define the current limit on the bottom side for an orthographic camera
  25155. * In scene unit
  25156. */
  25157. orthoBottom: Nullable<number>;
  25158. /**
  25159. * Define the current limit on the top side for an orthographic camera
  25160. * In scene unit
  25161. */
  25162. orthoTop: Nullable<number>;
  25163. /**
  25164. * Field Of View is set in Radians. (default is 0.8)
  25165. */
  25166. fov: number;
  25167. /**
  25168. * Define the minimum distance the camera can see from.
  25169. * This is important to note that the depth buffer are not infinite and the closer it starts
  25170. * the more your scene might encounter depth fighting issue.
  25171. */
  25172. minZ: number;
  25173. /**
  25174. * Define the maximum distance the camera can see to.
  25175. * This is important to note that the depth buffer are not infinite and the further it end
  25176. * the more your scene might encounter depth fighting issue.
  25177. */
  25178. maxZ: number;
  25179. /**
  25180. * Define the default inertia of the camera.
  25181. * This helps giving a smooth feeling to the camera movement.
  25182. */
  25183. inertia: number;
  25184. /**
  25185. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25186. */
  25187. mode: number;
  25188. /**
  25189. * Define wether the camera is intermediate.
  25190. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25191. */
  25192. isIntermediate: boolean;
  25193. /**
  25194. * Define the viewport of the camera.
  25195. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25196. */
  25197. viewport: Viewport;
  25198. /**
  25199. * Restricts the camera to viewing objects with the same layerMask.
  25200. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25201. */
  25202. layerMask: number;
  25203. /**
  25204. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25205. */
  25206. fovMode: number;
  25207. /**
  25208. * Rig mode of the camera.
  25209. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25210. * This is normally controlled byt the camera themselves as internal use.
  25211. */
  25212. cameraRigMode: number;
  25213. /**
  25214. * Defines the distance between both "eyes" in case of a RIG
  25215. */
  25216. interaxialDistance: number;
  25217. /**
  25218. * Defines if stereoscopic rendering is done side by side or over under.
  25219. */
  25220. isStereoscopicSideBySide: boolean;
  25221. /**
  25222. * 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
  25223. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25224. * else in the scene. (Eg. security camera)
  25225. *
  25226. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  25227. */
  25228. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25229. /**
  25230. * When set, the camera will render to this render target instead of the default canvas
  25231. *
  25232. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25233. */
  25234. outputRenderTarget: Nullable<RenderTargetTexture>;
  25235. /**
  25236. * Observable triggered when the camera view matrix has changed.
  25237. */
  25238. onViewMatrixChangedObservable: Observable<Camera>;
  25239. /**
  25240. * Observable triggered when the camera Projection matrix has changed.
  25241. */
  25242. onProjectionMatrixChangedObservable: Observable<Camera>;
  25243. /**
  25244. * Observable triggered when the inputs have been processed.
  25245. */
  25246. onAfterCheckInputsObservable: Observable<Camera>;
  25247. /**
  25248. * Observable triggered when reset has been called and applied to the camera.
  25249. */
  25250. onRestoreStateObservable: Observable<Camera>;
  25251. /** @hidden */
  25252. _cameraRigParams: any;
  25253. /** @hidden */
  25254. _rigCameras: Camera[];
  25255. /** @hidden */
  25256. _rigPostProcess: Nullable<PostProcess>;
  25257. protected _webvrViewMatrix: Matrix;
  25258. /** @hidden */
  25259. _skipRendering: boolean;
  25260. /** @hidden */
  25261. _projectionMatrix: Matrix;
  25262. /** @hidden */
  25263. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25264. /** @hidden */
  25265. _activeMeshes: SmartArray<AbstractMesh>;
  25266. protected _globalPosition: Vector3;
  25267. /** @hidden */
  25268. _computedViewMatrix: Matrix;
  25269. private _doNotComputeProjectionMatrix;
  25270. private _transformMatrix;
  25271. private _frustumPlanes;
  25272. private _refreshFrustumPlanes;
  25273. private _storedFov;
  25274. private _stateStored;
  25275. /**
  25276. * Instantiates a new camera object.
  25277. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25278. * @see http://doc.babylonjs.com/features/cameras
  25279. * @param name Defines the name of the camera in the scene
  25280. * @param position Defines the position of the camera
  25281. * @param scene Defines the scene the camera belongs too
  25282. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25283. */
  25284. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25285. /**
  25286. * Store current camera state (fov, position, etc..)
  25287. * @returns the camera
  25288. */
  25289. storeState(): Camera;
  25290. /**
  25291. * Restores the camera state values if it has been stored. You must call storeState() first
  25292. */
  25293. protected _restoreStateValues(): boolean;
  25294. /**
  25295. * Restored camera state. You must call storeState() first.
  25296. * @returns true if restored and false otherwise
  25297. */
  25298. restoreState(): boolean;
  25299. /**
  25300. * Gets the class name of the camera.
  25301. * @returns the class name
  25302. */
  25303. getClassName(): string;
  25304. /** @hidden */
  25305. readonly _isCamera: boolean;
  25306. /**
  25307. * Gets a string representation of the camera useful for debug purpose.
  25308. * @param fullDetails Defines that a more verboe level of logging is required
  25309. * @returns the string representation
  25310. */
  25311. toString(fullDetails?: boolean): string;
  25312. /**
  25313. * Gets the current world space position of the camera.
  25314. */
  25315. readonly globalPosition: Vector3;
  25316. /**
  25317. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25318. * @returns the active meshe list
  25319. */
  25320. getActiveMeshes(): SmartArray<AbstractMesh>;
  25321. /**
  25322. * Check wether a mesh is part of the current active mesh list of the camera
  25323. * @param mesh Defines the mesh to check
  25324. * @returns true if active, false otherwise
  25325. */
  25326. isActiveMesh(mesh: Mesh): boolean;
  25327. /**
  25328. * Is this camera ready to be used/rendered
  25329. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25330. * @return true if the camera is ready
  25331. */
  25332. isReady(completeCheck?: boolean): boolean;
  25333. /** @hidden */
  25334. _initCache(): void;
  25335. /** @hidden */
  25336. _updateCache(ignoreParentClass?: boolean): void;
  25337. /** @hidden */
  25338. _isSynchronized(): boolean;
  25339. /** @hidden */
  25340. _isSynchronizedViewMatrix(): boolean;
  25341. /** @hidden */
  25342. _isSynchronizedProjectionMatrix(): boolean;
  25343. /**
  25344. * Attach the input controls to a specific dom element to get the input from.
  25345. * @param element Defines the element the controls should be listened from
  25346. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25347. */
  25348. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25349. /**
  25350. * Detach the current controls from the specified dom element.
  25351. * @param element Defines the element to stop listening the inputs from
  25352. */
  25353. detachControl(element: HTMLElement): void;
  25354. /**
  25355. * Update the camera state according to the different inputs gathered during the frame.
  25356. */
  25357. update(): void;
  25358. /** @hidden */
  25359. _checkInputs(): void;
  25360. /** @hidden */
  25361. readonly rigCameras: Camera[];
  25362. /**
  25363. * Gets the post process used by the rig cameras
  25364. */
  25365. readonly rigPostProcess: Nullable<PostProcess>;
  25366. /**
  25367. * Internal, gets the first post proces.
  25368. * @returns the first post process to be run on this camera.
  25369. */
  25370. _getFirstPostProcess(): Nullable<PostProcess>;
  25371. private _cascadePostProcessesToRigCams;
  25372. /**
  25373. * Attach a post process to the camera.
  25374. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25375. * @param postProcess The post process to attach to the camera
  25376. * @param insertAt The position of the post process in case several of them are in use in the scene
  25377. * @returns the position the post process has been inserted at
  25378. */
  25379. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25380. /**
  25381. * Detach a post process to the camera.
  25382. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25383. * @param postProcess The post process to detach from the camera
  25384. */
  25385. detachPostProcess(postProcess: PostProcess): void;
  25386. /**
  25387. * Gets the current world matrix of the camera
  25388. */
  25389. getWorldMatrix(): Matrix;
  25390. /** @hidden */
  25391. _getViewMatrix(): Matrix;
  25392. /**
  25393. * Gets the current view matrix of the camera.
  25394. * @param force forces the camera to recompute the matrix without looking at the cached state
  25395. * @returns the view matrix
  25396. */
  25397. getViewMatrix(force?: boolean): Matrix;
  25398. /**
  25399. * Freeze the projection matrix.
  25400. * It will prevent the cache check of the camera projection compute and can speed up perf
  25401. * if no parameter of the camera are meant to change
  25402. * @param projection Defines manually a projection if necessary
  25403. */
  25404. freezeProjectionMatrix(projection?: Matrix): void;
  25405. /**
  25406. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25407. */
  25408. unfreezeProjectionMatrix(): void;
  25409. /**
  25410. * Gets the current projection matrix of the camera.
  25411. * @param force forces the camera to recompute the matrix without looking at the cached state
  25412. * @returns the projection matrix
  25413. */
  25414. getProjectionMatrix(force?: boolean): Matrix;
  25415. /**
  25416. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25417. * @returns a Matrix
  25418. */
  25419. getTransformationMatrix(): Matrix;
  25420. private _updateFrustumPlanes;
  25421. /**
  25422. * Checks if a cullable object (mesh...) is in the camera frustum
  25423. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25424. * @param target The object to check
  25425. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25426. * @returns true if the object is in frustum otherwise false
  25427. */
  25428. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25429. /**
  25430. * Checks if a cullable object (mesh...) is in the camera frustum
  25431. * Unlike isInFrustum this cheks the full bounding box
  25432. * @param target The object to check
  25433. * @returns true if the object is in frustum otherwise false
  25434. */
  25435. isCompletelyInFrustum(target: ICullable): boolean;
  25436. /**
  25437. * Gets a ray in the forward direction from the camera.
  25438. * @param length Defines the length of the ray to create
  25439. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25440. * @param origin Defines the start point of the ray which defaults to the camera position
  25441. * @returns the forward ray
  25442. */
  25443. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25444. /**
  25445. * Releases resources associated with this node.
  25446. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25447. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25448. */
  25449. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25450. /** @hidden */
  25451. _isLeftCamera: boolean;
  25452. /**
  25453. * Gets the left camera of a rig setup in case of Rigged Camera
  25454. */
  25455. readonly isLeftCamera: boolean;
  25456. /** @hidden */
  25457. _isRightCamera: boolean;
  25458. /**
  25459. * Gets the right camera of a rig setup in case of Rigged Camera
  25460. */
  25461. readonly isRightCamera: boolean;
  25462. /**
  25463. * Gets the left camera of a rig setup in case of Rigged Camera
  25464. */
  25465. readonly leftCamera: Nullable<FreeCamera>;
  25466. /**
  25467. * Gets the right camera of a rig setup in case of Rigged Camera
  25468. */
  25469. readonly rightCamera: Nullable<FreeCamera>;
  25470. /**
  25471. * Gets the left camera target of a rig setup in case of Rigged Camera
  25472. * @returns the target position
  25473. */
  25474. getLeftTarget(): Nullable<Vector3>;
  25475. /**
  25476. * Gets the right camera target of a rig setup in case of Rigged Camera
  25477. * @returns the target position
  25478. */
  25479. getRightTarget(): Nullable<Vector3>;
  25480. /**
  25481. * @hidden
  25482. */
  25483. setCameraRigMode(mode: number, rigParams: any): void;
  25484. /** @hidden */
  25485. static _setStereoscopicRigMode(camera: Camera): void;
  25486. /** @hidden */
  25487. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25488. /** @hidden */
  25489. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25490. /** @hidden */
  25491. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25492. /** @hidden */
  25493. _getVRProjectionMatrix(): Matrix;
  25494. protected _updateCameraRotationMatrix(): void;
  25495. protected _updateWebVRCameraRotationMatrix(): void;
  25496. /**
  25497. * This function MUST be overwritten by the different WebVR cameras available.
  25498. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25499. * @hidden
  25500. */
  25501. _getWebVRProjectionMatrix(): Matrix;
  25502. /**
  25503. * This function MUST be overwritten by the different WebVR cameras available.
  25504. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25505. * @hidden
  25506. */
  25507. _getWebVRViewMatrix(): Matrix;
  25508. /** @hidden */
  25509. setCameraRigParameter(name: string, value: any): void;
  25510. /**
  25511. * needs to be overridden by children so sub has required properties to be copied
  25512. * @hidden
  25513. */
  25514. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25515. /**
  25516. * May need to be overridden by children
  25517. * @hidden
  25518. */
  25519. _updateRigCameras(): void;
  25520. /** @hidden */
  25521. _setupInputs(): void;
  25522. /**
  25523. * Serialiaze the camera setup to a json represention
  25524. * @returns the JSON representation
  25525. */
  25526. serialize(): any;
  25527. /**
  25528. * Clones the current camera.
  25529. * @param name The cloned camera name
  25530. * @returns the cloned camera
  25531. */
  25532. clone(name: string): Camera;
  25533. /**
  25534. * Gets the direction of the camera relative to a given local axis.
  25535. * @param localAxis Defines the reference axis to provide a relative direction.
  25536. * @return the direction
  25537. */
  25538. getDirection(localAxis: Vector3): Vector3;
  25539. /**
  25540. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25541. * @param localAxis Defines the reference axis to provide a relative direction.
  25542. * @param result Defines the vector to store the result in
  25543. */
  25544. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25545. /**
  25546. * Gets a camera constructor for a given camera type
  25547. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25548. * @param name The name of the camera the result will be able to instantiate
  25549. * @param scene The scene the result will construct the camera in
  25550. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25551. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25552. * @returns a factory method to construc the camera
  25553. */
  25554. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25555. /**
  25556. * Compute the world matrix of the camera.
  25557. * @returns the camera workd matrix
  25558. */
  25559. computeWorldMatrix(): Matrix;
  25560. /**
  25561. * Parse a JSON and creates the camera from the parsed information
  25562. * @param parsedCamera The JSON to parse
  25563. * @param scene The scene to instantiate the camera in
  25564. * @returns the newly constructed camera
  25565. */
  25566. static Parse(parsedCamera: any, scene: Scene): Camera;
  25567. }
  25568. }
  25569. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25570. import { Nullable } from "babylonjs/types";
  25571. import { Scene } from "babylonjs/scene";
  25572. import { Vector4 } from "babylonjs/Maths/math.vector";
  25573. import { Mesh } from "babylonjs/Meshes/mesh";
  25574. /**
  25575. * Class containing static functions to help procedurally build meshes
  25576. */
  25577. export class DiscBuilder {
  25578. /**
  25579. * Creates a plane polygonal mesh. By default, this is a disc
  25580. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25581. * * 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
  25582. * * 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
  25583. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25584. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25586. * @param name defines the name of the mesh
  25587. * @param options defines the options used to create the mesh
  25588. * @param scene defines the hosting scene
  25589. * @returns the plane polygonal mesh
  25590. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25591. */
  25592. static CreateDisc(name: string, options: {
  25593. radius?: number;
  25594. tessellation?: number;
  25595. arc?: number;
  25596. updatable?: boolean;
  25597. sideOrientation?: number;
  25598. frontUVs?: Vector4;
  25599. backUVs?: Vector4;
  25600. }, scene?: Nullable<Scene>): Mesh;
  25601. }
  25602. }
  25603. declare module "babylonjs/Particles/solidParticleSystem" {
  25604. import { Vector3 } from "babylonjs/Maths/math.vector";
  25605. import { Mesh } from "babylonjs/Meshes/mesh";
  25606. import { Scene, IDisposable } from "babylonjs/scene";
  25607. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25608. /**
  25609. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25610. *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.
  25611. * The SPS is also a particle system. It provides some methods to manage the particles.
  25612. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25613. *
  25614. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25615. */
  25616. export class SolidParticleSystem implements IDisposable {
  25617. /**
  25618. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25619. * Example : var p = SPS.particles[i];
  25620. */
  25621. particles: SolidParticle[];
  25622. /**
  25623. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25624. */
  25625. nbParticles: number;
  25626. /**
  25627. * If the particles must ever face the camera (default false). Useful for planar particles.
  25628. */
  25629. billboard: boolean;
  25630. /**
  25631. * Recompute normals when adding a shape
  25632. */
  25633. recomputeNormals: boolean;
  25634. /**
  25635. * This a counter ofr your own usage. It's not set by any SPS functions.
  25636. */
  25637. counter: number;
  25638. /**
  25639. * The SPS name. This name is also given to the underlying mesh.
  25640. */
  25641. name: string;
  25642. /**
  25643. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25644. */
  25645. mesh: Mesh;
  25646. /**
  25647. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25648. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25649. */
  25650. vars: any;
  25651. /**
  25652. * This array is populated when the SPS is set as 'pickable'.
  25653. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25654. * Each element of this array is an object `{idx: int, faceId: int}`.
  25655. * `idx` is the picked particle index in the `SPS.particles` array
  25656. * `faceId` is the picked face index counted within this particle.
  25657. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25658. */
  25659. pickedParticles: {
  25660. idx: number;
  25661. faceId: number;
  25662. }[];
  25663. /**
  25664. * This array is populated when `enableDepthSort` is set to true.
  25665. * Each element of this array is an instance of the class DepthSortedParticle.
  25666. */
  25667. depthSortedParticles: DepthSortedParticle[];
  25668. /**
  25669. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25670. * @hidden
  25671. */
  25672. _bSphereOnly: boolean;
  25673. /**
  25674. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25675. * @hidden
  25676. */
  25677. _bSphereRadiusFactor: number;
  25678. private _scene;
  25679. private _positions;
  25680. private _indices;
  25681. private _normals;
  25682. private _colors;
  25683. private _uvs;
  25684. private _indices32;
  25685. private _positions32;
  25686. private _normals32;
  25687. private _fixedNormal32;
  25688. private _colors32;
  25689. private _uvs32;
  25690. private _index;
  25691. private _updatable;
  25692. private _pickable;
  25693. private _isVisibilityBoxLocked;
  25694. private _alwaysVisible;
  25695. private _depthSort;
  25696. private _shapeCounter;
  25697. private _copy;
  25698. private _color;
  25699. private _computeParticleColor;
  25700. private _computeParticleTexture;
  25701. private _computeParticleRotation;
  25702. private _computeParticleVertex;
  25703. private _computeBoundingBox;
  25704. private _depthSortParticles;
  25705. private _camera;
  25706. private _mustUnrotateFixedNormals;
  25707. private _particlesIntersect;
  25708. private _needs32Bits;
  25709. /**
  25710. * Creates a SPS (Solid Particle System) object.
  25711. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25712. * @param scene (Scene) is the scene in which the SPS is added.
  25713. * @param options defines the options of the sps e.g.
  25714. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25715. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25716. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25717. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25718. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25719. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25720. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25721. */
  25722. constructor(name: string, scene: Scene, options?: {
  25723. updatable?: boolean;
  25724. isPickable?: boolean;
  25725. enableDepthSort?: boolean;
  25726. particleIntersection?: boolean;
  25727. boundingSphereOnly?: boolean;
  25728. bSphereRadiusFactor?: number;
  25729. });
  25730. /**
  25731. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25732. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25733. * @returns the created mesh
  25734. */
  25735. buildMesh(): Mesh;
  25736. /**
  25737. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25738. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25739. * Thus the particles generated from `digest()` have their property `position` set yet.
  25740. * @param mesh ( Mesh ) is the mesh to be digested
  25741. * @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
  25742. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25743. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25744. * @returns the current SPS
  25745. */
  25746. digest(mesh: Mesh, options?: {
  25747. facetNb?: number;
  25748. number?: number;
  25749. delta?: number;
  25750. }): SolidParticleSystem;
  25751. private _unrotateFixedNormals;
  25752. private _resetCopy;
  25753. private _meshBuilder;
  25754. private _posToShape;
  25755. private _uvsToShapeUV;
  25756. private _addParticle;
  25757. /**
  25758. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25759. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25760. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25761. * @param nb (positive integer) the number of particles to be created from this model
  25762. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25763. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25764. * @returns the number of shapes in the system
  25765. */
  25766. addShape(mesh: Mesh, nb: number, options?: {
  25767. positionFunction?: any;
  25768. vertexFunction?: any;
  25769. }): number;
  25770. private _rebuildParticle;
  25771. /**
  25772. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25773. * @returns the SPS.
  25774. */
  25775. rebuildMesh(): SolidParticleSystem;
  25776. /**
  25777. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25778. * This method calls `updateParticle()` for each particle of the SPS.
  25779. * For an animated SPS, it is usually called within the render loop.
  25780. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25781. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25782. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25783. * @returns the SPS.
  25784. */
  25785. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25786. /**
  25787. * Disposes the SPS.
  25788. */
  25789. dispose(): void;
  25790. /**
  25791. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25792. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25793. * @returns the SPS.
  25794. */
  25795. refreshVisibleSize(): SolidParticleSystem;
  25796. /**
  25797. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25798. * @param size the size (float) of the visibility box
  25799. * note : this doesn't lock the SPS mesh bounding box.
  25800. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25801. */
  25802. setVisibilityBox(size: number): void;
  25803. /**
  25804. * Gets whether the SPS as always visible or not
  25805. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25806. */
  25807. /**
  25808. * Sets the SPS as always visible or not
  25809. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25810. */
  25811. isAlwaysVisible: boolean;
  25812. /**
  25813. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25814. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25815. */
  25816. /**
  25817. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25818. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25819. */
  25820. isVisibilityBoxLocked: boolean;
  25821. /**
  25822. * Tells to `setParticles()` to compute the particle rotations or not.
  25823. * Default value : true. The SPS is faster when it's set to false.
  25824. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25825. */
  25826. /**
  25827. * Gets if `setParticles()` computes the particle rotations or not.
  25828. * Default value : true. The SPS is faster when it's set to false.
  25829. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25830. */
  25831. computeParticleRotation: boolean;
  25832. /**
  25833. * Tells to `setParticles()` to compute the particle colors or not.
  25834. * Default value : true. The SPS is faster when it's set to false.
  25835. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25836. */
  25837. /**
  25838. * Gets if `setParticles()` computes the particle colors or not.
  25839. * Default value : true. The SPS is faster when it's set to false.
  25840. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25841. */
  25842. computeParticleColor: boolean;
  25843. /**
  25844. * Gets if `setParticles()` computes the particle textures or not.
  25845. * Default value : true. The SPS is faster when it's set to false.
  25846. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25847. */
  25848. computeParticleTexture: boolean;
  25849. /**
  25850. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25851. * Default value : false. The SPS is faster when it's set to false.
  25852. * Note : the particle custom vertex positions aren't stored values.
  25853. */
  25854. /**
  25855. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25856. * Default value : false. The SPS is faster when it's set to false.
  25857. * Note : the particle custom vertex positions aren't stored values.
  25858. */
  25859. computeParticleVertex: boolean;
  25860. /**
  25861. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25862. */
  25863. /**
  25864. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25865. */
  25866. computeBoundingBox: boolean;
  25867. /**
  25868. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25869. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25870. * Default : `true`
  25871. */
  25872. /**
  25873. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25874. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25875. * Default : `true`
  25876. */
  25877. depthSortParticles: boolean;
  25878. /**
  25879. * This function does nothing. It may be overwritten to set all the particle first values.
  25880. * The SPS doesn't call this function, you may have to call it by your own.
  25881. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25882. */
  25883. initParticles(): void;
  25884. /**
  25885. * This function does nothing. It may be overwritten to recycle a particle.
  25886. * The SPS doesn't call this function, you may have to call it by your own.
  25887. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25888. * @param particle The particle to recycle
  25889. * @returns the recycled particle
  25890. */
  25891. recycleParticle(particle: SolidParticle): SolidParticle;
  25892. /**
  25893. * Updates a particle : this function should be overwritten by the user.
  25894. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25895. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25896. * @example : just set a particle position or velocity and recycle conditions
  25897. * @param particle The particle to update
  25898. * @returns the updated particle
  25899. */
  25900. updateParticle(particle: SolidParticle): SolidParticle;
  25901. /**
  25902. * Updates a vertex of a particle : it can be overwritten by the user.
  25903. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25904. * @param particle the current particle
  25905. * @param vertex the current index of the current particle
  25906. * @param pt the index of the current vertex in the particle shape
  25907. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25908. * @example : just set a vertex particle position
  25909. * @returns the updated vertex
  25910. */
  25911. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25912. /**
  25913. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25914. * This does nothing and may be overwritten by the user.
  25915. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25916. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25917. * @param update the boolean update value actually passed to setParticles()
  25918. */
  25919. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25920. /**
  25921. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25922. * This will be passed three parameters.
  25923. * This does nothing and may be overwritten by the user.
  25924. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25925. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25926. * @param update the boolean update value actually passed to setParticles()
  25927. */
  25928. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25929. }
  25930. }
  25931. declare module "babylonjs/Particles/solidParticle" {
  25932. import { Nullable } from "babylonjs/types";
  25933. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  25934. import { Color4 } from "babylonjs/Maths/math.color";
  25935. import { Mesh } from "babylonjs/Meshes/mesh";
  25936. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25937. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  25938. import { Plane } from "babylonjs/Maths/math.plane";
  25939. /**
  25940. * Represents one particle of a solid particle system.
  25941. */
  25942. export class SolidParticle {
  25943. /**
  25944. * particle global index
  25945. */
  25946. idx: number;
  25947. /**
  25948. * The color of the particle
  25949. */
  25950. color: Nullable<Color4>;
  25951. /**
  25952. * The world space position of the particle.
  25953. */
  25954. position: Vector3;
  25955. /**
  25956. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25957. */
  25958. rotation: Vector3;
  25959. /**
  25960. * The world space rotation quaternion of the particle.
  25961. */
  25962. rotationQuaternion: Nullable<Quaternion>;
  25963. /**
  25964. * The scaling of the particle.
  25965. */
  25966. scaling: Vector3;
  25967. /**
  25968. * The uvs of the particle.
  25969. */
  25970. uvs: Vector4;
  25971. /**
  25972. * The current speed of the particle.
  25973. */
  25974. velocity: Vector3;
  25975. /**
  25976. * The pivot point in the particle local space.
  25977. */
  25978. pivot: Vector3;
  25979. /**
  25980. * Must the particle be translated from its pivot point in its local space ?
  25981. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25982. * Default : false
  25983. */
  25984. translateFromPivot: boolean;
  25985. /**
  25986. * Is the particle active or not ?
  25987. */
  25988. alive: boolean;
  25989. /**
  25990. * Is the particle visible or not ?
  25991. */
  25992. isVisible: boolean;
  25993. /**
  25994. * Index of this particle in the global "positions" array (Internal use)
  25995. * @hidden
  25996. */
  25997. _pos: number;
  25998. /**
  25999. * @hidden Index of this particle in the global "indices" array (Internal use)
  26000. */
  26001. _ind: number;
  26002. /**
  26003. * @hidden ModelShape of this particle (Internal use)
  26004. */
  26005. _model: ModelShape;
  26006. /**
  26007. * ModelShape id of this particle
  26008. */
  26009. shapeId: number;
  26010. /**
  26011. * Index of the particle in its shape id (Internal use)
  26012. */
  26013. idxInShape: number;
  26014. /**
  26015. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26016. */
  26017. _modelBoundingInfo: BoundingInfo;
  26018. /**
  26019. * @hidden Particle BoundingInfo object (Internal use)
  26020. */
  26021. _boundingInfo: BoundingInfo;
  26022. /**
  26023. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26024. */
  26025. _sps: SolidParticleSystem;
  26026. /**
  26027. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26028. */
  26029. _stillInvisible: boolean;
  26030. /**
  26031. * @hidden Last computed particle rotation matrix
  26032. */
  26033. _rotationMatrix: number[];
  26034. /**
  26035. * Parent particle Id, if any.
  26036. * Default null.
  26037. */
  26038. parentId: Nullable<number>;
  26039. /**
  26040. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26041. * The possible values are :
  26042. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26043. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26044. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26045. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26046. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26047. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26048. * */
  26049. cullingStrategy: number;
  26050. /**
  26051. * @hidden Internal global position in the SPS.
  26052. */
  26053. _globalPosition: Vector3;
  26054. /**
  26055. * Creates a Solid Particle object.
  26056. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26057. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26058. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26059. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26060. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26061. * @param shapeId (integer) is the model shape identifier in the SPS.
  26062. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26063. * @param sps defines the sps it is associated to
  26064. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26065. */
  26066. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26067. /**
  26068. * Legacy support, changed scale to scaling
  26069. */
  26070. /**
  26071. * Legacy support, changed scale to scaling
  26072. */
  26073. scale: Vector3;
  26074. /**
  26075. * Legacy support, changed quaternion to rotationQuaternion
  26076. */
  26077. /**
  26078. * Legacy support, changed quaternion to rotationQuaternion
  26079. */
  26080. quaternion: Nullable<Quaternion>;
  26081. /**
  26082. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26083. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26084. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26085. * @returns true if it intersects
  26086. */
  26087. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26088. /**
  26089. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26090. * A particle is in the frustum if its bounding box intersects the frustum
  26091. * @param frustumPlanes defines the frustum to test
  26092. * @returns true if the particle is in the frustum planes
  26093. */
  26094. isInFrustum(frustumPlanes: Plane[]): boolean;
  26095. /**
  26096. * get the rotation matrix of the particle
  26097. * @hidden
  26098. */
  26099. getRotationMatrix(m: Matrix): void;
  26100. }
  26101. /**
  26102. * Represents the shape of the model used by one particle of a solid particle system.
  26103. * SPS internal tool, don't use it manually.
  26104. */
  26105. export class ModelShape {
  26106. /**
  26107. * The shape id
  26108. * @hidden
  26109. */
  26110. shapeID: number;
  26111. /**
  26112. * flat array of model positions (internal use)
  26113. * @hidden
  26114. */
  26115. _shape: Vector3[];
  26116. /**
  26117. * flat array of model UVs (internal use)
  26118. * @hidden
  26119. */
  26120. _shapeUV: number[];
  26121. /**
  26122. * length of the shape in the model indices array (internal use)
  26123. * @hidden
  26124. */
  26125. _indicesLength: number;
  26126. /**
  26127. * Custom position function (internal use)
  26128. * @hidden
  26129. */
  26130. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26131. /**
  26132. * Custom vertex function (internal use)
  26133. * @hidden
  26134. */
  26135. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26136. /**
  26137. * 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.
  26138. * SPS internal tool, don't use it manually.
  26139. * @hidden
  26140. */
  26141. 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>);
  26142. }
  26143. /**
  26144. * Represents a Depth Sorted Particle in the solid particle system.
  26145. */
  26146. export class DepthSortedParticle {
  26147. /**
  26148. * Index of the particle in the "indices" array
  26149. */
  26150. ind: number;
  26151. /**
  26152. * Length of the particle shape in the "indices" array
  26153. */
  26154. indicesLength: number;
  26155. /**
  26156. * Squared distance from the particle to the camera
  26157. */
  26158. sqDistance: number;
  26159. }
  26160. }
  26161. declare module "babylonjs/Collisions/meshCollisionData" {
  26162. import { Collider } from "babylonjs/Collisions/collider";
  26163. import { Vector3 } from "babylonjs/Maths/math.vector";
  26164. import { Nullable } from "babylonjs/types";
  26165. import { Observer } from "babylonjs/Misc/observable";
  26166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26167. /**
  26168. * @hidden
  26169. */
  26170. export class _MeshCollisionData {
  26171. _checkCollisions: boolean;
  26172. _collisionMask: number;
  26173. _collisionGroup: number;
  26174. _collider: Nullable<Collider>;
  26175. _oldPositionForCollisions: Vector3;
  26176. _diffPositionForCollisions: Vector3;
  26177. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26178. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26179. }
  26180. }
  26181. declare module "babylonjs/Meshes/abstractMesh" {
  26182. import { Observable } from "babylonjs/Misc/observable";
  26183. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26184. import { Camera } from "babylonjs/Cameras/camera";
  26185. import { Scene, IDisposable } from "babylonjs/scene";
  26186. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26187. import { Node } from "babylonjs/node";
  26188. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26189. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26190. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26191. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26192. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26193. import { Material } from "babylonjs/Materials/material";
  26194. import { Light } from "babylonjs/Lights/light";
  26195. import { Skeleton } from "babylonjs/Bones/skeleton";
  26196. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26197. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26198. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26199. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26200. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26201. import { Plane } from "babylonjs/Maths/math.plane";
  26202. import { Ray } from "babylonjs/Culling/ray";
  26203. import { Collider } from "babylonjs/Collisions/collider";
  26204. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26205. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26206. /** @hidden */
  26207. class _FacetDataStorage {
  26208. facetPositions: Vector3[];
  26209. facetNormals: Vector3[];
  26210. facetPartitioning: number[][];
  26211. facetNb: number;
  26212. partitioningSubdivisions: number;
  26213. partitioningBBoxRatio: number;
  26214. facetDataEnabled: boolean;
  26215. facetParameters: any;
  26216. bbSize: Vector3;
  26217. subDiv: {
  26218. max: number;
  26219. X: number;
  26220. Y: number;
  26221. Z: number;
  26222. };
  26223. facetDepthSort: boolean;
  26224. facetDepthSortEnabled: boolean;
  26225. depthSortedIndices: IndicesArray;
  26226. depthSortedFacets: {
  26227. ind: number;
  26228. sqDistance: number;
  26229. }[];
  26230. facetDepthSortFunction: (f1: {
  26231. ind: number;
  26232. sqDistance: number;
  26233. }, f2: {
  26234. ind: number;
  26235. sqDistance: number;
  26236. }) => number;
  26237. facetDepthSortFrom: Vector3;
  26238. facetDepthSortOrigin: Vector3;
  26239. invertedMatrix: Matrix;
  26240. }
  26241. /**
  26242. * @hidden
  26243. **/
  26244. class _InternalAbstractMeshDataInfo {
  26245. _hasVertexAlpha: boolean;
  26246. _useVertexColors: boolean;
  26247. _numBoneInfluencers: number;
  26248. _applyFog: boolean;
  26249. _receiveShadows: boolean;
  26250. _facetData: _FacetDataStorage;
  26251. _visibility: number;
  26252. _skeleton: Nullable<Skeleton>;
  26253. _layerMask: number;
  26254. _computeBonesUsingShaders: boolean;
  26255. _isActive: boolean;
  26256. _onlyForInstances: boolean;
  26257. _isActiveIntermediate: boolean;
  26258. _onlyForInstancesIntermediate: boolean;
  26259. }
  26260. /**
  26261. * Class used to store all common mesh properties
  26262. */
  26263. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26264. /** No occlusion */
  26265. static OCCLUSION_TYPE_NONE: number;
  26266. /** Occlusion set to optimisitic */
  26267. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26268. /** Occlusion set to strict */
  26269. static OCCLUSION_TYPE_STRICT: number;
  26270. /** Use an accurante occlusion algorithm */
  26271. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26272. /** Use a conservative occlusion algorithm */
  26273. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26274. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26275. * Test order :
  26276. * Is the bounding sphere outside the frustum ?
  26277. * If not, are the bounding box vertices outside the frustum ?
  26278. * It not, then the cullable object is in the frustum.
  26279. */
  26280. static readonly CULLINGSTRATEGY_STANDARD: number;
  26281. /** Culling strategy : Bounding Sphere Only.
  26282. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26283. * It's also less accurate than the standard because some not visible objects can still be selected.
  26284. * Test : is the bounding sphere outside the frustum ?
  26285. * If not, then the cullable object is in the frustum.
  26286. */
  26287. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26288. /** Culling strategy : Optimistic Inclusion.
  26289. * This in an inclusion test first, then the standard exclusion test.
  26290. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26291. * 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.
  26292. * Anyway, it's as accurate as the standard strategy.
  26293. * Test :
  26294. * Is the cullable object bounding sphere center in the frustum ?
  26295. * If not, apply the default culling strategy.
  26296. */
  26297. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26298. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26299. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26300. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26301. * 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.
  26302. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26303. * Test :
  26304. * Is the cullable object bounding sphere center in the frustum ?
  26305. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26306. */
  26307. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26308. /**
  26309. * No billboard
  26310. */
  26311. static readonly BILLBOARDMODE_NONE: number;
  26312. /** Billboard on X axis */
  26313. static readonly BILLBOARDMODE_X: number;
  26314. /** Billboard on Y axis */
  26315. static readonly BILLBOARDMODE_Y: number;
  26316. /** Billboard on Z axis */
  26317. static readonly BILLBOARDMODE_Z: number;
  26318. /** Billboard on all axes */
  26319. static readonly BILLBOARDMODE_ALL: number;
  26320. /** @hidden */
  26321. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26322. /**
  26323. * The culling strategy to use to check whether the mesh must be rendered or not.
  26324. * This value can be changed at any time and will be used on the next render mesh selection.
  26325. * The possible values are :
  26326. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26327. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26328. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26329. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26330. * Please read each static variable documentation to get details about the culling process.
  26331. * */
  26332. cullingStrategy: number;
  26333. /**
  26334. * Gets the number of facets in the mesh
  26335. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26336. */
  26337. readonly facetNb: number;
  26338. /**
  26339. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26340. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26341. */
  26342. partitioningSubdivisions: number;
  26343. /**
  26344. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26345. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26346. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26347. */
  26348. partitioningBBoxRatio: number;
  26349. /**
  26350. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26351. * Works only for updatable meshes.
  26352. * Doesn't work with multi-materials
  26353. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26354. */
  26355. mustDepthSortFacets: boolean;
  26356. /**
  26357. * The location (Vector3) where the facet depth sort must be computed from.
  26358. * By default, the active camera position.
  26359. * Used only when facet depth sort is enabled
  26360. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26361. */
  26362. facetDepthSortFrom: Vector3;
  26363. /**
  26364. * gets a boolean indicating if facetData is enabled
  26365. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26366. */
  26367. readonly isFacetDataEnabled: boolean;
  26368. /** @hidden */
  26369. _updateNonUniformScalingState(value: boolean): boolean;
  26370. /**
  26371. * An event triggered when this mesh collides with another one
  26372. */
  26373. onCollideObservable: Observable<AbstractMesh>;
  26374. /** Set a function to call when this mesh collides with another one */
  26375. onCollide: () => void;
  26376. /**
  26377. * An event triggered when the collision's position changes
  26378. */
  26379. onCollisionPositionChangeObservable: Observable<Vector3>;
  26380. /** Set a function to call when the collision's position changes */
  26381. onCollisionPositionChange: () => void;
  26382. /**
  26383. * An event triggered when material is changed
  26384. */
  26385. onMaterialChangedObservable: Observable<AbstractMesh>;
  26386. /**
  26387. * Gets or sets the orientation for POV movement & rotation
  26388. */
  26389. definedFacingForward: boolean;
  26390. /** @hidden */
  26391. _occlusionQuery: Nullable<WebGLQuery>;
  26392. /** @hidden */
  26393. _renderingGroup: Nullable<RenderingGroup>;
  26394. /**
  26395. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26396. */
  26397. /**
  26398. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26399. */
  26400. visibility: number;
  26401. /** Gets or sets the alpha index used to sort transparent meshes
  26402. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26403. */
  26404. alphaIndex: number;
  26405. /**
  26406. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26407. */
  26408. isVisible: boolean;
  26409. /**
  26410. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26411. */
  26412. isPickable: boolean;
  26413. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26414. showSubMeshesBoundingBox: boolean;
  26415. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26416. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26417. */
  26418. isBlocker: boolean;
  26419. /**
  26420. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26421. */
  26422. enablePointerMoveEvents: boolean;
  26423. /**
  26424. * Specifies the rendering group id for this mesh (0 by default)
  26425. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26426. */
  26427. renderingGroupId: number;
  26428. private _material;
  26429. /** Gets or sets current material */
  26430. material: Nullable<Material>;
  26431. /**
  26432. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26433. * @see http://doc.babylonjs.com/babylon101/shadows
  26434. */
  26435. receiveShadows: boolean;
  26436. /** Defines color to use when rendering outline */
  26437. outlineColor: Color3;
  26438. /** Define width to use when rendering outline */
  26439. outlineWidth: number;
  26440. /** Defines color to use when rendering overlay */
  26441. overlayColor: Color3;
  26442. /** Defines alpha to use when rendering overlay */
  26443. overlayAlpha: number;
  26444. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26445. hasVertexAlpha: boolean;
  26446. /** 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) */
  26447. useVertexColors: boolean;
  26448. /**
  26449. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26450. */
  26451. computeBonesUsingShaders: boolean;
  26452. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26453. numBoneInfluencers: number;
  26454. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26455. applyFog: boolean;
  26456. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26457. useOctreeForRenderingSelection: boolean;
  26458. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26459. useOctreeForPicking: boolean;
  26460. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26461. useOctreeForCollisions: boolean;
  26462. /**
  26463. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26464. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26465. */
  26466. layerMask: number;
  26467. /**
  26468. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26469. */
  26470. alwaysSelectAsActiveMesh: boolean;
  26471. /**
  26472. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26473. */
  26474. doNotSyncBoundingInfo: boolean;
  26475. /**
  26476. * Gets or sets the current action manager
  26477. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26478. */
  26479. actionManager: Nullable<AbstractActionManager>;
  26480. private _meshCollisionData;
  26481. /**
  26482. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26483. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26484. */
  26485. ellipsoid: Vector3;
  26486. /**
  26487. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26488. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26489. */
  26490. ellipsoidOffset: Vector3;
  26491. /**
  26492. * Gets or sets a collision mask used to mask collisions (default is -1).
  26493. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26494. */
  26495. collisionMask: number;
  26496. /**
  26497. * Gets or sets the current collision group mask (-1 by default).
  26498. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26499. */
  26500. collisionGroup: number;
  26501. /**
  26502. * Defines edge width used when edgesRenderer is enabled
  26503. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26504. */
  26505. edgesWidth: number;
  26506. /**
  26507. * Defines edge color used when edgesRenderer is enabled
  26508. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26509. */
  26510. edgesColor: Color4;
  26511. /** @hidden */
  26512. _edgesRenderer: Nullable<IEdgesRenderer>;
  26513. /** @hidden */
  26514. _masterMesh: Nullable<AbstractMesh>;
  26515. /** @hidden */
  26516. _boundingInfo: Nullable<BoundingInfo>;
  26517. /** @hidden */
  26518. _renderId: number;
  26519. /**
  26520. * Gets or sets the list of subMeshes
  26521. * @see http://doc.babylonjs.com/how_to/multi_materials
  26522. */
  26523. subMeshes: SubMesh[];
  26524. /** @hidden */
  26525. _intersectionsInProgress: AbstractMesh[];
  26526. /** @hidden */
  26527. _unIndexed: boolean;
  26528. /** @hidden */
  26529. _lightSources: Light[];
  26530. /** Gets the list of lights affecting that mesh */
  26531. readonly lightSources: Light[];
  26532. /** @hidden */
  26533. readonly _positions: Nullable<Vector3[]>;
  26534. /** @hidden */
  26535. _waitingData: {
  26536. lods: Nullable<any>;
  26537. actions: Nullable<any>;
  26538. freezeWorldMatrix: Nullable<boolean>;
  26539. };
  26540. /** @hidden */
  26541. _bonesTransformMatrices: Nullable<Float32Array>;
  26542. /** @hidden */
  26543. _transformMatrixTexture: Nullable<RawTexture>;
  26544. /**
  26545. * Gets or sets a skeleton to apply skining transformations
  26546. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26547. */
  26548. skeleton: Nullable<Skeleton>;
  26549. /**
  26550. * An event triggered when the mesh is rebuilt.
  26551. */
  26552. onRebuildObservable: Observable<AbstractMesh>;
  26553. /**
  26554. * Creates a new AbstractMesh
  26555. * @param name defines the name of the mesh
  26556. * @param scene defines the hosting scene
  26557. */
  26558. constructor(name: string, scene?: Nullable<Scene>);
  26559. /**
  26560. * Returns the string "AbstractMesh"
  26561. * @returns "AbstractMesh"
  26562. */
  26563. getClassName(): string;
  26564. /**
  26565. * Gets a string representation of the current mesh
  26566. * @param fullDetails defines a boolean indicating if full details must be included
  26567. * @returns a string representation of the current mesh
  26568. */
  26569. toString(fullDetails?: boolean): string;
  26570. /**
  26571. * @hidden
  26572. */
  26573. protected _getEffectiveParent(): Nullable<Node>;
  26574. /** @hidden */
  26575. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26576. /** @hidden */
  26577. _rebuild(): void;
  26578. /** @hidden */
  26579. _resyncLightSources(): void;
  26580. /** @hidden */
  26581. _resyncLighSource(light: Light): void;
  26582. /** @hidden */
  26583. _unBindEffect(): void;
  26584. /** @hidden */
  26585. _removeLightSource(light: Light): void;
  26586. private _markSubMeshesAsDirty;
  26587. /** @hidden */
  26588. _markSubMeshesAsLightDirty(): void;
  26589. /** @hidden */
  26590. _markSubMeshesAsAttributesDirty(): void;
  26591. /** @hidden */
  26592. _markSubMeshesAsMiscDirty(): void;
  26593. /**
  26594. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26595. */
  26596. scaling: Vector3;
  26597. /**
  26598. * Returns true if the mesh is blocked. Implemented by child classes
  26599. */
  26600. readonly isBlocked: boolean;
  26601. /**
  26602. * Returns the mesh itself by default. Implemented by child classes
  26603. * @param camera defines the camera to use to pick the right LOD level
  26604. * @returns the currentAbstractMesh
  26605. */
  26606. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26607. /**
  26608. * Returns 0 by default. Implemented by child classes
  26609. * @returns an integer
  26610. */
  26611. getTotalVertices(): number;
  26612. /**
  26613. * Returns a positive integer : the total number of indices in this mesh geometry.
  26614. * @returns the numner of indices or zero if the mesh has no geometry.
  26615. */
  26616. getTotalIndices(): number;
  26617. /**
  26618. * Returns null by default. Implemented by child classes
  26619. * @returns null
  26620. */
  26621. getIndices(): Nullable<IndicesArray>;
  26622. /**
  26623. * Returns the array of the requested vertex data kind. Implemented by child classes
  26624. * @param kind defines the vertex data kind to use
  26625. * @returns null
  26626. */
  26627. getVerticesData(kind: string): Nullable<FloatArray>;
  26628. /**
  26629. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26630. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26631. * Note that a new underlying VertexBuffer object is created each call.
  26632. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26633. * @param kind defines vertex data kind:
  26634. * * VertexBuffer.PositionKind
  26635. * * VertexBuffer.UVKind
  26636. * * VertexBuffer.UV2Kind
  26637. * * VertexBuffer.UV3Kind
  26638. * * VertexBuffer.UV4Kind
  26639. * * VertexBuffer.UV5Kind
  26640. * * VertexBuffer.UV6Kind
  26641. * * VertexBuffer.ColorKind
  26642. * * VertexBuffer.MatricesIndicesKind
  26643. * * VertexBuffer.MatricesIndicesExtraKind
  26644. * * VertexBuffer.MatricesWeightsKind
  26645. * * VertexBuffer.MatricesWeightsExtraKind
  26646. * @param data defines the data source
  26647. * @param updatable defines if the data must be flagged as updatable (or static)
  26648. * @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
  26649. * @returns the current mesh
  26650. */
  26651. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26652. /**
  26653. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26654. * If the mesh has no geometry, it is simply returned as it is.
  26655. * @param kind defines vertex data kind:
  26656. * * VertexBuffer.PositionKind
  26657. * * VertexBuffer.UVKind
  26658. * * VertexBuffer.UV2Kind
  26659. * * VertexBuffer.UV3Kind
  26660. * * VertexBuffer.UV4Kind
  26661. * * VertexBuffer.UV5Kind
  26662. * * VertexBuffer.UV6Kind
  26663. * * VertexBuffer.ColorKind
  26664. * * VertexBuffer.MatricesIndicesKind
  26665. * * VertexBuffer.MatricesIndicesExtraKind
  26666. * * VertexBuffer.MatricesWeightsKind
  26667. * * VertexBuffer.MatricesWeightsExtraKind
  26668. * @param data defines the data source
  26669. * @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
  26670. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26671. * @returns the current mesh
  26672. */
  26673. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26674. /**
  26675. * Sets the mesh indices,
  26676. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26677. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26678. * @param totalVertices Defines the total number of vertices
  26679. * @returns the current mesh
  26680. */
  26681. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26682. /**
  26683. * Gets a boolean indicating if specific vertex data is present
  26684. * @param kind defines the vertex data kind to use
  26685. * @returns true is data kind is present
  26686. */
  26687. isVerticesDataPresent(kind: string): boolean;
  26688. /**
  26689. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26690. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26691. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26692. * @returns a BoundingInfo
  26693. */
  26694. getBoundingInfo(): BoundingInfo;
  26695. /**
  26696. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26697. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26698. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26699. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26700. * @returns the current mesh
  26701. */
  26702. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26703. /**
  26704. * Overwrite the current bounding info
  26705. * @param boundingInfo defines the new bounding info
  26706. * @returns the current mesh
  26707. */
  26708. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26709. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26710. readonly useBones: boolean;
  26711. /** @hidden */
  26712. _preActivate(): void;
  26713. /** @hidden */
  26714. _preActivateForIntermediateRendering(renderId: number): void;
  26715. /** @hidden */
  26716. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26717. /** @hidden */
  26718. _postActivate(): void;
  26719. /** @hidden */
  26720. _freeze(): void;
  26721. /** @hidden */
  26722. _unFreeze(): void;
  26723. /**
  26724. * Gets the current world matrix
  26725. * @returns a Matrix
  26726. */
  26727. getWorldMatrix(): Matrix;
  26728. /** @hidden */
  26729. _getWorldMatrixDeterminant(): number;
  26730. /**
  26731. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26732. */
  26733. readonly isAnInstance: boolean;
  26734. /**
  26735. * Perform relative position change from the point of view of behind the front of the mesh.
  26736. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26737. * Supports definition of mesh facing forward or backward
  26738. * @param amountRight defines the distance on the right axis
  26739. * @param amountUp defines the distance on the up axis
  26740. * @param amountForward defines the distance on the forward axis
  26741. * @returns the current mesh
  26742. */
  26743. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26744. /**
  26745. * Calculate relative position change from the point of view of behind the front of the mesh.
  26746. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26747. * Supports definition of mesh facing forward or backward
  26748. * @param amountRight defines the distance on the right axis
  26749. * @param amountUp defines the distance on the up axis
  26750. * @param amountForward defines the distance on the forward axis
  26751. * @returns the new displacement vector
  26752. */
  26753. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26754. /**
  26755. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26756. * Supports definition of mesh facing forward or backward
  26757. * @param flipBack defines the flip
  26758. * @param twirlClockwise defines the twirl
  26759. * @param tiltRight defines the tilt
  26760. * @returns the current mesh
  26761. */
  26762. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26763. /**
  26764. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26765. * Supports definition of mesh facing forward or backward.
  26766. * @param flipBack defines the flip
  26767. * @param twirlClockwise defines the twirl
  26768. * @param tiltRight defines the tilt
  26769. * @returns the new rotation vector
  26770. */
  26771. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26772. /**
  26773. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26774. * This means the mesh underlying bounding box and sphere are recomputed.
  26775. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26776. * @returns the current mesh
  26777. */
  26778. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26779. /** @hidden */
  26780. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26781. /** @hidden */
  26782. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26783. /** @hidden */
  26784. _updateBoundingInfo(): AbstractMesh;
  26785. /** @hidden */
  26786. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26787. /** @hidden */
  26788. protected _afterComputeWorldMatrix(): void;
  26789. /** @hidden */
  26790. readonly _effectiveMesh: AbstractMesh;
  26791. /**
  26792. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26793. * A mesh is in the frustum if its bounding box intersects the frustum
  26794. * @param frustumPlanes defines the frustum to test
  26795. * @returns true if the mesh is in the frustum planes
  26796. */
  26797. isInFrustum(frustumPlanes: Plane[]): boolean;
  26798. /**
  26799. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26800. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26801. * @param frustumPlanes defines the frustum to test
  26802. * @returns true if the mesh is completely in the frustum planes
  26803. */
  26804. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26805. /**
  26806. * True if the mesh intersects another mesh or a SolidParticle object
  26807. * @param mesh defines a target mesh or SolidParticle to test
  26808. * @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)
  26809. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26810. * @returns true if there is an intersection
  26811. */
  26812. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26813. /**
  26814. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26815. * @param point defines the point to test
  26816. * @returns true if there is an intersection
  26817. */
  26818. intersectsPoint(point: Vector3): boolean;
  26819. /**
  26820. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26821. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26822. */
  26823. checkCollisions: boolean;
  26824. /**
  26825. * Gets Collider object used to compute collisions (not physics)
  26826. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26827. */
  26828. readonly collider: Nullable<Collider>;
  26829. /**
  26830. * Move the mesh using collision engine
  26831. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26832. * @param displacement defines the requested displacement vector
  26833. * @returns the current mesh
  26834. */
  26835. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26836. private _onCollisionPositionChange;
  26837. /** @hidden */
  26838. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26839. /** @hidden */
  26840. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26841. /** @hidden */
  26842. _checkCollision(collider: Collider): AbstractMesh;
  26843. /** @hidden */
  26844. _generatePointsArray(): boolean;
  26845. /**
  26846. * Checks if the passed Ray intersects with the mesh
  26847. * @param ray defines the ray to use
  26848. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26849. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26850. * @returns the picking info
  26851. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26852. */
  26853. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26854. /**
  26855. * Clones the current mesh
  26856. * @param name defines the mesh name
  26857. * @param newParent defines the new mesh parent
  26858. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26859. * @returns the new mesh
  26860. */
  26861. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26862. /**
  26863. * Disposes all the submeshes of the current meshnp
  26864. * @returns the current mesh
  26865. */
  26866. releaseSubMeshes(): AbstractMesh;
  26867. /**
  26868. * Releases resources associated with this abstract mesh.
  26869. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26870. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26871. */
  26872. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26873. /**
  26874. * Adds the passed mesh as a child to the current mesh
  26875. * @param mesh defines the child mesh
  26876. * @returns the current mesh
  26877. */
  26878. addChild(mesh: AbstractMesh): AbstractMesh;
  26879. /**
  26880. * Removes the passed mesh from the current mesh children list
  26881. * @param mesh defines the child mesh
  26882. * @returns the current mesh
  26883. */
  26884. removeChild(mesh: AbstractMesh): AbstractMesh;
  26885. /** @hidden */
  26886. private _initFacetData;
  26887. /**
  26888. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26889. * This method can be called within the render loop.
  26890. * 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
  26891. * @returns the current mesh
  26892. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26893. */
  26894. updateFacetData(): AbstractMesh;
  26895. /**
  26896. * Returns the facetLocalNormals array.
  26897. * The normals are expressed in the mesh local spac
  26898. * @returns an array of Vector3
  26899. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26900. */
  26901. getFacetLocalNormals(): Vector3[];
  26902. /**
  26903. * Returns the facetLocalPositions array.
  26904. * The facet positions are expressed in the mesh local space
  26905. * @returns an array of Vector3
  26906. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26907. */
  26908. getFacetLocalPositions(): Vector3[];
  26909. /**
  26910. * Returns the facetLocalPartioning array
  26911. * @returns an array of array of numbers
  26912. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26913. */
  26914. getFacetLocalPartitioning(): number[][];
  26915. /**
  26916. * Returns the i-th facet position in the world system.
  26917. * This method allocates a new Vector3 per call
  26918. * @param i defines the facet index
  26919. * @returns a new Vector3
  26920. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26921. */
  26922. getFacetPosition(i: number): Vector3;
  26923. /**
  26924. * Sets the reference Vector3 with the i-th facet position in the world system
  26925. * @param i defines the facet index
  26926. * @param ref defines the target vector
  26927. * @returns the current mesh
  26928. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26929. */
  26930. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26931. /**
  26932. * Returns the i-th facet normal in the world system.
  26933. * This method allocates a new Vector3 per call
  26934. * @param i defines the facet index
  26935. * @returns a new Vector3
  26936. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26937. */
  26938. getFacetNormal(i: number): Vector3;
  26939. /**
  26940. * Sets the reference Vector3 with the i-th facet normal in the world system
  26941. * @param i defines the facet index
  26942. * @param ref defines the target vector
  26943. * @returns the current mesh
  26944. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26945. */
  26946. getFacetNormalToRef(i: number, ref: Vector3): this;
  26947. /**
  26948. * 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)
  26949. * @param x defines x coordinate
  26950. * @param y defines y coordinate
  26951. * @param z defines z coordinate
  26952. * @returns the array of facet indexes
  26953. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26954. */
  26955. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26956. /**
  26957. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26958. * @param projected sets as the (x,y,z) world projection on the facet
  26959. * @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
  26960. * @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
  26961. * @param x defines x coordinate
  26962. * @param y defines y coordinate
  26963. * @param z defines z coordinate
  26964. * @returns the face index if found (or null instead)
  26965. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26966. */
  26967. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26968. /**
  26969. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26970. * @param projected sets as the (x,y,z) local projection on the facet
  26971. * @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
  26972. * @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
  26973. * @param x defines x coordinate
  26974. * @param y defines y coordinate
  26975. * @param z defines z coordinate
  26976. * @returns the face index if found (or null instead)
  26977. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26978. */
  26979. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26980. /**
  26981. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26982. * @returns the parameters
  26983. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26984. */
  26985. getFacetDataParameters(): any;
  26986. /**
  26987. * Disables the feature FacetData and frees the related memory
  26988. * @returns the current mesh
  26989. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26990. */
  26991. disableFacetData(): AbstractMesh;
  26992. /**
  26993. * Updates the AbstractMesh indices array
  26994. * @param indices defines the data source
  26995. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26996. * @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)
  26997. * @returns the current mesh
  26998. */
  26999. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27000. /**
  27001. * Creates new normals data for the mesh
  27002. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27003. * @returns the current mesh
  27004. */
  27005. createNormals(updatable: boolean): AbstractMesh;
  27006. /**
  27007. * Align the mesh with a normal
  27008. * @param normal defines the normal to use
  27009. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27010. * @returns the current mesh
  27011. */
  27012. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27013. /** @hidden */
  27014. _checkOcclusionQuery(): boolean;
  27015. /**
  27016. * Disables the mesh edge rendering mode
  27017. * @returns the currentAbstractMesh
  27018. */
  27019. disableEdgesRendering(): AbstractMesh;
  27020. /**
  27021. * Enables the edge rendering mode on the mesh.
  27022. * This mode makes the mesh edges visible
  27023. * @param epsilon defines the maximal distance between two angles to detect a face
  27024. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27025. * @returns the currentAbstractMesh
  27026. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27027. */
  27028. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27029. }
  27030. }
  27031. declare module "babylonjs/Actions/actionEvent" {
  27032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27033. import { Nullable } from "babylonjs/types";
  27034. import { Sprite } from "babylonjs/Sprites/sprite";
  27035. import { Scene } from "babylonjs/scene";
  27036. import { Vector2 } from "babylonjs/Maths/math.vector";
  27037. /**
  27038. * Interface used to define ActionEvent
  27039. */
  27040. export interface IActionEvent {
  27041. /** The mesh or sprite that triggered the action */
  27042. source: any;
  27043. /** The X mouse cursor position at the time of the event */
  27044. pointerX: number;
  27045. /** The Y mouse cursor position at the time of the event */
  27046. pointerY: number;
  27047. /** The mesh that is currently pointed at (can be null) */
  27048. meshUnderPointer: Nullable<AbstractMesh>;
  27049. /** the original (browser) event that triggered the ActionEvent */
  27050. sourceEvent?: any;
  27051. /** additional data for the event */
  27052. additionalData?: any;
  27053. }
  27054. /**
  27055. * ActionEvent is the event being sent when an action is triggered.
  27056. */
  27057. export class ActionEvent implements IActionEvent {
  27058. /** The mesh or sprite that triggered the action */
  27059. source: any;
  27060. /** The X mouse cursor position at the time of the event */
  27061. pointerX: number;
  27062. /** The Y mouse cursor position at the time of the event */
  27063. pointerY: number;
  27064. /** The mesh that is currently pointed at (can be null) */
  27065. meshUnderPointer: Nullable<AbstractMesh>;
  27066. /** the original (browser) event that triggered the ActionEvent */
  27067. sourceEvent?: any;
  27068. /** additional data for the event */
  27069. additionalData?: any;
  27070. /**
  27071. * Creates a new ActionEvent
  27072. * @param source The mesh or sprite that triggered the action
  27073. * @param pointerX The X mouse cursor position at the time of the event
  27074. * @param pointerY The Y mouse cursor position at the time of the event
  27075. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27076. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27077. * @param additionalData additional data for the event
  27078. */
  27079. constructor(
  27080. /** The mesh or sprite that triggered the action */
  27081. source: any,
  27082. /** The X mouse cursor position at the time of the event */
  27083. pointerX: number,
  27084. /** The Y mouse cursor position at the time of the event */
  27085. pointerY: number,
  27086. /** The mesh that is currently pointed at (can be null) */
  27087. meshUnderPointer: Nullable<AbstractMesh>,
  27088. /** the original (browser) event that triggered the ActionEvent */
  27089. sourceEvent?: any,
  27090. /** additional data for the event */
  27091. additionalData?: any);
  27092. /**
  27093. * Helper function to auto-create an ActionEvent from a source mesh.
  27094. * @param source The source mesh that triggered the event
  27095. * @param evt The original (browser) event
  27096. * @param additionalData additional data for the event
  27097. * @returns the new ActionEvent
  27098. */
  27099. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27100. /**
  27101. * Helper function to auto-create an ActionEvent from a source sprite
  27102. * @param source The source sprite that triggered the event
  27103. * @param scene Scene associated with the sprite
  27104. * @param evt The original (browser) event
  27105. * @param additionalData additional data for the event
  27106. * @returns the new ActionEvent
  27107. */
  27108. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27109. /**
  27110. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27111. * @param scene the scene where the event occurred
  27112. * @param evt The original (browser) event
  27113. * @returns the new ActionEvent
  27114. */
  27115. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27116. /**
  27117. * Helper function to auto-create an ActionEvent from a primitive
  27118. * @param prim defines the target primitive
  27119. * @param pointerPos defines the pointer position
  27120. * @param evt The original (browser) event
  27121. * @param additionalData additional data for the event
  27122. * @returns the new ActionEvent
  27123. */
  27124. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27125. }
  27126. }
  27127. declare module "babylonjs/Actions/abstractActionManager" {
  27128. import { IDisposable } from "babylonjs/scene";
  27129. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27130. import { IAction } from "babylonjs/Actions/action";
  27131. import { Nullable } from "babylonjs/types";
  27132. /**
  27133. * Abstract class used to decouple action Manager from scene and meshes.
  27134. * Do not instantiate.
  27135. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27136. */
  27137. export abstract class AbstractActionManager implements IDisposable {
  27138. /** Gets the list of active triggers */
  27139. static Triggers: {
  27140. [key: string]: number;
  27141. };
  27142. /** Gets the cursor to use when hovering items */
  27143. hoverCursor: string;
  27144. /** Gets the list of actions */
  27145. actions: IAction[];
  27146. /**
  27147. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27148. */
  27149. isRecursive: boolean;
  27150. /**
  27151. * Releases all associated resources
  27152. */
  27153. abstract dispose(): void;
  27154. /**
  27155. * Does this action manager has pointer triggers
  27156. */
  27157. abstract readonly hasPointerTriggers: boolean;
  27158. /**
  27159. * Does this action manager has pick triggers
  27160. */
  27161. abstract readonly hasPickTriggers: boolean;
  27162. /**
  27163. * Process a specific trigger
  27164. * @param trigger defines the trigger to process
  27165. * @param evt defines the event details to be processed
  27166. */
  27167. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27168. /**
  27169. * Does this action manager handles actions of any of the given triggers
  27170. * @param triggers defines the triggers to be tested
  27171. * @return a boolean indicating whether one (or more) of the triggers is handled
  27172. */
  27173. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27174. /**
  27175. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27176. * speed.
  27177. * @param triggerA defines the trigger to be tested
  27178. * @param triggerB defines the trigger to be tested
  27179. * @return a boolean indicating whether one (or more) of the triggers is handled
  27180. */
  27181. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27182. /**
  27183. * Does this action manager handles actions of a given trigger
  27184. * @param trigger defines the trigger to be tested
  27185. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27186. * @return whether the trigger is handled
  27187. */
  27188. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27189. /**
  27190. * Serialize this manager to a JSON object
  27191. * @param name defines the property name to store this manager
  27192. * @returns a JSON representation of this manager
  27193. */
  27194. abstract serialize(name: string): any;
  27195. /**
  27196. * Registers an action to this action manager
  27197. * @param action defines the action to be registered
  27198. * @return the action amended (prepared) after registration
  27199. */
  27200. abstract registerAction(action: IAction): Nullable<IAction>;
  27201. /**
  27202. * Unregisters an action to this action manager
  27203. * @param action defines the action to be unregistered
  27204. * @return a boolean indicating whether the action has been unregistered
  27205. */
  27206. abstract unregisterAction(action: IAction): Boolean;
  27207. /**
  27208. * Does exist one action manager with at least one trigger
  27209. **/
  27210. static readonly HasTriggers: boolean;
  27211. /**
  27212. * Does exist one action manager with at least one pick trigger
  27213. **/
  27214. static readonly HasPickTriggers: boolean;
  27215. /**
  27216. * Does exist one action manager that handles actions of a given trigger
  27217. * @param trigger defines the trigger to be tested
  27218. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27219. **/
  27220. static HasSpecificTrigger(trigger: number): boolean;
  27221. }
  27222. }
  27223. declare module "babylonjs/node" {
  27224. import { Scene } from "babylonjs/scene";
  27225. import { Nullable } from "babylonjs/types";
  27226. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27227. import { Engine } from "babylonjs/Engines/engine";
  27228. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27229. import { Observable } from "babylonjs/Misc/observable";
  27230. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27231. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27232. import { Animatable } from "babylonjs/Animations/animatable";
  27233. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27234. import { Animation } from "babylonjs/Animations/animation";
  27235. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27237. /**
  27238. * Defines how a node can be built from a string name.
  27239. */
  27240. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27241. /**
  27242. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27243. */
  27244. export class Node implements IBehaviorAware<Node> {
  27245. /** @hidden */
  27246. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27247. private static _NodeConstructors;
  27248. /**
  27249. * Add a new node constructor
  27250. * @param type defines the type name of the node to construct
  27251. * @param constructorFunc defines the constructor function
  27252. */
  27253. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27254. /**
  27255. * Returns a node constructor based on type name
  27256. * @param type defines the type name
  27257. * @param name defines the new node name
  27258. * @param scene defines the hosting scene
  27259. * @param options defines optional options to transmit to constructors
  27260. * @returns the new constructor or null
  27261. */
  27262. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27263. /**
  27264. * Gets or sets the name of the node
  27265. */
  27266. name: string;
  27267. /**
  27268. * Gets or sets the id of the node
  27269. */
  27270. id: string;
  27271. /**
  27272. * Gets or sets the unique id of the node
  27273. */
  27274. uniqueId: number;
  27275. /**
  27276. * Gets or sets a string used to store user defined state for the node
  27277. */
  27278. state: string;
  27279. /**
  27280. * Gets or sets an object used to store user defined information for the node
  27281. */
  27282. metadata: any;
  27283. /**
  27284. * For internal use only. Please do not use.
  27285. */
  27286. reservedDataStore: any;
  27287. /**
  27288. * List of inspectable custom properties (used by the Inspector)
  27289. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27290. */
  27291. inspectableCustomProperties: IInspectable[];
  27292. /**
  27293. * Gets or sets a boolean used to define if the node must be serialized
  27294. */
  27295. doNotSerialize: boolean;
  27296. /** @hidden */
  27297. _isDisposed: boolean;
  27298. /**
  27299. * Gets a list of Animations associated with the node
  27300. */
  27301. animations: import("babylonjs/Animations/animation").Animation[];
  27302. protected _ranges: {
  27303. [name: string]: Nullable<AnimationRange>;
  27304. };
  27305. /**
  27306. * Callback raised when the node is ready to be used
  27307. */
  27308. onReady: Nullable<(node: Node) => void>;
  27309. private _isEnabled;
  27310. private _isParentEnabled;
  27311. private _isReady;
  27312. /** @hidden */
  27313. _currentRenderId: number;
  27314. private _parentUpdateId;
  27315. /** @hidden */
  27316. _childUpdateId: number;
  27317. /** @hidden */
  27318. _waitingParentId: Nullable<string>;
  27319. /** @hidden */
  27320. _scene: Scene;
  27321. /** @hidden */
  27322. _cache: any;
  27323. private _parentNode;
  27324. private _children;
  27325. /** @hidden */
  27326. _worldMatrix: Matrix;
  27327. /** @hidden */
  27328. _worldMatrixDeterminant: number;
  27329. /** @hidden */
  27330. _worldMatrixDeterminantIsDirty: boolean;
  27331. /** @hidden */
  27332. private _sceneRootNodesIndex;
  27333. /**
  27334. * Gets a boolean indicating if the node has been disposed
  27335. * @returns true if the node was disposed
  27336. */
  27337. isDisposed(): boolean;
  27338. /**
  27339. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27340. * @see https://doc.babylonjs.com/how_to/parenting
  27341. */
  27342. parent: Nullable<Node>;
  27343. private addToSceneRootNodes;
  27344. private removeFromSceneRootNodes;
  27345. private _animationPropertiesOverride;
  27346. /**
  27347. * Gets or sets the animation properties override
  27348. */
  27349. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27350. /**
  27351. * Gets a string idenfifying the name of the class
  27352. * @returns "Node" string
  27353. */
  27354. getClassName(): string;
  27355. /** @hidden */
  27356. readonly _isNode: boolean;
  27357. /**
  27358. * An event triggered when the mesh is disposed
  27359. */
  27360. onDisposeObservable: Observable<Node>;
  27361. private _onDisposeObserver;
  27362. /**
  27363. * Sets a callback that will be raised when the node will be disposed
  27364. */
  27365. onDispose: () => void;
  27366. /**
  27367. * Creates a new Node
  27368. * @param name the name and id to be given to this node
  27369. * @param scene the scene this node will be added to
  27370. * @param addToRootNodes the node will be added to scene.rootNodes
  27371. */
  27372. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27373. /**
  27374. * Gets the scene of the node
  27375. * @returns a scene
  27376. */
  27377. getScene(): Scene;
  27378. /**
  27379. * Gets the engine of the node
  27380. * @returns a Engine
  27381. */
  27382. getEngine(): Engine;
  27383. private _behaviors;
  27384. /**
  27385. * Attach a behavior to the node
  27386. * @see http://doc.babylonjs.com/features/behaviour
  27387. * @param behavior defines the behavior to attach
  27388. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27389. * @returns the current Node
  27390. */
  27391. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27392. /**
  27393. * Remove an attached behavior
  27394. * @see http://doc.babylonjs.com/features/behaviour
  27395. * @param behavior defines the behavior to attach
  27396. * @returns the current Node
  27397. */
  27398. removeBehavior(behavior: Behavior<Node>): Node;
  27399. /**
  27400. * Gets the list of attached behaviors
  27401. * @see http://doc.babylonjs.com/features/behaviour
  27402. */
  27403. readonly behaviors: Behavior<Node>[];
  27404. /**
  27405. * Gets an attached behavior by name
  27406. * @param name defines the name of the behavior to look for
  27407. * @see http://doc.babylonjs.com/features/behaviour
  27408. * @returns null if behavior was not found else the requested behavior
  27409. */
  27410. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27411. /**
  27412. * Returns the latest update of the World matrix
  27413. * @returns a Matrix
  27414. */
  27415. getWorldMatrix(): Matrix;
  27416. /** @hidden */
  27417. _getWorldMatrixDeterminant(): number;
  27418. /**
  27419. * Returns directly the latest state of the mesh World matrix.
  27420. * A Matrix is returned.
  27421. */
  27422. readonly worldMatrixFromCache: Matrix;
  27423. /** @hidden */
  27424. _initCache(): void;
  27425. /** @hidden */
  27426. updateCache(force?: boolean): void;
  27427. /** @hidden */
  27428. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27429. /** @hidden */
  27430. _updateCache(ignoreParentClass?: boolean): void;
  27431. /** @hidden */
  27432. _isSynchronized(): boolean;
  27433. /** @hidden */
  27434. _markSyncedWithParent(): void;
  27435. /** @hidden */
  27436. isSynchronizedWithParent(): boolean;
  27437. /** @hidden */
  27438. isSynchronized(): boolean;
  27439. /**
  27440. * Is this node ready to be used/rendered
  27441. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27442. * @return true if the node is ready
  27443. */
  27444. isReady(completeCheck?: boolean): boolean;
  27445. /**
  27446. * Is this node enabled?
  27447. * 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
  27448. * @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
  27449. * @return whether this node (and its parent) is enabled
  27450. */
  27451. isEnabled(checkAncestors?: boolean): boolean;
  27452. /** @hidden */
  27453. protected _syncParentEnabledState(): void;
  27454. /**
  27455. * Set the enabled state of this node
  27456. * @param value defines the new enabled state
  27457. */
  27458. setEnabled(value: boolean): void;
  27459. /**
  27460. * Is this node a descendant of the given node?
  27461. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27462. * @param ancestor defines the parent node to inspect
  27463. * @returns a boolean indicating if this node is a descendant of the given node
  27464. */
  27465. isDescendantOf(ancestor: Node): boolean;
  27466. /** @hidden */
  27467. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27468. /**
  27469. * Will return all nodes that have this node as ascendant
  27470. * @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
  27471. * @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
  27472. * @return all children nodes of all types
  27473. */
  27474. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27475. /**
  27476. * Get all child-meshes of this node
  27477. * @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)
  27478. * @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
  27479. * @returns an array of AbstractMesh
  27480. */
  27481. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27482. /**
  27483. * Get all direct children of this node
  27484. * @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
  27485. * @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)
  27486. * @returns an array of Node
  27487. */
  27488. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27489. /** @hidden */
  27490. _setReady(state: boolean): void;
  27491. /**
  27492. * Get an animation by name
  27493. * @param name defines the name of the animation to look for
  27494. * @returns null if not found else the requested animation
  27495. */
  27496. getAnimationByName(name: string): Nullable<Animation>;
  27497. /**
  27498. * Creates an animation range for this node
  27499. * @param name defines the name of the range
  27500. * @param from defines the starting key
  27501. * @param to defines the end key
  27502. */
  27503. createAnimationRange(name: string, from: number, to: number): void;
  27504. /**
  27505. * Delete a specific animation range
  27506. * @param name defines the name of the range to delete
  27507. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27508. */
  27509. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27510. /**
  27511. * Get an animation range by name
  27512. * @param name defines the name of the animation range to look for
  27513. * @returns null if not found else the requested animation range
  27514. */
  27515. getAnimationRange(name: string): Nullable<AnimationRange>;
  27516. /**
  27517. * Gets the list of all animation ranges defined on this node
  27518. * @returns an array
  27519. */
  27520. getAnimationRanges(): Nullable<AnimationRange>[];
  27521. /**
  27522. * Will start the animation sequence
  27523. * @param name defines the range frames for animation sequence
  27524. * @param loop defines if the animation should loop (false by default)
  27525. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27526. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27527. * @returns the object created for this animation. If range does not exist, it will return null
  27528. */
  27529. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27530. /**
  27531. * Serialize animation ranges into a JSON compatible object
  27532. * @returns serialization object
  27533. */
  27534. serializeAnimationRanges(): any;
  27535. /**
  27536. * Computes the world matrix of the node
  27537. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27538. * @returns the world matrix
  27539. */
  27540. computeWorldMatrix(force?: boolean): Matrix;
  27541. /**
  27542. * Releases resources associated with this node.
  27543. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27544. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27545. */
  27546. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27547. /**
  27548. * Parse animation range data from a serialization object and store them into a given node
  27549. * @param node defines where to store the animation ranges
  27550. * @param parsedNode defines the serialization object to read data from
  27551. * @param scene defines the hosting scene
  27552. */
  27553. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27554. /**
  27555. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27556. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27557. * @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
  27558. * @returns the new bounding vectors
  27559. */
  27560. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27561. min: Vector3;
  27562. max: Vector3;
  27563. };
  27564. }
  27565. }
  27566. declare module "babylonjs/Animations/animation" {
  27567. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27568. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27569. import { Color3 } from "babylonjs/Maths/math.color";
  27570. import { Nullable } from "babylonjs/types";
  27571. import { Scene } from "babylonjs/scene";
  27572. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27573. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27574. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27575. import { Node } from "babylonjs/node";
  27576. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27577. import { Size } from "babylonjs/Maths/math.size";
  27578. import { Animatable } from "babylonjs/Animations/animatable";
  27579. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27580. /**
  27581. * @hidden
  27582. */
  27583. export class _IAnimationState {
  27584. key: number;
  27585. repeatCount: number;
  27586. workValue?: any;
  27587. loopMode?: number;
  27588. offsetValue?: any;
  27589. highLimitValue?: any;
  27590. }
  27591. /**
  27592. * Class used to store any kind of animation
  27593. */
  27594. export class Animation {
  27595. /**Name of the animation */
  27596. name: string;
  27597. /**Property to animate */
  27598. targetProperty: string;
  27599. /**The frames per second of the animation */
  27600. framePerSecond: number;
  27601. /**The data type of the animation */
  27602. dataType: number;
  27603. /**The loop mode of the animation */
  27604. loopMode?: number | undefined;
  27605. /**Specifies if blending should be enabled */
  27606. enableBlending?: boolean | undefined;
  27607. /**
  27608. * Use matrix interpolation instead of using direct key value when animating matrices
  27609. */
  27610. static AllowMatricesInterpolation: boolean;
  27611. /**
  27612. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27613. */
  27614. static AllowMatrixDecomposeForInterpolation: boolean;
  27615. /**
  27616. * Stores the key frames of the animation
  27617. */
  27618. private _keys;
  27619. /**
  27620. * Stores the easing function of the animation
  27621. */
  27622. private _easingFunction;
  27623. /**
  27624. * @hidden Internal use only
  27625. */
  27626. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27627. /**
  27628. * The set of event that will be linked to this animation
  27629. */
  27630. private _events;
  27631. /**
  27632. * Stores an array of target property paths
  27633. */
  27634. targetPropertyPath: string[];
  27635. /**
  27636. * Stores the blending speed of the animation
  27637. */
  27638. blendingSpeed: number;
  27639. /**
  27640. * Stores the animation ranges for the animation
  27641. */
  27642. private _ranges;
  27643. /**
  27644. * @hidden Internal use
  27645. */
  27646. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27647. /**
  27648. * Sets up an animation
  27649. * @param property The property to animate
  27650. * @param animationType The animation type to apply
  27651. * @param framePerSecond The frames per second of the animation
  27652. * @param easingFunction The easing function used in the animation
  27653. * @returns The created animation
  27654. */
  27655. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27656. /**
  27657. * Create and start an animation on a node
  27658. * @param name defines the name of the global animation that will be run on all nodes
  27659. * @param node defines the root node where the animation will take place
  27660. * @param targetProperty defines property to animate
  27661. * @param framePerSecond defines the number of frame per second yo use
  27662. * @param totalFrame defines the number of frames in total
  27663. * @param from defines the initial value
  27664. * @param to defines the final value
  27665. * @param loopMode defines which loop mode you want to use (off by default)
  27666. * @param easingFunction defines the easing function to use (linear by default)
  27667. * @param onAnimationEnd defines the callback to call when animation end
  27668. * @returns the animatable created for this animation
  27669. */
  27670. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27671. /**
  27672. * Create and start an animation on a node and its descendants
  27673. * @param name defines the name of the global animation that will be run on all nodes
  27674. * @param node defines the root node where the animation will take place
  27675. * @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
  27676. * @param targetProperty defines property to animate
  27677. * @param framePerSecond defines the number of frame per second to use
  27678. * @param totalFrame defines the number of frames in total
  27679. * @param from defines the initial value
  27680. * @param to defines the final value
  27681. * @param loopMode defines which loop mode you want to use (off by default)
  27682. * @param easingFunction defines the easing function to use (linear by default)
  27683. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27684. * @returns the list of animatables created for all nodes
  27685. * @example https://www.babylonjs-playground.com/#MH0VLI
  27686. */
  27687. 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[]>;
  27688. /**
  27689. * Creates a new animation, merges it with the existing animations and starts it
  27690. * @param name Name of the animation
  27691. * @param node Node which contains the scene that begins the animations
  27692. * @param targetProperty Specifies which property to animate
  27693. * @param framePerSecond The frames per second of the animation
  27694. * @param totalFrame The total number of frames
  27695. * @param from The frame at the beginning of the animation
  27696. * @param to The frame at the end of the animation
  27697. * @param loopMode Specifies the loop mode of the animation
  27698. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27699. * @param onAnimationEnd Callback to run once the animation is complete
  27700. * @returns Nullable animation
  27701. */
  27702. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27703. /**
  27704. * Transition property of an host to the target Value
  27705. * @param property The property to transition
  27706. * @param targetValue The target Value of the property
  27707. * @param host The object where the property to animate belongs
  27708. * @param scene Scene used to run the animation
  27709. * @param frameRate Framerate (in frame/s) to use
  27710. * @param transition The transition type we want to use
  27711. * @param duration The duration of the animation, in milliseconds
  27712. * @param onAnimationEnd Callback trigger at the end of the animation
  27713. * @returns Nullable animation
  27714. */
  27715. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27716. /**
  27717. * Return the array of runtime animations currently using this animation
  27718. */
  27719. readonly runtimeAnimations: RuntimeAnimation[];
  27720. /**
  27721. * Specifies if any of the runtime animations are currently running
  27722. */
  27723. readonly hasRunningRuntimeAnimations: boolean;
  27724. /**
  27725. * Initializes the animation
  27726. * @param name Name of the animation
  27727. * @param targetProperty Property to animate
  27728. * @param framePerSecond The frames per second of the animation
  27729. * @param dataType The data type of the animation
  27730. * @param loopMode The loop mode of the animation
  27731. * @param enableBlending Specifies if blending should be enabled
  27732. */
  27733. constructor(
  27734. /**Name of the animation */
  27735. name: string,
  27736. /**Property to animate */
  27737. targetProperty: string,
  27738. /**The frames per second of the animation */
  27739. framePerSecond: number,
  27740. /**The data type of the animation */
  27741. dataType: number,
  27742. /**The loop mode of the animation */
  27743. loopMode?: number | undefined,
  27744. /**Specifies if blending should be enabled */
  27745. enableBlending?: boolean | undefined);
  27746. /**
  27747. * Converts the animation to a string
  27748. * @param fullDetails support for multiple levels of logging within scene loading
  27749. * @returns String form of the animation
  27750. */
  27751. toString(fullDetails?: boolean): string;
  27752. /**
  27753. * Add an event to this animation
  27754. * @param event Event to add
  27755. */
  27756. addEvent(event: AnimationEvent): void;
  27757. /**
  27758. * Remove all events found at the given frame
  27759. * @param frame The frame to remove events from
  27760. */
  27761. removeEvents(frame: number): void;
  27762. /**
  27763. * Retrieves all the events from the animation
  27764. * @returns Events from the animation
  27765. */
  27766. getEvents(): AnimationEvent[];
  27767. /**
  27768. * Creates an animation range
  27769. * @param name Name of the animation range
  27770. * @param from Starting frame of the animation range
  27771. * @param to Ending frame of the animation
  27772. */
  27773. createRange(name: string, from: number, to: number): void;
  27774. /**
  27775. * Deletes an animation range by name
  27776. * @param name Name of the animation range to delete
  27777. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27778. */
  27779. deleteRange(name: string, deleteFrames?: boolean): void;
  27780. /**
  27781. * Gets the animation range by name, or null if not defined
  27782. * @param name Name of the animation range
  27783. * @returns Nullable animation range
  27784. */
  27785. getRange(name: string): Nullable<AnimationRange>;
  27786. /**
  27787. * Gets the key frames from the animation
  27788. * @returns The key frames of the animation
  27789. */
  27790. getKeys(): Array<IAnimationKey>;
  27791. /**
  27792. * Gets the highest frame rate of the animation
  27793. * @returns Highest frame rate of the animation
  27794. */
  27795. getHighestFrame(): number;
  27796. /**
  27797. * Gets the easing function of the animation
  27798. * @returns Easing function of the animation
  27799. */
  27800. getEasingFunction(): IEasingFunction;
  27801. /**
  27802. * Sets the easing function of the animation
  27803. * @param easingFunction A custom mathematical formula for animation
  27804. */
  27805. setEasingFunction(easingFunction: EasingFunction): void;
  27806. /**
  27807. * Interpolates a scalar linearly
  27808. * @param startValue Start value of the animation curve
  27809. * @param endValue End value of the animation curve
  27810. * @param gradient Scalar amount to interpolate
  27811. * @returns Interpolated scalar value
  27812. */
  27813. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27814. /**
  27815. * Interpolates a scalar cubically
  27816. * @param startValue Start value of the animation curve
  27817. * @param outTangent End tangent of the animation
  27818. * @param endValue End value of the animation curve
  27819. * @param inTangent Start tangent of the animation curve
  27820. * @param gradient Scalar amount to interpolate
  27821. * @returns Interpolated scalar value
  27822. */
  27823. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27824. /**
  27825. * Interpolates a quaternion using a spherical linear interpolation
  27826. * @param startValue Start value of the animation curve
  27827. * @param endValue End value of the animation curve
  27828. * @param gradient Scalar amount to interpolate
  27829. * @returns Interpolated quaternion value
  27830. */
  27831. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27832. /**
  27833. * Interpolates a quaternion cubically
  27834. * @param startValue Start value of the animation curve
  27835. * @param outTangent End tangent of the animation curve
  27836. * @param endValue End value of the animation curve
  27837. * @param inTangent Start tangent of the animation curve
  27838. * @param gradient Scalar amount to interpolate
  27839. * @returns Interpolated quaternion value
  27840. */
  27841. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27842. /**
  27843. * Interpolates a Vector3 linearl
  27844. * @param startValue Start value of the animation curve
  27845. * @param endValue End value of the animation curve
  27846. * @param gradient Scalar amount to interpolate
  27847. * @returns Interpolated scalar value
  27848. */
  27849. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27850. /**
  27851. * Interpolates a Vector3 cubically
  27852. * @param startValue Start value of the animation curve
  27853. * @param outTangent End tangent of the animation
  27854. * @param endValue End value of the animation curve
  27855. * @param inTangent Start tangent of the animation curve
  27856. * @param gradient Scalar amount to interpolate
  27857. * @returns InterpolatedVector3 value
  27858. */
  27859. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27860. /**
  27861. * Interpolates a Vector2 linearly
  27862. * @param startValue Start value of the animation curve
  27863. * @param endValue End value of the animation curve
  27864. * @param gradient Scalar amount to interpolate
  27865. * @returns Interpolated Vector2 value
  27866. */
  27867. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27868. /**
  27869. * Interpolates a Vector2 cubically
  27870. * @param startValue Start value of the animation curve
  27871. * @param outTangent End tangent of the animation
  27872. * @param endValue End value of the animation curve
  27873. * @param inTangent Start tangent of the animation curve
  27874. * @param gradient Scalar amount to interpolate
  27875. * @returns Interpolated Vector2 value
  27876. */
  27877. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27878. /**
  27879. * Interpolates a size linearly
  27880. * @param startValue Start value of the animation curve
  27881. * @param endValue End value of the animation curve
  27882. * @param gradient Scalar amount to interpolate
  27883. * @returns Interpolated Size value
  27884. */
  27885. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27886. /**
  27887. * Interpolates a Color3 linearly
  27888. * @param startValue Start value of the animation curve
  27889. * @param endValue End value of the animation curve
  27890. * @param gradient Scalar amount to interpolate
  27891. * @returns Interpolated Color3 value
  27892. */
  27893. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27894. /**
  27895. * @hidden Internal use only
  27896. */
  27897. _getKeyValue(value: any): any;
  27898. /**
  27899. * @hidden Internal use only
  27900. */
  27901. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27902. /**
  27903. * Defines the function to use to interpolate matrices
  27904. * @param startValue defines the start matrix
  27905. * @param endValue defines the end matrix
  27906. * @param gradient defines the gradient between both matrices
  27907. * @param result defines an optional target matrix where to store the interpolation
  27908. * @returns the interpolated matrix
  27909. */
  27910. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27911. /**
  27912. * Makes a copy of the animation
  27913. * @returns Cloned animation
  27914. */
  27915. clone(): Animation;
  27916. /**
  27917. * Sets the key frames of the animation
  27918. * @param values The animation key frames to set
  27919. */
  27920. setKeys(values: Array<IAnimationKey>): void;
  27921. /**
  27922. * Serializes the animation to an object
  27923. * @returns Serialized object
  27924. */
  27925. serialize(): any;
  27926. /**
  27927. * Float animation type
  27928. */
  27929. private static _ANIMATIONTYPE_FLOAT;
  27930. /**
  27931. * Vector3 animation type
  27932. */
  27933. private static _ANIMATIONTYPE_VECTOR3;
  27934. /**
  27935. * Quaternion animation type
  27936. */
  27937. private static _ANIMATIONTYPE_QUATERNION;
  27938. /**
  27939. * Matrix animation type
  27940. */
  27941. private static _ANIMATIONTYPE_MATRIX;
  27942. /**
  27943. * Color3 animation type
  27944. */
  27945. private static _ANIMATIONTYPE_COLOR3;
  27946. /**
  27947. * Vector2 animation type
  27948. */
  27949. private static _ANIMATIONTYPE_VECTOR2;
  27950. /**
  27951. * Size animation type
  27952. */
  27953. private static _ANIMATIONTYPE_SIZE;
  27954. /**
  27955. * Relative Loop Mode
  27956. */
  27957. private static _ANIMATIONLOOPMODE_RELATIVE;
  27958. /**
  27959. * Cycle Loop Mode
  27960. */
  27961. private static _ANIMATIONLOOPMODE_CYCLE;
  27962. /**
  27963. * Constant Loop Mode
  27964. */
  27965. private static _ANIMATIONLOOPMODE_CONSTANT;
  27966. /**
  27967. * Get the float animation type
  27968. */
  27969. static readonly ANIMATIONTYPE_FLOAT: number;
  27970. /**
  27971. * Get the Vector3 animation type
  27972. */
  27973. static readonly ANIMATIONTYPE_VECTOR3: number;
  27974. /**
  27975. * Get the Vector2 animation type
  27976. */
  27977. static readonly ANIMATIONTYPE_VECTOR2: number;
  27978. /**
  27979. * Get the Size animation type
  27980. */
  27981. static readonly ANIMATIONTYPE_SIZE: number;
  27982. /**
  27983. * Get the Quaternion animation type
  27984. */
  27985. static readonly ANIMATIONTYPE_QUATERNION: number;
  27986. /**
  27987. * Get the Matrix animation type
  27988. */
  27989. static readonly ANIMATIONTYPE_MATRIX: number;
  27990. /**
  27991. * Get the Color3 animation type
  27992. */
  27993. static readonly ANIMATIONTYPE_COLOR3: number;
  27994. /**
  27995. * Get the Relative Loop Mode
  27996. */
  27997. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27998. /**
  27999. * Get the Cycle Loop Mode
  28000. */
  28001. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28002. /**
  28003. * Get the Constant Loop Mode
  28004. */
  28005. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28006. /** @hidden */
  28007. static _UniversalLerp(left: any, right: any, amount: number): any;
  28008. /**
  28009. * Parses an animation object and creates an animation
  28010. * @param parsedAnimation Parsed animation object
  28011. * @returns Animation object
  28012. */
  28013. static Parse(parsedAnimation: any): Animation;
  28014. /**
  28015. * Appends the serialized animations from the source animations
  28016. * @param source Source containing the animations
  28017. * @param destination Target to store the animations
  28018. */
  28019. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28020. }
  28021. }
  28022. declare module "babylonjs/Animations/animatable.interface" {
  28023. import { Nullable } from "babylonjs/types";
  28024. import { Animation } from "babylonjs/Animations/animation";
  28025. /**
  28026. * Interface containing an array of animations
  28027. */
  28028. export interface IAnimatable {
  28029. /**
  28030. * Array of animations
  28031. */
  28032. animations: Nullable<Array<Animation>>;
  28033. }
  28034. }
  28035. declare module "babylonjs/Materials/fresnelParameters" {
  28036. import { Color3 } from "babylonjs/Maths/math.color";
  28037. /**
  28038. * This represents all the required information to add a fresnel effect on a material:
  28039. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28040. */
  28041. export class FresnelParameters {
  28042. private _isEnabled;
  28043. /**
  28044. * Define if the fresnel effect is enable or not.
  28045. */
  28046. isEnabled: boolean;
  28047. /**
  28048. * Define the color used on edges (grazing angle)
  28049. */
  28050. leftColor: Color3;
  28051. /**
  28052. * Define the color used on center
  28053. */
  28054. rightColor: Color3;
  28055. /**
  28056. * Define bias applied to computed fresnel term
  28057. */
  28058. bias: number;
  28059. /**
  28060. * Defined the power exponent applied to fresnel term
  28061. */
  28062. power: number;
  28063. /**
  28064. * Clones the current fresnel and its valuues
  28065. * @returns a clone fresnel configuration
  28066. */
  28067. clone(): FresnelParameters;
  28068. /**
  28069. * Serializes the current fresnel parameters to a JSON representation.
  28070. * @return the JSON serialization
  28071. */
  28072. serialize(): any;
  28073. /**
  28074. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28075. * @param parsedFresnelParameters Define the JSON representation
  28076. * @returns the parsed parameters
  28077. */
  28078. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28079. }
  28080. }
  28081. declare module "babylonjs/Misc/decorators" {
  28082. import { Nullable } from "babylonjs/types";
  28083. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28084. import { Scene } from "babylonjs/scene";
  28085. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28086. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28087. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28088. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28089. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28090. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28091. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28092. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28093. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28094. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28095. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28096. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28097. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28098. /**
  28099. * Decorator used to define property that can be serialized as reference to a camera
  28100. * @param sourceName defines the name of the property to decorate
  28101. */
  28102. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28103. /**
  28104. * Class used to help serialization objects
  28105. */
  28106. export class SerializationHelper {
  28107. /** @hidden */
  28108. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28109. /** @hidden */
  28110. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28111. /** @hidden */
  28112. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28113. /** @hidden */
  28114. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28115. /**
  28116. * Appends the serialized animations from the source animations
  28117. * @param source Source containing the animations
  28118. * @param destination Target to store the animations
  28119. */
  28120. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28121. /**
  28122. * Static function used to serialized a specific entity
  28123. * @param entity defines the entity to serialize
  28124. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28125. * @returns a JSON compatible object representing the serialization of the entity
  28126. */
  28127. static Serialize<T>(entity: T, serializationObject?: any): any;
  28128. /**
  28129. * Creates a new entity from a serialization data object
  28130. * @param creationFunction defines a function used to instanciated the new entity
  28131. * @param source defines the source serialization data
  28132. * @param scene defines the hosting scene
  28133. * @param rootUrl defines the root url for resources
  28134. * @returns a new entity
  28135. */
  28136. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28137. /**
  28138. * Clones an object
  28139. * @param creationFunction defines the function used to instanciate the new object
  28140. * @param source defines the source object
  28141. * @returns the cloned object
  28142. */
  28143. static Clone<T>(creationFunction: () => T, source: T): T;
  28144. /**
  28145. * Instanciates a new object based on a source one (some data will be shared between both object)
  28146. * @param creationFunction defines the function used to instanciate the new object
  28147. * @param source defines the source object
  28148. * @returns the new object
  28149. */
  28150. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28151. }
  28152. }
  28153. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28154. import { Nullable } from "babylonjs/types";
  28155. /**
  28156. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28157. */
  28158. export interface CubeMapInfo {
  28159. /**
  28160. * The pixel array for the front face.
  28161. * This is stored in format, left to right, up to down format.
  28162. */
  28163. front: Nullable<ArrayBufferView>;
  28164. /**
  28165. * The pixel array for the back face.
  28166. * This is stored in format, left to right, up to down format.
  28167. */
  28168. back: Nullable<ArrayBufferView>;
  28169. /**
  28170. * The pixel array for the left face.
  28171. * This is stored in format, left to right, up to down format.
  28172. */
  28173. left: Nullable<ArrayBufferView>;
  28174. /**
  28175. * The pixel array for the right face.
  28176. * This is stored in format, left to right, up to down format.
  28177. */
  28178. right: Nullable<ArrayBufferView>;
  28179. /**
  28180. * The pixel array for the up face.
  28181. * This is stored in format, left to right, up to down format.
  28182. */
  28183. up: Nullable<ArrayBufferView>;
  28184. /**
  28185. * The pixel array for the down face.
  28186. * This is stored in format, left to right, up to down format.
  28187. */
  28188. down: Nullable<ArrayBufferView>;
  28189. /**
  28190. * The size of the cubemap stored.
  28191. *
  28192. * Each faces will be size * size pixels.
  28193. */
  28194. size: number;
  28195. /**
  28196. * The format of the texture.
  28197. *
  28198. * RGBA, RGB.
  28199. */
  28200. format: number;
  28201. /**
  28202. * The type of the texture data.
  28203. *
  28204. * UNSIGNED_INT, FLOAT.
  28205. */
  28206. type: number;
  28207. /**
  28208. * Specifies whether the texture is in gamma space.
  28209. */
  28210. gammaSpace: boolean;
  28211. }
  28212. /**
  28213. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28214. */
  28215. export class PanoramaToCubeMapTools {
  28216. private static FACE_FRONT;
  28217. private static FACE_BACK;
  28218. private static FACE_RIGHT;
  28219. private static FACE_LEFT;
  28220. private static FACE_DOWN;
  28221. private static FACE_UP;
  28222. /**
  28223. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28224. *
  28225. * @param float32Array The source data.
  28226. * @param inputWidth The width of the input panorama.
  28227. * @param inputHeight The height of the input panorama.
  28228. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28229. * @return The cubemap data
  28230. */
  28231. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28232. private static CreateCubemapTexture;
  28233. private static CalcProjectionSpherical;
  28234. }
  28235. }
  28236. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28237. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28238. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28239. import { Nullable } from "babylonjs/types";
  28240. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28241. /**
  28242. * Helper class dealing with the extraction of spherical polynomial dataArray
  28243. * from a cube map.
  28244. */
  28245. export class CubeMapToSphericalPolynomialTools {
  28246. private static FileFaces;
  28247. /**
  28248. * Converts a texture to the according Spherical Polynomial data.
  28249. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28250. *
  28251. * @param texture The texture to extract the information from.
  28252. * @return The Spherical Polynomial data.
  28253. */
  28254. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28255. /**
  28256. * Converts a cubemap to the according Spherical Polynomial data.
  28257. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28258. *
  28259. * @param cubeInfo The Cube map to extract the information from.
  28260. * @return The Spherical Polynomial data.
  28261. */
  28262. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28263. }
  28264. }
  28265. declare module "babylonjs/Misc/guid" {
  28266. /**
  28267. * Class used to manipulate GUIDs
  28268. */
  28269. export class GUID {
  28270. /**
  28271. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28272. * Be aware Math.random() could cause collisions, but:
  28273. * "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"
  28274. * @returns a pseudo random id
  28275. */
  28276. static RandomId(): string;
  28277. }
  28278. }
  28279. declare module "babylonjs/Materials/Textures/baseTexture" {
  28280. import { Observable } from "babylonjs/Misc/observable";
  28281. import { Nullable } from "babylonjs/types";
  28282. import { Scene } from "babylonjs/scene";
  28283. import { Matrix } from "babylonjs/Maths/math.vector";
  28284. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28285. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28286. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28287. import { ISize } from "babylonjs/Maths/math.size";
  28288. /**
  28289. * Base class of all the textures in babylon.
  28290. * It groups all the common properties the materials, post process, lights... might need
  28291. * in order to make a correct use of the texture.
  28292. */
  28293. export class BaseTexture implements IAnimatable {
  28294. /**
  28295. * Default anisotropic filtering level for the application.
  28296. * It is set to 4 as a good tradeoff between perf and quality.
  28297. */
  28298. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28299. /**
  28300. * Gets or sets the unique id of the texture
  28301. */
  28302. uniqueId: number;
  28303. /**
  28304. * Define the name of the texture.
  28305. */
  28306. name: string;
  28307. /**
  28308. * Gets or sets an object used to store user defined information.
  28309. */
  28310. metadata: any;
  28311. /**
  28312. * For internal use only. Please do not use.
  28313. */
  28314. reservedDataStore: any;
  28315. private _hasAlpha;
  28316. /**
  28317. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28318. */
  28319. hasAlpha: boolean;
  28320. /**
  28321. * Defines if the alpha value should be determined via the rgb values.
  28322. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28323. */
  28324. getAlphaFromRGB: boolean;
  28325. /**
  28326. * Intensity or strength of the texture.
  28327. * It is commonly used by materials to fine tune the intensity of the texture
  28328. */
  28329. level: number;
  28330. /**
  28331. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28332. * This is part of the texture as textures usually maps to one uv set.
  28333. */
  28334. coordinatesIndex: number;
  28335. private _coordinatesMode;
  28336. /**
  28337. * How a texture is mapped.
  28338. *
  28339. * | Value | Type | Description |
  28340. * | ----- | ----------------------------------- | ----------- |
  28341. * | 0 | EXPLICIT_MODE | |
  28342. * | 1 | SPHERICAL_MODE | |
  28343. * | 2 | PLANAR_MODE | |
  28344. * | 3 | CUBIC_MODE | |
  28345. * | 4 | PROJECTION_MODE | |
  28346. * | 5 | SKYBOX_MODE | |
  28347. * | 6 | INVCUBIC_MODE | |
  28348. * | 7 | EQUIRECTANGULAR_MODE | |
  28349. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28350. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28351. */
  28352. coordinatesMode: number;
  28353. /**
  28354. * | Value | Type | Description |
  28355. * | ----- | ------------------ | ----------- |
  28356. * | 0 | CLAMP_ADDRESSMODE | |
  28357. * | 1 | WRAP_ADDRESSMODE | |
  28358. * | 2 | MIRROR_ADDRESSMODE | |
  28359. */
  28360. wrapU: number;
  28361. /**
  28362. * | Value | Type | Description |
  28363. * | ----- | ------------------ | ----------- |
  28364. * | 0 | CLAMP_ADDRESSMODE | |
  28365. * | 1 | WRAP_ADDRESSMODE | |
  28366. * | 2 | MIRROR_ADDRESSMODE | |
  28367. */
  28368. wrapV: number;
  28369. /**
  28370. * | Value | Type | Description |
  28371. * | ----- | ------------------ | ----------- |
  28372. * | 0 | CLAMP_ADDRESSMODE | |
  28373. * | 1 | WRAP_ADDRESSMODE | |
  28374. * | 2 | MIRROR_ADDRESSMODE | |
  28375. */
  28376. wrapR: number;
  28377. /**
  28378. * With compliant hardware and browser (supporting anisotropic filtering)
  28379. * this defines the level of anisotropic filtering in the texture.
  28380. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28381. */
  28382. anisotropicFilteringLevel: number;
  28383. /**
  28384. * Define if the texture is a cube texture or if false a 2d texture.
  28385. */
  28386. isCube: boolean;
  28387. /**
  28388. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28389. */
  28390. is3D: boolean;
  28391. /**
  28392. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28393. * HDR texture are usually stored in linear space.
  28394. * This only impacts the PBR and Background materials
  28395. */
  28396. gammaSpace: boolean;
  28397. /**
  28398. * Gets whether or not the texture contains RGBD data.
  28399. */
  28400. readonly isRGBD: boolean;
  28401. /**
  28402. * Is Z inverted in the texture (useful in a cube texture).
  28403. */
  28404. invertZ: boolean;
  28405. /**
  28406. * Are mip maps generated for this texture or not.
  28407. */
  28408. readonly noMipmap: boolean;
  28409. /**
  28410. * @hidden
  28411. */
  28412. lodLevelInAlpha: boolean;
  28413. /**
  28414. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28415. */
  28416. lodGenerationOffset: number;
  28417. /**
  28418. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28419. */
  28420. lodGenerationScale: number;
  28421. /**
  28422. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28423. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28424. * average roughness values.
  28425. */
  28426. linearSpecularLOD: boolean;
  28427. /**
  28428. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28429. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28430. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28431. */
  28432. irradianceTexture: Nullable<BaseTexture>;
  28433. /**
  28434. * Define if the texture is a render target.
  28435. */
  28436. isRenderTarget: boolean;
  28437. /**
  28438. * Define the unique id of the texture in the scene.
  28439. */
  28440. readonly uid: string;
  28441. /**
  28442. * Return a string representation of the texture.
  28443. * @returns the texture as a string
  28444. */
  28445. toString(): string;
  28446. /**
  28447. * Get the class name of the texture.
  28448. * @returns "BaseTexture"
  28449. */
  28450. getClassName(): string;
  28451. /**
  28452. * Define the list of animation attached to the texture.
  28453. */
  28454. animations: import("babylonjs/Animations/animation").Animation[];
  28455. /**
  28456. * An event triggered when the texture is disposed.
  28457. */
  28458. onDisposeObservable: Observable<BaseTexture>;
  28459. private _onDisposeObserver;
  28460. /**
  28461. * Callback triggered when the texture has been disposed.
  28462. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28463. */
  28464. onDispose: () => void;
  28465. /**
  28466. * Define the current state of the loading sequence when in delayed load mode.
  28467. */
  28468. delayLoadState: number;
  28469. private _scene;
  28470. /** @hidden */
  28471. _texture: Nullable<InternalTexture>;
  28472. private _uid;
  28473. /**
  28474. * Define if the texture is preventinga material to render or not.
  28475. * If not and the texture is not ready, the engine will use a default black texture instead.
  28476. */
  28477. readonly isBlocking: boolean;
  28478. /**
  28479. * Instantiates a new BaseTexture.
  28480. * Base class of all the textures in babylon.
  28481. * It groups all the common properties the materials, post process, lights... might need
  28482. * in order to make a correct use of the texture.
  28483. * @param scene Define the scene the texture blongs to
  28484. */
  28485. constructor(scene: Nullable<Scene>);
  28486. /**
  28487. * Get the scene the texture belongs to.
  28488. * @returns the scene or null if undefined
  28489. */
  28490. getScene(): Nullable<Scene>;
  28491. /**
  28492. * Get the texture transform matrix used to offset tile the texture for istance.
  28493. * @returns the transformation matrix
  28494. */
  28495. getTextureMatrix(): Matrix;
  28496. /**
  28497. * Get the texture reflection matrix used to rotate/transform the reflection.
  28498. * @returns the reflection matrix
  28499. */
  28500. getReflectionTextureMatrix(): Matrix;
  28501. /**
  28502. * Get the underlying lower level texture from Babylon.
  28503. * @returns the insternal texture
  28504. */
  28505. getInternalTexture(): Nullable<InternalTexture>;
  28506. /**
  28507. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28508. * @returns true if ready or not blocking
  28509. */
  28510. isReadyOrNotBlocking(): boolean;
  28511. /**
  28512. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28513. * @returns true if fully ready
  28514. */
  28515. isReady(): boolean;
  28516. private _cachedSize;
  28517. /**
  28518. * Get the size of the texture.
  28519. * @returns the texture size.
  28520. */
  28521. getSize(): ISize;
  28522. /**
  28523. * Get the base size of the texture.
  28524. * It can be different from the size if the texture has been resized for POT for instance
  28525. * @returns the base size
  28526. */
  28527. getBaseSize(): ISize;
  28528. /**
  28529. * Update the sampling mode of the texture.
  28530. * Default is Trilinear mode.
  28531. *
  28532. * | Value | Type | Description |
  28533. * | ----- | ------------------ | ----------- |
  28534. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28535. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28536. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28537. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28538. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28539. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28540. * | 7 | NEAREST_LINEAR | |
  28541. * | 8 | NEAREST_NEAREST | |
  28542. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28543. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28544. * | 11 | LINEAR_LINEAR | |
  28545. * | 12 | LINEAR_NEAREST | |
  28546. *
  28547. * > _mag_: magnification filter (close to the viewer)
  28548. * > _min_: minification filter (far from the viewer)
  28549. * > _mip_: filter used between mip map levels
  28550. *@param samplingMode Define the new sampling mode of the texture
  28551. */
  28552. updateSamplingMode(samplingMode: number): void;
  28553. /**
  28554. * Scales the texture if is `canRescale()`
  28555. * @param ratio the resize factor we want to use to rescale
  28556. */
  28557. scale(ratio: number): void;
  28558. /**
  28559. * Get if the texture can rescale.
  28560. */
  28561. readonly canRescale: boolean;
  28562. /** @hidden */
  28563. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28564. /** @hidden */
  28565. _rebuild(): void;
  28566. /**
  28567. * Triggers the load sequence in delayed load mode.
  28568. */
  28569. delayLoad(): void;
  28570. /**
  28571. * Clones the texture.
  28572. * @returns the cloned texture
  28573. */
  28574. clone(): Nullable<BaseTexture>;
  28575. /**
  28576. * Get the texture underlying type (INT, FLOAT...)
  28577. */
  28578. readonly textureType: number;
  28579. /**
  28580. * Get the texture underlying format (RGB, RGBA...)
  28581. */
  28582. readonly textureFormat: number;
  28583. /**
  28584. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28585. * This will returns an RGBA array buffer containing either in values (0-255) or
  28586. * float values (0-1) depending of the underlying buffer type.
  28587. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28588. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28589. * @param buffer defines a user defined buffer to fill with data (can be null)
  28590. * @returns The Array buffer containing the pixels data.
  28591. */
  28592. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28593. /**
  28594. * Release and destroy the underlying lower level texture aka internalTexture.
  28595. */
  28596. releaseInternalTexture(): void;
  28597. /**
  28598. * Get the polynomial representation of the texture data.
  28599. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28600. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28601. */
  28602. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28603. /** @hidden */
  28604. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28605. /** @hidden */
  28606. readonly _lodTextureMid: Nullable<BaseTexture>;
  28607. /** @hidden */
  28608. readonly _lodTextureLow: Nullable<BaseTexture>;
  28609. /**
  28610. * Dispose the texture and release its associated resources.
  28611. */
  28612. dispose(): void;
  28613. /**
  28614. * Serialize the texture into a JSON representation that can be parsed later on.
  28615. * @returns the JSON representation of the texture
  28616. */
  28617. serialize(): any;
  28618. /**
  28619. * Helper function to be called back once a list of texture contains only ready textures.
  28620. * @param textures Define the list of textures to wait for
  28621. * @param callback Define the callback triggered once the entire list will be ready
  28622. */
  28623. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28624. }
  28625. }
  28626. declare module "babylonjs/Materials/Textures/internalTexture" {
  28627. import { Observable } from "babylonjs/Misc/observable";
  28628. import { Nullable, int } from "babylonjs/types";
  28629. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28630. import { Engine } from "babylonjs/Engines/engine";
  28631. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28632. /**
  28633. * Class used to store data associated with WebGL texture data for the engine
  28634. * This class should not be used directly
  28635. */
  28636. export class InternalTexture {
  28637. /** @hidden */
  28638. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28639. /**
  28640. * The source of the texture data is unknown
  28641. */
  28642. static DATASOURCE_UNKNOWN: number;
  28643. /**
  28644. * Texture data comes from an URL
  28645. */
  28646. static DATASOURCE_URL: number;
  28647. /**
  28648. * Texture data is only used for temporary storage
  28649. */
  28650. static DATASOURCE_TEMP: number;
  28651. /**
  28652. * Texture data comes from raw data (ArrayBuffer)
  28653. */
  28654. static DATASOURCE_RAW: number;
  28655. /**
  28656. * Texture content is dynamic (video or dynamic texture)
  28657. */
  28658. static DATASOURCE_DYNAMIC: number;
  28659. /**
  28660. * Texture content is generated by rendering to it
  28661. */
  28662. static DATASOURCE_RENDERTARGET: number;
  28663. /**
  28664. * Texture content is part of a multi render target process
  28665. */
  28666. static DATASOURCE_MULTIRENDERTARGET: number;
  28667. /**
  28668. * Texture data comes from a cube data file
  28669. */
  28670. static DATASOURCE_CUBE: number;
  28671. /**
  28672. * Texture data comes from a raw cube data
  28673. */
  28674. static DATASOURCE_CUBERAW: number;
  28675. /**
  28676. * Texture data come from a prefiltered cube data file
  28677. */
  28678. static DATASOURCE_CUBEPREFILTERED: number;
  28679. /**
  28680. * Texture content is raw 3D data
  28681. */
  28682. static DATASOURCE_RAW3D: number;
  28683. /**
  28684. * Texture content is a depth texture
  28685. */
  28686. static DATASOURCE_DEPTHTEXTURE: number;
  28687. /**
  28688. * Texture data comes from a raw cube data encoded with RGBD
  28689. */
  28690. static DATASOURCE_CUBERAW_RGBD: number;
  28691. /**
  28692. * Defines if the texture is ready
  28693. */
  28694. isReady: boolean;
  28695. /**
  28696. * Defines if the texture is a cube texture
  28697. */
  28698. isCube: boolean;
  28699. /**
  28700. * Defines if the texture contains 3D data
  28701. */
  28702. is3D: boolean;
  28703. /**
  28704. * Defines if the texture contains multiview data
  28705. */
  28706. isMultiview: boolean;
  28707. /**
  28708. * Gets the URL used to load this texture
  28709. */
  28710. url: string;
  28711. /**
  28712. * Gets the sampling mode of the texture
  28713. */
  28714. samplingMode: number;
  28715. /**
  28716. * Gets a boolean indicating if the texture needs mipmaps generation
  28717. */
  28718. generateMipMaps: boolean;
  28719. /**
  28720. * Gets the number of samples used by the texture (WebGL2+ only)
  28721. */
  28722. samples: number;
  28723. /**
  28724. * Gets the type of the texture (int, float...)
  28725. */
  28726. type: number;
  28727. /**
  28728. * Gets the format of the texture (RGB, RGBA...)
  28729. */
  28730. format: number;
  28731. /**
  28732. * Observable called when the texture is loaded
  28733. */
  28734. onLoadedObservable: Observable<InternalTexture>;
  28735. /**
  28736. * Gets the width of the texture
  28737. */
  28738. width: number;
  28739. /**
  28740. * Gets the height of the texture
  28741. */
  28742. height: number;
  28743. /**
  28744. * Gets the depth of the texture
  28745. */
  28746. depth: number;
  28747. /**
  28748. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28749. */
  28750. baseWidth: number;
  28751. /**
  28752. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28753. */
  28754. baseHeight: number;
  28755. /**
  28756. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28757. */
  28758. baseDepth: number;
  28759. /**
  28760. * Gets a boolean indicating if the texture is inverted on Y axis
  28761. */
  28762. invertY: boolean;
  28763. /** @hidden */
  28764. _invertVScale: boolean;
  28765. /** @hidden */
  28766. _associatedChannel: number;
  28767. /** @hidden */
  28768. _dataSource: number;
  28769. /** @hidden */
  28770. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  28771. /** @hidden */
  28772. _bufferView: Nullable<ArrayBufferView>;
  28773. /** @hidden */
  28774. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28775. /** @hidden */
  28776. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28777. /** @hidden */
  28778. _size: number;
  28779. /** @hidden */
  28780. _extension: string;
  28781. /** @hidden */
  28782. _files: Nullable<string[]>;
  28783. /** @hidden */
  28784. _workingCanvas: Nullable<HTMLCanvasElement>;
  28785. /** @hidden */
  28786. _workingContext: Nullable<CanvasRenderingContext2D>;
  28787. /** @hidden */
  28788. _framebuffer: Nullable<WebGLFramebuffer>;
  28789. /** @hidden */
  28790. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28791. /** @hidden */
  28792. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28793. /** @hidden */
  28794. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28795. /** @hidden */
  28796. _attachments: Nullable<number[]>;
  28797. /** @hidden */
  28798. _cachedCoordinatesMode: Nullable<number>;
  28799. /** @hidden */
  28800. _cachedWrapU: Nullable<number>;
  28801. /** @hidden */
  28802. _cachedWrapV: Nullable<number>;
  28803. /** @hidden */
  28804. _cachedWrapR: Nullable<number>;
  28805. /** @hidden */
  28806. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28807. /** @hidden */
  28808. _isDisabled: boolean;
  28809. /** @hidden */
  28810. _compression: Nullable<string>;
  28811. /** @hidden */
  28812. _generateStencilBuffer: boolean;
  28813. /** @hidden */
  28814. _generateDepthBuffer: boolean;
  28815. /** @hidden */
  28816. _comparisonFunction: number;
  28817. /** @hidden */
  28818. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28819. /** @hidden */
  28820. _lodGenerationScale: number;
  28821. /** @hidden */
  28822. _lodGenerationOffset: number;
  28823. /** @hidden */
  28824. _colorTextureArray: Nullable<WebGLTexture>;
  28825. /** @hidden */
  28826. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28827. /** @hidden */
  28828. _lodTextureHigh: Nullable<BaseTexture>;
  28829. /** @hidden */
  28830. _lodTextureMid: Nullable<BaseTexture>;
  28831. /** @hidden */
  28832. _lodTextureLow: Nullable<BaseTexture>;
  28833. /** @hidden */
  28834. _isRGBD: boolean;
  28835. /** @hidden */
  28836. _linearSpecularLOD: boolean;
  28837. /** @hidden */
  28838. _irradianceTexture: Nullable<BaseTexture>;
  28839. /** @hidden */
  28840. _webGLTexture: Nullable<WebGLTexture>;
  28841. /** @hidden */
  28842. _references: number;
  28843. private _engine;
  28844. /**
  28845. * Gets the Engine the texture belongs to.
  28846. * @returns The babylon engine
  28847. */
  28848. getEngine(): Engine;
  28849. /**
  28850. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28851. */
  28852. readonly dataSource: number;
  28853. /**
  28854. * Creates a new InternalTexture
  28855. * @param engine defines the engine to use
  28856. * @param dataSource defines the type of data that will be used
  28857. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28858. */
  28859. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28860. /**
  28861. * Increments the number of references (ie. the number of Texture that point to it)
  28862. */
  28863. incrementReferences(): void;
  28864. /**
  28865. * Change the size of the texture (not the size of the content)
  28866. * @param width defines the new width
  28867. * @param height defines the new height
  28868. * @param depth defines the new depth (1 by default)
  28869. */
  28870. updateSize(width: int, height: int, depth?: int): void;
  28871. /** @hidden */
  28872. _rebuild(): void;
  28873. /** @hidden */
  28874. _swapAndDie(target: InternalTexture): void;
  28875. /**
  28876. * Dispose the current allocated resources
  28877. */
  28878. dispose(): void;
  28879. }
  28880. }
  28881. declare module "babylonjs/Materials/effect" {
  28882. import { Observable } from "babylonjs/Misc/observable";
  28883. import { Nullable } from "babylonjs/types";
  28884. import { IDisposable } from "babylonjs/scene";
  28885. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28886. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28887. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28888. import { Engine } from "babylonjs/Engines/engine";
  28889. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28890. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28891. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28892. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28893. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28894. /**
  28895. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28896. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28897. */
  28898. export class EffectFallbacks {
  28899. private _defines;
  28900. private _currentRank;
  28901. private _maxRank;
  28902. private _mesh;
  28903. /**
  28904. * Removes the fallback from the bound mesh.
  28905. */
  28906. unBindMesh(): void;
  28907. /**
  28908. * Adds a fallback on the specified property.
  28909. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28910. * @param define The name of the define in the shader
  28911. */
  28912. addFallback(rank: number, define: string): void;
  28913. /**
  28914. * Sets the mesh to use CPU skinning when needing to fallback.
  28915. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28916. * @param mesh The mesh to use the fallbacks.
  28917. */
  28918. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28919. /**
  28920. * Checks to see if more fallbacks are still availible.
  28921. */
  28922. readonly isMoreFallbacks: boolean;
  28923. /**
  28924. * Removes the defines that should be removed when falling back.
  28925. * @param currentDefines defines the current define statements for the shader.
  28926. * @param effect defines the current effect we try to compile
  28927. * @returns The resulting defines with defines of the current rank removed.
  28928. */
  28929. reduce(currentDefines: string, effect: Effect): string;
  28930. }
  28931. /**
  28932. * Options to be used when creating an effect.
  28933. */
  28934. export class EffectCreationOptions {
  28935. /**
  28936. * Atrributes that will be used in the shader.
  28937. */
  28938. attributes: string[];
  28939. /**
  28940. * Uniform varible names that will be set in the shader.
  28941. */
  28942. uniformsNames: string[];
  28943. /**
  28944. * Uniform buffer varible names that will be set in the shader.
  28945. */
  28946. uniformBuffersNames: string[];
  28947. /**
  28948. * Sampler texture variable names that will be set in the shader.
  28949. */
  28950. samplers: string[];
  28951. /**
  28952. * Define statements that will be set in the shader.
  28953. */
  28954. defines: any;
  28955. /**
  28956. * Possible fallbacks for this effect to improve performance when needed.
  28957. */
  28958. fallbacks: Nullable<EffectFallbacks>;
  28959. /**
  28960. * Callback that will be called when the shader is compiled.
  28961. */
  28962. onCompiled: Nullable<(effect: Effect) => void>;
  28963. /**
  28964. * Callback that will be called if an error occurs during shader compilation.
  28965. */
  28966. onError: Nullable<(effect: Effect, errors: string) => void>;
  28967. /**
  28968. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28969. */
  28970. indexParameters: any;
  28971. /**
  28972. * Max number of lights that can be used in the shader.
  28973. */
  28974. maxSimultaneousLights: number;
  28975. /**
  28976. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28977. */
  28978. transformFeedbackVaryings: Nullable<string[]>;
  28979. }
  28980. /**
  28981. * Effect containing vertex and fragment shader that can be executed on an object.
  28982. */
  28983. export class Effect implements IDisposable {
  28984. /**
  28985. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28986. */
  28987. static ShadersRepository: string;
  28988. /**
  28989. * Name of the effect.
  28990. */
  28991. name: any;
  28992. /**
  28993. * String container all the define statements that should be set on the shader.
  28994. */
  28995. defines: string;
  28996. /**
  28997. * Callback that will be called when the shader is compiled.
  28998. */
  28999. onCompiled: Nullable<(effect: Effect) => void>;
  29000. /**
  29001. * Callback that will be called if an error occurs during shader compilation.
  29002. */
  29003. onError: Nullable<(effect: Effect, errors: string) => void>;
  29004. /**
  29005. * Callback that will be called when effect is bound.
  29006. */
  29007. onBind: Nullable<(effect: Effect) => void>;
  29008. /**
  29009. * Unique ID of the effect.
  29010. */
  29011. uniqueId: number;
  29012. /**
  29013. * Observable that will be called when the shader is compiled.
  29014. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29015. */
  29016. onCompileObservable: Observable<Effect>;
  29017. /**
  29018. * Observable that will be called if an error occurs during shader compilation.
  29019. */
  29020. onErrorObservable: Observable<Effect>;
  29021. /** @hidden */
  29022. _onBindObservable: Nullable<Observable<Effect>>;
  29023. /**
  29024. * Observable that will be called when effect is bound.
  29025. */
  29026. readonly onBindObservable: Observable<Effect>;
  29027. /** @hidden */
  29028. _bonesComputationForcedToCPU: boolean;
  29029. private static _uniqueIdSeed;
  29030. private _engine;
  29031. private _uniformBuffersNames;
  29032. private _uniformsNames;
  29033. private _samplerList;
  29034. private _samplers;
  29035. private _isReady;
  29036. private _compilationError;
  29037. private _attributesNames;
  29038. private _attributes;
  29039. private _uniforms;
  29040. /**
  29041. * Key for the effect.
  29042. * @hidden
  29043. */
  29044. _key: string;
  29045. private _indexParameters;
  29046. private _fallbacks;
  29047. private _vertexSourceCode;
  29048. private _fragmentSourceCode;
  29049. private _vertexSourceCodeOverride;
  29050. private _fragmentSourceCodeOverride;
  29051. private _transformFeedbackVaryings;
  29052. /**
  29053. * Compiled shader to webGL program.
  29054. * @hidden
  29055. */
  29056. _pipelineContext: Nullable<IPipelineContext>;
  29057. private _valueCache;
  29058. private static _baseCache;
  29059. /**
  29060. * Instantiates an effect.
  29061. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29062. * @param baseName Name of the effect.
  29063. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29064. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29065. * @param samplers List of sampler variables that will be passed to the shader.
  29066. * @param engine Engine to be used to render the effect
  29067. * @param defines Define statements to be added to the shader.
  29068. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29069. * @param onCompiled Callback that will be called when the shader is compiled.
  29070. * @param onError Callback that will be called if an error occurs during shader compilation.
  29071. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29072. */
  29073. 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);
  29074. private _useFinalCode;
  29075. /**
  29076. * Unique key for this effect
  29077. */
  29078. readonly key: string;
  29079. /**
  29080. * If the effect has been compiled and prepared.
  29081. * @returns if the effect is compiled and prepared.
  29082. */
  29083. isReady(): boolean;
  29084. /**
  29085. * The engine the effect was initialized with.
  29086. * @returns the engine.
  29087. */
  29088. getEngine(): Engine;
  29089. /**
  29090. * The pipeline context for this effect
  29091. * @returns the associated pipeline context
  29092. */
  29093. getPipelineContext(): Nullable<IPipelineContext>;
  29094. /**
  29095. * The set of names of attribute variables for the shader.
  29096. * @returns An array of attribute names.
  29097. */
  29098. getAttributesNames(): string[];
  29099. /**
  29100. * Returns the attribute at the given index.
  29101. * @param index The index of the attribute.
  29102. * @returns The location of the attribute.
  29103. */
  29104. getAttributeLocation(index: number): number;
  29105. /**
  29106. * Returns the attribute based on the name of the variable.
  29107. * @param name of the attribute to look up.
  29108. * @returns the attribute location.
  29109. */
  29110. getAttributeLocationByName(name: string): number;
  29111. /**
  29112. * The number of attributes.
  29113. * @returns the numnber of attributes.
  29114. */
  29115. getAttributesCount(): number;
  29116. /**
  29117. * Gets the index of a uniform variable.
  29118. * @param uniformName of the uniform to look up.
  29119. * @returns the index.
  29120. */
  29121. getUniformIndex(uniformName: string): number;
  29122. /**
  29123. * Returns the attribute based on the name of the variable.
  29124. * @param uniformName of the uniform to look up.
  29125. * @returns the location of the uniform.
  29126. */
  29127. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29128. /**
  29129. * Returns an array of sampler variable names
  29130. * @returns The array of sampler variable neames.
  29131. */
  29132. getSamplers(): string[];
  29133. /**
  29134. * The error from the last compilation.
  29135. * @returns the error string.
  29136. */
  29137. getCompilationError(): string;
  29138. /**
  29139. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29140. * @param func The callback to be used.
  29141. */
  29142. executeWhenCompiled(func: (effect: Effect) => void): void;
  29143. private _checkIsReady;
  29144. /** @hidden */
  29145. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29146. /** @hidden */
  29147. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29148. /** @hidden */
  29149. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29150. /**
  29151. * Recompiles the webGL program
  29152. * @param vertexSourceCode The source code for the vertex shader.
  29153. * @param fragmentSourceCode The source code for the fragment shader.
  29154. * @param onCompiled Callback called when completed.
  29155. * @param onError Callback called on error.
  29156. * @hidden
  29157. */
  29158. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29159. /**
  29160. * Prepares the effect
  29161. * @hidden
  29162. */
  29163. _prepareEffect(): void;
  29164. /**
  29165. * Checks if the effect is supported. (Must be called after compilation)
  29166. */
  29167. readonly isSupported: boolean;
  29168. /**
  29169. * Binds a texture to the engine to be used as output of the shader.
  29170. * @param channel Name of the output variable.
  29171. * @param texture Texture to bind.
  29172. * @hidden
  29173. */
  29174. _bindTexture(channel: string, texture: InternalTexture): void;
  29175. /**
  29176. * Sets a texture on the engine to be used in the shader.
  29177. * @param channel Name of the sampler variable.
  29178. * @param texture Texture to set.
  29179. */
  29180. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29181. /**
  29182. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29183. * @param channel Name of the sampler variable.
  29184. * @param texture Texture to set.
  29185. */
  29186. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29187. /**
  29188. * Sets an array of textures on the engine to be used in the shader.
  29189. * @param channel Name of the variable.
  29190. * @param textures Textures to set.
  29191. */
  29192. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29193. /**
  29194. * 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)
  29195. * @param channel Name of the sampler variable.
  29196. * @param postProcess Post process to get the input texture from.
  29197. */
  29198. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29199. /**
  29200. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29201. * 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)
  29202. * @param channel Name of the sampler variable.
  29203. * @param postProcess Post process to get the output texture from.
  29204. */
  29205. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29206. /** @hidden */
  29207. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29208. /** @hidden */
  29209. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29210. /** @hidden */
  29211. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29212. /** @hidden */
  29213. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29214. /**
  29215. * Binds a buffer to a uniform.
  29216. * @param buffer Buffer to bind.
  29217. * @param name Name of the uniform variable to bind to.
  29218. */
  29219. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29220. /**
  29221. * Binds block to a uniform.
  29222. * @param blockName Name of the block to bind.
  29223. * @param index Index to bind.
  29224. */
  29225. bindUniformBlock(blockName: string, index: number): void;
  29226. /**
  29227. * Sets an interger value on a uniform variable.
  29228. * @param uniformName Name of the variable.
  29229. * @param value Value to be set.
  29230. * @returns this effect.
  29231. */
  29232. setInt(uniformName: string, value: number): Effect;
  29233. /**
  29234. * Sets an int array on a uniform variable.
  29235. * @param uniformName Name of the variable.
  29236. * @param array array to be set.
  29237. * @returns this effect.
  29238. */
  29239. setIntArray(uniformName: string, array: Int32Array): Effect;
  29240. /**
  29241. * 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)
  29242. * @param uniformName Name of the variable.
  29243. * @param array array to be set.
  29244. * @returns this effect.
  29245. */
  29246. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29247. /**
  29248. * 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)
  29249. * @param uniformName Name of the variable.
  29250. * @param array array to be set.
  29251. * @returns this effect.
  29252. */
  29253. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29254. /**
  29255. * 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)
  29256. * @param uniformName Name of the variable.
  29257. * @param array array to be set.
  29258. * @returns this effect.
  29259. */
  29260. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29261. /**
  29262. * Sets an float array on a uniform variable.
  29263. * @param uniformName Name of the variable.
  29264. * @param array array to be set.
  29265. * @returns this effect.
  29266. */
  29267. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29268. /**
  29269. * 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)
  29270. * @param uniformName Name of the variable.
  29271. * @param array array to be set.
  29272. * @returns this effect.
  29273. */
  29274. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29275. /**
  29276. * 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)
  29277. * @param uniformName Name of the variable.
  29278. * @param array array to be set.
  29279. * @returns this effect.
  29280. */
  29281. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29282. /**
  29283. * 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)
  29284. * @param uniformName Name of the variable.
  29285. * @param array array to be set.
  29286. * @returns this effect.
  29287. */
  29288. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29289. /**
  29290. * Sets an array on a uniform variable.
  29291. * @param uniformName Name of the variable.
  29292. * @param array array to be set.
  29293. * @returns this effect.
  29294. */
  29295. setArray(uniformName: string, array: number[]): Effect;
  29296. /**
  29297. * 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)
  29298. * @param uniformName Name of the variable.
  29299. * @param array array to be set.
  29300. * @returns this effect.
  29301. */
  29302. setArray2(uniformName: string, array: number[]): Effect;
  29303. /**
  29304. * 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)
  29305. * @param uniformName Name of the variable.
  29306. * @param array array to be set.
  29307. * @returns this effect.
  29308. */
  29309. setArray3(uniformName: string, array: number[]): Effect;
  29310. /**
  29311. * 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)
  29312. * @param uniformName Name of the variable.
  29313. * @param array array to be set.
  29314. * @returns this effect.
  29315. */
  29316. setArray4(uniformName: string, array: number[]): Effect;
  29317. /**
  29318. * Sets matrices on a uniform variable.
  29319. * @param uniformName Name of the variable.
  29320. * @param matrices matrices to be set.
  29321. * @returns this effect.
  29322. */
  29323. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29324. /**
  29325. * Sets matrix on a uniform variable.
  29326. * @param uniformName Name of the variable.
  29327. * @param matrix matrix to be set.
  29328. * @returns this effect.
  29329. */
  29330. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29331. /**
  29332. * 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)
  29333. * @param uniformName Name of the variable.
  29334. * @param matrix matrix to be set.
  29335. * @returns this effect.
  29336. */
  29337. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29338. /**
  29339. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29340. * @param uniformName Name of the variable.
  29341. * @param matrix matrix to be set.
  29342. * @returns this effect.
  29343. */
  29344. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29345. /**
  29346. * Sets a float on a uniform variable.
  29347. * @param uniformName Name of the variable.
  29348. * @param value value to be set.
  29349. * @returns this effect.
  29350. */
  29351. setFloat(uniformName: string, value: number): Effect;
  29352. /**
  29353. * Sets a boolean on a uniform variable.
  29354. * @param uniformName Name of the variable.
  29355. * @param bool value to be set.
  29356. * @returns this effect.
  29357. */
  29358. setBool(uniformName: string, bool: boolean): Effect;
  29359. /**
  29360. * Sets a Vector2 on a uniform variable.
  29361. * @param uniformName Name of the variable.
  29362. * @param vector2 vector2 to be set.
  29363. * @returns this effect.
  29364. */
  29365. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29366. /**
  29367. * Sets a float2 on a uniform variable.
  29368. * @param uniformName Name of the variable.
  29369. * @param x First float in float2.
  29370. * @param y Second float in float2.
  29371. * @returns this effect.
  29372. */
  29373. setFloat2(uniformName: string, x: number, y: number): Effect;
  29374. /**
  29375. * Sets a Vector3 on a uniform variable.
  29376. * @param uniformName Name of the variable.
  29377. * @param vector3 Value to be set.
  29378. * @returns this effect.
  29379. */
  29380. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29381. /**
  29382. * Sets a float3 on a uniform variable.
  29383. * @param uniformName Name of the variable.
  29384. * @param x First float in float3.
  29385. * @param y Second float in float3.
  29386. * @param z Third float in float3.
  29387. * @returns this effect.
  29388. */
  29389. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29390. /**
  29391. * Sets a Vector4 on a uniform variable.
  29392. * @param uniformName Name of the variable.
  29393. * @param vector4 Value to be set.
  29394. * @returns this effect.
  29395. */
  29396. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29397. /**
  29398. * Sets a float4 on a uniform variable.
  29399. * @param uniformName Name of the variable.
  29400. * @param x First float in float4.
  29401. * @param y Second float in float4.
  29402. * @param z Third float in float4.
  29403. * @param w Fourth float in float4.
  29404. * @returns this effect.
  29405. */
  29406. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29407. /**
  29408. * Sets a Color3 on a uniform variable.
  29409. * @param uniformName Name of the variable.
  29410. * @param color3 Value to be set.
  29411. * @returns this effect.
  29412. */
  29413. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29414. /**
  29415. * Sets a Color4 on a uniform variable.
  29416. * @param uniformName Name of the variable.
  29417. * @param color3 Value to be set.
  29418. * @param alpha Alpha value to be set.
  29419. * @returns this effect.
  29420. */
  29421. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29422. /**
  29423. * Sets a Color4 on a uniform variable
  29424. * @param uniformName defines the name of the variable
  29425. * @param color4 defines the value to be set
  29426. * @returns this effect.
  29427. */
  29428. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29429. /** Release all associated resources */
  29430. dispose(): void;
  29431. /**
  29432. * This function will add a new shader to the shader store
  29433. * @param name the name of the shader
  29434. * @param pixelShader optional pixel shader content
  29435. * @param vertexShader optional vertex shader content
  29436. */
  29437. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29438. /**
  29439. * Store of each shader (The can be looked up using effect.key)
  29440. */
  29441. static ShadersStore: {
  29442. [key: string]: string;
  29443. };
  29444. /**
  29445. * Store of each included file for a shader (The can be looked up using effect.key)
  29446. */
  29447. static IncludesShadersStore: {
  29448. [key: string]: string;
  29449. };
  29450. /**
  29451. * Resets the cache of effects.
  29452. */
  29453. static ResetCache(): void;
  29454. }
  29455. }
  29456. declare module "babylonjs/Materials/uniformBuffer" {
  29457. import { Nullable, FloatArray } from "babylonjs/types";
  29458. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  29459. import { Engine } from "babylonjs/Engines/engine";
  29460. import { Effect } from "babylonjs/Materials/effect";
  29461. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29462. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29463. import { Color3 } from "babylonjs/Maths/math.color";
  29464. /**
  29465. * Uniform buffer objects.
  29466. *
  29467. * Handles blocks of uniform on the GPU.
  29468. *
  29469. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29470. *
  29471. * For more information, please refer to :
  29472. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29473. */
  29474. export class UniformBuffer {
  29475. private _engine;
  29476. private _buffer;
  29477. private _data;
  29478. private _bufferData;
  29479. private _dynamic?;
  29480. private _uniformLocations;
  29481. private _uniformSizes;
  29482. private _uniformLocationPointer;
  29483. private _needSync;
  29484. private _noUBO;
  29485. private _currentEffect;
  29486. private static _MAX_UNIFORM_SIZE;
  29487. private static _tempBuffer;
  29488. /**
  29489. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  29490. * This is dynamic to allow compat with webgl 1 and 2.
  29491. * You will need to pass the name of the uniform as well as the value.
  29492. */
  29493. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  29494. /**
  29495. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  29496. * This is dynamic to allow compat with webgl 1 and 2.
  29497. * You will need to pass the name of the uniform as well as the value.
  29498. */
  29499. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  29500. /**
  29501. * Lambda to Update a single float in a uniform buffer.
  29502. * This is dynamic to allow compat with webgl 1 and 2.
  29503. * You will need to pass the name of the uniform as well as the value.
  29504. */
  29505. updateFloat: (name: string, x: number) => void;
  29506. /**
  29507. * Lambda to Update a vec2 of float in a uniform buffer.
  29508. * This is dynamic to allow compat with webgl 1 and 2.
  29509. * You will need to pass the name of the uniform as well as the value.
  29510. */
  29511. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  29512. /**
  29513. * Lambda to Update a vec3 of float in a uniform buffer.
  29514. * This is dynamic to allow compat with webgl 1 and 2.
  29515. * You will need to pass the name of the uniform as well as the value.
  29516. */
  29517. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  29518. /**
  29519. * Lambda to Update a vec4 of float in a uniform buffer.
  29520. * This is dynamic to allow compat with webgl 1 and 2.
  29521. * You will need to pass the name of the uniform as well as the value.
  29522. */
  29523. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  29524. /**
  29525. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  29526. * This is dynamic to allow compat with webgl 1 and 2.
  29527. * You will need to pass the name of the uniform as well as the value.
  29528. */
  29529. updateMatrix: (name: string, mat: Matrix) => void;
  29530. /**
  29531. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  29532. * This is dynamic to allow compat with webgl 1 and 2.
  29533. * You will need to pass the name of the uniform as well as the value.
  29534. */
  29535. updateVector3: (name: string, vector: Vector3) => void;
  29536. /**
  29537. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  29538. * This is dynamic to allow compat with webgl 1 and 2.
  29539. * You will need to pass the name of the uniform as well as the value.
  29540. */
  29541. updateVector4: (name: string, vector: Vector4) => void;
  29542. /**
  29543. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  29544. * This is dynamic to allow compat with webgl 1 and 2.
  29545. * You will need to pass the name of the uniform as well as the value.
  29546. */
  29547. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  29548. /**
  29549. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  29550. * This is dynamic to allow compat with webgl 1 and 2.
  29551. * You will need to pass the name of the uniform as well as the value.
  29552. */
  29553. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  29554. /**
  29555. * Instantiates a new Uniform buffer objects.
  29556. *
  29557. * Handles blocks of uniform on the GPU.
  29558. *
  29559. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29560. *
  29561. * For more information, please refer to :
  29562. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29563. * @param engine Define the engine the buffer is associated with
  29564. * @param data Define the data contained in the buffer
  29565. * @param dynamic Define if the buffer is updatable
  29566. */
  29567. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  29568. /**
  29569. * Indicates if the buffer is using the WebGL2 UBO implementation,
  29570. * or just falling back on setUniformXXX calls.
  29571. */
  29572. readonly useUbo: boolean;
  29573. /**
  29574. * Indicates if the WebGL underlying uniform buffer is in sync
  29575. * with the javascript cache data.
  29576. */
  29577. readonly isSync: boolean;
  29578. /**
  29579. * Indicates if the WebGL underlying uniform buffer is dynamic.
  29580. * Also, a dynamic UniformBuffer will disable cache verification and always
  29581. * update the underlying WebGL uniform buffer to the GPU.
  29582. * @returns if Dynamic, otherwise false
  29583. */
  29584. isDynamic(): boolean;
  29585. /**
  29586. * The data cache on JS side.
  29587. * @returns the underlying data as a float array
  29588. */
  29589. getData(): Float32Array;
  29590. /**
  29591. * The underlying WebGL Uniform buffer.
  29592. * @returns the webgl buffer
  29593. */
  29594. getBuffer(): Nullable<DataBuffer>;
  29595. /**
  29596. * std140 layout specifies how to align data within an UBO structure.
  29597. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  29598. * for specs.
  29599. */
  29600. private _fillAlignment;
  29601. /**
  29602. * Adds an uniform in the buffer.
  29603. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  29604. * for the layout to be correct !
  29605. * @param name Name of the uniform, as used in the uniform block in the shader.
  29606. * @param size Data size, or data directly.
  29607. */
  29608. addUniform(name: string, size: number | number[]): void;
  29609. /**
  29610. * Adds a Matrix 4x4 to the uniform buffer.
  29611. * @param name Name of the uniform, as used in the uniform block in the shader.
  29612. * @param mat A 4x4 matrix.
  29613. */
  29614. addMatrix(name: string, mat: Matrix): void;
  29615. /**
  29616. * Adds a vec2 to the uniform buffer.
  29617. * @param name Name of the uniform, as used in the uniform block in the shader.
  29618. * @param x Define the x component value of the vec2
  29619. * @param y Define the y component value of the vec2
  29620. */
  29621. addFloat2(name: string, x: number, y: number): void;
  29622. /**
  29623. * Adds a vec3 to the uniform buffer.
  29624. * @param name Name of the uniform, as used in the uniform block in the shader.
  29625. * @param x Define the x component value of the vec3
  29626. * @param y Define the y component value of the vec3
  29627. * @param z Define the z component value of the vec3
  29628. */
  29629. addFloat3(name: string, x: number, y: number, z: number): void;
  29630. /**
  29631. * Adds a vec3 to the uniform buffer.
  29632. * @param name Name of the uniform, as used in the uniform block in the shader.
  29633. * @param color Define the vec3 from a Color
  29634. */
  29635. addColor3(name: string, color: Color3): void;
  29636. /**
  29637. * Adds a vec4 to the uniform buffer.
  29638. * @param name Name of the uniform, as used in the uniform block in the shader.
  29639. * @param color Define the rgb components from a Color
  29640. * @param alpha Define the a component of the vec4
  29641. */
  29642. addColor4(name: string, color: Color3, alpha: number): void;
  29643. /**
  29644. * Adds a vec3 to the uniform buffer.
  29645. * @param name Name of the uniform, as used in the uniform block in the shader.
  29646. * @param vector Define the vec3 components from a Vector
  29647. */
  29648. addVector3(name: string, vector: Vector3): void;
  29649. /**
  29650. * Adds a Matrix 3x3 to the uniform buffer.
  29651. * @param name Name of the uniform, as used in the uniform block in the shader.
  29652. */
  29653. addMatrix3x3(name: string): void;
  29654. /**
  29655. * Adds a Matrix 2x2 to the uniform buffer.
  29656. * @param name Name of the uniform, as used in the uniform block in the shader.
  29657. */
  29658. addMatrix2x2(name: string): void;
  29659. /**
  29660. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29661. */
  29662. create(): void;
  29663. /** @hidden */
  29664. _rebuild(): void;
  29665. /**
  29666. * Updates the WebGL Uniform Buffer on the GPU.
  29667. * If the `dynamic` flag is set to true, no cache comparison is done.
  29668. * Otherwise, the buffer will be updated only if the cache differs.
  29669. */
  29670. update(): void;
  29671. /**
  29672. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29673. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29674. * @param data Define the flattened data
  29675. * @param size Define the size of the data.
  29676. */
  29677. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29678. private _updateMatrix3x3ForUniform;
  29679. private _updateMatrix3x3ForEffect;
  29680. private _updateMatrix2x2ForEffect;
  29681. private _updateMatrix2x2ForUniform;
  29682. private _updateFloatForEffect;
  29683. private _updateFloatForUniform;
  29684. private _updateFloat2ForEffect;
  29685. private _updateFloat2ForUniform;
  29686. private _updateFloat3ForEffect;
  29687. private _updateFloat3ForUniform;
  29688. private _updateFloat4ForEffect;
  29689. private _updateFloat4ForUniform;
  29690. private _updateMatrixForEffect;
  29691. private _updateMatrixForUniform;
  29692. private _updateVector3ForEffect;
  29693. private _updateVector3ForUniform;
  29694. private _updateVector4ForEffect;
  29695. private _updateVector4ForUniform;
  29696. private _updateColor3ForEffect;
  29697. private _updateColor3ForUniform;
  29698. private _updateColor4ForEffect;
  29699. private _updateColor4ForUniform;
  29700. /**
  29701. * Sets a sampler uniform on the effect.
  29702. * @param name Define the name of the sampler.
  29703. * @param texture Define the texture to set in the sampler
  29704. */
  29705. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29706. /**
  29707. * Directly updates the value of the uniform in the cache AND on the GPU.
  29708. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29709. * @param data Define the flattened data
  29710. */
  29711. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29712. /**
  29713. * Binds this uniform buffer to an effect.
  29714. * @param effect Define the effect to bind the buffer to
  29715. * @param name Name of the uniform block in the shader.
  29716. */
  29717. bindToEffect(effect: Effect, name: string): void;
  29718. /**
  29719. * Disposes the uniform buffer.
  29720. */
  29721. dispose(): void;
  29722. }
  29723. }
  29724. declare module "babylonjs/Audio/analyser" {
  29725. import { Scene } from "babylonjs/scene";
  29726. /**
  29727. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29728. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29729. */
  29730. export class Analyser {
  29731. /**
  29732. * Gets or sets the smoothing
  29733. * @ignorenaming
  29734. */
  29735. SMOOTHING: number;
  29736. /**
  29737. * Gets or sets the FFT table size
  29738. * @ignorenaming
  29739. */
  29740. FFT_SIZE: number;
  29741. /**
  29742. * Gets or sets the bar graph amplitude
  29743. * @ignorenaming
  29744. */
  29745. BARGRAPHAMPLITUDE: number;
  29746. /**
  29747. * Gets or sets the position of the debug canvas
  29748. * @ignorenaming
  29749. */
  29750. DEBUGCANVASPOS: {
  29751. x: number;
  29752. y: number;
  29753. };
  29754. /**
  29755. * Gets or sets the debug canvas size
  29756. * @ignorenaming
  29757. */
  29758. DEBUGCANVASSIZE: {
  29759. width: number;
  29760. height: number;
  29761. };
  29762. private _byteFreqs;
  29763. private _byteTime;
  29764. private _floatFreqs;
  29765. private _webAudioAnalyser;
  29766. private _debugCanvas;
  29767. private _debugCanvasContext;
  29768. private _scene;
  29769. private _registerFunc;
  29770. private _audioEngine;
  29771. /**
  29772. * Creates a new analyser
  29773. * @param scene defines hosting scene
  29774. */
  29775. constructor(scene: Scene);
  29776. /**
  29777. * Get the number of data values you will have to play with for the visualization
  29778. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29779. * @returns a number
  29780. */
  29781. getFrequencyBinCount(): number;
  29782. /**
  29783. * Gets the current frequency data as a byte array
  29784. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29785. * @returns a Uint8Array
  29786. */
  29787. getByteFrequencyData(): Uint8Array;
  29788. /**
  29789. * Gets the current waveform as a byte array
  29790. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29791. * @returns a Uint8Array
  29792. */
  29793. getByteTimeDomainData(): Uint8Array;
  29794. /**
  29795. * Gets the current frequency data as a float array
  29796. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29797. * @returns a Float32Array
  29798. */
  29799. getFloatFrequencyData(): Float32Array;
  29800. /**
  29801. * Renders the debug canvas
  29802. */
  29803. drawDebugCanvas(): void;
  29804. /**
  29805. * Stops rendering the debug canvas and removes it
  29806. */
  29807. stopDebugCanvas(): void;
  29808. /**
  29809. * Connects two audio nodes
  29810. * @param inputAudioNode defines first node to connect
  29811. * @param outputAudioNode defines second node to connect
  29812. */
  29813. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29814. /**
  29815. * Releases all associated resources
  29816. */
  29817. dispose(): void;
  29818. }
  29819. }
  29820. declare module "babylonjs/Audio/audioEngine" {
  29821. import { IDisposable } from "babylonjs/scene";
  29822. import { Analyser } from "babylonjs/Audio/analyser";
  29823. import { Nullable } from "babylonjs/types";
  29824. import { Observable } from "babylonjs/Misc/observable";
  29825. /**
  29826. * This represents an audio engine and it is responsible
  29827. * to play, synchronize and analyse sounds throughout the application.
  29828. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29829. */
  29830. export interface IAudioEngine extends IDisposable {
  29831. /**
  29832. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29833. */
  29834. readonly canUseWebAudio: boolean;
  29835. /**
  29836. * Gets the current AudioContext if available.
  29837. */
  29838. readonly audioContext: Nullable<AudioContext>;
  29839. /**
  29840. * The master gain node defines the global audio volume of your audio engine.
  29841. */
  29842. readonly masterGain: GainNode;
  29843. /**
  29844. * Gets whether or not mp3 are supported by your browser.
  29845. */
  29846. readonly isMP3supported: boolean;
  29847. /**
  29848. * Gets whether or not ogg are supported by your browser.
  29849. */
  29850. readonly isOGGsupported: boolean;
  29851. /**
  29852. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29853. * @ignoreNaming
  29854. */
  29855. WarnedWebAudioUnsupported: boolean;
  29856. /**
  29857. * Defines if the audio engine relies on a custom unlocked button.
  29858. * In this case, the embedded button will not be displayed.
  29859. */
  29860. useCustomUnlockedButton: boolean;
  29861. /**
  29862. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29863. */
  29864. readonly unlocked: boolean;
  29865. /**
  29866. * Event raised when audio has been unlocked on the browser.
  29867. */
  29868. onAudioUnlockedObservable: Observable<AudioEngine>;
  29869. /**
  29870. * Event raised when audio has been locked on the browser.
  29871. */
  29872. onAudioLockedObservable: Observable<AudioEngine>;
  29873. /**
  29874. * Flags the audio engine in Locked state.
  29875. * This happens due to new browser policies preventing audio to autoplay.
  29876. */
  29877. lock(): void;
  29878. /**
  29879. * Unlocks the audio engine once a user action has been done on the dom.
  29880. * This is helpful to resume play once browser policies have been satisfied.
  29881. */
  29882. unlock(): void;
  29883. }
  29884. /**
  29885. * This represents the default audio engine used in babylon.
  29886. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29887. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29888. */
  29889. export class AudioEngine implements IAudioEngine {
  29890. private _audioContext;
  29891. private _audioContextInitialized;
  29892. private _muteButton;
  29893. private _hostElement;
  29894. /**
  29895. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29896. */
  29897. canUseWebAudio: boolean;
  29898. /**
  29899. * The master gain node defines the global audio volume of your audio engine.
  29900. */
  29901. masterGain: GainNode;
  29902. /**
  29903. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29904. * @ignoreNaming
  29905. */
  29906. WarnedWebAudioUnsupported: boolean;
  29907. /**
  29908. * Gets whether or not mp3 are supported by your browser.
  29909. */
  29910. isMP3supported: boolean;
  29911. /**
  29912. * Gets whether or not ogg are supported by your browser.
  29913. */
  29914. isOGGsupported: boolean;
  29915. /**
  29916. * Gets whether audio has been unlocked on the device.
  29917. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29918. * a user interaction has happened.
  29919. */
  29920. unlocked: boolean;
  29921. /**
  29922. * Defines if the audio engine relies on a custom unlocked button.
  29923. * In this case, the embedded button will not be displayed.
  29924. */
  29925. useCustomUnlockedButton: boolean;
  29926. /**
  29927. * Event raised when audio has been unlocked on the browser.
  29928. */
  29929. onAudioUnlockedObservable: Observable<AudioEngine>;
  29930. /**
  29931. * Event raised when audio has been locked on the browser.
  29932. */
  29933. onAudioLockedObservable: Observable<AudioEngine>;
  29934. /**
  29935. * Gets the current AudioContext if available.
  29936. */
  29937. readonly audioContext: Nullable<AudioContext>;
  29938. private _connectedAnalyser;
  29939. /**
  29940. * Instantiates a new audio engine.
  29941. *
  29942. * There should be only one per page as some browsers restrict the number
  29943. * of audio contexts you can create.
  29944. * @param hostElement defines the host element where to display the mute icon if necessary
  29945. */
  29946. constructor(hostElement?: Nullable<HTMLElement>);
  29947. /**
  29948. * Flags the audio engine in Locked state.
  29949. * This happens due to new browser policies preventing audio to autoplay.
  29950. */
  29951. lock(): void;
  29952. /**
  29953. * Unlocks the audio engine once a user action has been done on the dom.
  29954. * This is helpful to resume play once browser policies have been satisfied.
  29955. */
  29956. unlock(): void;
  29957. private _resumeAudioContext;
  29958. private _initializeAudioContext;
  29959. private _tryToRun;
  29960. private _triggerRunningState;
  29961. private _triggerSuspendedState;
  29962. private _displayMuteButton;
  29963. private _moveButtonToTopLeft;
  29964. private _onResize;
  29965. private _hideMuteButton;
  29966. /**
  29967. * Destroy and release the resources associated with the audio ccontext.
  29968. */
  29969. dispose(): void;
  29970. /**
  29971. * Gets the global volume sets on the master gain.
  29972. * @returns the global volume if set or -1 otherwise
  29973. */
  29974. getGlobalVolume(): number;
  29975. /**
  29976. * Sets the global volume of your experience (sets on the master gain).
  29977. * @param newVolume Defines the new global volume of the application
  29978. */
  29979. setGlobalVolume(newVolume: number): void;
  29980. /**
  29981. * Connect the audio engine to an audio analyser allowing some amazing
  29982. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  29983. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  29984. * @param analyser The analyser to connect to the engine
  29985. */
  29986. connectToAnalyser(analyser: Analyser): void;
  29987. }
  29988. }
  29989. declare module "babylonjs/Loading/loadingScreen" {
  29990. /**
  29991. * Interface used to present a loading screen while loading a scene
  29992. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29993. */
  29994. export interface ILoadingScreen {
  29995. /**
  29996. * Function called to display the loading screen
  29997. */
  29998. displayLoadingUI: () => void;
  29999. /**
  30000. * Function called to hide the loading screen
  30001. */
  30002. hideLoadingUI: () => void;
  30003. /**
  30004. * Gets or sets the color to use for the background
  30005. */
  30006. loadingUIBackgroundColor: string;
  30007. /**
  30008. * Gets or sets the text to display while loading
  30009. */
  30010. loadingUIText: string;
  30011. }
  30012. /**
  30013. * Class used for the default loading screen
  30014. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30015. */
  30016. export class DefaultLoadingScreen implements ILoadingScreen {
  30017. private _renderingCanvas;
  30018. private _loadingText;
  30019. private _loadingDivBackgroundColor;
  30020. private _loadingDiv;
  30021. private _loadingTextDiv;
  30022. /** Gets or sets the logo url to use for the default loading screen */
  30023. static DefaultLogoUrl: string;
  30024. /** Gets or sets the spinner url to use for the default loading screen */
  30025. static DefaultSpinnerUrl: string;
  30026. /**
  30027. * Creates a new default loading screen
  30028. * @param _renderingCanvas defines the canvas used to render the scene
  30029. * @param _loadingText defines the default text to display
  30030. * @param _loadingDivBackgroundColor defines the default background color
  30031. */
  30032. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30033. /**
  30034. * Function called to display the loading screen
  30035. */
  30036. displayLoadingUI(): void;
  30037. /**
  30038. * Function called to hide the loading screen
  30039. */
  30040. hideLoadingUI(): void;
  30041. /**
  30042. * Gets or sets the text to display while loading
  30043. */
  30044. loadingUIText: string;
  30045. /**
  30046. * Gets or sets the color to use for the background
  30047. */
  30048. loadingUIBackgroundColor: string;
  30049. private _resizeLoadingUI;
  30050. }
  30051. }
  30052. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  30053. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30054. import { Engine } from "babylonjs/Engines/engine";
  30055. import { Nullable } from "babylonjs/types";
  30056. /** @hidden */
  30057. export class WebGLPipelineContext implements IPipelineContext {
  30058. engine: Engine;
  30059. program: Nullable<WebGLProgram>;
  30060. context?: WebGLRenderingContext;
  30061. vertexShader?: WebGLShader;
  30062. fragmentShader?: WebGLShader;
  30063. isParallelCompiled: boolean;
  30064. onCompiled?: () => void;
  30065. transformFeedback?: WebGLTransformFeedback | null;
  30066. readonly isAsync: boolean;
  30067. readonly isReady: boolean;
  30068. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  30069. }
  30070. }
  30071. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  30072. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30073. /** @hidden */
  30074. export class WebGLDataBuffer extends DataBuffer {
  30075. private _buffer;
  30076. constructor(resource: WebGLBuffer);
  30077. readonly underlyingResource: any;
  30078. }
  30079. }
  30080. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30081. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30082. /** @hidden */
  30083. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30084. attributeProcessor(attribute: string): string;
  30085. varyingProcessor(varying: string, isFragment: boolean): string;
  30086. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30087. }
  30088. }
  30089. declare module "babylonjs/Misc/perfCounter" {
  30090. /**
  30091. * This class is used to track a performance counter which is number based.
  30092. * The user has access to many properties which give statistics of different nature.
  30093. *
  30094. * The implementer can track two kinds of Performance Counter: time and count.
  30095. * 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.
  30096. * 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.
  30097. */
  30098. export class PerfCounter {
  30099. /**
  30100. * Gets or sets a global boolean to turn on and off all the counters
  30101. */
  30102. static Enabled: boolean;
  30103. /**
  30104. * Returns the smallest value ever
  30105. */
  30106. readonly min: number;
  30107. /**
  30108. * Returns the biggest value ever
  30109. */
  30110. readonly max: number;
  30111. /**
  30112. * Returns the average value since the performance counter is running
  30113. */
  30114. readonly average: number;
  30115. /**
  30116. * Returns the average value of the last second the counter was monitored
  30117. */
  30118. readonly lastSecAverage: number;
  30119. /**
  30120. * Returns the current value
  30121. */
  30122. readonly current: number;
  30123. /**
  30124. * Gets the accumulated total
  30125. */
  30126. readonly total: number;
  30127. /**
  30128. * Gets the total value count
  30129. */
  30130. readonly count: number;
  30131. /**
  30132. * Creates a new counter
  30133. */
  30134. constructor();
  30135. /**
  30136. * Call this method to start monitoring a new frame.
  30137. * 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.
  30138. */
  30139. fetchNewFrame(): void;
  30140. /**
  30141. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30142. * @param newCount the count value to add to the monitored count
  30143. * @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.
  30144. */
  30145. addCount(newCount: number, fetchResult: boolean): void;
  30146. /**
  30147. * Start monitoring this performance counter
  30148. */
  30149. beginMonitoring(): void;
  30150. /**
  30151. * Compute the time lapsed since the previous beginMonitoring() call.
  30152. * @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
  30153. */
  30154. endMonitoring(newFrame?: boolean): void;
  30155. private _fetchResult;
  30156. private _startMonitoringTime;
  30157. private _min;
  30158. private _max;
  30159. private _average;
  30160. private _current;
  30161. private _totalValueCount;
  30162. private _totalAccumulated;
  30163. private _lastSecAverage;
  30164. private _lastSecAccumulated;
  30165. private _lastSecTime;
  30166. private _lastSecValueCount;
  30167. }
  30168. }
  30169. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  30170. /**
  30171. * Interface for any object that can request an animation frame
  30172. */
  30173. export interface ICustomAnimationFrameRequester {
  30174. /**
  30175. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30176. */
  30177. renderFunction?: Function;
  30178. /**
  30179. * Called to request the next frame to render to
  30180. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30181. */
  30182. requestAnimationFrame: Function;
  30183. /**
  30184. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30185. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30186. */
  30187. requestID?: number;
  30188. }
  30189. }
  30190. declare module "babylonjs/Materials/Textures/videoTexture" {
  30191. import { Observable } from "babylonjs/Misc/observable";
  30192. import { Nullable } from "babylonjs/types";
  30193. import { Scene } from "babylonjs/scene";
  30194. import { Texture } from "babylonjs/Materials/Textures/texture";
  30195. /**
  30196. * Settings for finer control over video usage
  30197. */
  30198. export interface VideoTextureSettings {
  30199. /**
  30200. * Applies `autoplay` to video, if specified
  30201. */
  30202. autoPlay?: boolean;
  30203. /**
  30204. * Applies `loop` to video, if specified
  30205. */
  30206. loop?: boolean;
  30207. /**
  30208. * Automatically updates internal texture from video at every frame in the render loop
  30209. */
  30210. autoUpdateTexture: boolean;
  30211. /**
  30212. * Image src displayed during the video loading or until the user interacts with the video.
  30213. */
  30214. poster?: string;
  30215. }
  30216. /**
  30217. * If you want to display a video in your scene, this is the special texture for that.
  30218. * This special texture works similar to other textures, with the exception of a few parameters.
  30219. * @see https://doc.babylonjs.com/how_to/video_texture
  30220. */
  30221. export class VideoTexture extends Texture {
  30222. /**
  30223. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30224. */
  30225. readonly autoUpdateTexture: boolean;
  30226. /**
  30227. * The video instance used by the texture internally
  30228. */
  30229. readonly video: HTMLVideoElement;
  30230. private _onUserActionRequestedObservable;
  30231. /**
  30232. * Event triggerd when a dom action is required by the user to play the video.
  30233. * This happens due to recent changes in browser policies preventing video to auto start.
  30234. */
  30235. readonly onUserActionRequestedObservable: Observable<Texture>;
  30236. private _generateMipMaps;
  30237. private _engine;
  30238. private _stillImageCaptured;
  30239. private _displayingPosterTexture;
  30240. private _settings;
  30241. private _createInternalTextureOnEvent;
  30242. /**
  30243. * Creates a video texture.
  30244. * If you want to display a video in your scene, this is the special texture for that.
  30245. * This special texture works similar to other textures, with the exception of a few parameters.
  30246. * @see https://doc.babylonjs.com/how_to/video_texture
  30247. * @param name optional name, will detect from video source, if not defined
  30248. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30249. * @param scene is obviously the current scene.
  30250. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30251. * @param invertY is false by default but can be used to invert video on Y axis
  30252. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30253. * @param settings allows finer control over video usage
  30254. */
  30255. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30256. private _getName;
  30257. private _getVideo;
  30258. private _createInternalTexture;
  30259. private reset;
  30260. /**
  30261. * @hidden Internal method to initiate `update`.
  30262. */
  30263. _rebuild(): void;
  30264. /**
  30265. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30266. */
  30267. update(): void;
  30268. /**
  30269. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30270. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30271. */
  30272. updateTexture(isVisible: boolean): void;
  30273. protected _updateInternalTexture: () => void;
  30274. /**
  30275. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30276. * @param url New url.
  30277. */
  30278. updateURL(url: string): void;
  30279. /**
  30280. * Dispose the texture and release its associated resources.
  30281. */
  30282. dispose(): void;
  30283. /**
  30284. * Creates a video texture straight from a stream.
  30285. * @param scene Define the scene the texture should be created in
  30286. * @param stream Define the stream the texture should be created from
  30287. * @returns The created video texture as a promise
  30288. */
  30289. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30290. /**
  30291. * Creates a video texture straight from your WebCam video feed.
  30292. * @param scene Define the scene the texture should be created in
  30293. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30294. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30295. * @returns The created video texture as a promise
  30296. */
  30297. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30298. minWidth: number;
  30299. maxWidth: number;
  30300. minHeight: number;
  30301. maxHeight: number;
  30302. deviceId: string;
  30303. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30304. /**
  30305. * Creates a video texture straight from your WebCam video feed.
  30306. * @param scene Define the scene the texture should be created in
  30307. * @param onReady Define a callback to triggered once the texture will be ready
  30308. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30309. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30310. */
  30311. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30312. minWidth: number;
  30313. maxWidth: number;
  30314. minHeight: number;
  30315. maxHeight: number;
  30316. deviceId: string;
  30317. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30318. }
  30319. }
  30320. declare module "babylonjs/Engines/engine" {
  30321. import { Observable } from "babylonjs/Misc/observable";
  30322. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  30323. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30324. import { Scene } from "babylonjs/scene";
  30325. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30326. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30327. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  30328. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30329. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30330. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30331. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  30332. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30333. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  30334. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  30335. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  30336. import { WebRequest } from "babylonjs/Misc/webRequest";
  30337. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30338. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30339. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30340. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30341. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30342. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30343. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  30344. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30345. import { Material } from "babylonjs/Materials/material";
  30346. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30347. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30348. /**
  30349. * Defines the interface used by objects containing a viewport (like a camera)
  30350. */
  30351. interface IViewportOwnerLike {
  30352. /**
  30353. * Gets or sets the viewport
  30354. */
  30355. viewport: IViewportLike;
  30356. }
  30357. /**
  30358. * Interface for attribute information associated with buffer instanciation
  30359. */
  30360. export class InstancingAttributeInfo {
  30361. /**
  30362. * Index/offset of the attribute in the vertex shader
  30363. */
  30364. index: number;
  30365. /**
  30366. * size of the attribute, 1, 2, 3 or 4
  30367. */
  30368. attributeSize: number;
  30369. /**
  30370. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30371. * default is FLOAT
  30372. */
  30373. attribyteType: number;
  30374. /**
  30375. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30376. */
  30377. normalized: boolean;
  30378. /**
  30379. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30380. */
  30381. offset: number;
  30382. /**
  30383. * Name of the GLSL attribute, for debugging purpose only
  30384. */
  30385. attributeName: string;
  30386. }
  30387. /**
  30388. * Define options used to create a depth texture
  30389. */
  30390. export class DepthTextureCreationOptions {
  30391. /** Specifies whether or not a stencil should be allocated in the texture */
  30392. generateStencil?: boolean;
  30393. /** Specifies whether or not bilinear filtering is enable on the texture */
  30394. bilinearFiltering?: boolean;
  30395. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  30396. comparisonFunction?: number;
  30397. /** Specifies if the created texture is a cube texture */
  30398. isCube?: boolean;
  30399. }
  30400. /**
  30401. * Class used to describe the capabilities of the engine relatively to the current browser
  30402. */
  30403. export class EngineCapabilities {
  30404. /** Maximum textures units per fragment shader */
  30405. maxTexturesImageUnits: number;
  30406. /** Maximum texture units per vertex shader */
  30407. maxVertexTextureImageUnits: number;
  30408. /** Maximum textures units in the entire pipeline */
  30409. maxCombinedTexturesImageUnits: number;
  30410. /** Maximum texture size */
  30411. maxTextureSize: number;
  30412. /** Maximum cube texture size */
  30413. maxCubemapTextureSize: number;
  30414. /** Maximum render texture size */
  30415. maxRenderTextureSize: number;
  30416. /** Maximum number of vertex attributes */
  30417. maxVertexAttribs: number;
  30418. /** Maximum number of varyings */
  30419. maxVaryingVectors: number;
  30420. /** Maximum number of uniforms per vertex shader */
  30421. maxVertexUniformVectors: number;
  30422. /** Maximum number of uniforms per fragment shader */
  30423. maxFragmentUniformVectors: number;
  30424. /** Defines if standard derivates (dx/dy) are supported */
  30425. standardDerivatives: boolean;
  30426. /** Defines if s3tc texture compression is supported */
  30427. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  30428. /** Defines if pvrtc texture compression is supported */
  30429. pvrtc: any;
  30430. /** Defines if etc1 texture compression is supported */
  30431. etc1: any;
  30432. /** Defines if etc2 texture compression is supported */
  30433. etc2: any;
  30434. /** Defines if astc texture compression is supported */
  30435. astc: any;
  30436. /** Defines if float textures are supported */
  30437. textureFloat: boolean;
  30438. /** Defines if vertex array objects are supported */
  30439. vertexArrayObject: boolean;
  30440. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30441. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  30442. /** Gets the maximum level of anisotropy supported */
  30443. maxAnisotropy: number;
  30444. /** Defines if instancing is supported */
  30445. instancedArrays: boolean;
  30446. /** Defines if 32 bits indices are supported */
  30447. uintIndices: boolean;
  30448. /** Defines if high precision shaders are supported */
  30449. highPrecisionShaderSupported: boolean;
  30450. /** Defines if depth reading in the fragment shader is supported */
  30451. fragmentDepthSupported: boolean;
  30452. /** Defines if float texture linear filtering is supported*/
  30453. textureFloatLinearFiltering: boolean;
  30454. /** Defines if rendering to float textures is supported */
  30455. textureFloatRender: boolean;
  30456. /** Defines if half float textures are supported*/
  30457. textureHalfFloat: boolean;
  30458. /** Defines if half float texture linear filtering is supported*/
  30459. textureHalfFloatLinearFiltering: boolean;
  30460. /** Defines if rendering to half float textures is supported */
  30461. textureHalfFloatRender: boolean;
  30462. /** Defines if textureLOD shader command is supported */
  30463. textureLOD: boolean;
  30464. /** Defines if draw buffers extension is supported */
  30465. drawBuffersExtension: boolean;
  30466. /** Defines if depth textures are supported */
  30467. depthTextureExtension: boolean;
  30468. /** Defines if float color buffer are supported */
  30469. colorBufferFloat: boolean;
  30470. /** Gets disjoint timer query extension (null if not supported) */
  30471. timerQuery: EXT_disjoint_timer_query;
  30472. /** Defines if timestamp can be used with timer query */
  30473. canUseTimestampForTimerQuery: boolean;
  30474. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30475. multiview: any;
  30476. /** Function used to let the system compiles shaders in background */
  30477. parallelShaderCompile: {
  30478. COMPLETION_STATUS_KHR: number;
  30479. };
  30480. }
  30481. /** Interface defining initialization parameters for Engine class */
  30482. export interface EngineOptions extends WebGLContextAttributes {
  30483. /**
  30484. * Defines if the engine should no exceed a specified device ratio
  30485. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30486. */
  30487. limitDeviceRatio?: number;
  30488. /**
  30489. * Defines if webvr should be enabled automatically
  30490. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30491. */
  30492. autoEnableWebVR?: boolean;
  30493. /**
  30494. * Defines if webgl2 should be turned off even if supported
  30495. * @see http://doc.babylonjs.com/features/webgl2
  30496. */
  30497. disableWebGL2Support?: boolean;
  30498. /**
  30499. * Defines if webaudio should be initialized as well
  30500. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30501. */
  30502. audioEngine?: boolean;
  30503. /**
  30504. * Defines if animations should run using a deterministic lock step
  30505. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30506. */
  30507. deterministicLockstep?: boolean;
  30508. /** Defines the maximum steps to use with deterministic lock step mode */
  30509. lockstepMaxSteps?: number;
  30510. /**
  30511. * Defines that engine should ignore context lost events
  30512. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30513. */
  30514. doNotHandleContextLost?: boolean;
  30515. /**
  30516. * Defines that engine should ignore modifying touch action attribute and style
  30517. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30518. */
  30519. doNotHandleTouchAction?: boolean;
  30520. /**
  30521. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30522. */
  30523. useHighPrecisionFloats?: boolean;
  30524. }
  30525. /**
  30526. * Defines the interface used by display changed events
  30527. */
  30528. export interface IDisplayChangedEventArgs {
  30529. /** Gets the vrDisplay object (if any) */
  30530. vrDisplay: Nullable<any>;
  30531. /** Gets a boolean indicating if webVR is supported */
  30532. vrSupported: boolean;
  30533. }
  30534. /**
  30535. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30536. */
  30537. export class Engine {
  30538. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30539. static ExceptionList: ({
  30540. key: string;
  30541. capture: string;
  30542. captureConstraint: number;
  30543. targets: string[];
  30544. } | {
  30545. key: string;
  30546. capture: null;
  30547. captureConstraint: null;
  30548. targets: string[];
  30549. })[];
  30550. /** Gets the list of created engines */
  30551. static readonly Instances: Engine[];
  30552. /**
  30553. * Gets the latest created engine
  30554. */
  30555. static readonly LastCreatedEngine: Nullable<Engine>;
  30556. /**
  30557. * Gets the latest created scene
  30558. */
  30559. static readonly LastCreatedScene: Nullable<Scene>;
  30560. /**
  30561. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30562. * @param flag defines which part of the materials must be marked as dirty
  30563. * @param predicate defines a predicate used to filter which materials should be affected
  30564. */
  30565. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30566. /** @hidden */
  30567. static _TextureLoaders: IInternalTextureLoader[];
  30568. /** Defines that alpha blending is disabled */
  30569. static readonly ALPHA_DISABLE: number;
  30570. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30571. static readonly ALPHA_ADD: number;
  30572. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30573. static readonly ALPHA_COMBINE: number;
  30574. /** Defines that alpha blending to DEST - SRC * DEST */
  30575. static readonly ALPHA_SUBTRACT: number;
  30576. /** Defines that alpha blending to SRC * DEST */
  30577. static readonly ALPHA_MULTIPLY: number;
  30578. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30579. static readonly ALPHA_MAXIMIZED: number;
  30580. /** Defines that alpha blending to SRC + DEST */
  30581. static readonly ALPHA_ONEONE: number;
  30582. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30583. static readonly ALPHA_PREMULTIPLIED: number;
  30584. /**
  30585. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30586. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30587. */
  30588. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30589. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30590. static readonly ALPHA_INTERPOLATE: number;
  30591. /**
  30592. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30593. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30594. */
  30595. static readonly ALPHA_SCREENMODE: number;
  30596. /** Defines that the ressource is not delayed*/
  30597. static readonly DELAYLOADSTATE_NONE: number;
  30598. /** Defines that the ressource was successfully delay loaded */
  30599. static readonly DELAYLOADSTATE_LOADED: number;
  30600. /** Defines that the ressource is currently delay loading */
  30601. static readonly DELAYLOADSTATE_LOADING: number;
  30602. /** Defines that the ressource is delayed and has not started loading */
  30603. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30604. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30605. static readonly NEVER: number;
  30606. /** 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 */
  30607. static readonly ALWAYS: number;
  30608. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30609. static readonly LESS: number;
  30610. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30611. static readonly EQUAL: number;
  30612. /** 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 */
  30613. static readonly LEQUAL: number;
  30614. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30615. static readonly GREATER: number;
  30616. /** 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 */
  30617. static readonly GEQUAL: number;
  30618. /** 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 */
  30619. static readonly NOTEQUAL: number;
  30620. /** Passed to stencilOperation to specify that stencil value must be kept */
  30621. static readonly KEEP: number;
  30622. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30623. static readonly REPLACE: number;
  30624. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30625. static readonly INCR: number;
  30626. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30627. static readonly DECR: number;
  30628. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30629. static readonly INVERT: number;
  30630. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30631. static readonly INCR_WRAP: number;
  30632. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30633. static readonly DECR_WRAP: number;
  30634. /** Texture is not repeating outside of 0..1 UVs */
  30635. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30636. /** Texture is repeating outside of 0..1 UVs */
  30637. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30638. /** Texture is repeating and mirrored */
  30639. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30640. /** ALPHA */
  30641. static readonly TEXTUREFORMAT_ALPHA: number;
  30642. /** LUMINANCE */
  30643. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30644. /** LUMINANCE_ALPHA */
  30645. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30646. /** RGB */
  30647. static readonly TEXTUREFORMAT_RGB: number;
  30648. /** RGBA */
  30649. static readonly TEXTUREFORMAT_RGBA: number;
  30650. /** RED */
  30651. static readonly TEXTUREFORMAT_RED: number;
  30652. /** RED (2nd reference) */
  30653. static readonly TEXTUREFORMAT_R: number;
  30654. /** RG */
  30655. static readonly TEXTUREFORMAT_RG: number;
  30656. /** RED_INTEGER */
  30657. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30658. /** RED_INTEGER (2nd reference) */
  30659. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30660. /** RG_INTEGER */
  30661. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30662. /** RGB_INTEGER */
  30663. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30664. /** RGBA_INTEGER */
  30665. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30666. /** UNSIGNED_BYTE */
  30667. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30668. /** UNSIGNED_BYTE (2nd reference) */
  30669. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30670. /** FLOAT */
  30671. static readonly TEXTURETYPE_FLOAT: number;
  30672. /** HALF_FLOAT */
  30673. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30674. /** BYTE */
  30675. static readonly TEXTURETYPE_BYTE: number;
  30676. /** SHORT */
  30677. static readonly TEXTURETYPE_SHORT: number;
  30678. /** UNSIGNED_SHORT */
  30679. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30680. /** INT */
  30681. static readonly TEXTURETYPE_INT: number;
  30682. /** UNSIGNED_INT */
  30683. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30684. /** UNSIGNED_SHORT_4_4_4_4 */
  30685. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30686. /** UNSIGNED_SHORT_5_5_5_1 */
  30687. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30688. /** UNSIGNED_SHORT_5_6_5 */
  30689. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30690. /** UNSIGNED_INT_2_10_10_10_REV */
  30691. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30692. /** UNSIGNED_INT_24_8 */
  30693. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30694. /** UNSIGNED_INT_10F_11F_11F_REV */
  30695. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30696. /** UNSIGNED_INT_5_9_9_9_REV */
  30697. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30698. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30699. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30700. /** nearest is mag = nearest and min = nearest and mip = linear */
  30701. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30702. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30703. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30704. /** Trilinear is mag = linear and min = linear and mip = linear */
  30705. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30706. /** nearest is mag = nearest and min = nearest and mip = linear */
  30707. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30708. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30709. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30710. /** Trilinear is mag = linear and min = linear and mip = linear */
  30711. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30712. /** mag = nearest and min = nearest and mip = nearest */
  30713. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30714. /** mag = nearest and min = linear and mip = nearest */
  30715. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30716. /** mag = nearest and min = linear and mip = linear */
  30717. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30718. /** mag = nearest and min = linear and mip = none */
  30719. static readonly TEXTURE_NEAREST_LINEAR: number;
  30720. /** mag = nearest and min = nearest and mip = none */
  30721. static readonly TEXTURE_NEAREST_NEAREST: number;
  30722. /** mag = linear and min = nearest and mip = nearest */
  30723. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30724. /** mag = linear and min = nearest and mip = linear */
  30725. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30726. /** mag = linear and min = linear and mip = none */
  30727. static readonly TEXTURE_LINEAR_LINEAR: number;
  30728. /** mag = linear and min = nearest and mip = none */
  30729. static readonly TEXTURE_LINEAR_NEAREST: number;
  30730. /** Explicit coordinates mode */
  30731. static readonly TEXTURE_EXPLICIT_MODE: number;
  30732. /** Spherical coordinates mode */
  30733. static readonly TEXTURE_SPHERICAL_MODE: number;
  30734. /** Planar coordinates mode */
  30735. static readonly TEXTURE_PLANAR_MODE: number;
  30736. /** Cubic coordinates mode */
  30737. static readonly TEXTURE_CUBIC_MODE: number;
  30738. /** Projection coordinates mode */
  30739. static readonly TEXTURE_PROJECTION_MODE: number;
  30740. /** Skybox coordinates mode */
  30741. static readonly TEXTURE_SKYBOX_MODE: number;
  30742. /** Inverse Cubic coordinates mode */
  30743. static readonly TEXTURE_INVCUBIC_MODE: number;
  30744. /** Equirectangular coordinates mode */
  30745. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30746. /** Equirectangular Fixed coordinates mode */
  30747. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30748. /** Equirectangular Fixed Mirrored coordinates mode */
  30749. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30750. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30751. static readonly SCALEMODE_FLOOR: number;
  30752. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30753. static readonly SCALEMODE_NEAREST: number;
  30754. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30755. static readonly SCALEMODE_CEILING: number;
  30756. /**
  30757. * Returns the current npm package of the sdk
  30758. */
  30759. static readonly NpmPackage: string;
  30760. /**
  30761. * Returns the current version of the framework
  30762. */
  30763. static readonly Version: string;
  30764. /**
  30765. * Returns a string describing the current engine
  30766. */
  30767. readonly description: string;
  30768. /**
  30769. * Gets or sets the epsilon value used by collision engine
  30770. */
  30771. static CollisionsEpsilon: number;
  30772. /**
  30773. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30774. */
  30775. static ShadersRepository: string;
  30776. /**
  30777. * Method called to create the default loading screen.
  30778. * This can be overriden in your own app.
  30779. * @param canvas The rendering canvas element
  30780. * @returns The loading screen
  30781. */
  30782. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30783. /**
  30784. * Method called to create the default rescale post process on each engine.
  30785. */
  30786. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30787. /** @hidden */
  30788. _shaderProcessor: IShaderProcessor;
  30789. /**
  30790. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30791. */
  30792. forcePOTTextures: boolean;
  30793. /**
  30794. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30795. */
  30796. isFullscreen: boolean;
  30797. /**
  30798. * Gets a boolean indicating if the pointer is currently locked
  30799. */
  30800. isPointerLock: boolean;
  30801. /**
  30802. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30803. */
  30804. cullBackFaces: boolean;
  30805. /**
  30806. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30807. */
  30808. renderEvenInBackground: boolean;
  30809. /**
  30810. * Gets or sets a boolean indicating that cache can be kept between frames
  30811. */
  30812. preventCacheWipeBetweenFrames: boolean;
  30813. /**
  30814. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30815. **/
  30816. enableOfflineSupport: boolean;
  30817. /**
  30818. * 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)
  30819. **/
  30820. disableManifestCheck: boolean;
  30821. /**
  30822. * Gets the list of created scenes
  30823. */
  30824. scenes: Scene[];
  30825. /**
  30826. * Event raised when a new scene is created
  30827. */
  30828. onNewSceneAddedObservable: Observable<Scene>;
  30829. /**
  30830. * Gets the list of created postprocesses
  30831. */
  30832. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  30833. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30834. validateShaderPrograms: boolean;
  30835. /**
  30836. * Observable event triggered each time the rendering canvas is resized
  30837. */
  30838. onResizeObservable: Observable<Engine>;
  30839. /**
  30840. * Observable event triggered each time the canvas loses focus
  30841. */
  30842. onCanvasBlurObservable: Observable<Engine>;
  30843. /**
  30844. * Observable event triggered each time the canvas gains focus
  30845. */
  30846. onCanvasFocusObservable: Observable<Engine>;
  30847. /**
  30848. * Observable event triggered each time the canvas receives pointerout event
  30849. */
  30850. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30851. /**
  30852. * Observable event triggered before each texture is initialized
  30853. */
  30854. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30855. /**
  30856. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30857. */
  30858. disableUniformBuffers: boolean;
  30859. /** @hidden */
  30860. _uniformBuffers: UniformBuffer[];
  30861. /**
  30862. * Gets a boolean indicating that the engine supports uniform buffers
  30863. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30864. */
  30865. readonly supportsUniformBuffers: boolean;
  30866. /**
  30867. * Observable raised when the engine begins a new frame
  30868. */
  30869. onBeginFrameObservable: Observable<Engine>;
  30870. /**
  30871. * If set, will be used to request the next animation frame for the render loop
  30872. */
  30873. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30874. /**
  30875. * Observable raised when the engine ends the current frame
  30876. */
  30877. onEndFrameObservable: Observable<Engine>;
  30878. /**
  30879. * Observable raised when the engine is about to compile a shader
  30880. */
  30881. onBeforeShaderCompilationObservable: Observable<Engine>;
  30882. /**
  30883. * Observable raised when the engine has jsut compiled a shader
  30884. */
  30885. onAfterShaderCompilationObservable: Observable<Engine>;
  30886. /** @hidden */
  30887. _gl: WebGLRenderingContext;
  30888. private _renderingCanvas;
  30889. private _windowIsBackground;
  30890. private _webGLVersion;
  30891. protected _highPrecisionShadersAllowed: boolean;
  30892. /** @hidden */
  30893. readonly _shouldUseHighPrecisionShader: boolean;
  30894. /**
  30895. * Gets a boolean indicating that only power of 2 textures are supported
  30896. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30897. */
  30898. readonly needPOTTextures: boolean;
  30899. /** @hidden */
  30900. _badOS: boolean;
  30901. /** @hidden */
  30902. _badDesktopOS: boolean;
  30903. /**
  30904. * Gets the audio engine
  30905. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30906. * @ignorenaming
  30907. */
  30908. static audioEngine: IAudioEngine;
  30909. /**
  30910. * Default AudioEngine factory responsible of creating the Audio Engine.
  30911. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30912. */
  30913. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30914. /**
  30915. * Default offline support factory responsible of creating a tool used to store data locally.
  30916. * By default, this will create a Database object if the workload has been embedded.
  30917. */
  30918. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30919. private _onFocus;
  30920. private _onBlur;
  30921. private _onCanvasPointerOut;
  30922. private _onCanvasBlur;
  30923. private _onCanvasFocus;
  30924. private _onFullscreenChange;
  30925. private _onPointerLockChange;
  30926. private _hardwareScalingLevel;
  30927. /** @hidden */
  30928. _caps: EngineCapabilities;
  30929. private _pointerLockRequested;
  30930. private _isStencilEnable;
  30931. private _colorWrite;
  30932. private _loadingScreen;
  30933. /** @hidden */
  30934. _drawCalls: PerfCounter;
  30935. private _glVersion;
  30936. private _glRenderer;
  30937. private _glVendor;
  30938. private _videoTextureSupported;
  30939. private _renderingQueueLaunched;
  30940. private _activeRenderLoops;
  30941. private _deterministicLockstep;
  30942. private _lockstepMaxSteps;
  30943. /**
  30944. * Observable signaled when a context lost event is raised
  30945. */
  30946. onContextLostObservable: Observable<Engine>;
  30947. /**
  30948. * Observable signaled when a context restored event is raised
  30949. */
  30950. onContextRestoredObservable: Observable<Engine>;
  30951. private _onContextLost;
  30952. private _onContextRestored;
  30953. private _contextWasLost;
  30954. /** @hidden */
  30955. _doNotHandleContextLost: boolean;
  30956. /**
  30957. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30958. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30959. */
  30960. doNotHandleContextLost: boolean;
  30961. private _performanceMonitor;
  30962. private _fps;
  30963. private _deltaTime;
  30964. /**
  30965. * Turn this value on if you want to pause FPS computation when in background
  30966. */
  30967. disablePerformanceMonitorInBackground: boolean;
  30968. /**
  30969. * Gets the performance monitor attached to this engine
  30970. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30971. */
  30972. readonly performanceMonitor: PerformanceMonitor;
  30973. /**
  30974. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30975. */
  30976. disableVertexArrayObjects: boolean;
  30977. /** @hidden */
  30978. protected _depthCullingState: _DepthCullingState;
  30979. /** @hidden */
  30980. protected _stencilState: _StencilState;
  30981. /** @hidden */
  30982. protected _alphaState: _AlphaState;
  30983. /** @hidden */
  30984. protected _alphaMode: number;
  30985. /** @hidden */
  30986. _internalTexturesCache: InternalTexture[];
  30987. /** @hidden */
  30988. protected _activeChannel: number;
  30989. private _currentTextureChannel;
  30990. /** @hidden */
  30991. protected _boundTexturesCache: {
  30992. [key: string]: Nullable<InternalTexture>;
  30993. };
  30994. /** @hidden */
  30995. protected _currentEffect: Nullable<Effect>;
  30996. /** @hidden */
  30997. protected _currentProgram: Nullable<WebGLProgram>;
  30998. private _compiledEffects;
  30999. private _vertexAttribArraysEnabled;
  31000. /** @hidden */
  31001. protected _cachedViewport: Nullable<IViewportLike>;
  31002. private _cachedVertexArrayObject;
  31003. /** @hidden */
  31004. protected _cachedVertexBuffers: any;
  31005. /** @hidden */
  31006. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31007. /** @hidden */
  31008. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31009. /** @hidden */
  31010. _currentRenderTarget: Nullable<InternalTexture>;
  31011. private _uintIndicesCurrentlySet;
  31012. private _currentBoundBuffer;
  31013. /** @hidden */
  31014. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31015. private _currentBufferPointers;
  31016. private _currentInstanceLocations;
  31017. private _currentInstanceBuffers;
  31018. private _textureUnits;
  31019. /** @hidden */
  31020. _workingCanvas: Nullable<HTMLCanvasElement>;
  31021. /** @hidden */
  31022. _workingContext: Nullable<CanvasRenderingContext2D>;
  31023. private _rescalePostProcess;
  31024. private _dummyFramebuffer;
  31025. private _externalData;
  31026. /** @hidden */
  31027. _bindedRenderFunction: any;
  31028. private _vaoRecordInProgress;
  31029. private _mustWipeVertexAttributes;
  31030. private _emptyTexture;
  31031. private _emptyCubeTexture;
  31032. private _emptyTexture3D;
  31033. /** @hidden */
  31034. _frameHandler: number;
  31035. private _nextFreeTextureSlots;
  31036. private _maxSimultaneousTextures;
  31037. private _activeRequests;
  31038. private _texturesSupported;
  31039. /** @hidden */
  31040. _textureFormatInUse: Nullable<string>;
  31041. /**
  31042. * Gets the list of texture formats supported
  31043. */
  31044. readonly texturesSupported: Array<string>;
  31045. /**
  31046. * Gets the list of texture formats in use
  31047. */
  31048. readonly textureFormatInUse: Nullable<string>;
  31049. /**
  31050. * Gets the current viewport
  31051. */
  31052. readonly currentViewport: Nullable<IViewportLike>;
  31053. /**
  31054. * Gets the default empty texture
  31055. */
  31056. readonly emptyTexture: InternalTexture;
  31057. /**
  31058. * Gets the default empty 3D texture
  31059. */
  31060. readonly emptyTexture3D: InternalTexture;
  31061. /**
  31062. * Gets the default empty cube texture
  31063. */
  31064. readonly emptyCubeTexture: InternalTexture;
  31065. /**
  31066. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31067. */
  31068. readonly premultipliedAlpha: boolean;
  31069. /**
  31070. * Creates a new engine
  31071. * @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
  31072. * @param antialias defines enable antialiasing (default: false)
  31073. * @param options defines further options to be sent to the getContext() function
  31074. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31075. */
  31076. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31077. /**
  31078. * Initializes a webVR display and starts listening to display change events
  31079. * The onVRDisplayChangedObservable will be notified upon these changes
  31080. * @returns The onVRDisplayChangedObservable
  31081. */
  31082. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31083. /** @hidden */
  31084. _prepareVRComponent(): void;
  31085. /** @hidden */
  31086. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  31087. /** @hidden */
  31088. _submitVRFrame(): void;
  31089. /**
  31090. * Call this function to leave webVR mode
  31091. * Will do nothing if webVR is not supported or if there is no webVR device
  31092. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31093. */
  31094. disableVR(): void;
  31095. /**
  31096. * Gets a boolean indicating that the system is in VR mode and is presenting
  31097. * @returns true if VR mode is engaged
  31098. */
  31099. isVRPresenting(): boolean;
  31100. /** @hidden */
  31101. _requestVRFrame(): void;
  31102. private _disableTouchAction;
  31103. private _rebuildInternalTextures;
  31104. private _rebuildEffects;
  31105. /**
  31106. * Gets a boolean indicating if all created effects are ready
  31107. * @returns true if all effects are ready
  31108. */
  31109. areAllEffectsReady(): boolean;
  31110. private _rebuildBuffers;
  31111. private _initGLContext;
  31112. /**
  31113. * Gets version of the current webGL context
  31114. */
  31115. readonly webGLVersion: number;
  31116. /**
  31117. * Gets a string idenfifying the name of the class
  31118. * @returns "Engine" string
  31119. */
  31120. getClassName(): string;
  31121. /**
  31122. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31123. */
  31124. readonly isStencilEnable: boolean;
  31125. /** @hidden */
  31126. _prepareWorkingCanvas(): void;
  31127. /**
  31128. * Reset the texture cache to empty state
  31129. */
  31130. resetTextureCache(): void;
  31131. /**
  31132. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31133. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31134. * @returns true if engine is in deterministic lock step mode
  31135. */
  31136. isDeterministicLockStep(): boolean;
  31137. /**
  31138. * Gets the max steps when engine is running in deterministic lock step
  31139. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31140. * @returns the max steps
  31141. */
  31142. getLockstepMaxSteps(): number;
  31143. /**
  31144. * Gets an object containing information about the current webGL context
  31145. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31146. */
  31147. getGlInfo(): {
  31148. vendor: string;
  31149. renderer: string;
  31150. version: string;
  31151. };
  31152. /**
  31153. * Gets current aspect ratio
  31154. * @param viewportOwner defines the camera to use to get the aspect ratio
  31155. * @param useScreen defines if screen size must be used (or the current render target if any)
  31156. * @returns a number defining the aspect ratio
  31157. */
  31158. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31159. /**
  31160. * Gets current screen aspect ratio
  31161. * @returns a number defining the aspect ratio
  31162. */
  31163. getScreenAspectRatio(): number;
  31164. /**
  31165. * Gets the current render width
  31166. * @param useScreen defines if screen size must be used (or the current render target if any)
  31167. * @returns a number defining the current render width
  31168. */
  31169. getRenderWidth(useScreen?: boolean): number;
  31170. /**
  31171. * Gets the current render height
  31172. * @param useScreen defines if screen size must be used (or the current render target if any)
  31173. * @returns a number defining the current render height
  31174. */
  31175. getRenderHeight(useScreen?: boolean): number;
  31176. /**
  31177. * Gets the HTML canvas attached with the current webGL context
  31178. * @returns a HTML canvas
  31179. */
  31180. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31181. /**
  31182. * Gets the client rect of the HTML canvas attached with the current webGL context
  31183. * @returns a client rectanglee
  31184. */
  31185. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31186. /**
  31187. * Defines the hardware scaling level.
  31188. * By default the hardware scaling level is computed from the window device ratio.
  31189. * 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.
  31190. * @param level defines the level to use
  31191. */
  31192. setHardwareScalingLevel(level: number): void;
  31193. /**
  31194. * Gets the current hardware scaling level.
  31195. * By default the hardware scaling level is computed from the window device ratio.
  31196. * 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.
  31197. * @returns a number indicating the current hardware scaling level
  31198. */
  31199. getHardwareScalingLevel(): number;
  31200. /**
  31201. * Gets the list of loaded textures
  31202. * @returns an array containing all loaded textures
  31203. */
  31204. getLoadedTexturesCache(): InternalTexture[];
  31205. /**
  31206. * Gets the object containing all engine capabilities
  31207. * @returns the EngineCapabilities object
  31208. */
  31209. getCaps(): EngineCapabilities;
  31210. /**
  31211. * Gets the current depth function
  31212. * @returns a number defining the depth function
  31213. */
  31214. getDepthFunction(): Nullable<number>;
  31215. /**
  31216. * Sets the current depth function
  31217. * @param depthFunc defines the function to use
  31218. */
  31219. setDepthFunction(depthFunc: number): void;
  31220. /**
  31221. * Sets the current depth function to GREATER
  31222. */
  31223. setDepthFunctionToGreater(): void;
  31224. /**
  31225. * Sets the current depth function to GEQUAL
  31226. */
  31227. setDepthFunctionToGreaterOrEqual(): void;
  31228. /**
  31229. * Sets the current depth function to LESS
  31230. */
  31231. setDepthFunctionToLess(): void;
  31232. private _cachedStencilBuffer;
  31233. private _cachedStencilFunction;
  31234. private _cachedStencilMask;
  31235. private _cachedStencilOperationPass;
  31236. private _cachedStencilOperationFail;
  31237. private _cachedStencilOperationDepthFail;
  31238. private _cachedStencilReference;
  31239. /**
  31240. * Caches the the state of the stencil buffer
  31241. */
  31242. cacheStencilState(): void;
  31243. /**
  31244. * Restores the state of the stencil buffer
  31245. */
  31246. restoreStencilState(): void;
  31247. /**
  31248. * Sets the current depth function to LEQUAL
  31249. */
  31250. setDepthFunctionToLessOrEqual(): void;
  31251. /**
  31252. * Gets a boolean indicating if stencil buffer is enabled
  31253. * @returns the current stencil buffer state
  31254. */
  31255. getStencilBuffer(): boolean;
  31256. /**
  31257. * Enable or disable the stencil buffer
  31258. * @param enable defines if the stencil buffer must be enabled or disabled
  31259. */
  31260. setStencilBuffer(enable: boolean): void;
  31261. /**
  31262. * Gets the current stencil mask
  31263. * @returns a number defining the new stencil mask to use
  31264. */
  31265. getStencilMask(): number;
  31266. /**
  31267. * Sets the current stencil mask
  31268. * @param mask defines the new stencil mask to use
  31269. */
  31270. setStencilMask(mask: number): void;
  31271. /**
  31272. * Gets the current stencil function
  31273. * @returns a number defining the stencil function to use
  31274. */
  31275. getStencilFunction(): number;
  31276. /**
  31277. * Gets the current stencil reference value
  31278. * @returns a number defining the stencil reference value to use
  31279. */
  31280. getStencilFunctionReference(): number;
  31281. /**
  31282. * Gets the current stencil mask
  31283. * @returns a number defining the stencil mask to use
  31284. */
  31285. getStencilFunctionMask(): number;
  31286. /**
  31287. * Sets the current stencil function
  31288. * @param stencilFunc defines the new stencil function to use
  31289. */
  31290. setStencilFunction(stencilFunc: number): void;
  31291. /**
  31292. * Sets the current stencil reference
  31293. * @param reference defines the new stencil reference to use
  31294. */
  31295. setStencilFunctionReference(reference: number): void;
  31296. /**
  31297. * Sets the current stencil mask
  31298. * @param mask defines the new stencil mask to use
  31299. */
  31300. setStencilFunctionMask(mask: number): void;
  31301. /**
  31302. * Gets the current stencil operation when stencil fails
  31303. * @returns a number defining stencil operation to use when stencil fails
  31304. */
  31305. getStencilOperationFail(): number;
  31306. /**
  31307. * Gets the current stencil operation when depth fails
  31308. * @returns a number defining stencil operation to use when depth fails
  31309. */
  31310. getStencilOperationDepthFail(): number;
  31311. /**
  31312. * Gets the current stencil operation when stencil passes
  31313. * @returns a number defining stencil operation to use when stencil passes
  31314. */
  31315. getStencilOperationPass(): number;
  31316. /**
  31317. * Sets the stencil operation to use when stencil fails
  31318. * @param operation defines the stencil operation to use when stencil fails
  31319. */
  31320. setStencilOperationFail(operation: number): void;
  31321. /**
  31322. * Sets the stencil operation to use when depth fails
  31323. * @param operation defines the stencil operation to use when depth fails
  31324. */
  31325. setStencilOperationDepthFail(operation: number): void;
  31326. /**
  31327. * Sets the stencil operation to use when stencil passes
  31328. * @param operation defines the stencil operation to use when stencil passes
  31329. */
  31330. setStencilOperationPass(operation: number): void;
  31331. /**
  31332. * Sets a boolean indicating if the dithering state is enabled or disabled
  31333. * @param value defines the dithering state
  31334. */
  31335. setDitheringState(value: boolean): void;
  31336. /**
  31337. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31338. * @param value defines the rasterizer state
  31339. */
  31340. setRasterizerState(value: boolean): void;
  31341. /**
  31342. * stop executing a render loop function and remove it from the execution array
  31343. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31344. */
  31345. stopRenderLoop(renderFunction?: () => void): void;
  31346. /** @hidden */
  31347. _renderLoop(): void;
  31348. /**
  31349. * Register and execute a render loop. The engine can have more than one render function
  31350. * @param renderFunction defines the function to continuously execute
  31351. */
  31352. runRenderLoop(renderFunction: () => void): void;
  31353. /**
  31354. * Toggle full screen mode
  31355. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31356. */
  31357. switchFullscreen(requestPointerLock: boolean): void;
  31358. /**
  31359. * Enters full screen mode
  31360. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31361. */
  31362. enterFullscreen(requestPointerLock: boolean): void;
  31363. /**
  31364. * Exits full screen mode
  31365. */
  31366. exitFullscreen(): void;
  31367. /**
  31368. * Enters Pointerlock mode
  31369. */
  31370. enterPointerlock(): void;
  31371. /**
  31372. * Exits Pointerlock mode
  31373. */
  31374. exitPointerlock(): void;
  31375. /**
  31376. * Clear the current render buffer or the current render target (if any is set up)
  31377. * @param color defines the color to use
  31378. * @param backBuffer defines if the back buffer must be cleared
  31379. * @param depth defines if the depth buffer must be cleared
  31380. * @param stencil defines if the stencil buffer must be cleared
  31381. */
  31382. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31383. /**
  31384. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31385. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31386. * @param y defines the y-coordinate of the corner of the clear rectangle
  31387. * @param width defines the width of the clear rectangle
  31388. * @param height defines the height of the clear rectangle
  31389. * @param clearColor defines the clear color
  31390. */
  31391. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31392. /**
  31393. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31394. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31395. * @param y defines the y-coordinate of the corner of the clear rectangle
  31396. * @param width defines the width of the clear rectangle
  31397. * @param height defines the height of the clear rectangle
  31398. */
  31399. enableScissor(x: number, y: number, width: number, height: number): void;
  31400. /**
  31401. * Disable previously set scissor test rectangle
  31402. */
  31403. disableScissor(): void;
  31404. private _viewportCached;
  31405. /** @hidden */
  31406. _viewport(x: number, y: number, width: number, height: number): void;
  31407. /**
  31408. * Set the WebGL's viewport
  31409. * @param viewport defines the viewport element to be used
  31410. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31411. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31412. */
  31413. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31414. /**
  31415. * Directly set the WebGL Viewport
  31416. * @param x defines the x coordinate of the viewport (in screen space)
  31417. * @param y defines the y coordinate of the viewport (in screen space)
  31418. * @param width defines the width of the viewport (in screen space)
  31419. * @param height defines the height of the viewport (in screen space)
  31420. * @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
  31421. */
  31422. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31423. /**
  31424. * Begin a new frame
  31425. */
  31426. beginFrame(): void;
  31427. /**
  31428. * Enf the current frame
  31429. */
  31430. endFrame(): void;
  31431. /**
  31432. * Resize the view according to the canvas' size
  31433. */
  31434. resize(): void;
  31435. /**
  31436. * Force a specific size of the canvas
  31437. * @param width defines the new canvas' width
  31438. * @param height defines the new canvas' height
  31439. */
  31440. setSize(width: number, height: number): void;
  31441. /**
  31442. * Binds the frame buffer to the specified texture.
  31443. * @param texture The texture to render to or null for the default canvas
  31444. * @param faceIndex The face of the texture to render to in case of cube texture
  31445. * @param requiredWidth The width of the target to render to
  31446. * @param requiredHeight The height of the target to render to
  31447. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31448. * @param depthStencilTexture The depth stencil texture to use to render
  31449. * @param lodLevel defines le lod level to bind to the frame buffer
  31450. */
  31451. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31452. /** @hidden */
  31453. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31454. /**
  31455. * Unbind the current render target texture from the webGL context
  31456. * @param texture defines the render target texture to unbind
  31457. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31458. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31459. */
  31460. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31461. /**
  31462. * Force the mipmap generation for the given render target texture
  31463. * @param texture defines the render target texture to use
  31464. */
  31465. generateMipMapsForCubemap(texture: InternalTexture): void;
  31466. /**
  31467. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31468. */
  31469. flushFramebuffer(): void;
  31470. /**
  31471. * Unbind the current render target and bind the default framebuffer
  31472. */
  31473. restoreDefaultFramebuffer(): void;
  31474. /**
  31475. * Create an uniform buffer
  31476. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31477. * @param elements defines the content of the uniform buffer
  31478. * @returns the webGL uniform buffer
  31479. */
  31480. createUniformBuffer(elements: FloatArray): DataBuffer;
  31481. /**
  31482. * Create a dynamic uniform buffer
  31483. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31484. * @param elements defines the content of the uniform buffer
  31485. * @returns the webGL uniform buffer
  31486. */
  31487. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  31488. /**
  31489. * Update an existing uniform buffer
  31490. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31491. * @param uniformBuffer defines the target uniform buffer
  31492. * @param elements defines the content to update
  31493. * @param offset defines the offset in the uniform buffer where update should start
  31494. * @param count defines the size of the data to update
  31495. */
  31496. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  31497. private _resetVertexBufferBinding;
  31498. /**
  31499. * Creates a vertex buffer
  31500. * @param data the data for the vertex buffer
  31501. * @returns the new WebGL static buffer
  31502. */
  31503. createVertexBuffer(data: DataArray): DataBuffer;
  31504. /**
  31505. * Creates a dynamic vertex buffer
  31506. * @param data the data for the dynamic vertex buffer
  31507. * @returns the new WebGL dynamic buffer
  31508. */
  31509. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31510. /**
  31511. * Update a dynamic index buffer
  31512. * @param indexBuffer defines the target index buffer
  31513. * @param indices defines the data to update
  31514. * @param offset defines the offset in the target index buffer where update should start
  31515. */
  31516. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31517. /**
  31518. * Updates a dynamic vertex buffer.
  31519. * @param vertexBuffer the vertex buffer to update
  31520. * @param data the data used to update the vertex buffer
  31521. * @param byteOffset the byte offset of the data
  31522. * @param byteLength the byte length of the data
  31523. */
  31524. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31525. private _resetIndexBufferBinding;
  31526. /**
  31527. * Creates a new index buffer
  31528. * @param indices defines the content of the index buffer
  31529. * @param updatable defines if the index buffer must be updatable
  31530. * @returns a new webGL buffer
  31531. */
  31532. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31533. /**
  31534. * Bind a webGL buffer to the webGL context
  31535. * @param buffer defines the buffer to bind
  31536. */
  31537. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31538. /**
  31539. * Bind an uniform buffer to the current webGL context
  31540. * @param buffer defines the buffer to bind
  31541. */
  31542. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  31543. /**
  31544. * Bind a buffer to the current webGL context at a given location
  31545. * @param buffer defines the buffer to bind
  31546. * @param location defines the index where to bind the buffer
  31547. */
  31548. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  31549. /**
  31550. * Bind a specific block at a given index in a specific shader program
  31551. * @param pipelineContext defines the pipeline context to use
  31552. * @param blockName defines the block name
  31553. * @param index defines the index where to bind the block
  31554. */
  31555. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  31556. private bindIndexBuffer;
  31557. private bindBuffer;
  31558. /**
  31559. * update the bound buffer with the given data
  31560. * @param data defines the data to update
  31561. */
  31562. updateArrayBuffer(data: Float32Array): void;
  31563. private _vertexAttribPointer;
  31564. private _bindIndexBufferWithCache;
  31565. private _bindVertexBuffersAttributes;
  31566. /**
  31567. * Records a vertex array object
  31568. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31569. * @param vertexBuffers defines the list of vertex buffers to store
  31570. * @param indexBuffer defines the index buffer to store
  31571. * @param effect defines the effect to store
  31572. * @returns the new vertex array object
  31573. */
  31574. recordVertexArrayObject(vertexBuffers: {
  31575. [key: string]: VertexBuffer;
  31576. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31577. /**
  31578. * Bind a specific vertex array object
  31579. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31580. * @param vertexArrayObject defines the vertex array object to bind
  31581. * @param indexBuffer defines the index buffer to bind
  31582. */
  31583. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31584. /**
  31585. * Bind webGl buffers directly to the webGL context
  31586. * @param vertexBuffer defines the vertex buffer to bind
  31587. * @param indexBuffer defines the index buffer to bind
  31588. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31589. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31590. * @param effect defines the effect associated with the vertex buffer
  31591. */
  31592. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31593. private _unbindVertexArrayObject;
  31594. /**
  31595. * Bind a list of vertex buffers to the webGL context
  31596. * @param vertexBuffers defines the list of vertex buffers to bind
  31597. * @param indexBuffer defines the index buffer to bind
  31598. * @param effect defines the effect associated with the vertex buffers
  31599. */
  31600. bindBuffers(vertexBuffers: {
  31601. [key: string]: Nullable<VertexBuffer>;
  31602. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31603. /**
  31604. * Unbind all instance attributes
  31605. */
  31606. unbindInstanceAttributes(): void;
  31607. /**
  31608. * Release and free the memory of a vertex array object
  31609. * @param vao defines the vertex array object to delete
  31610. */
  31611. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31612. /** @hidden */
  31613. _releaseBuffer(buffer: DataBuffer): boolean;
  31614. /**
  31615. * Creates a webGL buffer to use with instanciation
  31616. * @param capacity defines the size of the buffer
  31617. * @returns the webGL buffer
  31618. */
  31619. createInstancesBuffer(capacity: number): DataBuffer;
  31620. /**
  31621. * Delete a webGL buffer used with instanciation
  31622. * @param buffer defines the webGL buffer to delete
  31623. */
  31624. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31625. /**
  31626. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31627. * @param instancesBuffer defines the webGL buffer to update and bind
  31628. * @param data defines the data to store in the buffer
  31629. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31630. */
  31631. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31632. /**
  31633. * Apply all cached states (depth, culling, stencil and alpha)
  31634. */
  31635. applyStates(): void;
  31636. /**
  31637. * Send a draw order
  31638. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31639. * @param indexStart defines the starting index
  31640. * @param indexCount defines the number of index to draw
  31641. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31642. */
  31643. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31644. /**
  31645. * Draw a list of points
  31646. * @param verticesStart defines the index of first vertex to draw
  31647. * @param verticesCount defines the count of vertices to draw
  31648. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31649. */
  31650. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31651. /**
  31652. * Draw a list of unindexed primitives
  31653. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31654. * @param verticesStart defines the index of first vertex to draw
  31655. * @param verticesCount defines the count of vertices to draw
  31656. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31657. */
  31658. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31659. /**
  31660. * Draw a list of indexed primitives
  31661. * @param fillMode defines the primitive to use
  31662. * @param indexStart defines the starting index
  31663. * @param indexCount defines the number of index to draw
  31664. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31665. */
  31666. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31667. /**
  31668. * Draw a list of unindexed primitives
  31669. * @param fillMode defines the primitive to use
  31670. * @param verticesStart defines the index of first vertex to draw
  31671. * @param verticesCount defines the count of vertices to draw
  31672. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31673. */
  31674. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31675. private _drawMode;
  31676. /** @hidden */
  31677. _releaseEffect(effect: Effect): void;
  31678. /** @hidden */
  31679. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31680. /**
  31681. * Create a new effect (used to store vertex/fragment shaders)
  31682. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31683. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31684. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31685. * @param samplers defines an array of string used to represent textures
  31686. * @param defines defines the string containing the defines to use to compile the shaders
  31687. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31688. * @param onCompiled defines a function to call when the effect creation is successful
  31689. * @param onError defines a function to call when the effect creation has failed
  31690. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31691. * @returns the new Effect
  31692. */
  31693. 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;
  31694. private _compileShader;
  31695. private _compileRawShader;
  31696. /**
  31697. * Directly creates a webGL program
  31698. * @param pipelineContext defines the pipeline context to attach to
  31699. * @param vertexCode defines the vertex shader code to use
  31700. * @param fragmentCode defines the fragment shader code to use
  31701. * @param context defines the webGL context to use (if not set, the current one will be used)
  31702. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31703. * @returns the new webGL program
  31704. */
  31705. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31706. /**
  31707. * Creates a webGL program
  31708. * @param pipelineContext defines the pipeline context to attach to
  31709. * @param vertexCode defines the vertex shader code to use
  31710. * @param fragmentCode defines the fragment shader code to use
  31711. * @param defines defines the string containing the defines to use to compile the shaders
  31712. * @param context defines the webGL context to use (if not set, the current one will be used)
  31713. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31714. * @returns the new webGL program
  31715. */
  31716. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31717. /**
  31718. * Creates a new pipeline context
  31719. * @returns the new pipeline
  31720. */
  31721. createPipelineContext(): WebGLPipelineContext;
  31722. private _createShaderProgram;
  31723. private _finalizePipelineContext;
  31724. /** @hidden */
  31725. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31726. /** @hidden */
  31727. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31728. /** @hidden */
  31729. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31730. /**
  31731. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31732. * @param pipelineContext defines the pipeline context to use
  31733. * @param uniformsNames defines the list of uniform names
  31734. * @returns an array of webGL uniform locations
  31735. */
  31736. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31737. /**
  31738. * Gets the lsit of active attributes for a given webGL program
  31739. * @param pipelineContext defines the pipeline context to use
  31740. * @param attributesNames defines the list of attribute names to get
  31741. * @returns an array of indices indicating the offset of each attribute
  31742. */
  31743. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31744. /**
  31745. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31746. * @param effect defines the effect to activate
  31747. */
  31748. enableEffect(effect: Nullable<Effect>): void;
  31749. /**
  31750. * Set the value of an uniform to an array of int32
  31751. * @param uniform defines the webGL uniform location where to store the value
  31752. * @param array defines the array of int32 to store
  31753. */
  31754. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31755. /**
  31756. * Set the value of an uniform to an array of int32 (stored as vec2)
  31757. * @param uniform defines the webGL uniform location where to store the value
  31758. * @param array defines the array of int32 to store
  31759. */
  31760. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31761. /**
  31762. * Set the value of an uniform to an array of int32 (stored as vec3)
  31763. * @param uniform defines the webGL uniform location where to store the value
  31764. * @param array defines the array of int32 to store
  31765. */
  31766. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31767. /**
  31768. * Set the value of an uniform to an array of int32 (stored as vec4)
  31769. * @param uniform defines the webGL uniform location where to store the value
  31770. * @param array defines the array of int32 to store
  31771. */
  31772. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31773. /**
  31774. * Set the value of an uniform to an array of float32
  31775. * @param uniform defines the webGL uniform location where to store the value
  31776. * @param array defines the array of float32 to store
  31777. */
  31778. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31779. /**
  31780. * Set the value of an uniform to an array of float32 (stored as vec2)
  31781. * @param uniform defines the webGL uniform location where to store the value
  31782. * @param array defines the array of float32 to store
  31783. */
  31784. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31785. /**
  31786. * Set the value of an uniform to an array of float32 (stored as vec3)
  31787. * @param uniform defines the webGL uniform location where to store the value
  31788. * @param array defines the array of float32 to store
  31789. */
  31790. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31791. /**
  31792. * Set the value of an uniform to an array of float32 (stored as vec4)
  31793. * @param uniform defines the webGL uniform location where to store the value
  31794. * @param array defines the array of float32 to store
  31795. */
  31796. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31797. /**
  31798. * Set the value of an uniform to an array of number
  31799. * @param uniform defines the webGL uniform location where to store the value
  31800. * @param array defines the array of number to store
  31801. */
  31802. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31803. /**
  31804. * Set the value of an uniform to an array of number (stored as vec2)
  31805. * @param uniform defines the webGL uniform location where to store the value
  31806. * @param array defines the array of number to store
  31807. */
  31808. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31809. /**
  31810. * Set the value of an uniform to an array of number (stored as vec3)
  31811. * @param uniform defines the webGL uniform location where to store the value
  31812. * @param array defines the array of number to store
  31813. */
  31814. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31815. /**
  31816. * Set the value of an uniform to an array of number (stored as vec4)
  31817. * @param uniform defines the webGL uniform location where to store the value
  31818. * @param array defines the array of number to store
  31819. */
  31820. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31821. /**
  31822. * Set the value of an uniform to an array of float32 (stored as matrices)
  31823. * @param uniform defines the webGL uniform location where to store the value
  31824. * @param matrices defines the array of float32 to store
  31825. */
  31826. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31827. /**
  31828. * Set the value of an uniform to a matrix (3x3)
  31829. * @param uniform defines the webGL uniform location where to store the value
  31830. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31831. */
  31832. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31833. /**
  31834. * Set the value of an uniform to a matrix (2x2)
  31835. * @param uniform defines the webGL uniform location where to store the value
  31836. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31837. */
  31838. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31839. /**
  31840. * Set the value of an uniform to a number (int)
  31841. * @param uniform defines the webGL uniform location where to store the value
  31842. * @param value defines the int number to store
  31843. */
  31844. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31845. /**
  31846. * Set the value of an uniform to a number (float)
  31847. * @param uniform defines the webGL uniform location where to store the value
  31848. * @param value defines the float number to store
  31849. */
  31850. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31851. /**
  31852. * Set the value of an uniform to a vec2
  31853. * @param uniform defines the webGL uniform location where to store the value
  31854. * @param x defines the 1st component of the value
  31855. * @param y defines the 2nd component of the value
  31856. */
  31857. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31858. /**
  31859. * Set the value of an uniform to a vec3
  31860. * @param uniform defines the webGL uniform location where to store the value
  31861. * @param x defines the 1st component of the value
  31862. * @param y defines the 2nd component of the value
  31863. * @param z defines the 3rd component of the value
  31864. */
  31865. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31866. /**
  31867. * Set the value of an uniform to a boolean
  31868. * @param uniform defines the webGL uniform location where to store the value
  31869. * @param bool defines the boolean to store
  31870. */
  31871. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31872. /**
  31873. * Set the value of an uniform to a vec4
  31874. * @param uniform defines the webGL uniform location where to store the value
  31875. * @param x defines the 1st component of the value
  31876. * @param y defines the 2nd component of the value
  31877. * @param z defines the 3rd component of the value
  31878. * @param w defines the 4th component of the value
  31879. */
  31880. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31881. /**
  31882. * Sets a Color4 on a uniform variable
  31883. * @param uniform defines the uniform location
  31884. * @param color4 defines the value to be set
  31885. */
  31886. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31887. /**
  31888. * Set various states to the webGL context
  31889. * @param culling defines backface culling state
  31890. * @param zOffset defines the value to apply to zOffset (0 by default)
  31891. * @param force defines if states must be applied even if cache is up to date
  31892. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31893. */
  31894. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31895. /**
  31896. * Set the z offset to apply to current rendering
  31897. * @param value defines the offset to apply
  31898. */
  31899. setZOffset(value: number): void;
  31900. /**
  31901. * Gets the current value of the zOffset
  31902. * @returns the current zOffset state
  31903. */
  31904. getZOffset(): number;
  31905. /**
  31906. * Enable or disable depth buffering
  31907. * @param enable defines the state to set
  31908. */
  31909. setDepthBuffer(enable: boolean): void;
  31910. /**
  31911. * Gets a boolean indicating if depth writing is enabled
  31912. * @returns the current depth writing state
  31913. */
  31914. getDepthWrite(): boolean;
  31915. /**
  31916. * Enable or disable depth writing
  31917. * @param enable defines the state to set
  31918. */
  31919. setDepthWrite(enable: boolean): void;
  31920. /**
  31921. * Enable or disable color writing
  31922. * @param enable defines the state to set
  31923. */
  31924. setColorWrite(enable: boolean): void;
  31925. /**
  31926. * Gets a boolean indicating if color writing is enabled
  31927. * @returns the current color writing state
  31928. */
  31929. getColorWrite(): boolean;
  31930. /**
  31931. * Sets alpha constants used by some alpha blending modes
  31932. * @param r defines the red component
  31933. * @param g defines the green component
  31934. * @param b defines the blue component
  31935. * @param a defines the alpha component
  31936. */
  31937. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31938. /**
  31939. * Sets the current alpha mode
  31940. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31941. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31942. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31943. */
  31944. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31945. /**
  31946. * Gets the current alpha mode
  31947. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31948. * @returns the current alpha mode
  31949. */
  31950. getAlphaMode(): number;
  31951. /**
  31952. * Clears the list of texture accessible through engine.
  31953. * This can help preventing texture load conflict due to name collision.
  31954. */
  31955. clearInternalTexturesCache(): void;
  31956. /**
  31957. * Force the entire cache to be cleared
  31958. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31959. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31960. */
  31961. wipeCaches(bruteForce?: boolean): void;
  31962. /**
  31963. * Set the compressed texture format to use, based on the formats you have, and the formats
  31964. * supported by the hardware / browser.
  31965. *
  31966. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31967. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31968. * to API arguments needed to compressed textures. This puts the burden on the container
  31969. * generator to house the arcane code for determining these for current & future formats.
  31970. *
  31971. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31972. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31973. *
  31974. * Note: The result of this call is not taken into account when a texture is base64.
  31975. *
  31976. * @param formatsAvailable defines the list of those format families you have created
  31977. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31978. *
  31979. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31980. * @returns The extension selected.
  31981. */
  31982. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31983. /** @hidden */
  31984. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31985. min: number;
  31986. mag: number;
  31987. };
  31988. /** @hidden */
  31989. _createTexture(): WebGLTexture;
  31990. /**
  31991. * Usually called from Texture.ts.
  31992. * Passed information to create a WebGLTexture
  31993. * @param urlArg defines a value which contains one of the following:
  31994. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31995. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31996. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31997. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31998. * @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)
  31999. * @param scene needed for loading to the correct scene
  32000. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32001. * @param onLoad optional callback to be called upon successful completion
  32002. * @param onError optional callback to be called upon failure
  32003. * @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
  32004. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32005. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32006. * @param forcedExtension defines the extension to use to pick the right loader
  32007. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32008. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32009. */
  32010. 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;
  32011. /**
  32012. * @hidden
  32013. * Rescales a texture
  32014. * @param source input texutre
  32015. * @param destination destination texture
  32016. * @param scene scene to use to render the resize
  32017. * @param internalFormat format to use when resizing
  32018. * @param onComplete callback to be called when resize has completed
  32019. */
  32020. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  32021. private _unpackFlipYCached;
  32022. /**
  32023. * In case you are sharing the context with other applications, it might
  32024. * be interested to not cache the unpack flip y state to ensure a consistent
  32025. * value would be set.
  32026. */
  32027. enableUnpackFlipYCached: boolean;
  32028. /** @hidden */
  32029. _unpackFlipY(value: boolean): void;
  32030. /** @hidden */
  32031. _getUnpackAlignement(): number;
  32032. /**
  32033. * Creates a dynamic texture
  32034. * @param width defines the width of the texture
  32035. * @param height defines the height of the texture
  32036. * @param generateMipMaps defines if the engine should generate the mip levels
  32037. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32038. * @returns the dynamic texture inside an InternalTexture
  32039. */
  32040. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  32041. /**
  32042. * Update the sampling mode of a given texture
  32043. * @param samplingMode defines the required sampling mode
  32044. * @param texture defines the texture to update
  32045. */
  32046. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32047. /**
  32048. * Update the content of a dynamic texture
  32049. * @param texture defines the texture to update
  32050. * @param canvas defines the canvas containing the source
  32051. * @param invertY defines if data must be stored with Y axis inverted
  32052. * @param premulAlpha defines if alpha is stored as premultiplied
  32053. * @param format defines the format of the data
  32054. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32055. */
  32056. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  32057. /**
  32058. * Update a video texture
  32059. * @param texture defines the texture to update
  32060. * @param video defines the video element to use
  32061. * @param invertY defines if data must be stored with Y axis inverted
  32062. */
  32063. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32064. /**
  32065. * Updates a depth texture Comparison Mode and Function.
  32066. * If the comparison Function is equal to 0, the mode will be set to none.
  32067. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32068. * @param texture The texture to set the comparison function for
  32069. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32070. */
  32071. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32072. /** @hidden */
  32073. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32074. width: number;
  32075. height: number;
  32076. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32077. /**
  32078. * Creates a depth stencil texture.
  32079. * This is only available in WebGL 2 or with the depth texture extension available.
  32080. * @param size The size of face edge in the texture.
  32081. * @param options The options defining the texture.
  32082. * @returns The texture
  32083. */
  32084. createDepthStencilTexture(size: number | {
  32085. width: number;
  32086. height: number;
  32087. }, options: DepthTextureCreationOptions): InternalTexture;
  32088. /**
  32089. * Creates a depth stencil texture.
  32090. * This is only available in WebGL 2 or with the depth texture extension available.
  32091. * @param size The size of face edge in the texture.
  32092. * @param options The options defining the texture.
  32093. * @returns The texture
  32094. */
  32095. private _createDepthStencilTexture;
  32096. /**
  32097. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32098. * @param renderTarget The render target to set the frame buffer for
  32099. */
  32100. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32101. /**
  32102. * Creates a new render target texture
  32103. * @param size defines the size of the texture
  32104. * @param options defines the options used to create the texture
  32105. * @returns a new render target texture stored in an InternalTexture
  32106. */
  32107. createRenderTargetTexture(size: number | {
  32108. width: number;
  32109. height: number;
  32110. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32111. /** @hidden */
  32112. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32113. /**
  32114. * Updates the sample count of a render target texture
  32115. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32116. * @param texture defines the texture to update
  32117. * @param samples defines the sample count to set
  32118. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32119. */
  32120. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32121. /** @hidden */
  32122. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32123. /** @hidden */
  32124. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32125. /** @hidden */
  32126. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32127. /** @hidden */
  32128. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  32129. /**
  32130. * @hidden
  32131. */
  32132. _setCubeMapTextureParams(loadMipmap: boolean): void;
  32133. private _prepareWebGLTextureContinuation;
  32134. private _prepareWebGLTexture;
  32135. /** @hidden */
  32136. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32137. /** @hidden */
  32138. _releaseFramebufferObjects(texture: InternalTexture): void;
  32139. /** @hidden */
  32140. _releaseTexture(texture: InternalTexture): void;
  32141. private setProgram;
  32142. private _boundUniforms;
  32143. /**
  32144. * Binds an effect to the webGL context
  32145. * @param effect defines the effect to bind
  32146. */
  32147. bindSamplers(effect: Effect): void;
  32148. private _activateCurrentTexture;
  32149. /** @hidden */
  32150. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32151. /** @hidden */
  32152. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32153. /**
  32154. * Sets a texture to the webGL context from a postprocess
  32155. * @param channel defines the channel to use
  32156. * @param postProcess defines the source postprocess
  32157. */
  32158. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32159. /**
  32160. * Binds the output of the passed in post process to the texture channel specified
  32161. * @param channel The channel the texture should be bound to
  32162. * @param postProcess The post process which's output should be bound
  32163. */
  32164. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32165. /**
  32166. * Unbind all textures from the webGL context
  32167. */
  32168. unbindAllTextures(): void;
  32169. /**
  32170. * Sets a texture to the according uniform.
  32171. * @param channel The texture channel
  32172. * @param uniform The uniform to set
  32173. * @param texture The texture to apply
  32174. */
  32175. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32176. /**
  32177. * Sets a depth stencil texture from a render target to the according uniform.
  32178. * @param channel The texture channel
  32179. * @param uniform The uniform to set
  32180. * @param texture The render target texture containing the depth stencil texture to apply
  32181. */
  32182. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32183. private _bindSamplerUniformToChannel;
  32184. private _getTextureWrapMode;
  32185. private _setTexture;
  32186. /**
  32187. * Sets an array of texture to the webGL context
  32188. * @param channel defines the channel where the texture array must be set
  32189. * @param uniform defines the associated uniform location
  32190. * @param textures defines the array of textures to bind
  32191. */
  32192. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32193. /** @hidden */
  32194. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32195. private _setTextureParameterFloat;
  32196. private _setTextureParameterInteger;
  32197. /**
  32198. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32199. * @param x defines the x coordinate of the rectangle where pixels must be read
  32200. * @param y defines the y coordinate of the rectangle where pixels must be read
  32201. * @param width defines the width of the rectangle where pixels must be read
  32202. * @param height defines the height of the rectangle where pixels must be read
  32203. * @returns a Uint8Array containing RGBA colors
  32204. */
  32205. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32206. /**
  32207. * Add an externaly attached data from its key.
  32208. * This method call will fail and return false, if such key already exists.
  32209. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32210. * @param key the unique key that identifies the data
  32211. * @param data the data object to associate to the key for this Engine instance
  32212. * @return true if no such key were already present and the data was added successfully, false otherwise
  32213. */
  32214. addExternalData<T>(key: string, data: T): boolean;
  32215. /**
  32216. * Get an externaly attached data from its key
  32217. * @param key the unique key that identifies the data
  32218. * @return the associated data, if present (can be null), or undefined if not present
  32219. */
  32220. getExternalData<T>(key: string): T;
  32221. /**
  32222. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32223. * @param key the unique key that identifies the data
  32224. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32225. * @return the associated data, can be null if the factory returned null.
  32226. */
  32227. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32228. /**
  32229. * Remove an externaly attached data from the Engine instance
  32230. * @param key the unique key that identifies the data
  32231. * @return true if the data was successfully removed, false if it doesn't exist
  32232. */
  32233. removeExternalData(key: string): boolean;
  32234. /**
  32235. * Unbind all vertex attributes from the webGL context
  32236. */
  32237. unbindAllAttributes(): void;
  32238. /**
  32239. * 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
  32240. */
  32241. releaseEffects(): void;
  32242. /**
  32243. * Dispose and release all associated resources
  32244. */
  32245. dispose(): void;
  32246. /**
  32247. * Display the loading screen
  32248. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32249. */
  32250. displayLoadingUI(): void;
  32251. /**
  32252. * Hide the loading screen
  32253. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32254. */
  32255. hideLoadingUI(): void;
  32256. /**
  32257. * Gets the current loading screen object
  32258. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32259. */
  32260. /**
  32261. * Sets the current loading screen object
  32262. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32263. */
  32264. loadingScreen: ILoadingScreen;
  32265. /**
  32266. * Sets the current loading screen text
  32267. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32268. */
  32269. loadingUIText: string;
  32270. /**
  32271. * Sets the current loading screen background color
  32272. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32273. */
  32274. loadingUIBackgroundColor: string;
  32275. /**
  32276. * Attach a new callback raised when context lost event is fired
  32277. * @param callback defines the callback to call
  32278. */
  32279. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32280. /**
  32281. * Attach a new callback raised when context restored event is fired
  32282. * @param callback defines the callback to call
  32283. */
  32284. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32285. /**
  32286. * Gets the source code of the vertex shader associated with a specific webGL program
  32287. * @param program defines the program to use
  32288. * @returns a string containing the source code of the vertex shader associated with the program
  32289. */
  32290. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32291. /**
  32292. * Gets the source code of the fragment shader associated with a specific webGL program
  32293. * @param program defines the program to use
  32294. * @returns a string containing the source code of the fragment shader associated with the program
  32295. */
  32296. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32297. /**
  32298. * Get the current error code of the webGL context
  32299. * @returns the error code
  32300. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32301. */
  32302. getError(): number;
  32303. /**
  32304. * Gets the current framerate
  32305. * @returns a number representing the framerate
  32306. */
  32307. getFps(): number;
  32308. /**
  32309. * Gets the time spent between current and previous frame
  32310. * @returns a number representing the delta time in ms
  32311. */
  32312. getDeltaTime(): number;
  32313. private _measureFps;
  32314. /** @hidden */
  32315. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32316. private _canRenderToFloatFramebuffer;
  32317. private _canRenderToHalfFloatFramebuffer;
  32318. private _canRenderToFramebuffer;
  32319. /** @hidden */
  32320. _getWebGLTextureType(type: number): number;
  32321. /** @hidden */
  32322. _getInternalFormat(format: number): number;
  32323. /** @hidden */
  32324. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32325. /** @hidden */
  32326. _getRGBAMultiSampleBufferFormat(type: number): number;
  32327. /** @hidden */
  32328. _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;
  32329. /** @hidden */
  32330. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32331. /**
  32332. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32333. * @returns true if the engine can be created
  32334. * @ignorenaming
  32335. */
  32336. static isSupported(): boolean;
  32337. /**
  32338. * Find the next highest power of two.
  32339. * @param x Number to start search from.
  32340. * @return Next highest power of two.
  32341. */
  32342. static CeilingPOT(x: number): number;
  32343. /**
  32344. * Find the next lowest power of two.
  32345. * @param x Number to start search from.
  32346. * @return Next lowest power of two.
  32347. */
  32348. static FloorPOT(x: number): number;
  32349. /**
  32350. * Find the nearest power of two.
  32351. * @param x Number to start search from.
  32352. * @return Next nearest power of two.
  32353. */
  32354. static NearestPOT(x: number): number;
  32355. /**
  32356. * Get the closest exponent of two
  32357. * @param value defines the value to approximate
  32358. * @param max defines the maximum value to return
  32359. * @param mode defines how to define the closest value
  32360. * @returns closest exponent of two of the given value
  32361. */
  32362. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32363. /**
  32364. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32365. * @param func - the function to be called
  32366. * @param requester - the object that will request the next frame. Falls back to window.
  32367. * @returns frame number
  32368. */
  32369. static QueueNewFrame(func: () => void, requester?: any): number;
  32370. /**
  32371. * Ask the browser to promote the current element to pointerlock mode
  32372. * @param element defines the DOM element to promote
  32373. */
  32374. static _RequestPointerlock(element: HTMLElement): void;
  32375. /**
  32376. * Asks the browser to exit pointerlock mode
  32377. */
  32378. static _ExitPointerlock(): void;
  32379. /**
  32380. * Ask the browser to promote the current element to fullscreen rendering mode
  32381. * @param element defines the DOM element to promote
  32382. */
  32383. static _RequestFullscreen(element: HTMLElement): void;
  32384. /**
  32385. * Asks the browser to exit fullscreen mode
  32386. */
  32387. static _ExitFullscreen(): void;
  32388. }
  32389. }
  32390. declare module "babylonjs/Engines/engineStore" {
  32391. import { Nullable } from "babylonjs/types";
  32392. import { Engine } from "babylonjs/Engines/engine";
  32393. import { Scene } from "babylonjs/scene";
  32394. /**
  32395. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32396. * during the life time of the application.
  32397. */
  32398. export class EngineStore {
  32399. /** Gets the list of created engines */
  32400. static Instances: import("babylonjs/Engines/engine").Engine[];
  32401. /** @hidden */
  32402. static _LastCreatedScene: Nullable<Scene>;
  32403. /**
  32404. * Gets the latest created engine
  32405. */
  32406. static readonly LastCreatedEngine: Nullable<Engine>;
  32407. /**
  32408. * Gets the latest created scene
  32409. */
  32410. static readonly LastCreatedScene: Nullable<Scene>;
  32411. /**
  32412. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32413. * @ignorenaming
  32414. */
  32415. static UseFallbackTexture: boolean;
  32416. /**
  32417. * Texture content used if a texture cannot loaded
  32418. * @ignorenaming
  32419. */
  32420. static FallbackTexture: string;
  32421. }
  32422. }
  32423. declare module "babylonjs/Misc/promise" {
  32424. /**
  32425. * Helper class that provides a small promise polyfill
  32426. */
  32427. export class PromisePolyfill {
  32428. /**
  32429. * Static function used to check if the polyfill is required
  32430. * If this is the case then the function will inject the polyfill to window.Promise
  32431. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32432. */
  32433. static Apply(force?: boolean): void;
  32434. }
  32435. }
  32436. declare module "babylonjs/Misc/tools" {
  32437. import { Nullable, float } from "babylonjs/types";
  32438. import { DomManagement } from "babylonjs/Misc/domManagement";
  32439. import { WebRequest } from "babylonjs/Misc/webRequest";
  32440. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32441. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32442. import { Camera } from "babylonjs/Cameras/camera";
  32443. import { Engine } from "babylonjs/Engines/engine";
  32444. interface IColor4Like {
  32445. r: float;
  32446. g: float;
  32447. b: float;
  32448. a: float;
  32449. }
  32450. /**
  32451. * Class containing a set of static utilities functions
  32452. */
  32453. export class Tools {
  32454. /**
  32455. * Gets or sets the base URL to use to load assets
  32456. */
  32457. static BaseUrl: string;
  32458. /**
  32459. * Enable/Disable Custom HTTP Request Headers globally.
  32460. * default = false
  32461. * @see CustomRequestHeaders
  32462. */
  32463. static UseCustomRequestHeaders: boolean;
  32464. /**
  32465. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32466. * i.e. when loading files, where the server/service expects an Authorization header
  32467. */
  32468. static CustomRequestHeaders: {
  32469. [key: string]: string;
  32470. };
  32471. /**
  32472. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32473. */
  32474. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32475. /**
  32476. * Default behaviour for cors in the application.
  32477. * It can be a string if the expected behavior is identical in the entire app.
  32478. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32479. */
  32480. static CorsBehavior: string | ((url: string | string[]) => string);
  32481. /**
  32482. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32483. * @ignorenaming
  32484. */
  32485. static UseFallbackTexture: boolean;
  32486. /**
  32487. * Use this object to register external classes like custom textures or material
  32488. * to allow the laoders to instantiate them
  32489. */
  32490. static RegisteredExternalClasses: {
  32491. [key: string]: Object;
  32492. };
  32493. /**
  32494. * Texture content used if a texture cannot loaded
  32495. * @ignorenaming
  32496. */
  32497. static fallbackTexture: string;
  32498. /**
  32499. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32500. * @param u defines the coordinate on X axis
  32501. * @param v defines the coordinate on Y axis
  32502. * @param width defines the width of the source data
  32503. * @param height defines the height of the source data
  32504. * @param pixels defines the source byte array
  32505. * @param color defines the output color
  32506. */
  32507. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32508. /**
  32509. * Interpolates between a and b via alpha
  32510. * @param a The lower value (returned when alpha = 0)
  32511. * @param b The upper value (returned when alpha = 1)
  32512. * @param alpha The interpolation-factor
  32513. * @return The mixed value
  32514. */
  32515. static Mix(a: number, b: number, alpha: number): number;
  32516. /**
  32517. * Tries to instantiate a new object from a given class name
  32518. * @param className defines the class name to instantiate
  32519. * @returns the new object or null if the system was not able to do the instantiation
  32520. */
  32521. static Instantiate(className: string): any;
  32522. /**
  32523. * Provides a slice function that will work even on IE
  32524. * @param data defines the array to slice
  32525. * @param start defines the start of the data (optional)
  32526. * @param end defines the end of the data (optional)
  32527. * @returns the new sliced array
  32528. */
  32529. static Slice<T>(data: T, start?: number, end?: number): T;
  32530. /**
  32531. * Polyfill for setImmediate
  32532. * @param action defines the action to execute after the current execution block
  32533. */
  32534. static SetImmediate(action: () => void): void;
  32535. /**
  32536. * Function indicating if a number is an exponent of 2
  32537. * @param value defines the value to test
  32538. * @returns true if the value is an exponent of 2
  32539. */
  32540. static IsExponentOfTwo(value: number): boolean;
  32541. private static _tmpFloatArray;
  32542. /**
  32543. * Returns the nearest 32-bit single precision float representation of a Number
  32544. * @param value A Number. If the parameter is of a different type, it will get converted
  32545. * to a number or to NaN if it cannot be converted
  32546. * @returns number
  32547. */
  32548. static FloatRound(value: number): number;
  32549. /**
  32550. * Extracts the filename from a path
  32551. * @param path defines the path to use
  32552. * @returns the filename
  32553. */
  32554. static GetFilename(path: string): string;
  32555. /**
  32556. * Extracts the "folder" part of a path (everything before the filename).
  32557. * @param uri The URI to extract the info from
  32558. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32559. * @returns The "folder" part of the path
  32560. */
  32561. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32562. /**
  32563. * Extracts text content from a DOM element hierarchy
  32564. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32565. */
  32566. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32567. /**
  32568. * Convert an angle in radians to degrees
  32569. * @param angle defines the angle to convert
  32570. * @returns the angle in degrees
  32571. */
  32572. static ToDegrees(angle: number): number;
  32573. /**
  32574. * Convert an angle in degrees to radians
  32575. * @param angle defines the angle to convert
  32576. * @returns the angle in radians
  32577. */
  32578. static ToRadians(angle: number): number;
  32579. /**
  32580. * Encode a buffer to a base64 string
  32581. * @param buffer defines the buffer to encode
  32582. * @returns the encoded string
  32583. */
  32584. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32585. /**
  32586. * Returns an array if obj is not an array
  32587. * @param obj defines the object to evaluate as an array
  32588. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32589. * @returns either obj directly if obj is an array or a new array containing obj
  32590. */
  32591. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32592. /**
  32593. * Gets the pointer prefix to use
  32594. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32595. */
  32596. static GetPointerPrefix(): string;
  32597. /**
  32598. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32599. * @param url define the url we are trying
  32600. * @param element define the dom element where to configure the cors policy
  32601. */
  32602. static SetCorsBehavior(url: string | string[], element: {
  32603. crossOrigin: string | null;
  32604. }): void;
  32605. /**
  32606. * Removes unwanted characters from an url
  32607. * @param url defines the url to clean
  32608. * @returns the cleaned url
  32609. */
  32610. static CleanUrl(url: string): string;
  32611. /**
  32612. * Gets or sets a function used to pre-process url before using them to load assets
  32613. */
  32614. static PreprocessUrl: (url: string) => string;
  32615. /**
  32616. * Loads an image as an HTMLImageElement.
  32617. * @param input url string, ArrayBuffer, or Blob to load
  32618. * @param onLoad callback called when the image successfully loads
  32619. * @param onError callback called when the image fails to load
  32620. * @param offlineProvider offline provider for caching
  32621. * @returns the HTMLImageElement of the loaded image
  32622. */
  32623. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32624. /**
  32625. * Loads a file
  32626. * @param url url string, ArrayBuffer, or Blob to load
  32627. * @param onSuccess callback called when the file successfully loads
  32628. * @param onProgress callback called while file is loading (if the server supports this mode)
  32629. * @param offlineProvider defines the offline provider for caching
  32630. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32631. * @param onError callback called when the file fails to load
  32632. * @returns a file request object
  32633. */
  32634. 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;
  32635. /**
  32636. * Loads a file from a url
  32637. * @param url the file url to load
  32638. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32639. */
  32640. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32641. /**
  32642. * Load a script (identified by an url). When the url returns, the
  32643. * content of this file is added into a new script element, attached to the DOM (body element)
  32644. * @param scriptUrl defines the url of the script to laod
  32645. * @param onSuccess defines the callback called when the script is loaded
  32646. * @param onError defines the callback to call if an error occurs
  32647. * @param scriptId defines the id of the script element
  32648. */
  32649. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32650. /**
  32651. * Load an asynchronous script (identified by an url). When the url returns, the
  32652. * content of this file is added into a new script element, attached to the DOM (body element)
  32653. * @param scriptUrl defines the url of the script to laod
  32654. * @param scriptId defines the id of the script element
  32655. * @returns a promise request object
  32656. */
  32657. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32658. /**
  32659. * Loads a file from a blob
  32660. * @param fileToLoad defines the blob to use
  32661. * @param callback defines the callback to call when data is loaded
  32662. * @param progressCallback defines the callback to call during loading process
  32663. * @returns a file request object
  32664. */
  32665. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32666. /**
  32667. * Loads a file
  32668. * @param fileToLoad defines the file to load
  32669. * @param callback defines the callback to call when data is loaded
  32670. * @param progressCallBack defines the callback to call during loading process
  32671. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32672. * @returns a file request object
  32673. */
  32674. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32675. /**
  32676. * Creates a data url from a given string content
  32677. * @param content defines the content to convert
  32678. * @returns the new data url link
  32679. */
  32680. static FileAsURL(content: string): string;
  32681. /**
  32682. * Format the given number to a specific decimal format
  32683. * @param value defines the number to format
  32684. * @param decimals defines the number of decimals to use
  32685. * @returns the formatted string
  32686. */
  32687. static Format(value: number, decimals?: number): string;
  32688. /**
  32689. * Tries to copy an object by duplicating every property
  32690. * @param source defines the source object
  32691. * @param destination defines the target object
  32692. * @param doNotCopyList defines a list of properties to avoid
  32693. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32694. */
  32695. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32696. /**
  32697. * Gets a boolean indicating if the given object has no own property
  32698. * @param obj defines the object to test
  32699. * @returns true if object has no own property
  32700. */
  32701. static IsEmpty(obj: any): boolean;
  32702. /**
  32703. * Function used to register events at window level
  32704. * @param events defines the events to register
  32705. */
  32706. static RegisterTopRootEvents(events: {
  32707. name: string;
  32708. handler: Nullable<(e: FocusEvent) => any>;
  32709. }[]): void;
  32710. /**
  32711. * Function used to unregister events from window level
  32712. * @param events defines the events to unregister
  32713. */
  32714. static UnregisterTopRootEvents(events: {
  32715. name: string;
  32716. handler: Nullable<(e: FocusEvent) => any>;
  32717. }[]): void;
  32718. /**
  32719. * @ignore
  32720. */
  32721. static _ScreenshotCanvas: HTMLCanvasElement;
  32722. /**
  32723. * Dumps the current bound framebuffer
  32724. * @param width defines the rendering width
  32725. * @param height defines the rendering height
  32726. * @param engine defines the hosting engine
  32727. * @param successCallback defines the callback triggered once the data are available
  32728. * @param mimeType defines the mime type of the result
  32729. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32730. */
  32731. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32732. /**
  32733. * Converts the canvas data to blob.
  32734. * This acts as a polyfill for browsers not supporting the to blob function.
  32735. * @param canvas Defines the canvas to extract the data from
  32736. * @param successCallback Defines the callback triggered once the data are available
  32737. * @param mimeType Defines the mime type of the result
  32738. */
  32739. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32740. /**
  32741. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32742. * @param successCallback defines the callback triggered once the data are available
  32743. * @param mimeType defines the mime type of the result
  32744. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32745. */
  32746. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32747. /**
  32748. * Downloads a blob in the browser
  32749. * @param blob defines the blob to download
  32750. * @param fileName defines the name of the downloaded file
  32751. */
  32752. static Download(blob: Blob, fileName: string): void;
  32753. /**
  32754. * Captures a screenshot of the current rendering
  32755. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32756. * @param engine defines the rendering engine
  32757. * @param camera defines the source camera
  32758. * @param size This parameter can be set to a single number or to an object with the
  32759. * following (optional) properties: precision, width, height. If a single number is passed,
  32760. * it will be used for both width and height. If an object is passed, the screenshot size
  32761. * will be derived from the parameters. The precision property is a multiplier allowing
  32762. * rendering at a higher or lower resolution
  32763. * @param successCallback defines the callback receives a single parameter which contains the
  32764. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32765. * src parameter of an <img> to display it
  32766. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32767. * Check your browser for supported MIME types
  32768. */
  32769. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32770. /**
  32771. * Captures a screenshot of the current rendering
  32772. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32773. * @param engine defines the rendering engine
  32774. * @param camera defines the source camera
  32775. * @param size This parameter can be set to a single number or to an object with the
  32776. * following (optional) properties: precision, width, height. If a single number is passed,
  32777. * it will be used for both width and height. If an object is passed, the screenshot size
  32778. * will be derived from the parameters. The precision property is a multiplier allowing
  32779. * rendering at a higher or lower resolution
  32780. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32781. * Check your browser for supported MIME types
  32782. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32783. * to the src parameter of an <img> to display it
  32784. */
  32785. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  32786. /**
  32787. * Generates an image screenshot from the specified camera.
  32788. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32789. * @param engine The engine to use for rendering
  32790. * @param camera The camera to use for rendering
  32791. * @param size This parameter can be set to a single number or to an object with the
  32792. * following (optional) properties: precision, width, height. If a single number is passed,
  32793. * it will be used for both width and height. If an object is passed, the screenshot size
  32794. * will be derived from the parameters. The precision property is a multiplier allowing
  32795. * rendering at a higher or lower resolution
  32796. * @param successCallback The callback receives a single parameter which contains the
  32797. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32798. * src parameter of an <img> to display it
  32799. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32800. * Check your browser for supported MIME types
  32801. * @param samples Texture samples (default: 1)
  32802. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32803. * @param fileName A name for for the downloaded file.
  32804. */
  32805. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32806. /**
  32807. * Generates an image screenshot from the specified camera.
  32808. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32809. * @param engine The engine to use for rendering
  32810. * @param camera The camera to use for rendering
  32811. * @param size This parameter can be set to a single number or to an object with the
  32812. * following (optional) properties: precision, width, height. If a single number is passed,
  32813. * it will be used for both width and height. If an object is passed, the screenshot size
  32814. * will be derived from the parameters. The precision property is a multiplier allowing
  32815. * rendering at a higher or lower resolution
  32816. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32817. * Check your browser for supported MIME types
  32818. * @param samples Texture samples (default: 1)
  32819. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32820. * @param fileName A name for for the downloaded file.
  32821. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32822. * to the src parameter of an <img> to display it
  32823. */
  32824. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32825. /**
  32826. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32827. * Be aware Math.random() could cause collisions, but:
  32828. * "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"
  32829. * @returns a pseudo random id
  32830. */
  32831. static RandomId(): string;
  32832. /**
  32833. * Test if the given uri is a base64 string
  32834. * @param uri The uri to test
  32835. * @return True if the uri is a base64 string or false otherwise
  32836. */
  32837. static IsBase64(uri: string): boolean;
  32838. /**
  32839. * Decode the given base64 uri.
  32840. * @param uri The uri to decode
  32841. * @return The decoded base64 data.
  32842. */
  32843. static DecodeBase64(uri: string): ArrayBuffer;
  32844. /**
  32845. * Gets the absolute url.
  32846. * @param url the input url
  32847. * @return the absolute url
  32848. */
  32849. static GetAbsoluteUrl(url: string): string;
  32850. /**
  32851. * No log
  32852. */
  32853. static readonly NoneLogLevel: number;
  32854. /**
  32855. * Only message logs
  32856. */
  32857. static readonly MessageLogLevel: number;
  32858. /**
  32859. * Only warning logs
  32860. */
  32861. static readonly WarningLogLevel: number;
  32862. /**
  32863. * Only error logs
  32864. */
  32865. static readonly ErrorLogLevel: number;
  32866. /**
  32867. * All logs
  32868. */
  32869. static readonly AllLogLevel: number;
  32870. /**
  32871. * Gets a value indicating the number of loading errors
  32872. * @ignorenaming
  32873. */
  32874. static readonly errorsCount: number;
  32875. /**
  32876. * Callback called when a new log is added
  32877. */
  32878. static OnNewCacheEntry: (entry: string) => void;
  32879. /**
  32880. * Log a message to the console
  32881. * @param message defines the message to log
  32882. */
  32883. static Log(message: string): void;
  32884. /**
  32885. * Write a warning message to the console
  32886. * @param message defines the message to log
  32887. */
  32888. static Warn(message: string): void;
  32889. /**
  32890. * Write an error message to the console
  32891. * @param message defines the message to log
  32892. */
  32893. static Error(message: string): void;
  32894. /**
  32895. * Gets current log cache (list of logs)
  32896. */
  32897. static readonly LogCache: string;
  32898. /**
  32899. * Clears the log cache
  32900. */
  32901. static ClearLogCache(): void;
  32902. /**
  32903. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32904. */
  32905. static LogLevels: number;
  32906. /**
  32907. * Checks if the window object exists
  32908. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32909. */
  32910. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32911. /**
  32912. * No performance log
  32913. */
  32914. static readonly PerformanceNoneLogLevel: number;
  32915. /**
  32916. * Use user marks to log performance
  32917. */
  32918. static readonly PerformanceUserMarkLogLevel: number;
  32919. /**
  32920. * Log performance to the console
  32921. */
  32922. static readonly PerformanceConsoleLogLevel: number;
  32923. private static _performance;
  32924. /**
  32925. * Sets the current performance log level
  32926. */
  32927. static PerformanceLogLevel: number;
  32928. private static _StartPerformanceCounterDisabled;
  32929. private static _EndPerformanceCounterDisabled;
  32930. private static _StartUserMark;
  32931. private static _EndUserMark;
  32932. private static _StartPerformanceConsole;
  32933. private static _EndPerformanceConsole;
  32934. /**
  32935. * Starts a performance counter
  32936. */
  32937. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32938. /**
  32939. * Ends a specific performance coutner
  32940. */
  32941. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32942. /**
  32943. * Gets either window.performance.now() if supported or Date.now() else
  32944. */
  32945. static readonly Now: number;
  32946. /**
  32947. * This method will return the name of the class used to create the instance of the given object.
  32948. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32949. * @param object the object to get the class name from
  32950. * @param isType defines if the object is actually a type
  32951. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32952. */
  32953. static GetClassName(object: any, isType?: boolean): string;
  32954. /**
  32955. * Gets the first element of an array satisfying a given predicate
  32956. * @param array defines the array to browse
  32957. * @param predicate defines the predicate to use
  32958. * @returns null if not found or the element
  32959. */
  32960. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32961. /**
  32962. * This method will return the name of the full name of the class, including its owning module (if any).
  32963. * 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).
  32964. * @param object the object to get the class name from
  32965. * @param isType defines if the object is actually a type
  32966. * @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.
  32967. * @ignorenaming
  32968. */
  32969. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32970. /**
  32971. * Returns a promise that resolves after the given amount of time.
  32972. * @param delay Number of milliseconds to delay
  32973. * @returns Promise that resolves after the given amount of time
  32974. */
  32975. static DelayAsync(delay: number): Promise<void>;
  32976. }
  32977. /**
  32978. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32979. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32980. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32981. * @param name The name of the class, case should be preserved
  32982. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32983. */
  32984. export function className(name: string, module?: string): (target: Object) => void;
  32985. /**
  32986. * An implementation of a loop for asynchronous functions.
  32987. */
  32988. export class AsyncLoop {
  32989. /**
  32990. * Defines the number of iterations for the loop
  32991. */
  32992. iterations: number;
  32993. /**
  32994. * Defines the current index of the loop.
  32995. */
  32996. index: number;
  32997. private _done;
  32998. private _fn;
  32999. private _successCallback;
  33000. /**
  33001. * Constructor.
  33002. * @param iterations the number of iterations.
  33003. * @param func the function to run each iteration
  33004. * @param successCallback the callback that will be called upon succesful execution
  33005. * @param offset starting offset.
  33006. */
  33007. constructor(
  33008. /**
  33009. * Defines the number of iterations for the loop
  33010. */
  33011. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33012. /**
  33013. * Execute the next iteration. Must be called after the last iteration was finished.
  33014. */
  33015. executeNext(): void;
  33016. /**
  33017. * Break the loop and run the success callback.
  33018. */
  33019. breakLoop(): void;
  33020. /**
  33021. * Create and run an async loop.
  33022. * @param iterations the number of iterations.
  33023. * @param fn the function to run each iteration
  33024. * @param successCallback the callback that will be called upon succesful execution
  33025. * @param offset starting offset.
  33026. * @returns the created async loop object
  33027. */
  33028. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33029. /**
  33030. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33031. * @param iterations total number of iterations
  33032. * @param syncedIterations number of synchronous iterations in each async iteration.
  33033. * @param fn the function to call each iteration.
  33034. * @param callback a success call back that will be called when iterating stops.
  33035. * @param breakFunction a break condition (optional)
  33036. * @param timeout timeout settings for the setTimeout function. default - 0.
  33037. * @returns the created async loop object
  33038. */
  33039. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33040. }
  33041. }
  33042. declare module "babylonjs/Collisions/collisionCoordinator" {
  33043. import { Nullable } from "babylonjs/types";
  33044. import { Scene } from "babylonjs/scene";
  33045. import { Vector3 } from "babylonjs/Maths/math.vector";
  33046. import { Collider } from "babylonjs/Collisions/collider";
  33047. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33048. /** @hidden */
  33049. export interface ICollisionCoordinator {
  33050. createCollider(): Collider;
  33051. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33052. init(scene: Scene): void;
  33053. }
  33054. /** @hidden */
  33055. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33056. private _scene;
  33057. private _scaledPosition;
  33058. private _scaledVelocity;
  33059. private _finalPosition;
  33060. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33061. createCollider(): Collider;
  33062. init(scene: Scene): void;
  33063. private _collideWithWorld;
  33064. }
  33065. }
  33066. declare module "babylonjs/Inputs/scene.inputManager" {
  33067. import { Nullable } from "babylonjs/types";
  33068. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33069. import { Vector2 } from "babylonjs/Maths/math.vector";
  33070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33071. import { Scene } from "babylonjs/scene";
  33072. /**
  33073. * Class used to manage all inputs for the scene.
  33074. */
  33075. export class InputManager {
  33076. /** The distance in pixel that you have to move to prevent some events */
  33077. static DragMovementThreshold: number;
  33078. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33079. static LongPressDelay: number;
  33080. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33081. static DoubleClickDelay: number;
  33082. /** If you need to check double click without raising a single click at first click, enable this flag */
  33083. static ExclusiveDoubleClickMode: boolean;
  33084. private _wheelEventName;
  33085. private _onPointerMove;
  33086. private _onPointerDown;
  33087. private _onPointerUp;
  33088. private _initClickEvent;
  33089. private _initActionManager;
  33090. private _delayedSimpleClick;
  33091. private _delayedSimpleClickTimeout;
  33092. private _previousDelayedSimpleClickTimeout;
  33093. private _meshPickProceed;
  33094. private _previousButtonPressed;
  33095. private _currentPickResult;
  33096. private _previousPickResult;
  33097. private _totalPointersPressed;
  33098. private _doubleClickOccured;
  33099. private _pointerOverMesh;
  33100. private _pickedDownMesh;
  33101. private _pickedUpMesh;
  33102. private _pointerX;
  33103. private _pointerY;
  33104. private _unTranslatedPointerX;
  33105. private _unTranslatedPointerY;
  33106. private _startingPointerPosition;
  33107. private _previousStartingPointerPosition;
  33108. private _startingPointerTime;
  33109. private _previousStartingPointerTime;
  33110. private _pointerCaptures;
  33111. private _onKeyDown;
  33112. private _onKeyUp;
  33113. private _onCanvasFocusObserver;
  33114. private _onCanvasBlurObserver;
  33115. private _scene;
  33116. /**
  33117. * Creates a new InputManager
  33118. * @param scene defines the hosting scene
  33119. */
  33120. constructor(scene: Scene);
  33121. /**
  33122. * Gets the mesh that is currently under the pointer
  33123. */
  33124. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33125. /**
  33126. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33127. */
  33128. readonly unTranslatedPointer: Vector2;
  33129. /**
  33130. * Gets or sets the current on-screen X position of the pointer
  33131. */
  33132. pointerX: number;
  33133. /**
  33134. * Gets or sets the current on-screen Y position of the pointer
  33135. */
  33136. pointerY: number;
  33137. private _updatePointerPosition;
  33138. private _processPointerMove;
  33139. private _setRayOnPointerInfo;
  33140. private _checkPrePointerObservable;
  33141. /**
  33142. * Use this method to simulate a pointer move on a mesh
  33143. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33144. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33145. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33146. */
  33147. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33148. /**
  33149. * Use this method to simulate a pointer down on a mesh
  33150. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33151. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33152. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33153. */
  33154. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33155. private _processPointerDown;
  33156. /** @hidden */
  33157. _isPointerSwiping(): boolean;
  33158. /**
  33159. * Use this method to simulate a pointer up on a mesh
  33160. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33161. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33162. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33163. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33164. */
  33165. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33166. private _processPointerUp;
  33167. /**
  33168. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33169. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33170. * @returns true if the pointer was captured
  33171. */
  33172. isPointerCaptured(pointerId?: number): boolean;
  33173. /**
  33174. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33175. * @param attachUp defines if you want to attach events to pointerup
  33176. * @param attachDown defines if you want to attach events to pointerdown
  33177. * @param attachMove defines if you want to attach events to pointermove
  33178. */
  33179. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33180. /**
  33181. * Detaches all event handlers
  33182. */
  33183. detachControl(): void;
  33184. /**
  33185. * Force the value of meshUnderPointer
  33186. * @param mesh defines the mesh to use
  33187. */
  33188. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33189. /**
  33190. * Gets the mesh under the pointer
  33191. * @returns a Mesh or null if no mesh is under the pointer
  33192. */
  33193. getPointerOverMesh(): Nullable<AbstractMesh>;
  33194. }
  33195. }
  33196. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33197. /**
  33198. * Helper class used to generate session unique ID
  33199. */
  33200. export class UniqueIdGenerator {
  33201. private static _UniqueIdCounter;
  33202. /**
  33203. * Gets an unique (relatively to the current scene) Id
  33204. */
  33205. static readonly UniqueId: number;
  33206. }
  33207. }
  33208. declare module "babylonjs/Animations/animationGroup" {
  33209. import { Animatable } from "babylonjs/Animations/animatable";
  33210. import { Animation } from "babylonjs/Animations/animation";
  33211. import { Scene, IDisposable } from "babylonjs/scene";
  33212. import { Observable } from "babylonjs/Misc/observable";
  33213. import { Nullable } from "babylonjs/types";
  33214. import "babylonjs/Animations/animatable";
  33215. /**
  33216. * This class defines the direct association between an animation and a target
  33217. */
  33218. export class TargetedAnimation {
  33219. /**
  33220. * Animation to perform
  33221. */
  33222. animation: Animation;
  33223. /**
  33224. * Target to animate
  33225. */
  33226. target: any;
  33227. /**
  33228. * Serialize the object
  33229. * @returns the JSON object representing the current entity
  33230. */
  33231. serialize(): any;
  33232. }
  33233. /**
  33234. * Use this class to create coordinated animations on multiple targets
  33235. */
  33236. export class AnimationGroup implements IDisposable {
  33237. /** The name of the animation group */
  33238. name: string;
  33239. private _scene;
  33240. private _targetedAnimations;
  33241. private _animatables;
  33242. private _from;
  33243. private _to;
  33244. private _isStarted;
  33245. private _isPaused;
  33246. private _speedRatio;
  33247. private _loopAnimation;
  33248. /**
  33249. * Gets or sets the unique id of the node
  33250. */
  33251. uniqueId: number;
  33252. /**
  33253. * This observable will notify when one animation have ended
  33254. */
  33255. onAnimationEndObservable: Observable<TargetedAnimation>;
  33256. /**
  33257. * Observer raised when one animation loops
  33258. */
  33259. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33260. /**
  33261. * This observable will notify when all animations have ended.
  33262. */
  33263. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33264. /**
  33265. * This observable will notify when all animations have paused.
  33266. */
  33267. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33268. /**
  33269. * This observable will notify when all animations are playing.
  33270. */
  33271. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33272. /**
  33273. * Gets the first frame
  33274. */
  33275. readonly from: number;
  33276. /**
  33277. * Gets the last frame
  33278. */
  33279. readonly to: number;
  33280. /**
  33281. * Define if the animations are started
  33282. */
  33283. readonly isStarted: boolean;
  33284. /**
  33285. * Gets a value indicating that the current group is playing
  33286. */
  33287. readonly isPlaying: boolean;
  33288. /**
  33289. * Gets or sets the speed ratio to use for all animations
  33290. */
  33291. /**
  33292. * Gets or sets the speed ratio to use for all animations
  33293. */
  33294. speedRatio: number;
  33295. /**
  33296. * Gets or sets if all animations should loop or not
  33297. */
  33298. loopAnimation: boolean;
  33299. /**
  33300. * Gets the targeted animations for this animation group
  33301. */
  33302. readonly targetedAnimations: Array<TargetedAnimation>;
  33303. /**
  33304. * returning the list of animatables controlled by this animation group.
  33305. */
  33306. readonly animatables: Array<Animatable>;
  33307. /**
  33308. * Instantiates a new Animation Group.
  33309. * This helps managing several animations at once.
  33310. * @see http://doc.babylonjs.com/how_to/group
  33311. * @param name Defines the name of the group
  33312. * @param scene Defines the scene the group belongs to
  33313. */
  33314. constructor(
  33315. /** The name of the animation group */
  33316. name: string, scene?: Nullable<Scene>);
  33317. /**
  33318. * Add an animation (with its target) in the group
  33319. * @param animation defines the animation we want to add
  33320. * @param target defines the target of the animation
  33321. * @returns the TargetedAnimation object
  33322. */
  33323. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33324. /**
  33325. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33326. * It can add constant keys at begin or end
  33327. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33328. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33329. * @returns the animation group
  33330. */
  33331. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33332. /**
  33333. * Start all animations on given targets
  33334. * @param loop defines if animations must loop
  33335. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33336. * @param from defines the from key (optional)
  33337. * @param to defines the to key (optional)
  33338. * @returns the current animation group
  33339. */
  33340. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33341. /**
  33342. * Pause all animations
  33343. * @returns the animation group
  33344. */
  33345. pause(): AnimationGroup;
  33346. /**
  33347. * Play all animations to initial state
  33348. * This function will start() the animations if they were not started or will restart() them if they were paused
  33349. * @param loop defines if animations must loop
  33350. * @returns the animation group
  33351. */
  33352. play(loop?: boolean): AnimationGroup;
  33353. /**
  33354. * Reset all animations to initial state
  33355. * @returns the animation group
  33356. */
  33357. reset(): AnimationGroup;
  33358. /**
  33359. * Restart animations from key 0
  33360. * @returns the animation group
  33361. */
  33362. restart(): AnimationGroup;
  33363. /**
  33364. * Stop all animations
  33365. * @returns the animation group
  33366. */
  33367. stop(): AnimationGroup;
  33368. /**
  33369. * Set animation weight for all animatables
  33370. * @param weight defines the weight to use
  33371. * @return the animationGroup
  33372. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33373. */
  33374. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33375. /**
  33376. * Synchronize and normalize all animatables with a source animatable
  33377. * @param root defines the root animatable to synchronize with
  33378. * @return the animationGroup
  33379. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33380. */
  33381. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33382. /**
  33383. * Goes to a specific frame in this animation group
  33384. * @param frame the frame number to go to
  33385. * @return the animationGroup
  33386. */
  33387. goToFrame(frame: number): AnimationGroup;
  33388. /**
  33389. * Dispose all associated resources
  33390. */
  33391. dispose(): void;
  33392. private _checkAnimationGroupEnded;
  33393. /**
  33394. * Clone the current animation group and returns a copy
  33395. * @param newName defines the name of the new group
  33396. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33397. * @returns the new aniamtion group
  33398. */
  33399. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33400. /**
  33401. * Serializes the animationGroup to an object
  33402. * @returns Serialized object
  33403. */
  33404. serialize(): any;
  33405. /**
  33406. * Returns a new AnimationGroup object parsed from the source provided.
  33407. * @param parsedAnimationGroup defines the source
  33408. * @param scene defines the scene that will receive the animationGroup
  33409. * @returns a new AnimationGroup
  33410. */
  33411. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33412. /**
  33413. * Returns the string "AnimationGroup"
  33414. * @returns "AnimationGroup"
  33415. */
  33416. getClassName(): string;
  33417. /**
  33418. * Creates a detailled string about the object
  33419. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33420. * @returns a string representing the object
  33421. */
  33422. toString(fullDetails?: boolean): string;
  33423. }
  33424. }
  33425. declare module "babylonjs/scene" {
  33426. import { Nullable } from "babylonjs/types";
  33427. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33428. import { Observable } from "babylonjs/Misc/observable";
  33429. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33430. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33431. import { Geometry } from "babylonjs/Meshes/geometry";
  33432. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33433. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33434. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33435. import { Mesh } from "babylonjs/Meshes/mesh";
  33436. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33437. import { Bone } from "babylonjs/Bones/bone";
  33438. import { Skeleton } from "babylonjs/Bones/skeleton";
  33439. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33440. import { Camera } from "babylonjs/Cameras/camera";
  33441. import { AbstractScene } from "babylonjs/abstractScene";
  33442. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33443. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33444. import { Material } from "babylonjs/Materials/material";
  33445. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33446. import { Effect } from "babylonjs/Materials/effect";
  33447. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33448. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33449. import { Light } from "babylonjs/Lights/light";
  33450. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33451. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33452. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33453. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33454. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33455. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33456. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33457. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33458. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33459. import { Engine } from "babylonjs/Engines/engine";
  33460. import { Node } from "babylonjs/node";
  33461. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33462. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33463. import { WebRequest } from "babylonjs/Misc/webRequest";
  33464. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33465. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33466. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33467. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33468. import { Plane } from "babylonjs/Maths/math.plane";
  33469. import { Ray } from "babylonjs/Culling/ray";
  33470. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33471. import { Animation } from "babylonjs/Animations/animation";
  33472. import { Animatable } from "babylonjs/Animations/animatable";
  33473. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33474. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33475. import { Collider } from "babylonjs/Collisions/collider";
  33476. /**
  33477. * Define an interface for all classes that will hold resources
  33478. */
  33479. export interface IDisposable {
  33480. /**
  33481. * Releases all held resources
  33482. */
  33483. dispose(): void;
  33484. }
  33485. /** Interface defining initialization parameters for Scene class */
  33486. export interface SceneOptions {
  33487. /**
  33488. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33489. * It will improve performance when the number of geometries becomes important.
  33490. */
  33491. useGeometryUniqueIdsMap?: boolean;
  33492. /**
  33493. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33494. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33495. */
  33496. useMaterialMeshMap?: boolean;
  33497. /**
  33498. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33499. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33500. */
  33501. useClonedMeshhMap?: boolean;
  33502. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33503. virtual?: boolean;
  33504. }
  33505. /**
  33506. * Represents a scene to be rendered by the engine.
  33507. * @see http://doc.babylonjs.com/features/scene
  33508. */
  33509. export class Scene extends AbstractScene implements IAnimatable {
  33510. /** The fog is deactivated */
  33511. static readonly FOGMODE_NONE: number;
  33512. /** The fog density is following an exponential function */
  33513. static readonly FOGMODE_EXP: number;
  33514. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33515. static readonly FOGMODE_EXP2: number;
  33516. /** The fog density is following a linear function. */
  33517. static readonly FOGMODE_LINEAR: number;
  33518. /**
  33519. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33520. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33521. */
  33522. static MinDeltaTime: number;
  33523. /**
  33524. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33525. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33526. */
  33527. static MaxDeltaTime: number;
  33528. /**
  33529. * Factory used to create the default material.
  33530. * @param name The name of the material to create
  33531. * @param scene The scene to create the material for
  33532. * @returns The default material
  33533. */
  33534. static DefaultMaterialFactory(scene: Scene): Material;
  33535. /**
  33536. * Factory used to create the a collision coordinator.
  33537. * @returns The collision coordinator
  33538. */
  33539. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33540. /** @hidden */
  33541. _inputManager: InputManager;
  33542. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33543. cameraToUseForPointers: Nullable<Camera>;
  33544. /** @hidden */
  33545. readonly _isScene: boolean;
  33546. /**
  33547. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33548. */
  33549. autoClear: boolean;
  33550. /**
  33551. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33552. */
  33553. autoClearDepthAndStencil: boolean;
  33554. /**
  33555. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33556. */
  33557. clearColor: Color4;
  33558. /**
  33559. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33560. */
  33561. ambientColor: Color3;
  33562. /**
  33563. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33564. * It should only be one of the following (if not the default embedded one):
  33565. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33566. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33567. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33568. * The material properties need to be setup according to the type of texture in use.
  33569. */
  33570. environmentBRDFTexture: BaseTexture;
  33571. /** @hidden */
  33572. protected _environmentTexture: Nullable<BaseTexture>;
  33573. /**
  33574. * Texture used in all pbr material as the reflection texture.
  33575. * As in the majority of the scene they are the same (exception for multi room and so on),
  33576. * this is easier to reference from here than from all the materials.
  33577. */
  33578. /**
  33579. * Texture used in all pbr material as the reflection texture.
  33580. * As in the majority of the scene they are the same (exception for multi room and so on),
  33581. * this is easier to set here than in all the materials.
  33582. */
  33583. environmentTexture: Nullable<BaseTexture>;
  33584. /** @hidden */
  33585. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33586. /**
  33587. * Default image processing configuration used either in the rendering
  33588. * Forward main pass or through the imageProcessingPostProcess if present.
  33589. * As in the majority of the scene they are the same (exception for multi camera),
  33590. * this is easier to reference from here than from all the materials and post process.
  33591. *
  33592. * No setter as we it is a shared configuration, you can set the values instead.
  33593. */
  33594. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33595. private _forceWireframe;
  33596. /**
  33597. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33598. */
  33599. forceWireframe: boolean;
  33600. private _forcePointsCloud;
  33601. /**
  33602. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33603. */
  33604. forcePointsCloud: boolean;
  33605. /**
  33606. * Gets or sets the active clipplane 1
  33607. */
  33608. clipPlane: Nullable<Plane>;
  33609. /**
  33610. * Gets or sets the active clipplane 2
  33611. */
  33612. clipPlane2: Nullable<Plane>;
  33613. /**
  33614. * Gets or sets the active clipplane 3
  33615. */
  33616. clipPlane3: Nullable<Plane>;
  33617. /**
  33618. * Gets or sets the active clipplane 4
  33619. */
  33620. clipPlane4: Nullable<Plane>;
  33621. /**
  33622. * Gets or sets a boolean indicating if animations are enabled
  33623. */
  33624. animationsEnabled: boolean;
  33625. private _animationPropertiesOverride;
  33626. /**
  33627. * Gets or sets the animation properties override
  33628. */
  33629. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33630. /**
  33631. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33632. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33633. */
  33634. useConstantAnimationDeltaTime: boolean;
  33635. /**
  33636. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33637. * Please note that it requires to run a ray cast through the scene on every frame
  33638. */
  33639. constantlyUpdateMeshUnderPointer: boolean;
  33640. /**
  33641. * Defines the HTML cursor to use when hovering over interactive elements
  33642. */
  33643. hoverCursor: string;
  33644. /**
  33645. * Defines the HTML default cursor to use (empty by default)
  33646. */
  33647. defaultCursor: string;
  33648. /**
  33649. * This is used to call preventDefault() on pointer down
  33650. * in order to block unwanted artifacts like system double clicks
  33651. */
  33652. preventDefaultOnPointerDown: boolean;
  33653. /**
  33654. * This is used to call preventDefault() on pointer up
  33655. * in order to block unwanted artifacts like system double clicks
  33656. */
  33657. preventDefaultOnPointerUp: boolean;
  33658. /**
  33659. * Gets or sets user defined metadata
  33660. */
  33661. metadata: any;
  33662. /**
  33663. * For internal use only. Please do not use.
  33664. */
  33665. reservedDataStore: any;
  33666. /**
  33667. * Gets the name of the plugin used to load this scene (null by default)
  33668. */
  33669. loadingPluginName: string;
  33670. /**
  33671. * Use this array to add regular expressions used to disable offline support for specific urls
  33672. */
  33673. disableOfflineSupportExceptionRules: RegExp[];
  33674. /**
  33675. * An event triggered when the scene is disposed.
  33676. */
  33677. onDisposeObservable: Observable<Scene>;
  33678. private _onDisposeObserver;
  33679. /** Sets a function to be executed when this scene is disposed. */
  33680. onDispose: () => void;
  33681. /**
  33682. * An event triggered before rendering the scene (right after animations and physics)
  33683. */
  33684. onBeforeRenderObservable: Observable<Scene>;
  33685. private _onBeforeRenderObserver;
  33686. /** Sets a function to be executed before rendering this scene */
  33687. beforeRender: Nullable<() => void>;
  33688. /**
  33689. * An event triggered after rendering the scene
  33690. */
  33691. onAfterRenderObservable: Observable<Scene>;
  33692. /**
  33693. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33694. */
  33695. onAfterRenderCameraObservable: Observable<Camera>;
  33696. private _onAfterRenderObserver;
  33697. /** Sets a function to be executed after rendering this scene */
  33698. afterRender: Nullable<() => void>;
  33699. /**
  33700. * An event triggered before animating the scene
  33701. */
  33702. onBeforeAnimationsObservable: Observable<Scene>;
  33703. /**
  33704. * An event triggered after animations processing
  33705. */
  33706. onAfterAnimationsObservable: Observable<Scene>;
  33707. /**
  33708. * An event triggered before draw calls are ready to be sent
  33709. */
  33710. onBeforeDrawPhaseObservable: Observable<Scene>;
  33711. /**
  33712. * An event triggered after draw calls have been sent
  33713. */
  33714. onAfterDrawPhaseObservable: Observable<Scene>;
  33715. /**
  33716. * An event triggered when the scene is ready
  33717. */
  33718. onReadyObservable: Observable<Scene>;
  33719. /**
  33720. * An event triggered before rendering a camera
  33721. */
  33722. onBeforeCameraRenderObservable: Observable<Camera>;
  33723. private _onBeforeCameraRenderObserver;
  33724. /** Sets a function to be executed before rendering a camera*/
  33725. beforeCameraRender: () => void;
  33726. /**
  33727. * An event triggered after rendering a camera
  33728. */
  33729. onAfterCameraRenderObservable: Observable<Camera>;
  33730. private _onAfterCameraRenderObserver;
  33731. /** Sets a function to be executed after rendering a camera*/
  33732. afterCameraRender: () => void;
  33733. /**
  33734. * An event triggered when active meshes evaluation is about to start
  33735. */
  33736. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33737. /**
  33738. * An event triggered when active meshes evaluation is done
  33739. */
  33740. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33741. /**
  33742. * An event triggered when particles rendering is about to start
  33743. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33744. */
  33745. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33746. /**
  33747. * An event triggered when particles rendering is done
  33748. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33749. */
  33750. onAfterParticlesRenderingObservable: Observable<Scene>;
  33751. /**
  33752. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33753. */
  33754. onDataLoadedObservable: Observable<Scene>;
  33755. /**
  33756. * An event triggered when a camera is created
  33757. */
  33758. onNewCameraAddedObservable: Observable<Camera>;
  33759. /**
  33760. * An event triggered when a camera is removed
  33761. */
  33762. onCameraRemovedObservable: Observable<Camera>;
  33763. /**
  33764. * An event triggered when a light is created
  33765. */
  33766. onNewLightAddedObservable: Observable<Light>;
  33767. /**
  33768. * An event triggered when a light is removed
  33769. */
  33770. onLightRemovedObservable: Observable<Light>;
  33771. /**
  33772. * An event triggered when a geometry is created
  33773. */
  33774. onNewGeometryAddedObservable: Observable<Geometry>;
  33775. /**
  33776. * An event triggered when a geometry is removed
  33777. */
  33778. onGeometryRemovedObservable: Observable<Geometry>;
  33779. /**
  33780. * An event triggered when a transform node is created
  33781. */
  33782. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33783. /**
  33784. * An event triggered when a transform node is removed
  33785. */
  33786. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33787. /**
  33788. * An event triggered when a mesh is created
  33789. */
  33790. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33791. /**
  33792. * An event triggered when a mesh is removed
  33793. */
  33794. onMeshRemovedObservable: Observable<AbstractMesh>;
  33795. /**
  33796. * An event triggered when a skeleton is created
  33797. */
  33798. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33799. /**
  33800. * An event triggered when a skeleton is removed
  33801. */
  33802. onSkeletonRemovedObservable: Observable<Skeleton>;
  33803. /**
  33804. * An event triggered when a material is created
  33805. */
  33806. onNewMaterialAddedObservable: Observable<Material>;
  33807. /**
  33808. * An event triggered when a material is removed
  33809. */
  33810. onMaterialRemovedObservable: Observable<Material>;
  33811. /**
  33812. * An event triggered when a texture is created
  33813. */
  33814. onNewTextureAddedObservable: Observable<BaseTexture>;
  33815. /**
  33816. * An event triggered when a texture is removed
  33817. */
  33818. onTextureRemovedObservable: Observable<BaseTexture>;
  33819. /**
  33820. * An event triggered when render targets are about to be rendered
  33821. * Can happen multiple times per frame.
  33822. */
  33823. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33824. /**
  33825. * An event triggered when render targets were rendered.
  33826. * Can happen multiple times per frame.
  33827. */
  33828. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33829. /**
  33830. * An event triggered before calculating deterministic simulation step
  33831. */
  33832. onBeforeStepObservable: Observable<Scene>;
  33833. /**
  33834. * An event triggered after calculating deterministic simulation step
  33835. */
  33836. onAfterStepObservable: Observable<Scene>;
  33837. /**
  33838. * An event triggered when the activeCamera property is updated
  33839. */
  33840. onActiveCameraChanged: Observable<Scene>;
  33841. /**
  33842. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33843. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33844. * 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)
  33845. */
  33846. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33847. /**
  33848. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33849. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33850. * 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)
  33851. */
  33852. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33853. /**
  33854. * This Observable will when a mesh has been imported into the scene.
  33855. */
  33856. onMeshImportedObservable: Observable<AbstractMesh>;
  33857. /**
  33858. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33859. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33860. */
  33861. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33862. /** @hidden */
  33863. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33864. /**
  33865. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33866. */
  33867. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33868. /**
  33869. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33870. */
  33871. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33872. /**
  33873. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33874. */
  33875. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33876. /** Callback called when a pointer move is detected */
  33877. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33878. /** Callback called when a pointer down is detected */
  33879. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33880. /** Callback called when a pointer up is detected */
  33881. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33882. /** Callback called when a pointer pick is detected */
  33883. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33884. /**
  33885. * 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).
  33886. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33887. */
  33888. onPrePointerObservable: Observable<PointerInfoPre>;
  33889. /**
  33890. * Observable event triggered each time an input event is received from the rendering canvas
  33891. */
  33892. onPointerObservable: Observable<PointerInfo>;
  33893. /**
  33894. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33895. */
  33896. readonly unTranslatedPointer: Vector2;
  33897. /**
  33898. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33899. */
  33900. static DragMovementThreshold: number;
  33901. /**
  33902. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33903. */
  33904. static LongPressDelay: number;
  33905. /**
  33906. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33907. */
  33908. static DoubleClickDelay: number;
  33909. /** If you need to check double click without raising a single click at first click, enable this flag */
  33910. static ExclusiveDoubleClickMode: boolean;
  33911. /** @hidden */
  33912. _mirroredCameraPosition: Nullable<Vector3>;
  33913. /**
  33914. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33915. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33916. */
  33917. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33918. /**
  33919. * Observable event triggered each time an keyboard event is received from the hosting window
  33920. */
  33921. onKeyboardObservable: Observable<KeyboardInfo>;
  33922. private _useRightHandedSystem;
  33923. /**
  33924. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33925. */
  33926. useRightHandedSystem: boolean;
  33927. private _timeAccumulator;
  33928. private _currentStepId;
  33929. private _currentInternalStep;
  33930. /**
  33931. * Sets the step Id used by deterministic lock step
  33932. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33933. * @param newStepId defines the step Id
  33934. */
  33935. setStepId(newStepId: number): void;
  33936. /**
  33937. * Gets the step Id used by deterministic lock step
  33938. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33939. * @returns the step Id
  33940. */
  33941. getStepId(): number;
  33942. /**
  33943. * Gets the internal step used by deterministic lock step
  33944. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33945. * @returns the internal step
  33946. */
  33947. getInternalStep(): number;
  33948. private _fogEnabled;
  33949. /**
  33950. * Gets or sets a boolean indicating if fog is enabled on this scene
  33951. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33952. * (Default is true)
  33953. */
  33954. fogEnabled: boolean;
  33955. private _fogMode;
  33956. /**
  33957. * Gets or sets the fog mode to use
  33958. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33959. * | mode | value |
  33960. * | --- | --- |
  33961. * | FOGMODE_NONE | 0 |
  33962. * | FOGMODE_EXP | 1 |
  33963. * | FOGMODE_EXP2 | 2 |
  33964. * | FOGMODE_LINEAR | 3 |
  33965. */
  33966. fogMode: number;
  33967. /**
  33968. * Gets or sets the fog color to use
  33969. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33970. * (Default is Color3(0.2, 0.2, 0.3))
  33971. */
  33972. fogColor: Color3;
  33973. /**
  33974. * Gets or sets the fog density to use
  33975. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33976. * (Default is 0.1)
  33977. */
  33978. fogDensity: number;
  33979. /**
  33980. * Gets or sets the fog start distance to use
  33981. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33982. * (Default is 0)
  33983. */
  33984. fogStart: number;
  33985. /**
  33986. * Gets or sets the fog end distance to use
  33987. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33988. * (Default is 1000)
  33989. */
  33990. fogEnd: number;
  33991. private _shadowsEnabled;
  33992. /**
  33993. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33994. */
  33995. shadowsEnabled: boolean;
  33996. private _lightsEnabled;
  33997. /**
  33998. * Gets or sets a boolean indicating if lights are enabled on this scene
  33999. */
  34000. lightsEnabled: boolean;
  34001. /** All of the active cameras added to this scene. */
  34002. activeCameras: Camera[];
  34003. /** @hidden */
  34004. _activeCamera: Nullable<Camera>;
  34005. /** Gets or sets the current active camera */
  34006. activeCamera: Nullable<Camera>;
  34007. private _defaultMaterial;
  34008. /** The default material used on meshes when no material is affected */
  34009. /** The default material used on meshes when no material is affected */
  34010. defaultMaterial: Material;
  34011. private _texturesEnabled;
  34012. /**
  34013. * Gets or sets a boolean indicating if textures are enabled on this scene
  34014. */
  34015. texturesEnabled: boolean;
  34016. /**
  34017. * Gets or sets a boolean indicating if particles are enabled on this scene
  34018. */
  34019. particlesEnabled: boolean;
  34020. /**
  34021. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34022. */
  34023. spritesEnabled: boolean;
  34024. private _skeletonsEnabled;
  34025. /**
  34026. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34027. */
  34028. skeletonsEnabled: boolean;
  34029. /**
  34030. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34031. */
  34032. lensFlaresEnabled: boolean;
  34033. /**
  34034. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34035. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34036. */
  34037. collisionsEnabled: boolean;
  34038. private _collisionCoordinator;
  34039. /** @hidden */
  34040. readonly collisionCoordinator: ICollisionCoordinator;
  34041. /**
  34042. * Defines the gravity applied to this scene (used only for collisions)
  34043. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34044. */
  34045. gravity: Vector3;
  34046. /**
  34047. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34048. */
  34049. postProcessesEnabled: boolean;
  34050. /**
  34051. * The list of postprocesses added to the scene
  34052. */
  34053. postProcesses: PostProcess[];
  34054. /**
  34055. * Gets the current postprocess manager
  34056. */
  34057. postProcessManager: PostProcessManager;
  34058. /**
  34059. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34060. */
  34061. renderTargetsEnabled: boolean;
  34062. /**
  34063. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34064. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34065. */
  34066. dumpNextRenderTargets: boolean;
  34067. /**
  34068. * The list of user defined render targets added to the scene
  34069. */
  34070. customRenderTargets: RenderTargetTexture[];
  34071. /**
  34072. * Defines if texture loading must be delayed
  34073. * If true, textures will only be loaded when they need to be rendered
  34074. */
  34075. useDelayedTextureLoading: boolean;
  34076. /**
  34077. * Gets the list of meshes imported to the scene through SceneLoader
  34078. */
  34079. importedMeshesFiles: String[];
  34080. /**
  34081. * Gets or sets a boolean indicating if probes are enabled on this scene
  34082. */
  34083. probesEnabled: boolean;
  34084. /**
  34085. * Gets or sets the current offline provider to use to store scene data
  34086. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34087. */
  34088. offlineProvider: IOfflineProvider;
  34089. /**
  34090. * Gets or sets the action manager associated with the scene
  34091. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34092. */
  34093. actionManager: AbstractActionManager;
  34094. private _meshesForIntersections;
  34095. /**
  34096. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34097. */
  34098. proceduralTexturesEnabled: boolean;
  34099. private _engine;
  34100. private _totalVertices;
  34101. /** @hidden */
  34102. _activeIndices: PerfCounter;
  34103. /** @hidden */
  34104. _activeParticles: PerfCounter;
  34105. /** @hidden */
  34106. _activeBones: PerfCounter;
  34107. private _animationRatio;
  34108. /** @hidden */
  34109. _animationTimeLast: number;
  34110. /** @hidden */
  34111. _animationTime: number;
  34112. /**
  34113. * Gets or sets a general scale for animation speed
  34114. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34115. */
  34116. animationTimeScale: number;
  34117. /** @hidden */
  34118. _cachedMaterial: Nullable<Material>;
  34119. /** @hidden */
  34120. _cachedEffect: Nullable<Effect>;
  34121. /** @hidden */
  34122. _cachedVisibility: Nullable<number>;
  34123. private _renderId;
  34124. private _frameId;
  34125. private _executeWhenReadyTimeoutId;
  34126. private _intermediateRendering;
  34127. private _viewUpdateFlag;
  34128. private _projectionUpdateFlag;
  34129. /** @hidden */
  34130. _toBeDisposed: Nullable<IDisposable>[];
  34131. private _activeRequests;
  34132. /** @hidden */
  34133. _pendingData: any[];
  34134. private _isDisposed;
  34135. /**
  34136. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34137. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34138. */
  34139. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34140. private _activeMeshes;
  34141. private _processedMaterials;
  34142. private _renderTargets;
  34143. /** @hidden */
  34144. _activeParticleSystems: SmartArray<IParticleSystem>;
  34145. private _activeSkeletons;
  34146. private _softwareSkinnedMeshes;
  34147. private _renderingManager;
  34148. /** @hidden */
  34149. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34150. private _transformMatrix;
  34151. private _sceneUbo;
  34152. /** @hidden */
  34153. _viewMatrix: Matrix;
  34154. private _projectionMatrix;
  34155. /** @hidden */
  34156. _forcedViewPosition: Nullable<Vector3>;
  34157. /** @hidden */
  34158. _frustumPlanes: Plane[];
  34159. /**
  34160. * Gets the list of frustum planes (built from the active camera)
  34161. */
  34162. readonly frustumPlanes: Plane[];
  34163. /**
  34164. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34165. * This is useful if there are more lights that the maximum simulteanous authorized
  34166. */
  34167. requireLightSorting: boolean;
  34168. /** @hidden */
  34169. readonly useMaterialMeshMap: boolean;
  34170. /** @hidden */
  34171. readonly useClonedMeshhMap: boolean;
  34172. private _externalData;
  34173. private _uid;
  34174. /**
  34175. * @hidden
  34176. * Backing store of defined scene components.
  34177. */
  34178. _components: ISceneComponent[];
  34179. /**
  34180. * @hidden
  34181. * Backing store of defined scene components.
  34182. */
  34183. _serializableComponents: ISceneSerializableComponent[];
  34184. /**
  34185. * List of components to register on the next registration step.
  34186. */
  34187. private _transientComponents;
  34188. /**
  34189. * Registers the transient components if needed.
  34190. */
  34191. private _registerTransientComponents;
  34192. /**
  34193. * @hidden
  34194. * Add a component to the scene.
  34195. * Note that the ccomponent could be registered on th next frame if this is called after
  34196. * the register component stage.
  34197. * @param component Defines the component to add to the scene
  34198. */
  34199. _addComponent(component: ISceneComponent): void;
  34200. /**
  34201. * @hidden
  34202. * Gets a component from the scene.
  34203. * @param name defines the name of the component to retrieve
  34204. * @returns the component or null if not present
  34205. */
  34206. _getComponent(name: string): Nullable<ISceneComponent>;
  34207. /**
  34208. * @hidden
  34209. * Defines the actions happening before camera updates.
  34210. */
  34211. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34212. /**
  34213. * @hidden
  34214. * Defines the actions happening before clear the canvas.
  34215. */
  34216. _beforeClearStage: Stage<SimpleStageAction>;
  34217. /**
  34218. * @hidden
  34219. * Defines the actions when collecting render targets for the frame.
  34220. */
  34221. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34222. /**
  34223. * @hidden
  34224. * Defines the actions happening for one camera in the frame.
  34225. */
  34226. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34227. /**
  34228. * @hidden
  34229. * Defines the actions happening during the per mesh ready checks.
  34230. */
  34231. _isReadyForMeshStage: Stage<MeshStageAction>;
  34232. /**
  34233. * @hidden
  34234. * Defines the actions happening before evaluate active mesh checks.
  34235. */
  34236. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34237. /**
  34238. * @hidden
  34239. * Defines the actions happening during the evaluate sub mesh checks.
  34240. */
  34241. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34242. /**
  34243. * @hidden
  34244. * Defines the actions happening during the active mesh stage.
  34245. */
  34246. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34247. /**
  34248. * @hidden
  34249. * Defines the actions happening during the per camera render target step.
  34250. */
  34251. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34252. /**
  34253. * @hidden
  34254. * Defines the actions happening just before the active camera is drawing.
  34255. */
  34256. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34257. /**
  34258. * @hidden
  34259. * Defines the actions happening just before a render target is drawing.
  34260. */
  34261. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34262. /**
  34263. * @hidden
  34264. * Defines the actions happening just before a rendering group is drawing.
  34265. */
  34266. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34267. /**
  34268. * @hidden
  34269. * Defines the actions happening just before a mesh is drawing.
  34270. */
  34271. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34272. /**
  34273. * @hidden
  34274. * Defines the actions happening just after a mesh has been drawn.
  34275. */
  34276. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34277. /**
  34278. * @hidden
  34279. * Defines the actions happening just after a rendering group has been drawn.
  34280. */
  34281. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34282. /**
  34283. * @hidden
  34284. * Defines the actions happening just after the active camera has been drawn.
  34285. */
  34286. _afterCameraDrawStage: Stage<CameraStageAction>;
  34287. /**
  34288. * @hidden
  34289. * Defines the actions happening just after a render target has been drawn.
  34290. */
  34291. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34292. /**
  34293. * @hidden
  34294. * Defines the actions happening just after rendering all cameras and computing intersections.
  34295. */
  34296. _afterRenderStage: Stage<SimpleStageAction>;
  34297. /**
  34298. * @hidden
  34299. * Defines the actions happening when a pointer move event happens.
  34300. */
  34301. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34302. /**
  34303. * @hidden
  34304. * Defines the actions happening when a pointer down event happens.
  34305. */
  34306. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34307. /**
  34308. * @hidden
  34309. * Defines the actions happening when a pointer up event happens.
  34310. */
  34311. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34312. /**
  34313. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34314. */
  34315. private geometriesByUniqueId;
  34316. /**
  34317. * Creates a new Scene
  34318. * @param engine defines the engine to use to render this scene
  34319. * @param options defines the scene options
  34320. */
  34321. constructor(engine: Engine, options?: SceneOptions);
  34322. /**
  34323. * Gets a string idenfifying the name of the class
  34324. * @returns "Scene" string
  34325. */
  34326. getClassName(): string;
  34327. private _defaultMeshCandidates;
  34328. /**
  34329. * @hidden
  34330. */
  34331. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34332. private _defaultSubMeshCandidates;
  34333. /**
  34334. * @hidden
  34335. */
  34336. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34337. /**
  34338. * Sets the default candidate providers for the scene.
  34339. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34340. * and getCollidingSubMeshCandidates to their default function
  34341. */
  34342. setDefaultCandidateProviders(): void;
  34343. /**
  34344. * Gets the mesh that is currently under the pointer
  34345. */
  34346. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34347. /**
  34348. * Gets or sets the current on-screen X position of the pointer
  34349. */
  34350. pointerX: number;
  34351. /**
  34352. * Gets or sets the current on-screen Y position of the pointer
  34353. */
  34354. pointerY: number;
  34355. /**
  34356. * Gets the cached material (ie. the latest rendered one)
  34357. * @returns the cached material
  34358. */
  34359. getCachedMaterial(): Nullable<Material>;
  34360. /**
  34361. * Gets the cached effect (ie. the latest rendered one)
  34362. * @returns the cached effect
  34363. */
  34364. getCachedEffect(): Nullable<Effect>;
  34365. /**
  34366. * Gets the cached visibility state (ie. the latest rendered one)
  34367. * @returns the cached visibility state
  34368. */
  34369. getCachedVisibility(): Nullable<number>;
  34370. /**
  34371. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34372. * @param material defines the current material
  34373. * @param effect defines the current effect
  34374. * @param visibility defines the current visibility state
  34375. * @returns true if one parameter is not cached
  34376. */
  34377. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34378. /**
  34379. * Gets the engine associated with the scene
  34380. * @returns an Engine
  34381. */
  34382. getEngine(): Engine;
  34383. /**
  34384. * Gets the total number of vertices rendered per frame
  34385. * @returns the total number of vertices rendered per frame
  34386. */
  34387. getTotalVertices(): number;
  34388. /**
  34389. * Gets the performance counter for total vertices
  34390. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34391. */
  34392. readonly totalVerticesPerfCounter: PerfCounter;
  34393. /**
  34394. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34395. * @returns the total number of active indices rendered per frame
  34396. */
  34397. getActiveIndices(): number;
  34398. /**
  34399. * Gets the performance counter for active indices
  34400. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34401. */
  34402. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34403. /**
  34404. * Gets the total number of active particles rendered per frame
  34405. * @returns the total number of active particles rendered per frame
  34406. */
  34407. getActiveParticles(): number;
  34408. /**
  34409. * Gets the performance counter for active particles
  34410. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34411. */
  34412. readonly activeParticlesPerfCounter: PerfCounter;
  34413. /**
  34414. * Gets the total number of active bones rendered per frame
  34415. * @returns the total number of active bones rendered per frame
  34416. */
  34417. getActiveBones(): number;
  34418. /**
  34419. * Gets the performance counter for active bones
  34420. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34421. */
  34422. readonly activeBonesPerfCounter: PerfCounter;
  34423. /**
  34424. * Gets the array of active meshes
  34425. * @returns an array of AbstractMesh
  34426. */
  34427. getActiveMeshes(): SmartArray<AbstractMesh>;
  34428. /**
  34429. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34430. * @returns a number
  34431. */
  34432. getAnimationRatio(): number;
  34433. /**
  34434. * Gets an unique Id for the current render phase
  34435. * @returns a number
  34436. */
  34437. getRenderId(): number;
  34438. /**
  34439. * Gets an unique Id for the current frame
  34440. * @returns a number
  34441. */
  34442. getFrameId(): number;
  34443. /** Call this function if you want to manually increment the render Id*/
  34444. incrementRenderId(): void;
  34445. private _createUbo;
  34446. /**
  34447. * Use this method to simulate a pointer move on a mesh
  34448. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34449. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34450. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34451. * @returns the current scene
  34452. */
  34453. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34454. /**
  34455. * Use this method to simulate a pointer down on a mesh
  34456. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34457. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34458. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34459. * @returns the current scene
  34460. */
  34461. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34462. /**
  34463. * Use this method to simulate a pointer up on a mesh
  34464. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34465. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34466. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34467. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34468. * @returns the current scene
  34469. */
  34470. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34471. /**
  34472. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34473. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34474. * @returns true if the pointer was captured
  34475. */
  34476. isPointerCaptured(pointerId?: number): boolean;
  34477. /**
  34478. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34479. * @param attachUp defines if you want to attach events to pointerup
  34480. * @param attachDown defines if you want to attach events to pointerdown
  34481. * @param attachMove defines if you want to attach events to pointermove
  34482. */
  34483. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34484. /** Detaches all event handlers*/
  34485. detachControl(): void;
  34486. /**
  34487. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34488. * Delay loaded resources are not taking in account
  34489. * @return true if all required resources are ready
  34490. */
  34491. isReady(): boolean;
  34492. /** Resets all cached information relative to material (including effect and visibility) */
  34493. resetCachedMaterial(): void;
  34494. /**
  34495. * Registers a function to be called before every frame render
  34496. * @param func defines the function to register
  34497. */
  34498. registerBeforeRender(func: () => void): void;
  34499. /**
  34500. * Unregisters a function called before every frame render
  34501. * @param func defines the function to unregister
  34502. */
  34503. unregisterBeforeRender(func: () => void): void;
  34504. /**
  34505. * Registers a function to be called after every frame render
  34506. * @param func defines the function to register
  34507. */
  34508. registerAfterRender(func: () => void): void;
  34509. /**
  34510. * Unregisters a function called after every frame render
  34511. * @param func defines the function to unregister
  34512. */
  34513. unregisterAfterRender(func: () => void): void;
  34514. private _executeOnceBeforeRender;
  34515. /**
  34516. * The provided function will run before render once and will be disposed afterwards.
  34517. * A timeout delay can be provided so that the function will be executed in N ms.
  34518. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34519. * @param func The function to be executed.
  34520. * @param timeout optional delay in ms
  34521. */
  34522. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34523. /** @hidden */
  34524. _addPendingData(data: any): void;
  34525. /** @hidden */
  34526. _removePendingData(data: any): void;
  34527. /**
  34528. * Returns the number of items waiting to be loaded
  34529. * @returns the number of items waiting to be loaded
  34530. */
  34531. getWaitingItemsCount(): number;
  34532. /**
  34533. * Returns a boolean indicating if the scene is still loading data
  34534. */
  34535. readonly isLoading: boolean;
  34536. /**
  34537. * Registers a function to be executed when the scene is ready
  34538. * @param {Function} func - the function to be executed
  34539. */
  34540. executeWhenReady(func: () => void): void;
  34541. /**
  34542. * Returns a promise that resolves when the scene is ready
  34543. * @returns A promise that resolves when the scene is ready
  34544. */
  34545. whenReadyAsync(): Promise<void>;
  34546. /** @hidden */
  34547. _checkIsReady(): void;
  34548. /**
  34549. * Gets all animatable attached to the scene
  34550. */
  34551. readonly animatables: Animatable[];
  34552. /**
  34553. * Resets the last animation time frame.
  34554. * Useful to override when animations start running when loading a scene for the first time.
  34555. */
  34556. resetLastAnimationTimeFrame(): void;
  34557. /**
  34558. * Gets the current view matrix
  34559. * @returns a Matrix
  34560. */
  34561. getViewMatrix(): Matrix;
  34562. /**
  34563. * Gets the current projection matrix
  34564. * @returns a Matrix
  34565. */
  34566. getProjectionMatrix(): Matrix;
  34567. /**
  34568. * Gets the current transform matrix
  34569. * @returns a Matrix made of View * Projection
  34570. */
  34571. getTransformMatrix(): Matrix;
  34572. /**
  34573. * Sets the current transform matrix
  34574. * @param viewL defines the View matrix to use
  34575. * @param projectionL defines the Projection matrix to use
  34576. * @param viewR defines the right View matrix to use (if provided)
  34577. * @param projectionR defines the right Projection matrix to use (if provided)
  34578. */
  34579. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34580. /**
  34581. * Gets the uniform buffer used to store scene data
  34582. * @returns a UniformBuffer
  34583. */
  34584. getSceneUniformBuffer(): UniformBuffer;
  34585. /**
  34586. * Gets an unique (relatively to the current scene) Id
  34587. * @returns an unique number for the scene
  34588. */
  34589. getUniqueId(): number;
  34590. /**
  34591. * Add a mesh to the list of scene's meshes
  34592. * @param newMesh defines the mesh to add
  34593. * @param recursive if all child meshes should also be added to the scene
  34594. */
  34595. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34596. /**
  34597. * Remove a mesh for the list of scene's meshes
  34598. * @param toRemove defines the mesh to remove
  34599. * @param recursive if all child meshes should also be removed from the scene
  34600. * @returns the index where the mesh was in the mesh list
  34601. */
  34602. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34603. /**
  34604. * Add a transform node to the list of scene's transform nodes
  34605. * @param newTransformNode defines the transform node to add
  34606. */
  34607. addTransformNode(newTransformNode: TransformNode): void;
  34608. /**
  34609. * Remove a transform node for the list of scene's transform nodes
  34610. * @param toRemove defines the transform node to remove
  34611. * @returns the index where the transform node was in the transform node list
  34612. */
  34613. removeTransformNode(toRemove: TransformNode): number;
  34614. /**
  34615. * Remove a skeleton for the list of scene's skeletons
  34616. * @param toRemove defines the skeleton to remove
  34617. * @returns the index where the skeleton was in the skeleton list
  34618. */
  34619. removeSkeleton(toRemove: Skeleton): number;
  34620. /**
  34621. * Remove a morph target for the list of scene's morph targets
  34622. * @param toRemove defines the morph target to remove
  34623. * @returns the index where the morph target was in the morph target list
  34624. */
  34625. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34626. /**
  34627. * Remove a light for the list of scene's lights
  34628. * @param toRemove defines the light to remove
  34629. * @returns the index where the light was in the light list
  34630. */
  34631. removeLight(toRemove: Light): number;
  34632. /**
  34633. * Remove a camera for the list of scene's cameras
  34634. * @param toRemove defines the camera to remove
  34635. * @returns the index where the camera was in the camera list
  34636. */
  34637. removeCamera(toRemove: Camera): number;
  34638. /**
  34639. * Remove a particle system for the list of scene's particle systems
  34640. * @param toRemove defines the particle system to remove
  34641. * @returns the index where the particle system was in the particle system list
  34642. */
  34643. removeParticleSystem(toRemove: IParticleSystem): number;
  34644. /**
  34645. * Remove a animation for the list of scene's animations
  34646. * @param toRemove defines the animation to remove
  34647. * @returns the index where the animation was in the animation list
  34648. */
  34649. removeAnimation(toRemove: Animation): number;
  34650. /**
  34651. * Will stop the animation of the given target
  34652. * @param target - the target
  34653. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34654. * @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)
  34655. */
  34656. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34657. /**
  34658. * Removes the given animation group from this scene.
  34659. * @param toRemove The animation group to remove
  34660. * @returns The index of the removed animation group
  34661. */
  34662. removeAnimationGroup(toRemove: AnimationGroup): number;
  34663. /**
  34664. * Removes the given multi-material from this scene.
  34665. * @param toRemove The multi-material to remove
  34666. * @returns The index of the removed multi-material
  34667. */
  34668. removeMultiMaterial(toRemove: MultiMaterial): number;
  34669. /**
  34670. * Removes the given material from this scene.
  34671. * @param toRemove The material to remove
  34672. * @returns The index of the removed material
  34673. */
  34674. removeMaterial(toRemove: Material): number;
  34675. /**
  34676. * Removes the given action manager from this scene.
  34677. * @param toRemove The action manager to remove
  34678. * @returns The index of the removed action manager
  34679. */
  34680. removeActionManager(toRemove: AbstractActionManager): number;
  34681. /**
  34682. * Removes the given texture from this scene.
  34683. * @param toRemove The texture to remove
  34684. * @returns The index of the removed texture
  34685. */
  34686. removeTexture(toRemove: BaseTexture): number;
  34687. /**
  34688. * Adds the given light to this scene
  34689. * @param newLight The light to add
  34690. */
  34691. addLight(newLight: Light): void;
  34692. /**
  34693. * Sorts the list list based on light priorities
  34694. */
  34695. sortLightsByPriority(): void;
  34696. /**
  34697. * Adds the given camera to this scene
  34698. * @param newCamera The camera to add
  34699. */
  34700. addCamera(newCamera: Camera): void;
  34701. /**
  34702. * Adds the given skeleton to this scene
  34703. * @param newSkeleton The skeleton to add
  34704. */
  34705. addSkeleton(newSkeleton: Skeleton): void;
  34706. /**
  34707. * Adds the given particle system to this scene
  34708. * @param newParticleSystem The particle system to add
  34709. */
  34710. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34711. /**
  34712. * Adds the given animation to this scene
  34713. * @param newAnimation The animation to add
  34714. */
  34715. addAnimation(newAnimation: Animation): void;
  34716. /**
  34717. * Adds the given animation group to this scene.
  34718. * @param newAnimationGroup The animation group to add
  34719. */
  34720. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34721. /**
  34722. * Adds the given multi-material to this scene
  34723. * @param newMultiMaterial The multi-material to add
  34724. */
  34725. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34726. /**
  34727. * Adds the given material to this scene
  34728. * @param newMaterial The material to add
  34729. */
  34730. addMaterial(newMaterial: Material): void;
  34731. /**
  34732. * Adds the given morph target to this scene
  34733. * @param newMorphTargetManager The morph target to add
  34734. */
  34735. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34736. /**
  34737. * Adds the given geometry to this scene
  34738. * @param newGeometry The geometry to add
  34739. */
  34740. addGeometry(newGeometry: Geometry): void;
  34741. /**
  34742. * Adds the given action manager to this scene
  34743. * @param newActionManager The action manager to add
  34744. */
  34745. addActionManager(newActionManager: AbstractActionManager): void;
  34746. /**
  34747. * Adds the given texture to this scene.
  34748. * @param newTexture The texture to add
  34749. */
  34750. addTexture(newTexture: BaseTexture): void;
  34751. /**
  34752. * Switch active camera
  34753. * @param newCamera defines the new active camera
  34754. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34755. */
  34756. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34757. /**
  34758. * sets the active camera of the scene using its ID
  34759. * @param id defines the camera's ID
  34760. * @return the new active camera or null if none found.
  34761. */
  34762. setActiveCameraByID(id: string): Nullable<Camera>;
  34763. /**
  34764. * sets the active camera of the scene using its name
  34765. * @param name defines the camera's name
  34766. * @returns the new active camera or null if none found.
  34767. */
  34768. setActiveCameraByName(name: string): Nullable<Camera>;
  34769. /**
  34770. * get an animation group using its name
  34771. * @param name defines the material's name
  34772. * @return the animation group or null if none found.
  34773. */
  34774. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34775. /**
  34776. * Get a material using its unique id
  34777. * @param uniqueId defines the material's unique id
  34778. * @return the material or null if none found.
  34779. */
  34780. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34781. /**
  34782. * get a material using its id
  34783. * @param id defines the material's ID
  34784. * @return the material or null if none found.
  34785. */
  34786. getMaterialByID(id: string): Nullable<Material>;
  34787. /**
  34788. * Gets a the last added material using a given id
  34789. * @param id defines the material's ID
  34790. * @return the last material with the given id or null if none found.
  34791. */
  34792. getLastMaterialByID(id: string): Nullable<Material>;
  34793. /**
  34794. * Gets a material using its name
  34795. * @param name defines the material's name
  34796. * @return the material or null if none found.
  34797. */
  34798. getMaterialByName(name: string): Nullable<Material>;
  34799. /**
  34800. * Gets a camera using its id
  34801. * @param id defines the id to look for
  34802. * @returns the camera or null if not found
  34803. */
  34804. getCameraByID(id: string): Nullable<Camera>;
  34805. /**
  34806. * Gets a camera using its unique id
  34807. * @param uniqueId defines the unique id to look for
  34808. * @returns the camera or null if not found
  34809. */
  34810. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34811. /**
  34812. * Gets a camera using its name
  34813. * @param name defines the camera's name
  34814. * @return the camera or null if none found.
  34815. */
  34816. getCameraByName(name: string): Nullable<Camera>;
  34817. /**
  34818. * Gets a bone using its id
  34819. * @param id defines the bone's id
  34820. * @return the bone or null if not found
  34821. */
  34822. getBoneByID(id: string): Nullable<Bone>;
  34823. /**
  34824. * Gets a bone using its id
  34825. * @param name defines the bone's name
  34826. * @return the bone or null if not found
  34827. */
  34828. getBoneByName(name: string): Nullable<Bone>;
  34829. /**
  34830. * Gets a light node using its name
  34831. * @param name defines the the light's name
  34832. * @return the light or null if none found.
  34833. */
  34834. getLightByName(name: string): Nullable<Light>;
  34835. /**
  34836. * Gets a light node using its id
  34837. * @param id defines the light's id
  34838. * @return the light or null if none found.
  34839. */
  34840. getLightByID(id: string): Nullable<Light>;
  34841. /**
  34842. * Gets a light node using its scene-generated unique ID
  34843. * @param uniqueId defines the light's unique id
  34844. * @return the light or null if none found.
  34845. */
  34846. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34847. /**
  34848. * Gets a particle system by id
  34849. * @param id defines the particle system id
  34850. * @return the corresponding system or null if none found
  34851. */
  34852. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34853. /**
  34854. * Gets a geometry using its ID
  34855. * @param id defines the geometry's id
  34856. * @return the geometry or null if none found.
  34857. */
  34858. getGeometryByID(id: string): Nullable<Geometry>;
  34859. private _getGeometryByUniqueID;
  34860. /**
  34861. * Add a new geometry to this scene
  34862. * @param geometry defines the geometry to be added to the scene.
  34863. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34864. * @return a boolean defining if the geometry was added or not
  34865. */
  34866. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34867. /**
  34868. * Removes an existing geometry
  34869. * @param geometry defines the geometry to be removed from the scene
  34870. * @return a boolean defining if the geometry was removed or not
  34871. */
  34872. removeGeometry(geometry: Geometry): boolean;
  34873. /**
  34874. * Gets the list of geometries attached to the scene
  34875. * @returns an array of Geometry
  34876. */
  34877. getGeometries(): Geometry[];
  34878. /**
  34879. * Gets the first added mesh found of a given ID
  34880. * @param id defines the id to search for
  34881. * @return the mesh found or null if not found at all
  34882. */
  34883. getMeshByID(id: string): Nullable<AbstractMesh>;
  34884. /**
  34885. * Gets a list of meshes using their id
  34886. * @param id defines the id to search for
  34887. * @returns a list of meshes
  34888. */
  34889. getMeshesByID(id: string): Array<AbstractMesh>;
  34890. /**
  34891. * Gets the first added transform node found of a given ID
  34892. * @param id defines the id to search for
  34893. * @return the found transform node or null if not found at all.
  34894. */
  34895. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34896. /**
  34897. * Gets a transform node with its auto-generated unique id
  34898. * @param uniqueId efines the unique id to search for
  34899. * @return the found transform node or null if not found at all.
  34900. */
  34901. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34902. /**
  34903. * Gets a list of transform nodes using their id
  34904. * @param id defines the id to search for
  34905. * @returns a list of transform nodes
  34906. */
  34907. getTransformNodesByID(id: string): Array<TransformNode>;
  34908. /**
  34909. * Gets a mesh with its auto-generated unique id
  34910. * @param uniqueId defines the unique id to search for
  34911. * @return the found mesh or null if not found at all.
  34912. */
  34913. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34914. /**
  34915. * Gets a the last added mesh using a given id
  34916. * @param id defines the id to search for
  34917. * @return the found mesh or null if not found at all.
  34918. */
  34919. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34920. /**
  34921. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34922. * @param id defines the id to search for
  34923. * @return the found node or null if not found at all
  34924. */
  34925. getLastEntryByID(id: string): Nullable<Node>;
  34926. /**
  34927. * Gets a node (Mesh, Camera, Light) using a given id
  34928. * @param id defines the id to search for
  34929. * @return the found node or null if not found at all
  34930. */
  34931. getNodeByID(id: string): Nullable<Node>;
  34932. /**
  34933. * Gets a node (Mesh, Camera, Light) using a given name
  34934. * @param name defines the name to search for
  34935. * @return the found node or null if not found at all.
  34936. */
  34937. getNodeByName(name: string): Nullable<Node>;
  34938. /**
  34939. * Gets a mesh using a given name
  34940. * @param name defines the name to search for
  34941. * @return the found mesh or null if not found at all.
  34942. */
  34943. getMeshByName(name: string): Nullable<AbstractMesh>;
  34944. /**
  34945. * Gets a transform node using a given name
  34946. * @param name defines the name to search for
  34947. * @return the found transform node or null if not found at all.
  34948. */
  34949. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34950. /**
  34951. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34952. * @param id defines the id to search for
  34953. * @return the found skeleton or null if not found at all.
  34954. */
  34955. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34956. /**
  34957. * Gets a skeleton using a given auto generated unique id
  34958. * @param uniqueId defines the unique id to search for
  34959. * @return the found skeleton or null if not found at all.
  34960. */
  34961. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34962. /**
  34963. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34964. * @param id defines the id to search for
  34965. * @return the found skeleton or null if not found at all.
  34966. */
  34967. getSkeletonById(id: string): Nullable<Skeleton>;
  34968. /**
  34969. * Gets a skeleton using a given name
  34970. * @param name defines the name to search for
  34971. * @return the found skeleton or null if not found at all.
  34972. */
  34973. getSkeletonByName(name: string): Nullable<Skeleton>;
  34974. /**
  34975. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34976. * @param id defines the id to search for
  34977. * @return the found morph target manager or null if not found at all.
  34978. */
  34979. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34980. /**
  34981. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34982. * @param id defines the id to search for
  34983. * @return the found morph target or null if not found at all.
  34984. */
  34985. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34986. /**
  34987. * Gets a boolean indicating if the given mesh is active
  34988. * @param mesh defines the mesh to look for
  34989. * @returns true if the mesh is in the active list
  34990. */
  34991. isActiveMesh(mesh: AbstractMesh): boolean;
  34992. /**
  34993. * Return a unique id as a string which can serve as an identifier for the scene
  34994. */
  34995. readonly uid: string;
  34996. /**
  34997. * Add an externaly attached data from its key.
  34998. * This method call will fail and return false, if such key already exists.
  34999. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35000. * @param key the unique key that identifies the data
  35001. * @param data the data object to associate to the key for this Engine instance
  35002. * @return true if no such key were already present and the data was added successfully, false otherwise
  35003. */
  35004. addExternalData<T>(key: string, data: T): boolean;
  35005. /**
  35006. * Get an externaly attached data from its key
  35007. * @param key the unique key that identifies the data
  35008. * @return the associated data, if present (can be null), or undefined if not present
  35009. */
  35010. getExternalData<T>(key: string): Nullable<T>;
  35011. /**
  35012. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35013. * @param key the unique key that identifies the data
  35014. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35015. * @return the associated data, can be null if the factory returned null.
  35016. */
  35017. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35018. /**
  35019. * Remove an externaly attached data from the Engine instance
  35020. * @param key the unique key that identifies the data
  35021. * @return true if the data was successfully removed, false if it doesn't exist
  35022. */
  35023. removeExternalData(key: string): boolean;
  35024. private _evaluateSubMesh;
  35025. /**
  35026. * Clear the processed materials smart array preventing retention point in material dispose.
  35027. */
  35028. freeProcessedMaterials(): void;
  35029. private _preventFreeActiveMeshesAndRenderingGroups;
  35030. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35031. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35032. * when disposing several meshes in a row or a hierarchy of meshes.
  35033. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35034. */
  35035. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35036. /**
  35037. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35038. */
  35039. freeActiveMeshes(): void;
  35040. /**
  35041. * Clear the info related to rendering groups preventing retention points during dispose.
  35042. */
  35043. freeRenderingGroups(): void;
  35044. /** @hidden */
  35045. _isInIntermediateRendering(): boolean;
  35046. /**
  35047. * Lambda returning the list of potentially active meshes.
  35048. */
  35049. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35050. /**
  35051. * Lambda returning the list of potentially active sub meshes.
  35052. */
  35053. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35054. /**
  35055. * Lambda returning the list of potentially intersecting sub meshes.
  35056. */
  35057. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35058. /**
  35059. * Lambda returning the list of potentially colliding sub meshes.
  35060. */
  35061. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35062. private _activeMeshesFrozen;
  35063. /**
  35064. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35065. * @returns the current scene
  35066. */
  35067. freezeActiveMeshes(): Scene;
  35068. /**
  35069. * Use this function to restart evaluating active meshes on every frame
  35070. * @returns the current scene
  35071. */
  35072. unfreezeActiveMeshes(): Scene;
  35073. private _evaluateActiveMeshes;
  35074. private _activeMesh;
  35075. /**
  35076. * Update the transform matrix to update from the current active camera
  35077. * @param force defines a boolean used to force the update even if cache is up to date
  35078. */
  35079. updateTransformMatrix(force?: boolean): void;
  35080. private _bindFrameBuffer;
  35081. /** @hidden */
  35082. _allowPostProcessClearColor: boolean;
  35083. /** @hidden */
  35084. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35085. private _processSubCameras;
  35086. private _checkIntersections;
  35087. /** @hidden */
  35088. _advancePhysicsEngineStep(step: number): void;
  35089. /**
  35090. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35091. */
  35092. getDeterministicFrameTime: () => number;
  35093. /** @hidden */
  35094. _animate(): void;
  35095. /** Execute all animations (for a frame) */
  35096. animate(): void;
  35097. /**
  35098. * Render the scene
  35099. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35100. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35101. */
  35102. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35103. /**
  35104. * Freeze all materials
  35105. * A frozen material will not be updatable but should be faster to render
  35106. */
  35107. freezeMaterials(): void;
  35108. /**
  35109. * Unfreeze all materials
  35110. * A frozen material will not be updatable but should be faster to render
  35111. */
  35112. unfreezeMaterials(): void;
  35113. /**
  35114. * Releases all held ressources
  35115. */
  35116. dispose(): void;
  35117. /**
  35118. * Gets if the scene is already disposed
  35119. */
  35120. readonly isDisposed: boolean;
  35121. /**
  35122. * Call this function to reduce memory footprint of the scene.
  35123. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35124. */
  35125. clearCachedVertexData(): void;
  35126. /**
  35127. * This function will remove the local cached buffer data from texture.
  35128. * It will save memory but will prevent the texture from being rebuilt
  35129. */
  35130. cleanCachedTextureBuffer(): void;
  35131. /**
  35132. * Get the world extend vectors with an optional filter
  35133. *
  35134. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35135. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35136. */
  35137. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35138. min: Vector3;
  35139. max: Vector3;
  35140. };
  35141. /**
  35142. * Creates a ray that can be used to pick in the scene
  35143. * @param x defines the x coordinate of the origin (on-screen)
  35144. * @param y defines the y coordinate of the origin (on-screen)
  35145. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35146. * @param camera defines the camera to use for the picking
  35147. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35148. * @returns a Ray
  35149. */
  35150. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35151. /**
  35152. * Creates a ray that can be used to pick in the scene
  35153. * @param x defines the x coordinate of the origin (on-screen)
  35154. * @param y defines the y coordinate of the origin (on-screen)
  35155. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35156. * @param result defines the ray where to store the picking ray
  35157. * @param camera defines the camera to use for the picking
  35158. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35159. * @returns the current scene
  35160. */
  35161. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35162. /**
  35163. * Creates a ray that can be used to pick in the scene
  35164. * @param x defines the x coordinate of the origin (on-screen)
  35165. * @param y defines the y coordinate of the origin (on-screen)
  35166. * @param camera defines the camera to use for the picking
  35167. * @returns a Ray
  35168. */
  35169. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35170. /**
  35171. * Creates a ray that can be used to pick in the scene
  35172. * @param x defines the x coordinate of the origin (on-screen)
  35173. * @param y defines the y coordinate of the origin (on-screen)
  35174. * @param result defines the ray where to store the picking ray
  35175. * @param camera defines the camera to use for the picking
  35176. * @returns the current scene
  35177. */
  35178. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35179. /** Launch a ray to try to pick a mesh in the scene
  35180. * @param x position on screen
  35181. * @param y position on screen
  35182. * @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
  35183. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35184. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35185. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35186. * @returns a PickingInfo
  35187. */
  35188. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35189. /** Use the given ray to pick a mesh in the scene
  35190. * @param ray The ray to use to pick meshes
  35191. * @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
  35192. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35193. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35194. * @returns a PickingInfo
  35195. */
  35196. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35197. /**
  35198. * Launch a ray to try to pick a mesh in the scene
  35199. * @param x X position on screen
  35200. * @param y Y position on screen
  35201. * @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
  35202. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35203. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35204. * @returns an array of PickingInfo
  35205. */
  35206. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35207. /**
  35208. * Launch a ray to try to pick a mesh in the scene
  35209. * @param ray Ray to use
  35210. * @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
  35211. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35212. * @returns an array of PickingInfo
  35213. */
  35214. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35215. /**
  35216. * Force the value of meshUnderPointer
  35217. * @param mesh defines the mesh to use
  35218. */
  35219. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35220. /**
  35221. * Gets the mesh under the pointer
  35222. * @returns a Mesh or null if no mesh is under the pointer
  35223. */
  35224. getPointerOverMesh(): Nullable<AbstractMesh>;
  35225. /** @hidden */
  35226. _rebuildGeometries(): void;
  35227. /** @hidden */
  35228. _rebuildTextures(): void;
  35229. private _getByTags;
  35230. /**
  35231. * Get a list of meshes by tags
  35232. * @param tagsQuery defines the tags query to use
  35233. * @param forEach defines a predicate used to filter results
  35234. * @returns an array of Mesh
  35235. */
  35236. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35237. /**
  35238. * Get a list of cameras by tags
  35239. * @param tagsQuery defines the tags query to use
  35240. * @param forEach defines a predicate used to filter results
  35241. * @returns an array of Camera
  35242. */
  35243. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35244. /**
  35245. * Get a list of lights by tags
  35246. * @param tagsQuery defines the tags query to use
  35247. * @param forEach defines a predicate used to filter results
  35248. * @returns an array of Light
  35249. */
  35250. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35251. /**
  35252. * Get a list of materials by tags
  35253. * @param tagsQuery defines the tags query to use
  35254. * @param forEach defines a predicate used to filter results
  35255. * @returns an array of Material
  35256. */
  35257. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35258. /**
  35259. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35260. * This allowed control for front to back rendering or reversly depending of the special needs.
  35261. *
  35262. * @param renderingGroupId The rendering group id corresponding to its index
  35263. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35264. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35265. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35266. */
  35267. 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;
  35268. /**
  35269. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35270. *
  35271. * @param renderingGroupId The rendering group id corresponding to its index
  35272. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35273. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35274. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35275. */
  35276. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35277. /**
  35278. * Gets the current auto clear configuration for one rendering group of the rendering
  35279. * manager.
  35280. * @param index the rendering group index to get the information for
  35281. * @returns The auto clear setup for the requested rendering group
  35282. */
  35283. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35284. private _blockMaterialDirtyMechanism;
  35285. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35286. blockMaterialDirtyMechanism: boolean;
  35287. /**
  35288. * Will flag all materials as dirty to trigger new shader compilation
  35289. * @param flag defines the flag used to specify which material part must be marked as dirty
  35290. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35291. */
  35292. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35293. /** @hidden */
  35294. _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;
  35295. /** @hidden */
  35296. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35297. }
  35298. }
  35299. declare module "babylonjs/assetContainer" {
  35300. import { AbstractScene } from "babylonjs/abstractScene";
  35301. import { Scene } from "babylonjs/scene";
  35302. import { Mesh } from "babylonjs/Meshes/mesh";
  35303. /**
  35304. * Set of assets to keep when moving a scene into an asset container.
  35305. */
  35306. export class KeepAssets extends AbstractScene {
  35307. }
  35308. /**
  35309. * Container with a set of assets that can be added or removed from a scene.
  35310. */
  35311. export class AssetContainer extends AbstractScene {
  35312. /**
  35313. * The scene the AssetContainer belongs to.
  35314. */
  35315. scene: Scene;
  35316. /**
  35317. * Instantiates an AssetContainer.
  35318. * @param scene The scene the AssetContainer belongs to.
  35319. */
  35320. constructor(scene: Scene);
  35321. /**
  35322. * Adds all the assets from the container to the scene.
  35323. */
  35324. addAllToScene(): void;
  35325. /**
  35326. * Removes all the assets in the container from the scene
  35327. */
  35328. removeAllFromScene(): void;
  35329. /**
  35330. * Disposes all the assets in the container
  35331. */
  35332. dispose(): void;
  35333. private _moveAssets;
  35334. /**
  35335. * Removes all the assets contained in the scene and adds them to the container.
  35336. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35337. */
  35338. moveAllFromScene(keepAssets?: KeepAssets): void;
  35339. /**
  35340. * 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.
  35341. * @returns the root mesh
  35342. */
  35343. createRootMesh(): Mesh;
  35344. }
  35345. }
  35346. declare module "babylonjs/abstractScene" {
  35347. import { Scene } from "babylonjs/scene";
  35348. import { Nullable } from "babylonjs/types";
  35349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35350. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35351. import { Geometry } from "babylonjs/Meshes/geometry";
  35352. import { Skeleton } from "babylonjs/Bones/skeleton";
  35353. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35354. import { AssetContainer } from "babylonjs/assetContainer";
  35355. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35356. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35357. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35358. import { Material } from "babylonjs/Materials/material";
  35359. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35360. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35361. import { Camera } from "babylonjs/Cameras/camera";
  35362. import { Light } from "babylonjs/Lights/light";
  35363. import { Node } from "babylonjs/node";
  35364. import { Animation } from "babylonjs/Animations/animation";
  35365. /**
  35366. * Defines how the parser contract is defined.
  35367. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35368. */
  35369. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35370. /**
  35371. * Defines how the individual parser contract is defined.
  35372. * These parser can parse an individual asset
  35373. */
  35374. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35375. /**
  35376. * Base class of the scene acting as a container for the different elements composing a scene.
  35377. * This class is dynamically extended by the different components of the scene increasing
  35378. * flexibility and reducing coupling
  35379. */
  35380. export abstract class AbstractScene {
  35381. /**
  35382. * Stores the list of available parsers in the application.
  35383. */
  35384. private static _BabylonFileParsers;
  35385. /**
  35386. * Stores the list of available individual parsers in the application.
  35387. */
  35388. private static _IndividualBabylonFileParsers;
  35389. /**
  35390. * Adds a parser in the list of available ones
  35391. * @param name Defines the name of the parser
  35392. * @param parser Defines the parser to add
  35393. */
  35394. static AddParser(name: string, parser: BabylonFileParser): void;
  35395. /**
  35396. * Gets a general parser from the list of avaialble ones
  35397. * @param name Defines the name of the parser
  35398. * @returns the requested parser or null
  35399. */
  35400. static GetParser(name: string): Nullable<BabylonFileParser>;
  35401. /**
  35402. * Adds n individual parser in the list of available ones
  35403. * @param name Defines the name of the parser
  35404. * @param parser Defines the parser to add
  35405. */
  35406. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35407. /**
  35408. * Gets an individual parser from the list of avaialble ones
  35409. * @param name Defines the name of the parser
  35410. * @returns the requested parser or null
  35411. */
  35412. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35413. /**
  35414. * Parser json data and populate both a scene and its associated container object
  35415. * @param jsonData Defines the data to parse
  35416. * @param scene Defines the scene to parse the data for
  35417. * @param container Defines the container attached to the parsing sequence
  35418. * @param rootUrl Defines the root url of the data
  35419. */
  35420. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35421. /**
  35422. * Gets the list of root nodes (ie. nodes with no parent)
  35423. */
  35424. rootNodes: Node[];
  35425. /** All of the cameras added to this scene
  35426. * @see http://doc.babylonjs.com/babylon101/cameras
  35427. */
  35428. cameras: Camera[];
  35429. /**
  35430. * All of the lights added to this scene
  35431. * @see http://doc.babylonjs.com/babylon101/lights
  35432. */
  35433. lights: Light[];
  35434. /**
  35435. * All of the (abstract) meshes added to this scene
  35436. */
  35437. meshes: AbstractMesh[];
  35438. /**
  35439. * The list of skeletons added to the scene
  35440. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35441. */
  35442. skeletons: Skeleton[];
  35443. /**
  35444. * All of the particle systems added to this scene
  35445. * @see http://doc.babylonjs.com/babylon101/particles
  35446. */
  35447. particleSystems: IParticleSystem[];
  35448. /**
  35449. * Gets a list of Animations associated with the scene
  35450. */
  35451. animations: Animation[];
  35452. /**
  35453. * All of the animation groups added to this scene
  35454. * @see http://doc.babylonjs.com/how_to/group
  35455. */
  35456. animationGroups: AnimationGroup[];
  35457. /**
  35458. * All of the multi-materials added to this scene
  35459. * @see http://doc.babylonjs.com/how_to/multi_materials
  35460. */
  35461. multiMaterials: MultiMaterial[];
  35462. /**
  35463. * All of the materials added to this scene
  35464. * In the context of a Scene, it is not supposed to be modified manually.
  35465. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35466. * Note also that the order of the Material wihin the array is not significant and might change.
  35467. * @see http://doc.babylonjs.com/babylon101/materials
  35468. */
  35469. materials: Material[];
  35470. /**
  35471. * The list of morph target managers added to the scene
  35472. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35473. */
  35474. morphTargetManagers: MorphTargetManager[];
  35475. /**
  35476. * The list of geometries used in the scene.
  35477. */
  35478. geometries: Geometry[];
  35479. /**
  35480. * All of the tranform nodes added to this scene
  35481. * In the context of a Scene, it is not supposed to be modified manually.
  35482. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35483. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35484. * @see http://doc.babylonjs.com/how_to/transformnode
  35485. */
  35486. transformNodes: TransformNode[];
  35487. /**
  35488. * ActionManagers available on the scene.
  35489. */
  35490. actionManagers: AbstractActionManager[];
  35491. /**
  35492. * Textures to keep.
  35493. */
  35494. textures: BaseTexture[];
  35495. /**
  35496. * Environment texture for the scene
  35497. */
  35498. environmentTexture: Nullable<BaseTexture>;
  35499. }
  35500. }
  35501. declare module "babylonjs/Audio/sound" {
  35502. import { Observable } from "babylonjs/Misc/observable";
  35503. import { Vector3 } from "babylonjs/Maths/math.vector";
  35504. import { Nullable } from "babylonjs/types";
  35505. import { Scene } from "babylonjs/scene";
  35506. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35507. /**
  35508. * Interface used to define options for Sound class
  35509. */
  35510. export interface ISoundOptions {
  35511. /**
  35512. * Does the sound autoplay once loaded.
  35513. */
  35514. autoplay?: boolean;
  35515. /**
  35516. * Does the sound loop after it finishes playing once.
  35517. */
  35518. loop?: boolean;
  35519. /**
  35520. * Sound's volume
  35521. */
  35522. volume?: number;
  35523. /**
  35524. * Is it a spatial sound?
  35525. */
  35526. spatialSound?: boolean;
  35527. /**
  35528. * Maximum distance to hear that sound
  35529. */
  35530. maxDistance?: number;
  35531. /**
  35532. * Uses user defined attenuation function
  35533. */
  35534. useCustomAttenuation?: boolean;
  35535. /**
  35536. * Define the roll off factor of spatial sounds.
  35537. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35538. */
  35539. rolloffFactor?: number;
  35540. /**
  35541. * Define the reference distance the sound should be heard perfectly.
  35542. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35543. */
  35544. refDistance?: number;
  35545. /**
  35546. * Define the distance attenuation model the sound will follow.
  35547. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35548. */
  35549. distanceModel?: string;
  35550. /**
  35551. * Defines the playback speed (1 by default)
  35552. */
  35553. playbackRate?: number;
  35554. /**
  35555. * Defines if the sound is from a streaming source
  35556. */
  35557. streaming?: boolean;
  35558. /**
  35559. * Defines an optional length (in seconds) inside the sound file
  35560. */
  35561. length?: number;
  35562. /**
  35563. * Defines an optional offset (in seconds) inside the sound file
  35564. */
  35565. offset?: number;
  35566. /**
  35567. * If true, URLs will not be required to state the audio file codec to use.
  35568. */
  35569. skipCodecCheck?: boolean;
  35570. }
  35571. /**
  35572. * Defines a sound that can be played in the application.
  35573. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35574. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35575. */
  35576. export class Sound {
  35577. /**
  35578. * The name of the sound in the scene.
  35579. */
  35580. name: string;
  35581. /**
  35582. * Does the sound autoplay once loaded.
  35583. */
  35584. autoplay: boolean;
  35585. /**
  35586. * Does the sound loop after it finishes playing once.
  35587. */
  35588. loop: boolean;
  35589. /**
  35590. * Does the sound use a custom attenuation curve to simulate the falloff
  35591. * happening when the source gets further away from the camera.
  35592. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35593. */
  35594. useCustomAttenuation: boolean;
  35595. /**
  35596. * The sound track id this sound belongs to.
  35597. */
  35598. soundTrackId: number;
  35599. /**
  35600. * Is this sound currently played.
  35601. */
  35602. isPlaying: boolean;
  35603. /**
  35604. * Is this sound currently paused.
  35605. */
  35606. isPaused: boolean;
  35607. /**
  35608. * Does this sound enables spatial sound.
  35609. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35610. */
  35611. spatialSound: boolean;
  35612. /**
  35613. * Define the reference distance the sound should be heard perfectly.
  35614. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35615. */
  35616. refDistance: number;
  35617. /**
  35618. * Define the roll off factor of spatial sounds.
  35619. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35620. */
  35621. rolloffFactor: number;
  35622. /**
  35623. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35624. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35625. */
  35626. maxDistance: number;
  35627. /**
  35628. * Define the distance attenuation model the sound will follow.
  35629. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35630. */
  35631. distanceModel: string;
  35632. /**
  35633. * @hidden
  35634. * Back Compat
  35635. **/
  35636. onended: () => any;
  35637. /**
  35638. * Observable event when the current playing sound finishes.
  35639. */
  35640. onEndedObservable: Observable<Sound>;
  35641. private _panningModel;
  35642. private _playbackRate;
  35643. private _streaming;
  35644. private _startTime;
  35645. private _startOffset;
  35646. private _position;
  35647. /** @hidden */
  35648. _positionInEmitterSpace: boolean;
  35649. private _localDirection;
  35650. private _volume;
  35651. private _isReadyToPlay;
  35652. private _isDirectional;
  35653. private _readyToPlayCallback;
  35654. private _audioBuffer;
  35655. private _soundSource;
  35656. private _streamingSource;
  35657. private _soundPanner;
  35658. private _soundGain;
  35659. private _inputAudioNode;
  35660. private _outputAudioNode;
  35661. private _coneInnerAngle;
  35662. private _coneOuterAngle;
  35663. private _coneOuterGain;
  35664. private _scene;
  35665. private _connectedTransformNode;
  35666. private _customAttenuationFunction;
  35667. private _registerFunc;
  35668. private _isOutputConnected;
  35669. private _htmlAudioElement;
  35670. private _urlType;
  35671. private _length?;
  35672. private _offset?;
  35673. /** @hidden */
  35674. static _SceneComponentInitialization: (scene: Scene) => void;
  35675. /**
  35676. * Create a sound and attach it to a scene
  35677. * @param name Name of your sound
  35678. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35679. * @param scene defines the scene the sound belongs to
  35680. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35681. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35682. */
  35683. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35684. /**
  35685. * Release the sound and its associated resources
  35686. */
  35687. dispose(): void;
  35688. /**
  35689. * Gets if the sounds is ready to be played or not.
  35690. * @returns true if ready, otherwise false
  35691. */
  35692. isReady(): boolean;
  35693. private _soundLoaded;
  35694. /**
  35695. * Sets the data of the sound from an audiobuffer
  35696. * @param audioBuffer The audioBuffer containing the data
  35697. */
  35698. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35699. /**
  35700. * Updates the current sounds options such as maxdistance, loop...
  35701. * @param options A JSON object containing values named as the object properties
  35702. */
  35703. updateOptions(options: ISoundOptions): void;
  35704. private _createSpatialParameters;
  35705. private _updateSpatialParameters;
  35706. /**
  35707. * Switch the panning model to HRTF:
  35708. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35709. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35710. */
  35711. switchPanningModelToHRTF(): void;
  35712. /**
  35713. * Switch the panning model to Equal Power:
  35714. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35715. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35716. */
  35717. switchPanningModelToEqualPower(): void;
  35718. private _switchPanningModel;
  35719. /**
  35720. * Connect this sound to a sound track audio node like gain...
  35721. * @param soundTrackAudioNode the sound track audio node to connect to
  35722. */
  35723. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35724. /**
  35725. * Transform this sound into a directional source
  35726. * @param coneInnerAngle Size of the inner cone in degree
  35727. * @param coneOuterAngle Size of the outer cone in degree
  35728. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35729. */
  35730. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35731. /**
  35732. * Gets or sets the inner angle for the directional cone.
  35733. */
  35734. /**
  35735. * Gets or sets the inner angle for the directional cone.
  35736. */
  35737. directionalConeInnerAngle: number;
  35738. /**
  35739. * Gets or sets the outer angle for the directional cone.
  35740. */
  35741. /**
  35742. * Gets or sets the outer angle for the directional cone.
  35743. */
  35744. directionalConeOuterAngle: number;
  35745. /**
  35746. * Sets the position of the emitter if spatial sound is enabled
  35747. * @param newPosition Defines the new posisiton
  35748. */
  35749. setPosition(newPosition: Vector3): void;
  35750. /**
  35751. * Sets the local direction of the emitter if spatial sound is enabled
  35752. * @param newLocalDirection Defines the new local direction
  35753. */
  35754. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35755. private _updateDirection;
  35756. /** @hidden */
  35757. updateDistanceFromListener(): void;
  35758. /**
  35759. * Sets a new custom attenuation function for the sound.
  35760. * @param callback Defines the function used for the attenuation
  35761. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35762. */
  35763. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35764. /**
  35765. * Play the sound
  35766. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35767. * @param offset (optional) Start the sound at a specific time in seconds
  35768. * @param length (optional) Sound duration (in seconds)
  35769. */
  35770. play(time?: number, offset?: number, length?: number): void;
  35771. private _onended;
  35772. /**
  35773. * Stop the sound
  35774. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35775. */
  35776. stop(time?: number): void;
  35777. /**
  35778. * Put the sound in pause
  35779. */
  35780. pause(): void;
  35781. /**
  35782. * Sets a dedicated volume for this sounds
  35783. * @param newVolume Define the new volume of the sound
  35784. * @param time Define time for gradual change to new volume
  35785. */
  35786. setVolume(newVolume: number, time?: number): void;
  35787. /**
  35788. * Set the sound play back rate
  35789. * @param newPlaybackRate Define the playback rate the sound should be played at
  35790. */
  35791. setPlaybackRate(newPlaybackRate: number): void;
  35792. /**
  35793. * Gets the volume of the sound.
  35794. * @returns the volume of the sound
  35795. */
  35796. getVolume(): number;
  35797. /**
  35798. * Attach the sound to a dedicated mesh
  35799. * @param transformNode The transform node to connect the sound with
  35800. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35801. */
  35802. attachToMesh(transformNode: TransformNode): void;
  35803. /**
  35804. * Detach the sound from the previously attached mesh
  35805. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35806. */
  35807. detachFromMesh(): void;
  35808. private _onRegisterAfterWorldMatrixUpdate;
  35809. /**
  35810. * Clone the current sound in the scene.
  35811. * @returns the new sound clone
  35812. */
  35813. clone(): Nullable<Sound>;
  35814. /**
  35815. * Gets the current underlying audio buffer containing the data
  35816. * @returns the audio buffer
  35817. */
  35818. getAudioBuffer(): Nullable<AudioBuffer>;
  35819. /**
  35820. * Serializes the Sound in a JSON representation
  35821. * @returns the JSON representation of the sound
  35822. */
  35823. serialize(): any;
  35824. /**
  35825. * Parse a JSON representation of a sound to innstantiate in a given scene
  35826. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35827. * @param scene Define the scene the new parsed sound should be created in
  35828. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35829. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35830. * @returns the newly parsed sound
  35831. */
  35832. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35833. }
  35834. }
  35835. declare module "babylonjs/Actions/directAudioActions" {
  35836. import { Action } from "babylonjs/Actions/action";
  35837. import { Condition } from "babylonjs/Actions/condition";
  35838. import { Sound } from "babylonjs/Audio/sound";
  35839. /**
  35840. * This defines an action helpful to play a defined sound on a triggered action.
  35841. */
  35842. export class PlaySoundAction extends Action {
  35843. private _sound;
  35844. /**
  35845. * Instantiate the action
  35846. * @param triggerOptions defines the trigger options
  35847. * @param sound defines the sound to play
  35848. * @param condition defines the trigger related conditions
  35849. */
  35850. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35851. /** @hidden */
  35852. _prepare(): void;
  35853. /**
  35854. * Execute the action and play the sound.
  35855. */
  35856. execute(): void;
  35857. /**
  35858. * Serializes the actions and its related information.
  35859. * @param parent defines the object to serialize in
  35860. * @returns the serialized object
  35861. */
  35862. serialize(parent: any): any;
  35863. }
  35864. /**
  35865. * This defines an action helpful to stop a defined sound on a triggered action.
  35866. */
  35867. export class StopSoundAction extends Action {
  35868. private _sound;
  35869. /**
  35870. * Instantiate the action
  35871. * @param triggerOptions defines the trigger options
  35872. * @param sound defines the sound to stop
  35873. * @param condition defines the trigger related conditions
  35874. */
  35875. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35876. /** @hidden */
  35877. _prepare(): void;
  35878. /**
  35879. * Execute the action and stop the sound.
  35880. */
  35881. execute(): void;
  35882. /**
  35883. * Serializes the actions and its related information.
  35884. * @param parent defines the object to serialize in
  35885. * @returns the serialized object
  35886. */
  35887. serialize(parent: any): any;
  35888. }
  35889. }
  35890. declare module "babylonjs/Actions/interpolateValueAction" {
  35891. import { Action } from "babylonjs/Actions/action";
  35892. import { Condition } from "babylonjs/Actions/condition";
  35893. import { Observable } from "babylonjs/Misc/observable";
  35894. /**
  35895. * This defines an action responsible to change the value of a property
  35896. * by interpolating between its current value and the newly set one once triggered.
  35897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35898. */
  35899. export class InterpolateValueAction extends Action {
  35900. /**
  35901. * Defines the path of the property where the value should be interpolated
  35902. */
  35903. propertyPath: string;
  35904. /**
  35905. * Defines the target value at the end of the interpolation.
  35906. */
  35907. value: any;
  35908. /**
  35909. * Defines the time it will take for the property to interpolate to the value.
  35910. */
  35911. duration: number;
  35912. /**
  35913. * Defines if the other scene animations should be stopped when the action has been triggered
  35914. */
  35915. stopOtherAnimations?: boolean;
  35916. /**
  35917. * Defines a callback raised once the interpolation animation has been done.
  35918. */
  35919. onInterpolationDone?: () => void;
  35920. /**
  35921. * Observable triggered once the interpolation animation has been done.
  35922. */
  35923. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35924. private _target;
  35925. private _effectiveTarget;
  35926. private _property;
  35927. /**
  35928. * Instantiate the action
  35929. * @param triggerOptions defines the trigger options
  35930. * @param target defines the object containing the value to interpolate
  35931. * @param propertyPath defines the path to the property in the target object
  35932. * @param value defines the target value at the end of the interpolation
  35933. * @param duration deines the time it will take for the property to interpolate to the value.
  35934. * @param condition defines the trigger related conditions
  35935. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35936. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35937. */
  35938. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35939. /** @hidden */
  35940. _prepare(): void;
  35941. /**
  35942. * Execute the action starts the value interpolation.
  35943. */
  35944. execute(): void;
  35945. /**
  35946. * Serializes the actions and its related information.
  35947. * @param parent defines the object to serialize in
  35948. * @returns the serialized object
  35949. */
  35950. serialize(parent: any): any;
  35951. }
  35952. }
  35953. declare module "babylonjs/Actions/index" {
  35954. export * from "babylonjs/Actions/action";
  35955. export * from "babylonjs/Actions/actionEvent";
  35956. export * from "babylonjs/Actions/actionManager";
  35957. export * from "babylonjs/Actions/condition";
  35958. export * from "babylonjs/Actions/directActions";
  35959. export * from "babylonjs/Actions/directAudioActions";
  35960. export * from "babylonjs/Actions/interpolateValueAction";
  35961. }
  35962. declare module "babylonjs/Animations/index" {
  35963. export * from "babylonjs/Animations/animatable";
  35964. export * from "babylonjs/Animations/animation";
  35965. export * from "babylonjs/Animations/animationGroup";
  35966. export * from "babylonjs/Animations/animationPropertiesOverride";
  35967. export * from "babylonjs/Animations/easing";
  35968. export * from "babylonjs/Animations/runtimeAnimation";
  35969. export * from "babylonjs/Animations/animationEvent";
  35970. export * from "babylonjs/Animations/animationGroup";
  35971. export * from "babylonjs/Animations/animationKey";
  35972. export * from "babylonjs/Animations/animationRange";
  35973. export * from "babylonjs/Animations/animatable.interface";
  35974. }
  35975. declare module "babylonjs/Audio/soundTrack" {
  35976. import { Sound } from "babylonjs/Audio/sound";
  35977. import { Analyser } from "babylonjs/Audio/analyser";
  35978. import { Scene } from "babylonjs/scene";
  35979. /**
  35980. * Options allowed during the creation of a sound track.
  35981. */
  35982. export interface ISoundTrackOptions {
  35983. /**
  35984. * The volume the sound track should take during creation
  35985. */
  35986. volume?: number;
  35987. /**
  35988. * Define if the sound track is the main sound track of the scene
  35989. */
  35990. mainTrack?: boolean;
  35991. }
  35992. /**
  35993. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35994. * It will be also used in a future release to apply effects on a specific track.
  35995. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35996. */
  35997. export class SoundTrack {
  35998. /**
  35999. * The unique identifier of the sound track in the scene.
  36000. */
  36001. id: number;
  36002. /**
  36003. * The list of sounds included in the sound track.
  36004. */
  36005. soundCollection: Array<Sound>;
  36006. private _outputAudioNode;
  36007. private _scene;
  36008. private _isMainTrack;
  36009. private _connectedAnalyser;
  36010. private _options;
  36011. private _isInitialized;
  36012. /**
  36013. * Creates a new sound track.
  36014. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36015. * @param scene Define the scene the sound track belongs to
  36016. * @param options
  36017. */
  36018. constructor(scene: Scene, options?: ISoundTrackOptions);
  36019. private _initializeSoundTrackAudioGraph;
  36020. /**
  36021. * Release the sound track and its associated resources
  36022. */
  36023. dispose(): void;
  36024. /**
  36025. * Adds a sound to this sound track
  36026. * @param sound define the cound to add
  36027. * @ignoreNaming
  36028. */
  36029. AddSound(sound: Sound): void;
  36030. /**
  36031. * Removes a sound to this sound track
  36032. * @param sound define the cound to remove
  36033. * @ignoreNaming
  36034. */
  36035. RemoveSound(sound: Sound): void;
  36036. /**
  36037. * Set a global volume for the full sound track.
  36038. * @param newVolume Define the new volume of the sound track
  36039. */
  36040. setVolume(newVolume: number): void;
  36041. /**
  36042. * Switch the panning model to HRTF:
  36043. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36044. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36045. */
  36046. switchPanningModelToHRTF(): void;
  36047. /**
  36048. * Switch the panning model to Equal Power:
  36049. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36050. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36051. */
  36052. switchPanningModelToEqualPower(): void;
  36053. /**
  36054. * Connect the sound track to an audio analyser allowing some amazing
  36055. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36056. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36057. * @param analyser The analyser to connect to the engine
  36058. */
  36059. connectToAnalyser(analyser: Analyser): void;
  36060. }
  36061. }
  36062. declare module "babylonjs/Audio/audioSceneComponent" {
  36063. import { Sound } from "babylonjs/Audio/sound";
  36064. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36065. import { Nullable } from "babylonjs/types";
  36066. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36067. import { Scene } from "babylonjs/scene";
  36068. import { AbstractScene } from "babylonjs/abstractScene";
  36069. module "babylonjs/abstractScene" {
  36070. interface AbstractScene {
  36071. /**
  36072. * The list of sounds used in the scene.
  36073. */
  36074. sounds: Nullable<Array<Sound>>;
  36075. }
  36076. }
  36077. module "babylonjs/scene" {
  36078. interface Scene {
  36079. /**
  36080. * @hidden
  36081. * Backing field
  36082. */
  36083. _mainSoundTrack: SoundTrack;
  36084. /**
  36085. * The main sound track played by the scene.
  36086. * It cotains your primary collection of sounds.
  36087. */
  36088. mainSoundTrack: SoundTrack;
  36089. /**
  36090. * The list of sound tracks added to the scene
  36091. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36092. */
  36093. soundTracks: Nullable<Array<SoundTrack>>;
  36094. /**
  36095. * Gets a sound using a given name
  36096. * @param name defines the name to search for
  36097. * @return the found sound or null if not found at all.
  36098. */
  36099. getSoundByName(name: string): Nullable<Sound>;
  36100. /**
  36101. * Gets or sets if audio support is enabled
  36102. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36103. */
  36104. audioEnabled: boolean;
  36105. /**
  36106. * Gets or sets if audio will be output to headphones
  36107. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36108. */
  36109. headphone: boolean;
  36110. }
  36111. }
  36112. /**
  36113. * Defines the sound scene component responsible to manage any sounds
  36114. * in a given scene.
  36115. */
  36116. export class AudioSceneComponent implements ISceneSerializableComponent {
  36117. /**
  36118. * The component name helpfull to identify the component in the list of scene components.
  36119. */
  36120. readonly name: string;
  36121. /**
  36122. * The scene the component belongs to.
  36123. */
  36124. scene: Scene;
  36125. private _audioEnabled;
  36126. /**
  36127. * Gets whether audio is enabled or not.
  36128. * Please use related enable/disable method to switch state.
  36129. */
  36130. readonly audioEnabled: boolean;
  36131. private _headphone;
  36132. /**
  36133. * Gets whether audio is outputing to headphone or not.
  36134. * Please use the according Switch methods to change output.
  36135. */
  36136. readonly headphone: boolean;
  36137. /**
  36138. * Creates a new instance of the component for the given scene
  36139. * @param scene Defines the scene to register the component in
  36140. */
  36141. constructor(scene: Scene);
  36142. /**
  36143. * Registers the component in a given scene
  36144. */
  36145. register(): void;
  36146. /**
  36147. * Rebuilds the elements related to this component in case of
  36148. * context lost for instance.
  36149. */
  36150. rebuild(): void;
  36151. /**
  36152. * Serializes the component data to the specified json object
  36153. * @param serializationObject The object to serialize to
  36154. */
  36155. serialize(serializationObject: any): void;
  36156. /**
  36157. * Adds all the elements from the container to the scene
  36158. * @param container the container holding the elements
  36159. */
  36160. addFromContainer(container: AbstractScene): void;
  36161. /**
  36162. * Removes all the elements in the container from the scene
  36163. * @param container contains the elements to remove
  36164. * @param dispose if the removed element should be disposed (default: false)
  36165. */
  36166. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36167. /**
  36168. * Disposes the component and the associated ressources.
  36169. */
  36170. dispose(): void;
  36171. /**
  36172. * Disables audio in the associated scene.
  36173. */
  36174. disableAudio(): void;
  36175. /**
  36176. * Enables audio in the associated scene.
  36177. */
  36178. enableAudio(): void;
  36179. /**
  36180. * Switch audio to headphone output.
  36181. */
  36182. switchAudioModeForHeadphones(): void;
  36183. /**
  36184. * Switch audio to normal speakers.
  36185. */
  36186. switchAudioModeForNormalSpeakers(): void;
  36187. private _afterRender;
  36188. }
  36189. }
  36190. declare module "babylonjs/Audio/weightedsound" {
  36191. import { Sound } from "babylonjs/Audio/sound";
  36192. /**
  36193. * Wraps one or more Sound objects and selects one with random weight for playback.
  36194. */
  36195. export class WeightedSound {
  36196. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36197. loop: boolean;
  36198. private _coneInnerAngle;
  36199. private _coneOuterAngle;
  36200. private _volume;
  36201. /** A Sound is currently playing. */
  36202. isPlaying: boolean;
  36203. /** A Sound is currently paused. */
  36204. isPaused: boolean;
  36205. private _sounds;
  36206. private _weights;
  36207. private _currentIndex?;
  36208. /**
  36209. * Creates a new WeightedSound from the list of sounds given.
  36210. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36211. * @param sounds Array of Sounds that will be selected from.
  36212. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36213. */
  36214. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36215. /**
  36216. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36217. */
  36218. /**
  36219. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36220. */
  36221. directionalConeInnerAngle: number;
  36222. /**
  36223. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36224. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36225. */
  36226. /**
  36227. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36228. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36229. */
  36230. directionalConeOuterAngle: number;
  36231. /**
  36232. * Playback volume.
  36233. */
  36234. /**
  36235. * Playback volume.
  36236. */
  36237. volume: number;
  36238. private _onended;
  36239. /**
  36240. * Suspend playback
  36241. */
  36242. pause(): void;
  36243. /**
  36244. * Stop playback
  36245. */
  36246. stop(): void;
  36247. /**
  36248. * Start playback.
  36249. * @param startOffset Position the clip head at a specific time in seconds.
  36250. */
  36251. play(startOffset?: number): void;
  36252. }
  36253. }
  36254. declare module "babylonjs/Audio/index" {
  36255. export * from "babylonjs/Audio/analyser";
  36256. export * from "babylonjs/Audio/audioEngine";
  36257. export * from "babylonjs/Audio/audioSceneComponent";
  36258. export * from "babylonjs/Audio/sound";
  36259. export * from "babylonjs/Audio/soundTrack";
  36260. export * from "babylonjs/Audio/weightedsound";
  36261. }
  36262. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36263. import { Behavior } from "babylonjs/Behaviors/behavior";
  36264. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36265. import { BackEase } from "babylonjs/Animations/easing";
  36266. /**
  36267. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36268. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36269. */
  36270. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36271. /**
  36272. * Gets the name of the behavior.
  36273. */
  36274. readonly name: string;
  36275. /**
  36276. * The easing function used by animations
  36277. */
  36278. static EasingFunction: BackEase;
  36279. /**
  36280. * The easing mode used by animations
  36281. */
  36282. static EasingMode: number;
  36283. /**
  36284. * The duration of the animation, in milliseconds
  36285. */
  36286. transitionDuration: number;
  36287. /**
  36288. * Length of the distance animated by the transition when lower radius is reached
  36289. */
  36290. lowerRadiusTransitionRange: number;
  36291. /**
  36292. * Length of the distance animated by the transition when upper radius is reached
  36293. */
  36294. upperRadiusTransitionRange: number;
  36295. private _autoTransitionRange;
  36296. /**
  36297. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36298. */
  36299. /**
  36300. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36301. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36302. */
  36303. autoTransitionRange: boolean;
  36304. private _attachedCamera;
  36305. private _onAfterCheckInputsObserver;
  36306. private _onMeshTargetChangedObserver;
  36307. /**
  36308. * Initializes the behavior.
  36309. */
  36310. init(): void;
  36311. /**
  36312. * Attaches the behavior to its arc rotate camera.
  36313. * @param camera Defines the camera to attach the behavior to
  36314. */
  36315. attach(camera: ArcRotateCamera): void;
  36316. /**
  36317. * Detaches the behavior from its current arc rotate camera.
  36318. */
  36319. detach(): void;
  36320. private _radiusIsAnimating;
  36321. private _radiusBounceTransition;
  36322. private _animatables;
  36323. private _cachedWheelPrecision;
  36324. /**
  36325. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36326. * @param radiusLimit The limit to check against.
  36327. * @return Bool to indicate if at limit.
  36328. */
  36329. private _isRadiusAtLimit;
  36330. /**
  36331. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36332. * @param radiusDelta The delta by which to animate to. Can be negative.
  36333. */
  36334. private _applyBoundRadiusAnimation;
  36335. /**
  36336. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36337. */
  36338. protected _clearAnimationLocks(): void;
  36339. /**
  36340. * Stops and removes all animations that have been applied to the camera
  36341. */
  36342. stopAllAnimations(): void;
  36343. }
  36344. }
  36345. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36346. import { Behavior } from "babylonjs/Behaviors/behavior";
  36347. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36348. import { ExponentialEase } from "babylonjs/Animations/easing";
  36349. import { Nullable } from "babylonjs/types";
  36350. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36351. import { Vector3 } from "babylonjs/Maths/math.vector";
  36352. /**
  36353. * 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.
  36354. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36355. */
  36356. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36357. /**
  36358. * Gets the name of the behavior.
  36359. */
  36360. readonly name: string;
  36361. private _mode;
  36362. private _radiusScale;
  36363. private _positionScale;
  36364. private _defaultElevation;
  36365. private _elevationReturnTime;
  36366. private _elevationReturnWaitTime;
  36367. private _zoomStopsAnimation;
  36368. private _framingTime;
  36369. /**
  36370. * The easing function used by animations
  36371. */
  36372. static EasingFunction: ExponentialEase;
  36373. /**
  36374. * The easing mode used by animations
  36375. */
  36376. static EasingMode: number;
  36377. /**
  36378. * Sets the current mode used by the behavior
  36379. */
  36380. /**
  36381. * Gets current mode used by the behavior.
  36382. */
  36383. mode: number;
  36384. /**
  36385. * Sets the scale applied to the radius (1 by default)
  36386. */
  36387. /**
  36388. * Gets the scale applied to the radius
  36389. */
  36390. radiusScale: number;
  36391. /**
  36392. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36393. */
  36394. /**
  36395. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36396. */
  36397. positionScale: number;
  36398. /**
  36399. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36400. * behaviour is triggered, in radians.
  36401. */
  36402. /**
  36403. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36404. * behaviour is triggered, in radians.
  36405. */
  36406. defaultElevation: number;
  36407. /**
  36408. * Sets the time (in milliseconds) taken to return to the default beta position.
  36409. * Negative value indicates camera should not return to default.
  36410. */
  36411. /**
  36412. * Gets the time (in milliseconds) taken to return to the default beta position.
  36413. * Negative value indicates camera should not return to default.
  36414. */
  36415. elevationReturnTime: number;
  36416. /**
  36417. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36418. */
  36419. /**
  36420. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36421. */
  36422. elevationReturnWaitTime: number;
  36423. /**
  36424. * Sets the flag that indicates if user zooming should stop animation.
  36425. */
  36426. /**
  36427. * Gets the flag that indicates if user zooming should stop animation.
  36428. */
  36429. zoomStopsAnimation: boolean;
  36430. /**
  36431. * Sets the transition time when framing the mesh, in milliseconds
  36432. */
  36433. /**
  36434. * Gets the transition time when framing the mesh, in milliseconds
  36435. */
  36436. framingTime: number;
  36437. /**
  36438. * Define if the behavior should automatically change the configured
  36439. * camera limits and sensibilities.
  36440. */
  36441. autoCorrectCameraLimitsAndSensibility: boolean;
  36442. private _onPrePointerObservableObserver;
  36443. private _onAfterCheckInputsObserver;
  36444. private _onMeshTargetChangedObserver;
  36445. private _attachedCamera;
  36446. private _isPointerDown;
  36447. private _lastInteractionTime;
  36448. /**
  36449. * Initializes the behavior.
  36450. */
  36451. init(): void;
  36452. /**
  36453. * Attaches the behavior to its arc rotate camera.
  36454. * @param camera Defines the camera to attach the behavior to
  36455. */
  36456. attach(camera: ArcRotateCamera): void;
  36457. /**
  36458. * Detaches the behavior from its current arc rotate camera.
  36459. */
  36460. detach(): void;
  36461. private _animatables;
  36462. private _betaIsAnimating;
  36463. private _betaTransition;
  36464. private _radiusTransition;
  36465. private _vectorTransition;
  36466. /**
  36467. * Targets the given mesh and updates zoom level accordingly.
  36468. * @param mesh The mesh to target.
  36469. * @param radius Optional. If a cached radius position already exists, overrides default.
  36470. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36471. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36472. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36473. */
  36474. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36475. /**
  36476. * Targets the given mesh with its children and updates zoom level accordingly.
  36477. * @param mesh The mesh to target.
  36478. * @param radius Optional. If a cached radius position already exists, overrides default.
  36479. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36480. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36481. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36482. */
  36483. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36484. /**
  36485. * Targets the given meshes with their children and updates zoom level accordingly.
  36486. * @param meshes The mesh to target.
  36487. * @param radius Optional. If a cached radius position already exists, overrides default.
  36488. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36489. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36490. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36491. */
  36492. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36493. /**
  36494. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36495. * @param minimumWorld Determines the smaller position of the bounding box extend
  36496. * @param maximumWorld Determines the bigger position of the bounding box extend
  36497. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36498. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36499. */
  36500. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36501. /**
  36502. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36503. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36504. * frustum width.
  36505. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36506. * to fully enclose the mesh in the viewing frustum.
  36507. */
  36508. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36509. /**
  36510. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36511. * is automatically returned to its default position (expected to be above ground plane).
  36512. */
  36513. private _maintainCameraAboveGround;
  36514. /**
  36515. * Returns the frustum slope based on the canvas ratio and camera FOV
  36516. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36517. */
  36518. private _getFrustumSlope;
  36519. /**
  36520. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36521. */
  36522. private _clearAnimationLocks;
  36523. /**
  36524. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36525. */
  36526. private _applyUserInteraction;
  36527. /**
  36528. * Stops and removes all animations that have been applied to the camera
  36529. */
  36530. stopAllAnimations(): void;
  36531. /**
  36532. * Gets a value indicating if the user is moving the camera
  36533. */
  36534. readonly isUserIsMoving: boolean;
  36535. /**
  36536. * The camera can move all the way towards the mesh.
  36537. */
  36538. static IgnoreBoundsSizeMode: number;
  36539. /**
  36540. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36541. */
  36542. static FitFrustumSidesMode: number;
  36543. }
  36544. }
  36545. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36546. import { Nullable } from "babylonjs/types";
  36547. import { Camera } from "babylonjs/Cameras/camera";
  36548. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36549. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36550. /**
  36551. * Base class for Camera Pointer Inputs.
  36552. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36553. * for example usage.
  36554. */
  36555. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36556. /**
  36557. * Defines the camera the input is attached to.
  36558. */
  36559. abstract camera: Camera;
  36560. /**
  36561. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36562. */
  36563. protected _altKey: boolean;
  36564. protected _ctrlKey: boolean;
  36565. protected _metaKey: boolean;
  36566. protected _shiftKey: boolean;
  36567. /**
  36568. * Which mouse buttons were pressed at time of last mouse event.
  36569. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36570. */
  36571. protected _buttonsPressed: number;
  36572. /**
  36573. * Defines the buttons associated with the input to handle camera move.
  36574. */
  36575. buttons: number[];
  36576. /**
  36577. * Attach the input controls to a specific dom element to get the input from.
  36578. * @param element Defines the element the controls should be listened from
  36579. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36580. */
  36581. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36582. /**
  36583. * Detach the current controls from the specified dom element.
  36584. * @param element Defines the element to stop listening the inputs from
  36585. */
  36586. detachControl(element: Nullable<HTMLElement>): void;
  36587. /**
  36588. * Gets the class name of the current input.
  36589. * @returns the class name
  36590. */
  36591. getClassName(): string;
  36592. /**
  36593. * Get the friendly name associated with the input class.
  36594. * @returns the input friendly name
  36595. */
  36596. getSimpleName(): string;
  36597. /**
  36598. * Called on pointer POINTERDOUBLETAP event.
  36599. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36600. */
  36601. protected onDoubleTap(type: string): void;
  36602. /**
  36603. * Called on pointer POINTERMOVE event if only a single touch is active.
  36604. * Override this method to provide functionality.
  36605. */
  36606. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36607. /**
  36608. * Called on pointer POINTERMOVE event if multiple touches are active.
  36609. * Override this method to provide functionality.
  36610. */
  36611. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36612. /**
  36613. * Called on JS contextmenu event.
  36614. * Override this method to provide functionality.
  36615. */
  36616. protected onContextMenu(evt: PointerEvent): void;
  36617. /**
  36618. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36619. * press.
  36620. * Override this method to provide functionality.
  36621. */
  36622. protected onButtonDown(evt: PointerEvent): void;
  36623. /**
  36624. * Called each time a new POINTERUP event occurs. Ie, for each button
  36625. * release.
  36626. * Override this method to provide functionality.
  36627. */
  36628. protected onButtonUp(evt: PointerEvent): void;
  36629. /**
  36630. * Called when window becomes inactive.
  36631. * Override this method to provide functionality.
  36632. */
  36633. protected onLostFocus(): void;
  36634. private _pointerInput;
  36635. private _observer;
  36636. private _onLostFocus;
  36637. private pointA;
  36638. private pointB;
  36639. }
  36640. }
  36641. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36642. import { Nullable } from "babylonjs/types";
  36643. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36644. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36645. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36646. /**
  36647. * Manage the pointers inputs to control an arc rotate camera.
  36648. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36649. */
  36650. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36651. /**
  36652. * Defines the camera the input is attached to.
  36653. */
  36654. camera: ArcRotateCamera;
  36655. /**
  36656. * Gets the class name of the current input.
  36657. * @returns the class name
  36658. */
  36659. getClassName(): string;
  36660. /**
  36661. * Defines the buttons associated with the input to handle camera move.
  36662. */
  36663. buttons: number[];
  36664. /**
  36665. * Defines the pointer angular sensibility along the X axis or how fast is
  36666. * the camera rotating.
  36667. */
  36668. angularSensibilityX: number;
  36669. /**
  36670. * Defines the pointer angular sensibility along the Y axis or how fast is
  36671. * the camera rotating.
  36672. */
  36673. angularSensibilityY: number;
  36674. /**
  36675. * Defines the pointer pinch precision or how fast is the camera zooming.
  36676. */
  36677. pinchPrecision: number;
  36678. /**
  36679. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36680. * from 0.
  36681. * It defines the percentage of current camera.radius to use as delta when
  36682. * pinch zoom is used.
  36683. */
  36684. pinchDeltaPercentage: number;
  36685. /**
  36686. * Defines the pointer panning sensibility or how fast is the camera moving.
  36687. */
  36688. panningSensibility: number;
  36689. /**
  36690. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36691. */
  36692. multiTouchPanning: boolean;
  36693. /**
  36694. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36695. * zoom (pinch) through multitouch.
  36696. */
  36697. multiTouchPanAndZoom: boolean;
  36698. /**
  36699. * Revers pinch action direction.
  36700. */
  36701. pinchInwards: boolean;
  36702. private _isPanClick;
  36703. private _twoFingerActivityCount;
  36704. private _isPinching;
  36705. /**
  36706. * Called on pointer POINTERMOVE event if only a single touch is active.
  36707. */
  36708. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36709. /**
  36710. * Called on pointer POINTERDOUBLETAP event.
  36711. */
  36712. protected onDoubleTap(type: string): void;
  36713. /**
  36714. * Called on pointer POINTERMOVE event if multiple touches are active.
  36715. */
  36716. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36717. /**
  36718. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36719. * press.
  36720. */
  36721. protected onButtonDown(evt: PointerEvent): void;
  36722. /**
  36723. * Called each time a new POINTERUP event occurs. Ie, for each button
  36724. * release.
  36725. */
  36726. protected onButtonUp(evt: PointerEvent): void;
  36727. /**
  36728. * Called when window becomes inactive.
  36729. */
  36730. protected onLostFocus(): void;
  36731. }
  36732. }
  36733. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36734. import { Nullable } from "babylonjs/types";
  36735. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36736. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36737. /**
  36738. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36739. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36740. */
  36741. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36742. /**
  36743. * Defines the camera the input is attached to.
  36744. */
  36745. camera: ArcRotateCamera;
  36746. /**
  36747. * Defines the list of key codes associated with the up action (increase alpha)
  36748. */
  36749. keysUp: number[];
  36750. /**
  36751. * Defines the list of key codes associated with the down action (decrease alpha)
  36752. */
  36753. keysDown: number[];
  36754. /**
  36755. * Defines the list of key codes associated with the left action (increase beta)
  36756. */
  36757. keysLeft: number[];
  36758. /**
  36759. * Defines the list of key codes associated with the right action (decrease beta)
  36760. */
  36761. keysRight: number[];
  36762. /**
  36763. * Defines the list of key codes associated with the reset action.
  36764. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36765. */
  36766. keysReset: number[];
  36767. /**
  36768. * Defines the panning sensibility of the inputs.
  36769. * (How fast is the camera paning)
  36770. */
  36771. panningSensibility: number;
  36772. /**
  36773. * Defines the zooming sensibility of the inputs.
  36774. * (How fast is the camera zooming)
  36775. */
  36776. zoomingSensibility: number;
  36777. /**
  36778. * Defines wether maintaining the alt key down switch the movement mode from
  36779. * orientation to zoom.
  36780. */
  36781. useAltToZoom: boolean;
  36782. /**
  36783. * Rotation speed of the camera
  36784. */
  36785. angularSpeed: number;
  36786. private _keys;
  36787. private _ctrlPressed;
  36788. private _altPressed;
  36789. private _onCanvasBlurObserver;
  36790. private _onKeyboardObserver;
  36791. private _engine;
  36792. private _scene;
  36793. /**
  36794. * Attach the input controls to a specific dom element to get the input from.
  36795. * @param element Defines the element the controls should be listened from
  36796. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36797. */
  36798. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36799. /**
  36800. * Detach the current controls from the specified dom element.
  36801. * @param element Defines the element to stop listening the inputs from
  36802. */
  36803. detachControl(element: Nullable<HTMLElement>): void;
  36804. /**
  36805. * Update the current camera state depending on the inputs that have been used this frame.
  36806. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36807. */
  36808. checkInputs(): void;
  36809. /**
  36810. * Gets the class name of the current intput.
  36811. * @returns the class name
  36812. */
  36813. getClassName(): string;
  36814. /**
  36815. * Get the friendly name associated with the input class.
  36816. * @returns the input friendly name
  36817. */
  36818. getSimpleName(): string;
  36819. }
  36820. }
  36821. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36822. import { Nullable } from "babylonjs/types";
  36823. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36824. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36825. /**
  36826. * Manage the mouse wheel inputs to control an arc rotate camera.
  36827. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36828. */
  36829. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36830. /**
  36831. * Defines the camera the input is attached to.
  36832. */
  36833. camera: ArcRotateCamera;
  36834. /**
  36835. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36836. */
  36837. wheelPrecision: number;
  36838. /**
  36839. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36840. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36841. */
  36842. wheelDeltaPercentage: number;
  36843. private _wheel;
  36844. private _observer;
  36845. private computeDeltaFromMouseWheelLegacyEvent;
  36846. /**
  36847. * Attach the input controls to a specific dom element to get the input from.
  36848. * @param element Defines the element the controls should be listened from
  36849. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36850. */
  36851. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36852. /**
  36853. * Detach the current controls from the specified dom element.
  36854. * @param element Defines the element to stop listening the inputs from
  36855. */
  36856. detachControl(element: Nullable<HTMLElement>): void;
  36857. /**
  36858. * Gets the class name of the current intput.
  36859. * @returns the class name
  36860. */
  36861. getClassName(): string;
  36862. /**
  36863. * Get the friendly name associated with the input class.
  36864. * @returns the input friendly name
  36865. */
  36866. getSimpleName(): string;
  36867. }
  36868. }
  36869. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36870. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36871. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36872. /**
  36873. * Default Inputs manager for the ArcRotateCamera.
  36874. * It groups all the default supported inputs for ease of use.
  36875. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36876. */
  36877. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36878. /**
  36879. * Instantiates a new ArcRotateCameraInputsManager.
  36880. * @param camera Defines the camera the inputs belong to
  36881. */
  36882. constructor(camera: ArcRotateCamera);
  36883. /**
  36884. * Add mouse wheel input support to the input manager.
  36885. * @returns the current input manager
  36886. */
  36887. addMouseWheel(): ArcRotateCameraInputsManager;
  36888. /**
  36889. * Add pointers input support to the input manager.
  36890. * @returns the current input manager
  36891. */
  36892. addPointers(): ArcRotateCameraInputsManager;
  36893. /**
  36894. * Add keyboard input support to the input manager.
  36895. * @returns the current input manager
  36896. */
  36897. addKeyboard(): ArcRotateCameraInputsManager;
  36898. }
  36899. }
  36900. declare module "babylonjs/Cameras/arcRotateCamera" {
  36901. import { Observable } from "babylonjs/Misc/observable";
  36902. import { Nullable } from "babylonjs/types";
  36903. import { Scene } from "babylonjs/scene";
  36904. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  36905. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36906. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36907. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36908. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36909. import { Camera } from "babylonjs/Cameras/camera";
  36910. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36911. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36912. import { Collider } from "babylonjs/Collisions/collider";
  36913. /**
  36914. * This represents an orbital type of camera.
  36915. *
  36916. * 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.
  36917. * 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.
  36918. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36919. */
  36920. export class ArcRotateCamera extends TargetCamera {
  36921. /**
  36922. * Defines the rotation angle of the camera along the longitudinal axis.
  36923. */
  36924. alpha: number;
  36925. /**
  36926. * Defines the rotation angle of the camera along the latitudinal axis.
  36927. */
  36928. beta: number;
  36929. /**
  36930. * Defines the radius of the camera from it s target point.
  36931. */
  36932. radius: number;
  36933. protected _target: Vector3;
  36934. protected _targetHost: Nullable<AbstractMesh>;
  36935. /**
  36936. * Defines the target point of the camera.
  36937. * The camera looks towards it form the radius distance.
  36938. */
  36939. target: Vector3;
  36940. /**
  36941. * Define the current local position of the camera in the scene
  36942. */
  36943. position: Vector3;
  36944. protected _upVector: Vector3;
  36945. protected _upToYMatrix: Matrix;
  36946. protected _YToUpMatrix: Matrix;
  36947. /**
  36948. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36949. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36950. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36951. */
  36952. upVector: Vector3;
  36953. /**
  36954. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36955. */
  36956. setMatUp(): void;
  36957. /**
  36958. * Current inertia value on the longitudinal axis.
  36959. * The bigger this number the longer it will take for the camera to stop.
  36960. */
  36961. inertialAlphaOffset: number;
  36962. /**
  36963. * Current inertia value on the latitudinal axis.
  36964. * The bigger this number the longer it will take for the camera to stop.
  36965. */
  36966. inertialBetaOffset: number;
  36967. /**
  36968. * Current inertia value on the radius axis.
  36969. * The bigger this number the longer it will take for the camera to stop.
  36970. */
  36971. inertialRadiusOffset: number;
  36972. /**
  36973. * Minimum allowed angle on the longitudinal axis.
  36974. * This can help limiting how the Camera is able to move in the scene.
  36975. */
  36976. lowerAlphaLimit: Nullable<number>;
  36977. /**
  36978. * Maximum allowed angle on the longitudinal axis.
  36979. * This can help limiting how the Camera is able to move in the scene.
  36980. */
  36981. upperAlphaLimit: Nullable<number>;
  36982. /**
  36983. * Minimum allowed angle on the latitudinal axis.
  36984. * This can help limiting how the Camera is able to move in the scene.
  36985. */
  36986. lowerBetaLimit: number;
  36987. /**
  36988. * Maximum allowed angle on the latitudinal axis.
  36989. * This can help limiting how the Camera is able to move in the scene.
  36990. */
  36991. upperBetaLimit: number;
  36992. /**
  36993. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36994. * This can help limiting how the Camera is able to move in the scene.
  36995. */
  36996. lowerRadiusLimit: Nullable<number>;
  36997. /**
  36998. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36999. * This can help limiting how the Camera is able to move in the scene.
  37000. */
  37001. upperRadiusLimit: Nullable<number>;
  37002. /**
  37003. * Defines the current inertia value used during panning of the camera along the X axis.
  37004. */
  37005. inertialPanningX: number;
  37006. /**
  37007. * Defines the current inertia value used during panning of the camera along the Y axis.
  37008. */
  37009. inertialPanningY: number;
  37010. /**
  37011. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37012. * Basically if your fingers moves away from more than this distance you will be considered
  37013. * in pinch mode.
  37014. */
  37015. pinchToPanMaxDistance: number;
  37016. /**
  37017. * Defines the maximum distance the camera can pan.
  37018. * This could help keeping the cammera always in your scene.
  37019. */
  37020. panningDistanceLimit: Nullable<number>;
  37021. /**
  37022. * Defines the target of the camera before paning.
  37023. */
  37024. panningOriginTarget: Vector3;
  37025. /**
  37026. * Defines the value of the inertia used during panning.
  37027. * 0 would mean stop inertia and one would mean no decelleration at all.
  37028. */
  37029. panningInertia: number;
  37030. /**
  37031. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37032. */
  37033. angularSensibilityX: number;
  37034. /**
  37035. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37036. */
  37037. angularSensibilityY: number;
  37038. /**
  37039. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37040. */
  37041. pinchPrecision: number;
  37042. /**
  37043. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37044. * It will be used instead of pinchDeltaPrecision if different from 0.
  37045. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37046. */
  37047. pinchDeltaPercentage: number;
  37048. /**
  37049. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37050. */
  37051. panningSensibility: number;
  37052. /**
  37053. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37054. */
  37055. keysUp: number[];
  37056. /**
  37057. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37058. */
  37059. keysDown: number[];
  37060. /**
  37061. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37062. */
  37063. keysLeft: number[];
  37064. /**
  37065. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37066. */
  37067. keysRight: number[];
  37068. /**
  37069. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37070. */
  37071. wheelPrecision: number;
  37072. /**
  37073. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37074. * It will be used instead of pinchDeltaPrecision if different from 0.
  37075. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37076. */
  37077. wheelDeltaPercentage: number;
  37078. /**
  37079. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37080. */
  37081. zoomOnFactor: number;
  37082. /**
  37083. * Defines a screen offset for the camera position.
  37084. */
  37085. targetScreenOffset: Vector2;
  37086. /**
  37087. * Allows the camera to be completely reversed.
  37088. * If false the camera can not arrive upside down.
  37089. */
  37090. allowUpsideDown: boolean;
  37091. /**
  37092. * Define if double tap/click is used to restore the previously saved state of the camera.
  37093. */
  37094. useInputToRestoreState: boolean;
  37095. /** @hidden */
  37096. _viewMatrix: Matrix;
  37097. /** @hidden */
  37098. _useCtrlForPanning: boolean;
  37099. /** @hidden */
  37100. _panningMouseButton: number;
  37101. /**
  37102. * Defines the input associated to the camera.
  37103. */
  37104. inputs: ArcRotateCameraInputsManager;
  37105. /** @hidden */
  37106. _reset: () => void;
  37107. /**
  37108. * Defines the allowed panning axis.
  37109. */
  37110. panningAxis: Vector3;
  37111. protected _localDirection: Vector3;
  37112. protected _transformedDirection: Vector3;
  37113. private _bouncingBehavior;
  37114. /**
  37115. * Gets the bouncing behavior of the camera if it has been enabled.
  37116. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37117. */
  37118. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37119. /**
  37120. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37121. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37122. */
  37123. useBouncingBehavior: boolean;
  37124. private _framingBehavior;
  37125. /**
  37126. * Gets the framing behavior of the camera if it has been enabled.
  37127. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37128. */
  37129. readonly framingBehavior: Nullable<FramingBehavior>;
  37130. /**
  37131. * Defines if the framing behavior of the camera is enabled on the camera.
  37132. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37133. */
  37134. useFramingBehavior: boolean;
  37135. private _autoRotationBehavior;
  37136. /**
  37137. * Gets the auto rotation behavior of the camera if it has been enabled.
  37138. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37139. */
  37140. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37141. /**
  37142. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37143. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37144. */
  37145. useAutoRotationBehavior: boolean;
  37146. /**
  37147. * Observable triggered when the mesh target has been changed on the camera.
  37148. */
  37149. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37150. /**
  37151. * Event raised when the camera is colliding with a mesh.
  37152. */
  37153. onCollide: (collidedMesh: AbstractMesh) => void;
  37154. /**
  37155. * Defines whether the camera should check collision with the objects oh the scene.
  37156. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37157. */
  37158. checkCollisions: boolean;
  37159. /**
  37160. * Defines the collision radius of the camera.
  37161. * This simulates a sphere around the camera.
  37162. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37163. */
  37164. collisionRadius: Vector3;
  37165. protected _collider: Collider;
  37166. protected _previousPosition: Vector3;
  37167. protected _collisionVelocity: Vector3;
  37168. protected _newPosition: Vector3;
  37169. protected _previousAlpha: number;
  37170. protected _previousBeta: number;
  37171. protected _previousRadius: number;
  37172. protected _collisionTriggered: boolean;
  37173. protected _targetBoundingCenter: Nullable<Vector3>;
  37174. private _computationVector;
  37175. /**
  37176. * Instantiates a new ArcRotateCamera in a given scene
  37177. * @param name Defines the name of the camera
  37178. * @param alpha Defines the camera rotation along the logitudinal axis
  37179. * @param beta Defines the camera rotation along the latitudinal axis
  37180. * @param radius Defines the camera distance from its target
  37181. * @param target Defines the camera target
  37182. * @param scene Defines the scene the camera belongs to
  37183. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37184. */
  37185. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37186. /** @hidden */
  37187. _initCache(): void;
  37188. /** @hidden */
  37189. _updateCache(ignoreParentClass?: boolean): void;
  37190. protected _getTargetPosition(): Vector3;
  37191. private _storedAlpha;
  37192. private _storedBeta;
  37193. private _storedRadius;
  37194. private _storedTarget;
  37195. /**
  37196. * Stores the current state of the camera (alpha, beta, radius and target)
  37197. * @returns the camera itself
  37198. */
  37199. storeState(): Camera;
  37200. /**
  37201. * @hidden
  37202. * Restored camera state. You must call storeState() first
  37203. */
  37204. _restoreStateValues(): boolean;
  37205. /** @hidden */
  37206. _isSynchronizedViewMatrix(): boolean;
  37207. /**
  37208. * Attached controls to the current camera.
  37209. * @param element Defines the element the controls should be listened from
  37210. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37211. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37212. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37213. */
  37214. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37215. /**
  37216. * Detach the current controls from the camera.
  37217. * The camera will stop reacting to inputs.
  37218. * @param element Defines the element to stop listening the inputs from
  37219. */
  37220. detachControl(element: HTMLElement): void;
  37221. /** @hidden */
  37222. _checkInputs(): void;
  37223. protected _checkLimits(): void;
  37224. /**
  37225. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37226. */
  37227. rebuildAnglesAndRadius(): void;
  37228. /**
  37229. * Use a position to define the current camera related information like aplha, beta and radius
  37230. * @param position Defines the position to set the camera at
  37231. */
  37232. setPosition(position: Vector3): void;
  37233. /**
  37234. * Defines the target the camera should look at.
  37235. * This will automatically adapt alpha beta and radius to fit within the new target.
  37236. * @param target Defines the new target as a Vector or a mesh
  37237. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37238. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37239. */
  37240. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37241. /** @hidden */
  37242. _getViewMatrix(): Matrix;
  37243. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37244. /**
  37245. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37246. * @param meshes Defines the mesh to zoom on
  37247. * @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)
  37248. */
  37249. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37250. /**
  37251. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37252. * The target will be changed but the radius
  37253. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37254. * @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)
  37255. */
  37256. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37257. min: Vector3;
  37258. max: Vector3;
  37259. distance: number;
  37260. }, doNotUpdateMaxZ?: boolean): void;
  37261. /**
  37262. * @override
  37263. * Override Camera.createRigCamera
  37264. */
  37265. createRigCamera(name: string, cameraIndex: number): Camera;
  37266. /**
  37267. * @hidden
  37268. * @override
  37269. * Override Camera._updateRigCameras
  37270. */
  37271. _updateRigCameras(): void;
  37272. /**
  37273. * Destroy the camera and release the current resources hold by it.
  37274. */
  37275. dispose(): void;
  37276. /**
  37277. * Gets the current object class name.
  37278. * @return the class name
  37279. */
  37280. getClassName(): string;
  37281. }
  37282. }
  37283. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37284. import { Behavior } from "babylonjs/Behaviors/behavior";
  37285. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37286. /**
  37287. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37288. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37289. */
  37290. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37291. /**
  37292. * Gets the name of the behavior.
  37293. */
  37294. readonly name: string;
  37295. private _zoomStopsAnimation;
  37296. private _idleRotationSpeed;
  37297. private _idleRotationWaitTime;
  37298. private _idleRotationSpinupTime;
  37299. /**
  37300. * Sets the flag that indicates if user zooming should stop animation.
  37301. */
  37302. /**
  37303. * Gets the flag that indicates if user zooming should stop animation.
  37304. */
  37305. zoomStopsAnimation: boolean;
  37306. /**
  37307. * Sets the default speed at which the camera rotates around the model.
  37308. */
  37309. /**
  37310. * Gets the default speed at which the camera rotates around the model.
  37311. */
  37312. idleRotationSpeed: number;
  37313. /**
  37314. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37315. */
  37316. /**
  37317. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37318. */
  37319. idleRotationWaitTime: number;
  37320. /**
  37321. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37322. */
  37323. /**
  37324. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37325. */
  37326. idleRotationSpinupTime: number;
  37327. /**
  37328. * Gets a value indicating if the camera is currently rotating because of this behavior
  37329. */
  37330. readonly rotationInProgress: boolean;
  37331. private _onPrePointerObservableObserver;
  37332. private _onAfterCheckInputsObserver;
  37333. private _attachedCamera;
  37334. private _isPointerDown;
  37335. private _lastFrameTime;
  37336. private _lastInteractionTime;
  37337. private _cameraRotationSpeed;
  37338. /**
  37339. * Initializes the behavior.
  37340. */
  37341. init(): void;
  37342. /**
  37343. * Attaches the behavior to its arc rotate camera.
  37344. * @param camera Defines the camera to attach the behavior to
  37345. */
  37346. attach(camera: ArcRotateCamera): void;
  37347. /**
  37348. * Detaches the behavior from its current arc rotate camera.
  37349. */
  37350. detach(): void;
  37351. /**
  37352. * Returns true if user is scrolling.
  37353. * @return true if user is scrolling.
  37354. */
  37355. private _userIsZooming;
  37356. private _lastFrameRadius;
  37357. private _shouldAnimationStopForInteraction;
  37358. /**
  37359. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37360. */
  37361. private _applyUserInteraction;
  37362. private _userIsMoving;
  37363. }
  37364. }
  37365. declare module "babylonjs/Behaviors/Cameras/index" {
  37366. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37367. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37368. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37369. }
  37370. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37371. import { Mesh } from "babylonjs/Meshes/mesh";
  37372. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37373. import { Behavior } from "babylonjs/Behaviors/behavior";
  37374. /**
  37375. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37376. */
  37377. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37378. private ui;
  37379. /**
  37380. * The name of the behavior
  37381. */
  37382. name: string;
  37383. /**
  37384. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37385. */
  37386. distanceAwayFromFace: number;
  37387. /**
  37388. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37389. */
  37390. distanceAwayFromBottomOfFace: number;
  37391. private _faceVectors;
  37392. private _target;
  37393. private _scene;
  37394. private _onRenderObserver;
  37395. private _tmpMatrix;
  37396. private _tmpVector;
  37397. /**
  37398. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37399. * @param ui The transform node that should be attched to the mesh
  37400. */
  37401. constructor(ui: TransformNode);
  37402. /**
  37403. * Initializes the behavior
  37404. */
  37405. init(): void;
  37406. private _closestFace;
  37407. private _zeroVector;
  37408. private _lookAtTmpMatrix;
  37409. private _lookAtToRef;
  37410. /**
  37411. * Attaches the AttachToBoxBehavior to the passed in mesh
  37412. * @param target The mesh that the specified node will be attached to
  37413. */
  37414. attach(target: Mesh): void;
  37415. /**
  37416. * Detaches the behavior from the mesh
  37417. */
  37418. detach(): void;
  37419. }
  37420. }
  37421. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37422. import { Behavior } from "babylonjs/Behaviors/behavior";
  37423. import { Mesh } from "babylonjs/Meshes/mesh";
  37424. /**
  37425. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37426. */
  37427. export class FadeInOutBehavior implements Behavior<Mesh> {
  37428. /**
  37429. * Time in milliseconds to delay before fading in (Default: 0)
  37430. */
  37431. delay: number;
  37432. /**
  37433. * Time in milliseconds for the mesh to fade in (Default: 300)
  37434. */
  37435. fadeInTime: number;
  37436. private _millisecondsPerFrame;
  37437. private _hovered;
  37438. private _hoverValue;
  37439. private _ownerNode;
  37440. /**
  37441. * Instatiates the FadeInOutBehavior
  37442. */
  37443. constructor();
  37444. /**
  37445. * The name of the behavior
  37446. */
  37447. readonly name: string;
  37448. /**
  37449. * Initializes the behavior
  37450. */
  37451. init(): void;
  37452. /**
  37453. * Attaches the fade behavior on the passed in mesh
  37454. * @param ownerNode The mesh that will be faded in/out once attached
  37455. */
  37456. attach(ownerNode: Mesh): void;
  37457. /**
  37458. * Detaches the behavior from the mesh
  37459. */
  37460. detach(): void;
  37461. /**
  37462. * Triggers the mesh to begin fading in or out
  37463. * @param value if the object should fade in or out (true to fade in)
  37464. */
  37465. fadeIn(value: boolean): void;
  37466. private _update;
  37467. private _setAllVisibility;
  37468. }
  37469. }
  37470. declare module "babylonjs/Misc/pivotTools" {
  37471. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37472. /**
  37473. * Class containing a set of static utilities functions for managing Pivots
  37474. * @hidden
  37475. */
  37476. export class PivotTools {
  37477. private static _PivotCached;
  37478. private static _OldPivotPoint;
  37479. private static _PivotTranslation;
  37480. private static _PivotTmpVector;
  37481. /** @hidden */
  37482. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37483. /** @hidden */
  37484. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37485. }
  37486. }
  37487. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37488. import { Scene } from "babylonjs/scene";
  37489. import { Vector4 } from "babylonjs/Maths/math.vector";
  37490. import { Mesh } from "babylonjs/Meshes/mesh";
  37491. import { Nullable } from "babylonjs/types";
  37492. import { Plane } from "babylonjs/Maths/math.plane";
  37493. /**
  37494. * Class containing static functions to help procedurally build meshes
  37495. */
  37496. export class PlaneBuilder {
  37497. /**
  37498. * Creates a plane mesh
  37499. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37500. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37501. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37502. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37503. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37505. * @param name defines the name of the mesh
  37506. * @param options defines the options used to create the mesh
  37507. * @param scene defines the hosting scene
  37508. * @returns the plane mesh
  37509. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37510. */
  37511. static CreatePlane(name: string, options: {
  37512. size?: number;
  37513. width?: number;
  37514. height?: number;
  37515. sideOrientation?: number;
  37516. frontUVs?: Vector4;
  37517. backUVs?: Vector4;
  37518. updatable?: boolean;
  37519. sourcePlane?: Plane;
  37520. }, scene?: Nullable<Scene>): Mesh;
  37521. }
  37522. }
  37523. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37524. import { Behavior } from "babylonjs/Behaviors/behavior";
  37525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37526. import { Observable } from "babylonjs/Misc/observable";
  37527. import { Vector3 } from "babylonjs/Maths/math.vector";
  37528. import { Ray } from "babylonjs/Culling/ray";
  37529. import "babylonjs/Meshes/Builders/planeBuilder";
  37530. /**
  37531. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37532. */
  37533. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37534. private static _AnyMouseID;
  37535. /**
  37536. * Abstract mesh the behavior is set on
  37537. */
  37538. attachedNode: AbstractMesh;
  37539. private _dragPlane;
  37540. private _scene;
  37541. private _pointerObserver;
  37542. private _beforeRenderObserver;
  37543. private static _planeScene;
  37544. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37545. /**
  37546. * 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)
  37547. */
  37548. maxDragAngle: number;
  37549. /**
  37550. * @hidden
  37551. */
  37552. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37553. /**
  37554. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37555. */
  37556. currentDraggingPointerID: number;
  37557. /**
  37558. * The last position where the pointer hit the drag plane in world space
  37559. */
  37560. lastDragPosition: Vector3;
  37561. /**
  37562. * If the behavior is currently in a dragging state
  37563. */
  37564. dragging: boolean;
  37565. /**
  37566. * 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)
  37567. */
  37568. dragDeltaRatio: number;
  37569. /**
  37570. * If the drag plane orientation should be updated during the dragging (Default: true)
  37571. */
  37572. updateDragPlane: boolean;
  37573. private _debugMode;
  37574. private _moving;
  37575. /**
  37576. * Fires each time the attached mesh is dragged with the pointer
  37577. * * delta between last drag position and current drag position in world space
  37578. * * dragDistance along the drag axis
  37579. * * dragPlaneNormal normal of the current drag plane used during the drag
  37580. * * dragPlanePoint in world space where the drag intersects the drag plane
  37581. */
  37582. onDragObservable: Observable<{
  37583. delta: Vector3;
  37584. dragPlanePoint: Vector3;
  37585. dragPlaneNormal: Vector3;
  37586. dragDistance: number;
  37587. pointerId: number;
  37588. }>;
  37589. /**
  37590. * Fires each time a drag begins (eg. mouse down on mesh)
  37591. */
  37592. onDragStartObservable: Observable<{
  37593. dragPlanePoint: Vector3;
  37594. pointerId: number;
  37595. }>;
  37596. /**
  37597. * Fires each time a drag ends (eg. mouse release after drag)
  37598. */
  37599. onDragEndObservable: Observable<{
  37600. dragPlanePoint: Vector3;
  37601. pointerId: number;
  37602. }>;
  37603. /**
  37604. * If the attached mesh should be moved when dragged
  37605. */
  37606. moveAttached: boolean;
  37607. /**
  37608. * If the drag behavior will react to drag events (Default: true)
  37609. */
  37610. enabled: boolean;
  37611. /**
  37612. * If pointer events should start and release the drag (Default: true)
  37613. */
  37614. startAndReleaseDragOnPointerEvents: boolean;
  37615. /**
  37616. * If camera controls should be detached during the drag
  37617. */
  37618. detachCameraControls: boolean;
  37619. /**
  37620. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37621. */
  37622. useObjectOrienationForDragging: boolean;
  37623. private _options;
  37624. /**
  37625. * Creates a pointer drag behavior that can be attached to a mesh
  37626. * @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)
  37627. */
  37628. constructor(options?: {
  37629. dragAxis?: Vector3;
  37630. dragPlaneNormal?: Vector3;
  37631. });
  37632. /**
  37633. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37634. */
  37635. validateDrag: (targetPosition: Vector3) => boolean;
  37636. /**
  37637. * The name of the behavior
  37638. */
  37639. readonly name: string;
  37640. /**
  37641. * Initializes the behavior
  37642. */
  37643. init(): void;
  37644. private _tmpVector;
  37645. private _alternatePickedPoint;
  37646. private _worldDragAxis;
  37647. private _targetPosition;
  37648. private _attachedElement;
  37649. /**
  37650. * Attaches the drag behavior the passed in mesh
  37651. * @param ownerNode The mesh that will be dragged around once attached
  37652. */
  37653. attach(ownerNode: AbstractMesh): void;
  37654. /**
  37655. * Force relase the drag action by code.
  37656. */
  37657. releaseDrag(): void;
  37658. private _startDragRay;
  37659. private _lastPointerRay;
  37660. /**
  37661. * Simulates the start of a pointer drag event on the behavior
  37662. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37663. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37664. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37665. */
  37666. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37667. private _startDrag;
  37668. private _dragDelta;
  37669. private _moveDrag;
  37670. private _pickWithRayOnDragPlane;
  37671. private _pointA;
  37672. private _pointB;
  37673. private _pointC;
  37674. private _lineA;
  37675. private _lineB;
  37676. private _localAxis;
  37677. private _lookAt;
  37678. private _updateDragPlanePosition;
  37679. /**
  37680. * Detaches the behavior from the mesh
  37681. */
  37682. detach(): void;
  37683. }
  37684. }
  37685. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37686. import { Mesh } from "babylonjs/Meshes/mesh";
  37687. import { Behavior } from "babylonjs/Behaviors/behavior";
  37688. /**
  37689. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37690. */
  37691. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37692. private _dragBehaviorA;
  37693. private _dragBehaviorB;
  37694. private _startDistance;
  37695. private _initialScale;
  37696. private _targetScale;
  37697. private _ownerNode;
  37698. private _sceneRenderObserver;
  37699. /**
  37700. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37701. */
  37702. constructor();
  37703. /**
  37704. * The name of the behavior
  37705. */
  37706. readonly name: string;
  37707. /**
  37708. * Initializes the behavior
  37709. */
  37710. init(): void;
  37711. private _getCurrentDistance;
  37712. /**
  37713. * Attaches the scale behavior the passed in mesh
  37714. * @param ownerNode The mesh that will be scaled around once attached
  37715. */
  37716. attach(ownerNode: Mesh): void;
  37717. /**
  37718. * Detaches the behavior from the mesh
  37719. */
  37720. detach(): void;
  37721. }
  37722. }
  37723. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37724. import { Behavior } from "babylonjs/Behaviors/behavior";
  37725. import { Mesh } from "babylonjs/Meshes/mesh";
  37726. import { Observable } from "babylonjs/Misc/observable";
  37727. /**
  37728. * 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
  37729. */
  37730. export class SixDofDragBehavior implements Behavior<Mesh> {
  37731. private static _virtualScene;
  37732. private _ownerNode;
  37733. private _sceneRenderObserver;
  37734. private _scene;
  37735. private _targetPosition;
  37736. private _virtualOriginMesh;
  37737. private _virtualDragMesh;
  37738. private _pointerObserver;
  37739. private _moving;
  37740. private _startingOrientation;
  37741. /**
  37742. * 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)
  37743. */
  37744. private zDragFactor;
  37745. /**
  37746. * If the object should rotate to face the drag origin
  37747. */
  37748. rotateDraggedObject: boolean;
  37749. /**
  37750. * If the behavior is currently in a dragging state
  37751. */
  37752. dragging: boolean;
  37753. /**
  37754. * 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)
  37755. */
  37756. dragDeltaRatio: number;
  37757. /**
  37758. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37759. */
  37760. currentDraggingPointerID: number;
  37761. /**
  37762. * If camera controls should be detached during the drag
  37763. */
  37764. detachCameraControls: boolean;
  37765. /**
  37766. * Fires each time a drag starts
  37767. */
  37768. onDragStartObservable: Observable<{}>;
  37769. /**
  37770. * Fires each time a drag ends (eg. mouse release after drag)
  37771. */
  37772. onDragEndObservable: Observable<{}>;
  37773. /**
  37774. * 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
  37775. */
  37776. constructor();
  37777. /**
  37778. * The name of the behavior
  37779. */
  37780. readonly name: string;
  37781. /**
  37782. * Initializes the behavior
  37783. */
  37784. init(): void;
  37785. /**
  37786. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37787. */
  37788. private readonly _pointerCamera;
  37789. /**
  37790. * Attaches the scale behavior the passed in mesh
  37791. * @param ownerNode The mesh that will be scaled around once attached
  37792. */
  37793. attach(ownerNode: Mesh): void;
  37794. /**
  37795. * Detaches the behavior from the mesh
  37796. */
  37797. detach(): void;
  37798. }
  37799. }
  37800. declare module "babylonjs/Behaviors/Meshes/index" {
  37801. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37802. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37803. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37804. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37805. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37806. }
  37807. declare module "babylonjs/Behaviors/index" {
  37808. export * from "babylonjs/Behaviors/behavior";
  37809. export * from "babylonjs/Behaviors/Cameras/index";
  37810. export * from "babylonjs/Behaviors/Meshes/index";
  37811. }
  37812. declare module "babylonjs/Bones/boneIKController" {
  37813. import { Bone } from "babylonjs/Bones/bone";
  37814. import { Vector3 } from "babylonjs/Maths/math.vector";
  37815. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37816. import { Nullable } from "babylonjs/types";
  37817. /**
  37818. * Class used to apply inverse kinematics to bones
  37819. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37820. */
  37821. export class BoneIKController {
  37822. private static _tmpVecs;
  37823. private static _tmpQuat;
  37824. private static _tmpMats;
  37825. /**
  37826. * Gets or sets the target mesh
  37827. */
  37828. targetMesh: AbstractMesh;
  37829. /** Gets or sets the mesh used as pole */
  37830. poleTargetMesh: AbstractMesh;
  37831. /**
  37832. * Gets or sets the bone used as pole
  37833. */
  37834. poleTargetBone: Nullable<Bone>;
  37835. /**
  37836. * Gets or sets the target position
  37837. */
  37838. targetPosition: Vector3;
  37839. /**
  37840. * Gets or sets the pole target position
  37841. */
  37842. poleTargetPosition: Vector3;
  37843. /**
  37844. * Gets or sets the pole target local offset
  37845. */
  37846. poleTargetLocalOffset: Vector3;
  37847. /**
  37848. * Gets or sets the pole angle
  37849. */
  37850. poleAngle: number;
  37851. /**
  37852. * Gets or sets the mesh associated with the controller
  37853. */
  37854. mesh: AbstractMesh;
  37855. /**
  37856. * 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)
  37857. */
  37858. slerpAmount: number;
  37859. private _bone1Quat;
  37860. private _bone1Mat;
  37861. private _bone2Ang;
  37862. private _bone1;
  37863. private _bone2;
  37864. private _bone1Length;
  37865. private _bone2Length;
  37866. private _maxAngle;
  37867. private _maxReach;
  37868. private _rightHandedSystem;
  37869. private _bendAxis;
  37870. private _slerping;
  37871. private _adjustRoll;
  37872. /**
  37873. * Gets or sets maximum allowed angle
  37874. */
  37875. maxAngle: number;
  37876. /**
  37877. * Creates a new BoneIKController
  37878. * @param mesh defines the mesh to control
  37879. * @param bone defines the bone to control
  37880. * @param options defines options to set up the controller
  37881. */
  37882. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37883. targetMesh?: AbstractMesh;
  37884. poleTargetMesh?: AbstractMesh;
  37885. poleTargetBone?: Bone;
  37886. poleTargetLocalOffset?: Vector3;
  37887. poleAngle?: number;
  37888. bendAxis?: Vector3;
  37889. maxAngle?: number;
  37890. slerpAmount?: number;
  37891. });
  37892. private _setMaxAngle;
  37893. /**
  37894. * Force the controller to update the bones
  37895. */
  37896. update(): void;
  37897. }
  37898. }
  37899. declare module "babylonjs/Bones/boneLookController" {
  37900. import { Vector3 } from "babylonjs/Maths/math.vector";
  37901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37902. import { Bone } from "babylonjs/Bones/bone";
  37903. import { Space } from "babylonjs/Maths/math.axis";
  37904. /**
  37905. * Class used to make a bone look toward a point in space
  37906. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37907. */
  37908. export class BoneLookController {
  37909. private static _tmpVecs;
  37910. private static _tmpQuat;
  37911. private static _tmpMats;
  37912. /**
  37913. * The target Vector3 that the bone will look at
  37914. */
  37915. target: Vector3;
  37916. /**
  37917. * The mesh that the bone is attached to
  37918. */
  37919. mesh: AbstractMesh;
  37920. /**
  37921. * The bone that will be looking to the target
  37922. */
  37923. bone: Bone;
  37924. /**
  37925. * The up axis of the coordinate system that is used when the bone is rotated
  37926. */
  37927. upAxis: Vector3;
  37928. /**
  37929. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37930. */
  37931. upAxisSpace: Space;
  37932. /**
  37933. * Used to make an adjustment to the yaw of the bone
  37934. */
  37935. adjustYaw: number;
  37936. /**
  37937. * Used to make an adjustment to the pitch of the bone
  37938. */
  37939. adjustPitch: number;
  37940. /**
  37941. * Used to make an adjustment to the roll of the bone
  37942. */
  37943. adjustRoll: number;
  37944. /**
  37945. * 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)
  37946. */
  37947. slerpAmount: number;
  37948. private _minYaw;
  37949. private _maxYaw;
  37950. private _minPitch;
  37951. private _maxPitch;
  37952. private _minYawSin;
  37953. private _minYawCos;
  37954. private _maxYawSin;
  37955. private _maxYawCos;
  37956. private _midYawConstraint;
  37957. private _minPitchTan;
  37958. private _maxPitchTan;
  37959. private _boneQuat;
  37960. private _slerping;
  37961. private _transformYawPitch;
  37962. private _transformYawPitchInv;
  37963. private _firstFrameSkipped;
  37964. private _yawRange;
  37965. private _fowardAxis;
  37966. /**
  37967. * Gets or sets the minimum yaw angle that the bone can look to
  37968. */
  37969. minYaw: number;
  37970. /**
  37971. * Gets or sets the maximum yaw angle that the bone can look to
  37972. */
  37973. maxYaw: number;
  37974. /**
  37975. * Gets or sets the minimum pitch angle that the bone can look to
  37976. */
  37977. minPitch: number;
  37978. /**
  37979. * Gets or sets the maximum pitch angle that the bone can look to
  37980. */
  37981. maxPitch: number;
  37982. /**
  37983. * Create a BoneLookController
  37984. * @param mesh the mesh that the bone belongs to
  37985. * @param bone the bone that will be looking to the target
  37986. * @param target the target Vector3 to look at
  37987. * @param options optional settings:
  37988. * * maxYaw: the maximum angle the bone will yaw to
  37989. * * minYaw: the minimum angle the bone will yaw to
  37990. * * maxPitch: the maximum angle the bone will pitch to
  37991. * * minPitch: the minimum angle the bone will yaw to
  37992. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37993. * * upAxis: the up axis of the coordinate system
  37994. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37995. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37996. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37997. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37998. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37999. * * adjustRoll: used to make an adjustment to the roll of the bone
  38000. **/
  38001. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38002. maxYaw?: number;
  38003. minYaw?: number;
  38004. maxPitch?: number;
  38005. minPitch?: number;
  38006. slerpAmount?: number;
  38007. upAxis?: Vector3;
  38008. upAxisSpace?: Space;
  38009. yawAxis?: Vector3;
  38010. pitchAxis?: Vector3;
  38011. adjustYaw?: number;
  38012. adjustPitch?: number;
  38013. adjustRoll?: number;
  38014. });
  38015. /**
  38016. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38017. */
  38018. update(): void;
  38019. private _getAngleDiff;
  38020. private _getAngleBetween;
  38021. private _isAngleBetween;
  38022. }
  38023. }
  38024. declare module "babylonjs/Bones/index" {
  38025. export * from "babylonjs/Bones/bone";
  38026. export * from "babylonjs/Bones/boneIKController";
  38027. export * from "babylonjs/Bones/boneLookController";
  38028. export * from "babylonjs/Bones/skeleton";
  38029. }
  38030. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38031. import { Nullable } from "babylonjs/types";
  38032. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38033. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38034. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38035. /**
  38036. * Manage the gamepad inputs to control an arc rotate camera.
  38037. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38038. */
  38039. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38040. /**
  38041. * Defines the camera the input is attached to.
  38042. */
  38043. camera: ArcRotateCamera;
  38044. /**
  38045. * Defines the gamepad the input is gathering event from.
  38046. */
  38047. gamepad: Nullable<Gamepad>;
  38048. /**
  38049. * Defines the gamepad rotation sensiblity.
  38050. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38051. */
  38052. gamepadRotationSensibility: number;
  38053. /**
  38054. * Defines the gamepad move sensiblity.
  38055. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38056. */
  38057. gamepadMoveSensibility: number;
  38058. private _onGamepadConnectedObserver;
  38059. private _onGamepadDisconnectedObserver;
  38060. /**
  38061. * Attach the input controls to a specific dom element to get the input from.
  38062. * @param element Defines the element the controls should be listened from
  38063. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38064. */
  38065. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38066. /**
  38067. * Detach the current controls from the specified dom element.
  38068. * @param element Defines the element to stop listening the inputs from
  38069. */
  38070. detachControl(element: Nullable<HTMLElement>): void;
  38071. /**
  38072. * Update the current camera state depending on the inputs that have been used this frame.
  38073. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38074. */
  38075. checkInputs(): void;
  38076. /**
  38077. * Gets the class name of the current intput.
  38078. * @returns the class name
  38079. */
  38080. getClassName(): string;
  38081. /**
  38082. * Get the friendly name associated with the input class.
  38083. * @returns the input friendly name
  38084. */
  38085. getSimpleName(): string;
  38086. }
  38087. }
  38088. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38089. import { Nullable } from "babylonjs/types";
  38090. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38091. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38092. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38093. interface ArcRotateCameraInputsManager {
  38094. /**
  38095. * Add orientation input support to the input manager.
  38096. * @returns the current input manager
  38097. */
  38098. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38099. }
  38100. }
  38101. /**
  38102. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38103. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38104. */
  38105. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38106. /**
  38107. * Defines the camera the input is attached to.
  38108. */
  38109. camera: ArcRotateCamera;
  38110. /**
  38111. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38112. */
  38113. alphaCorrection: number;
  38114. /**
  38115. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38116. */
  38117. gammaCorrection: number;
  38118. private _alpha;
  38119. private _gamma;
  38120. private _dirty;
  38121. private _deviceOrientationHandler;
  38122. /**
  38123. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38124. */
  38125. constructor();
  38126. /**
  38127. * Attach the input controls to a specific dom element to get the input from.
  38128. * @param element Defines the element the controls should be listened from
  38129. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38130. */
  38131. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38132. /** @hidden */
  38133. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38134. /**
  38135. * Update the current camera state depending on the inputs that have been used this frame.
  38136. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38137. */
  38138. checkInputs(): void;
  38139. /**
  38140. * Detach the current controls from the specified dom element.
  38141. * @param element Defines the element to stop listening the inputs from
  38142. */
  38143. detachControl(element: Nullable<HTMLElement>): void;
  38144. /**
  38145. * Gets the class name of the current intput.
  38146. * @returns the class name
  38147. */
  38148. getClassName(): string;
  38149. /**
  38150. * Get the friendly name associated with the input class.
  38151. * @returns the input friendly name
  38152. */
  38153. getSimpleName(): string;
  38154. }
  38155. }
  38156. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38157. import { Nullable } from "babylonjs/types";
  38158. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38159. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38160. /**
  38161. * Listen to mouse events to control the camera.
  38162. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38163. */
  38164. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38165. /**
  38166. * Defines the camera the input is attached to.
  38167. */
  38168. camera: FlyCamera;
  38169. /**
  38170. * Defines if touch is enabled. (Default is true.)
  38171. */
  38172. touchEnabled: boolean;
  38173. /**
  38174. * Defines the buttons associated with the input to handle camera rotation.
  38175. */
  38176. buttons: number[];
  38177. /**
  38178. * Assign buttons for Yaw control.
  38179. */
  38180. buttonsYaw: number[];
  38181. /**
  38182. * Assign buttons for Pitch control.
  38183. */
  38184. buttonsPitch: number[];
  38185. /**
  38186. * Assign buttons for Roll control.
  38187. */
  38188. buttonsRoll: number[];
  38189. /**
  38190. * Detect if any button is being pressed while mouse is moved.
  38191. * -1 = Mouse locked.
  38192. * 0 = Left button.
  38193. * 1 = Middle Button.
  38194. * 2 = Right Button.
  38195. */
  38196. activeButton: number;
  38197. /**
  38198. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38199. * Higher values reduce its sensitivity.
  38200. */
  38201. angularSensibility: number;
  38202. private _mousemoveCallback;
  38203. private _observer;
  38204. private _rollObserver;
  38205. private previousPosition;
  38206. private noPreventDefault;
  38207. private element;
  38208. /**
  38209. * Listen to mouse events to control the camera.
  38210. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38211. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38212. */
  38213. constructor(touchEnabled?: boolean);
  38214. /**
  38215. * Attach the mouse control to the HTML DOM element.
  38216. * @param element Defines the element that listens to the input events.
  38217. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38218. */
  38219. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38220. /**
  38221. * Detach the current controls from the specified dom element.
  38222. * @param element Defines the element to stop listening the inputs from
  38223. */
  38224. detachControl(element: Nullable<HTMLElement>): void;
  38225. /**
  38226. * Gets the class name of the current input.
  38227. * @returns the class name.
  38228. */
  38229. getClassName(): string;
  38230. /**
  38231. * Get the friendly name associated with the input class.
  38232. * @returns the input's friendly name.
  38233. */
  38234. getSimpleName(): string;
  38235. private _pointerInput;
  38236. private _onMouseMove;
  38237. /**
  38238. * Rotate camera by mouse offset.
  38239. */
  38240. private rotateCamera;
  38241. }
  38242. }
  38243. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38244. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38245. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38246. /**
  38247. * Default Inputs manager for the FlyCamera.
  38248. * It groups all the default supported inputs for ease of use.
  38249. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38250. */
  38251. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38252. /**
  38253. * Instantiates a new FlyCameraInputsManager.
  38254. * @param camera Defines the camera the inputs belong to.
  38255. */
  38256. constructor(camera: FlyCamera);
  38257. /**
  38258. * Add keyboard input support to the input manager.
  38259. * @returns the new FlyCameraKeyboardMoveInput().
  38260. */
  38261. addKeyboard(): FlyCameraInputsManager;
  38262. /**
  38263. * Add mouse input support to the input manager.
  38264. * @param touchEnabled Enable touch screen support.
  38265. * @returns the new FlyCameraMouseInput().
  38266. */
  38267. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38268. }
  38269. }
  38270. declare module "babylonjs/Cameras/flyCamera" {
  38271. import { Scene } from "babylonjs/scene";
  38272. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38273. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38274. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38275. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38276. /**
  38277. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38278. * such as in a 3D Space Shooter or a Flight Simulator.
  38279. */
  38280. export class FlyCamera extends TargetCamera {
  38281. /**
  38282. * Define the collision ellipsoid of the camera.
  38283. * This is helpful for simulating a camera body, like a player's body.
  38284. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38285. */
  38286. ellipsoid: Vector3;
  38287. /**
  38288. * Define an offset for the position of the ellipsoid around the camera.
  38289. * This can be helpful if the camera is attached away from the player's body center,
  38290. * such as at its head.
  38291. */
  38292. ellipsoidOffset: Vector3;
  38293. /**
  38294. * Enable or disable collisions of the camera with the rest of the scene objects.
  38295. */
  38296. checkCollisions: boolean;
  38297. /**
  38298. * Enable or disable gravity on the camera.
  38299. */
  38300. applyGravity: boolean;
  38301. /**
  38302. * Define the current direction the camera is moving to.
  38303. */
  38304. cameraDirection: Vector3;
  38305. /**
  38306. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38307. * This overrides and empties cameraRotation.
  38308. */
  38309. rotationQuaternion: Quaternion;
  38310. /**
  38311. * Track Roll to maintain the wanted Rolling when looking around.
  38312. */
  38313. _trackRoll: number;
  38314. /**
  38315. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38316. */
  38317. rollCorrect: number;
  38318. /**
  38319. * Mimic a banked turn, Rolling the camera when Yawing.
  38320. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38321. */
  38322. bankedTurn: boolean;
  38323. /**
  38324. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38325. */
  38326. bankedTurnLimit: number;
  38327. /**
  38328. * Value of 0 disables the banked Roll.
  38329. * Value of 1 is equal to the Yaw angle in radians.
  38330. */
  38331. bankedTurnMultiplier: number;
  38332. /**
  38333. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38334. */
  38335. inputs: FlyCameraInputsManager;
  38336. /**
  38337. * Gets the input sensibility for mouse input.
  38338. * Higher values reduce sensitivity.
  38339. */
  38340. /**
  38341. * Sets the input sensibility for a mouse input.
  38342. * Higher values reduce sensitivity.
  38343. */
  38344. angularSensibility: number;
  38345. /**
  38346. * Get the keys for camera movement forward.
  38347. */
  38348. /**
  38349. * Set the keys for camera movement forward.
  38350. */
  38351. keysForward: number[];
  38352. /**
  38353. * Get the keys for camera movement backward.
  38354. */
  38355. keysBackward: number[];
  38356. /**
  38357. * Get the keys for camera movement up.
  38358. */
  38359. /**
  38360. * Set the keys for camera movement up.
  38361. */
  38362. keysUp: number[];
  38363. /**
  38364. * Get the keys for camera movement down.
  38365. */
  38366. /**
  38367. * Set the keys for camera movement down.
  38368. */
  38369. keysDown: number[];
  38370. /**
  38371. * Get the keys for camera movement left.
  38372. */
  38373. /**
  38374. * Set the keys for camera movement left.
  38375. */
  38376. keysLeft: number[];
  38377. /**
  38378. * Set the keys for camera movement right.
  38379. */
  38380. /**
  38381. * Set the keys for camera movement right.
  38382. */
  38383. keysRight: number[];
  38384. /**
  38385. * Event raised when the camera collides with a mesh in the scene.
  38386. */
  38387. onCollide: (collidedMesh: AbstractMesh) => void;
  38388. private _collider;
  38389. private _needMoveForGravity;
  38390. private _oldPosition;
  38391. private _diffPosition;
  38392. private _newPosition;
  38393. /** @hidden */
  38394. _localDirection: Vector3;
  38395. /** @hidden */
  38396. _transformedDirection: Vector3;
  38397. /**
  38398. * Instantiates a FlyCamera.
  38399. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38400. * such as in a 3D Space Shooter or a Flight Simulator.
  38401. * @param name Define the name of the camera in the scene.
  38402. * @param position Define the starting position of the camera in the scene.
  38403. * @param scene Define the scene the camera belongs to.
  38404. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38405. */
  38406. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38407. /**
  38408. * Attach a control to the HTML DOM element.
  38409. * @param element Defines the element that listens to the input events.
  38410. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38411. */
  38412. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38413. /**
  38414. * Detach a control from the HTML DOM element.
  38415. * The camera will stop reacting to that input.
  38416. * @param element Defines the element that listens to the input events.
  38417. */
  38418. detachControl(element: HTMLElement): void;
  38419. private _collisionMask;
  38420. /**
  38421. * Get the mask that the camera ignores in collision events.
  38422. */
  38423. /**
  38424. * Set the mask that the camera ignores in collision events.
  38425. */
  38426. collisionMask: number;
  38427. /** @hidden */
  38428. _collideWithWorld(displacement: Vector3): void;
  38429. /** @hidden */
  38430. private _onCollisionPositionChange;
  38431. /** @hidden */
  38432. _checkInputs(): void;
  38433. /** @hidden */
  38434. _decideIfNeedsToMove(): boolean;
  38435. /** @hidden */
  38436. _updatePosition(): void;
  38437. /**
  38438. * Restore the Roll to its target value at the rate specified.
  38439. * @param rate - Higher means slower restoring.
  38440. * @hidden
  38441. */
  38442. restoreRoll(rate: number): void;
  38443. /**
  38444. * Destroy the camera and release the current resources held by it.
  38445. */
  38446. dispose(): void;
  38447. /**
  38448. * Get the current object class name.
  38449. * @returns the class name.
  38450. */
  38451. getClassName(): string;
  38452. }
  38453. }
  38454. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38455. import { Nullable } from "babylonjs/types";
  38456. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38457. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38458. /**
  38459. * Listen to keyboard events to control the camera.
  38460. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38461. */
  38462. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38463. /**
  38464. * Defines the camera the input is attached to.
  38465. */
  38466. camera: FlyCamera;
  38467. /**
  38468. * The list of keyboard keys used to control the forward move of the camera.
  38469. */
  38470. keysForward: number[];
  38471. /**
  38472. * The list of keyboard keys used to control the backward move of the camera.
  38473. */
  38474. keysBackward: number[];
  38475. /**
  38476. * The list of keyboard keys used to control the forward move of the camera.
  38477. */
  38478. keysUp: number[];
  38479. /**
  38480. * The list of keyboard keys used to control the backward move of the camera.
  38481. */
  38482. keysDown: number[];
  38483. /**
  38484. * The list of keyboard keys used to control the right strafe move of the camera.
  38485. */
  38486. keysRight: number[];
  38487. /**
  38488. * The list of keyboard keys used to control the left strafe move of the camera.
  38489. */
  38490. keysLeft: number[];
  38491. private _keys;
  38492. private _onCanvasBlurObserver;
  38493. private _onKeyboardObserver;
  38494. private _engine;
  38495. private _scene;
  38496. /**
  38497. * Attach the input controls to a specific dom element to get the input from.
  38498. * @param element Defines the element the controls should be listened from
  38499. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38500. */
  38501. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38502. /**
  38503. * Detach the current controls from the specified dom element.
  38504. * @param element Defines the element to stop listening the inputs from
  38505. */
  38506. detachControl(element: Nullable<HTMLElement>): void;
  38507. /**
  38508. * Gets the class name of the current intput.
  38509. * @returns the class name
  38510. */
  38511. getClassName(): string;
  38512. /** @hidden */
  38513. _onLostFocus(e: FocusEvent): void;
  38514. /**
  38515. * Get the friendly name associated with the input class.
  38516. * @returns the input friendly name
  38517. */
  38518. getSimpleName(): string;
  38519. /**
  38520. * Update the current camera state depending on the inputs that have been used this frame.
  38521. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38522. */
  38523. checkInputs(): void;
  38524. }
  38525. }
  38526. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38527. import { Nullable } from "babylonjs/types";
  38528. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38529. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38530. /**
  38531. * Manage the mouse wheel inputs to control a follow camera.
  38532. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38533. */
  38534. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38535. /**
  38536. * Defines the camera the input is attached to.
  38537. */
  38538. camera: FollowCamera;
  38539. /**
  38540. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38541. */
  38542. axisControlRadius: boolean;
  38543. /**
  38544. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38545. */
  38546. axisControlHeight: boolean;
  38547. /**
  38548. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38549. */
  38550. axisControlRotation: boolean;
  38551. /**
  38552. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38553. * relation to mouseWheel events.
  38554. */
  38555. wheelPrecision: number;
  38556. /**
  38557. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38558. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38559. */
  38560. wheelDeltaPercentage: number;
  38561. private _wheel;
  38562. private _observer;
  38563. /**
  38564. * Attach the input controls to a specific dom element to get the input from.
  38565. * @param element Defines the element the controls should be listened from
  38566. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38567. */
  38568. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38569. /**
  38570. * Detach the current controls from the specified dom element.
  38571. * @param element Defines the element to stop listening the inputs from
  38572. */
  38573. detachControl(element: Nullable<HTMLElement>): void;
  38574. /**
  38575. * Gets the class name of the current intput.
  38576. * @returns the class name
  38577. */
  38578. getClassName(): string;
  38579. /**
  38580. * Get the friendly name associated with the input class.
  38581. * @returns the input friendly name
  38582. */
  38583. getSimpleName(): string;
  38584. }
  38585. }
  38586. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38587. import { Nullable } from "babylonjs/types";
  38588. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38589. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38590. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38591. /**
  38592. * Manage the pointers inputs to control an follow camera.
  38593. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38594. */
  38595. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38596. /**
  38597. * Defines the camera the input is attached to.
  38598. */
  38599. camera: FollowCamera;
  38600. /**
  38601. * Gets the class name of the current input.
  38602. * @returns the class name
  38603. */
  38604. getClassName(): string;
  38605. /**
  38606. * Defines the pointer angular sensibility along the X axis or how fast is
  38607. * the camera rotating.
  38608. * A negative number will reverse the axis direction.
  38609. */
  38610. angularSensibilityX: number;
  38611. /**
  38612. * Defines the pointer angular sensibility along the Y axis or how fast is
  38613. * the camera rotating.
  38614. * A negative number will reverse the axis direction.
  38615. */
  38616. angularSensibilityY: number;
  38617. /**
  38618. * Defines the pointer pinch precision or how fast is the camera zooming.
  38619. * A negative number will reverse the axis direction.
  38620. */
  38621. pinchPrecision: number;
  38622. /**
  38623. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38624. * from 0.
  38625. * It defines the percentage of current camera.radius to use as delta when
  38626. * pinch zoom is used.
  38627. */
  38628. pinchDeltaPercentage: number;
  38629. /**
  38630. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38631. */
  38632. axisXControlRadius: boolean;
  38633. /**
  38634. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38635. */
  38636. axisXControlHeight: boolean;
  38637. /**
  38638. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38639. */
  38640. axisXControlRotation: boolean;
  38641. /**
  38642. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38643. */
  38644. axisYControlRadius: boolean;
  38645. /**
  38646. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38647. */
  38648. axisYControlHeight: boolean;
  38649. /**
  38650. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38651. */
  38652. axisYControlRotation: boolean;
  38653. /**
  38654. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38655. */
  38656. axisPinchControlRadius: boolean;
  38657. /**
  38658. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38659. */
  38660. axisPinchControlHeight: boolean;
  38661. /**
  38662. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38663. */
  38664. axisPinchControlRotation: boolean;
  38665. /**
  38666. * Log error messages if basic misconfiguration has occurred.
  38667. */
  38668. warningEnable: boolean;
  38669. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38670. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38671. private _warningCounter;
  38672. private _warning;
  38673. }
  38674. }
  38675. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38676. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38677. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38678. /**
  38679. * Default Inputs manager for the FollowCamera.
  38680. * It groups all the default supported inputs for ease of use.
  38681. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38682. */
  38683. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38684. /**
  38685. * Instantiates a new FollowCameraInputsManager.
  38686. * @param camera Defines the camera the inputs belong to
  38687. */
  38688. constructor(camera: FollowCamera);
  38689. /**
  38690. * Add keyboard input support to the input manager.
  38691. * @returns the current input manager
  38692. */
  38693. addKeyboard(): FollowCameraInputsManager;
  38694. /**
  38695. * Add mouse wheel input support to the input manager.
  38696. * @returns the current input manager
  38697. */
  38698. addMouseWheel(): FollowCameraInputsManager;
  38699. /**
  38700. * Add pointers input support to the input manager.
  38701. * @returns the current input manager
  38702. */
  38703. addPointers(): FollowCameraInputsManager;
  38704. /**
  38705. * Add orientation input support to the input manager.
  38706. * @returns the current input manager
  38707. */
  38708. addVRDeviceOrientation(): FollowCameraInputsManager;
  38709. }
  38710. }
  38711. declare module "babylonjs/Cameras/followCamera" {
  38712. import { Nullable } from "babylonjs/types";
  38713. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38714. import { Scene } from "babylonjs/scene";
  38715. import { Vector3 } from "babylonjs/Maths/math.vector";
  38716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38717. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38718. /**
  38719. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38720. * an arc rotate version arcFollowCamera are available.
  38721. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38722. */
  38723. export class FollowCamera extends TargetCamera {
  38724. /**
  38725. * Distance the follow camera should follow an object at
  38726. */
  38727. radius: number;
  38728. /**
  38729. * Minimum allowed distance of the camera to the axis of rotation
  38730. * (The camera can not get closer).
  38731. * This can help limiting how the Camera is able to move in the scene.
  38732. */
  38733. lowerRadiusLimit: Nullable<number>;
  38734. /**
  38735. * Maximum allowed distance of the camera to the axis of rotation
  38736. * (The camera can not get further).
  38737. * This can help limiting how the Camera is able to move in the scene.
  38738. */
  38739. upperRadiusLimit: Nullable<number>;
  38740. /**
  38741. * Define a rotation offset between the camera and the object it follows
  38742. */
  38743. rotationOffset: number;
  38744. /**
  38745. * Minimum allowed angle to camera position relative to target object.
  38746. * This can help limiting how the Camera is able to move in the scene.
  38747. */
  38748. lowerRotationOffsetLimit: Nullable<number>;
  38749. /**
  38750. * Maximum allowed angle to camera position relative to target object.
  38751. * This can help limiting how the Camera is able to move in the scene.
  38752. */
  38753. upperRotationOffsetLimit: Nullable<number>;
  38754. /**
  38755. * Define a height offset between the camera and the object it follows.
  38756. * It can help following an object from the top (like a car chaing a plane)
  38757. */
  38758. heightOffset: number;
  38759. /**
  38760. * Minimum allowed height of camera position relative to target object.
  38761. * This can help limiting how the Camera is able to move in the scene.
  38762. */
  38763. lowerHeightOffsetLimit: Nullable<number>;
  38764. /**
  38765. * Maximum allowed height of camera position relative to target object.
  38766. * This can help limiting how the Camera is able to move in the scene.
  38767. */
  38768. upperHeightOffsetLimit: Nullable<number>;
  38769. /**
  38770. * Define how fast the camera can accelerate to follow it s target.
  38771. */
  38772. cameraAcceleration: number;
  38773. /**
  38774. * Define the speed limit of the camera following an object.
  38775. */
  38776. maxCameraSpeed: number;
  38777. /**
  38778. * Define the target of the camera.
  38779. */
  38780. lockedTarget: Nullable<AbstractMesh>;
  38781. /**
  38782. * Defines the input associated with the camera.
  38783. */
  38784. inputs: FollowCameraInputsManager;
  38785. /**
  38786. * Instantiates the follow camera.
  38787. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38788. * @param name Define the name of the camera in the scene
  38789. * @param position Define the position of the camera
  38790. * @param scene Define the scene the camera belong to
  38791. * @param lockedTarget Define the target of the camera
  38792. */
  38793. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38794. private _follow;
  38795. /**
  38796. * Attached controls to the current camera.
  38797. * @param element Defines the element the controls should be listened from
  38798. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38799. */
  38800. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38801. /**
  38802. * Detach the current controls from the camera.
  38803. * The camera will stop reacting to inputs.
  38804. * @param element Defines the element to stop listening the inputs from
  38805. */
  38806. detachControl(element: HTMLElement): void;
  38807. /** @hidden */
  38808. _checkInputs(): void;
  38809. private _checkLimits;
  38810. /**
  38811. * Gets the camera class name.
  38812. * @returns the class name
  38813. */
  38814. getClassName(): string;
  38815. }
  38816. /**
  38817. * Arc Rotate version of the follow camera.
  38818. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38819. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38820. */
  38821. export class ArcFollowCamera extends TargetCamera {
  38822. /** The longitudinal angle of the camera */
  38823. alpha: number;
  38824. /** The latitudinal angle of the camera */
  38825. beta: number;
  38826. /** The radius of the camera from its target */
  38827. radius: number;
  38828. /** Define the camera target (the messh it should follow) */
  38829. target: Nullable<AbstractMesh>;
  38830. private _cartesianCoordinates;
  38831. /**
  38832. * Instantiates a new ArcFollowCamera
  38833. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38834. * @param name Define the name of the camera
  38835. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38836. * @param beta Define the rotation angle of the camera around the elevation axis
  38837. * @param radius Define the radius of the camera from its target point
  38838. * @param target Define the target of the camera
  38839. * @param scene Define the scene the camera belongs to
  38840. */
  38841. constructor(name: string,
  38842. /** The longitudinal angle of the camera */
  38843. alpha: number,
  38844. /** The latitudinal angle of the camera */
  38845. beta: number,
  38846. /** The radius of the camera from its target */
  38847. radius: number,
  38848. /** Define the camera target (the messh it should follow) */
  38849. target: Nullable<AbstractMesh>, scene: Scene);
  38850. private _follow;
  38851. /** @hidden */
  38852. _checkInputs(): void;
  38853. /**
  38854. * Returns the class name of the object.
  38855. * It is mostly used internally for serialization purposes.
  38856. */
  38857. getClassName(): string;
  38858. }
  38859. }
  38860. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38861. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38862. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38863. import { Nullable } from "babylonjs/types";
  38864. /**
  38865. * Manage the keyboard inputs to control the movement of a follow camera.
  38866. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38867. */
  38868. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38869. /**
  38870. * Defines the camera the input is attached to.
  38871. */
  38872. camera: FollowCamera;
  38873. /**
  38874. * Defines the list of key codes associated with the up action (increase heightOffset)
  38875. */
  38876. keysHeightOffsetIncr: number[];
  38877. /**
  38878. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38879. */
  38880. keysHeightOffsetDecr: number[];
  38881. /**
  38882. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38883. */
  38884. keysHeightOffsetModifierAlt: boolean;
  38885. /**
  38886. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38887. */
  38888. keysHeightOffsetModifierCtrl: boolean;
  38889. /**
  38890. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38891. */
  38892. keysHeightOffsetModifierShift: boolean;
  38893. /**
  38894. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38895. */
  38896. keysRotationOffsetIncr: number[];
  38897. /**
  38898. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38899. */
  38900. keysRotationOffsetDecr: number[];
  38901. /**
  38902. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38903. */
  38904. keysRotationOffsetModifierAlt: boolean;
  38905. /**
  38906. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38907. */
  38908. keysRotationOffsetModifierCtrl: boolean;
  38909. /**
  38910. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38911. */
  38912. keysRotationOffsetModifierShift: boolean;
  38913. /**
  38914. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38915. */
  38916. keysRadiusIncr: number[];
  38917. /**
  38918. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38919. */
  38920. keysRadiusDecr: number[];
  38921. /**
  38922. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38923. */
  38924. keysRadiusModifierAlt: boolean;
  38925. /**
  38926. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38927. */
  38928. keysRadiusModifierCtrl: boolean;
  38929. /**
  38930. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38931. */
  38932. keysRadiusModifierShift: boolean;
  38933. /**
  38934. * Defines the rate of change of heightOffset.
  38935. */
  38936. heightSensibility: number;
  38937. /**
  38938. * Defines the rate of change of rotationOffset.
  38939. */
  38940. rotationSensibility: number;
  38941. /**
  38942. * Defines the rate of change of radius.
  38943. */
  38944. radiusSensibility: number;
  38945. private _keys;
  38946. private _ctrlPressed;
  38947. private _altPressed;
  38948. private _shiftPressed;
  38949. private _onCanvasBlurObserver;
  38950. private _onKeyboardObserver;
  38951. private _engine;
  38952. private _scene;
  38953. /**
  38954. * Attach the input controls to a specific dom element to get the input from.
  38955. * @param element Defines the element the controls should be listened from
  38956. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38957. */
  38958. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38959. /**
  38960. * Detach the current controls from the specified dom element.
  38961. * @param element Defines the element to stop listening the inputs from
  38962. */
  38963. detachControl(element: Nullable<HTMLElement>): void;
  38964. /**
  38965. * Update the current camera state depending on the inputs that have been used this frame.
  38966. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38967. */
  38968. checkInputs(): void;
  38969. /**
  38970. * Gets the class name of the current input.
  38971. * @returns the class name
  38972. */
  38973. getClassName(): string;
  38974. /**
  38975. * Get the friendly name associated with the input class.
  38976. * @returns the input friendly name
  38977. */
  38978. getSimpleName(): string;
  38979. /**
  38980. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38981. * allow modification of the heightOffset value.
  38982. */
  38983. private _modifierHeightOffset;
  38984. /**
  38985. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38986. * allow modification of the rotationOffset value.
  38987. */
  38988. private _modifierRotationOffset;
  38989. /**
  38990. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38991. * allow modification of the radius value.
  38992. */
  38993. private _modifierRadius;
  38994. }
  38995. }
  38996. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38997. import { Nullable } from "babylonjs/types";
  38998. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38999. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39000. import { Observable } from "babylonjs/Misc/observable";
  39001. module "babylonjs/Cameras/freeCameraInputsManager" {
  39002. interface FreeCameraInputsManager {
  39003. /**
  39004. * @hidden
  39005. */
  39006. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39007. /**
  39008. * Add orientation input support to the input manager.
  39009. * @returns the current input manager
  39010. */
  39011. addDeviceOrientation(): FreeCameraInputsManager;
  39012. }
  39013. }
  39014. /**
  39015. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39016. * Screen rotation is taken into account.
  39017. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39018. */
  39019. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39020. private _camera;
  39021. private _screenOrientationAngle;
  39022. private _constantTranform;
  39023. private _screenQuaternion;
  39024. private _alpha;
  39025. private _beta;
  39026. private _gamma;
  39027. /**
  39028. * Can be used to detect if a device orientation sensor is availible on a device
  39029. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39030. * @returns a promise that will resolve on orientation change
  39031. */
  39032. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39033. /**
  39034. * @hidden
  39035. */
  39036. _onDeviceOrientationChangedObservable: Observable<void>;
  39037. /**
  39038. * Instantiates a new input
  39039. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39040. */
  39041. constructor();
  39042. /**
  39043. * Define the camera controlled by the input.
  39044. */
  39045. camera: FreeCamera;
  39046. /**
  39047. * Attach the input controls to a specific dom element to get the input from.
  39048. * @param element Defines the element the controls should be listened from
  39049. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39050. */
  39051. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39052. private _orientationChanged;
  39053. private _deviceOrientation;
  39054. /**
  39055. * Detach the current controls from the specified dom element.
  39056. * @param element Defines the element to stop listening the inputs from
  39057. */
  39058. detachControl(element: Nullable<HTMLElement>): void;
  39059. /**
  39060. * Update the current camera state depending on the inputs that have been used this frame.
  39061. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39062. */
  39063. checkInputs(): void;
  39064. /**
  39065. * Gets the class name of the current intput.
  39066. * @returns the class name
  39067. */
  39068. getClassName(): string;
  39069. /**
  39070. * Get the friendly name associated with the input class.
  39071. * @returns the input friendly name
  39072. */
  39073. getSimpleName(): string;
  39074. }
  39075. }
  39076. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39077. import { Nullable } from "babylonjs/types";
  39078. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39079. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39080. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39081. /**
  39082. * Manage the gamepad inputs to control a free camera.
  39083. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39084. */
  39085. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39086. /**
  39087. * Define the camera the input is attached to.
  39088. */
  39089. camera: FreeCamera;
  39090. /**
  39091. * Define the Gamepad controlling the input
  39092. */
  39093. gamepad: Nullable<Gamepad>;
  39094. /**
  39095. * Defines the gamepad rotation sensiblity.
  39096. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39097. */
  39098. gamepadAngularSensibility: number;
  39099. /**
  39100. * Defines the gamepad move sensiblity.
  39101. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39102. */
  39103. gamepadMoveSensibility: number;
  39104. private _onGamepadConnectedObserver;
  39105. private _onGamepadDisconnectedObserver;
  39106. private _cameraTransform;
  39107. private _deltaTransform;
  39108. private _vector3;
  39109. private _vector2;
  39110. /**
  39111. * Attach the input controls to a specific dom element to get the input from.
  39112. * @param element Defines the element the controls should be listened from
  39113. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39114. */
  39115. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39116. /**
  39117. * Detach the current controls from the specified dom element.
  39118. * @param element Defines the element to stop listening the inputs from
  39119. */
  39120. detachControl(element: Nullable<HTMLElement>): void;
  39121. /**
  39122. * Update the current camera state depending on the inputs that have been used this frame.
  39123. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39124. */
  39125. checkInputs(): void;
  39126. /**
  39127. * Gets the class name of the current intput.
  39128. * @returns the class name
  39129. */
  39130. getClassName(): string;
  39131. /**
  39132. * Get the friendly name associated with the input class.
  39133. * @returns the input friendly name
  39134. */
  39135. getSimpleName(): string;
  39136. }
  39137. }
  39138. declare module "babylonjs/Misc/virtualJoystick" {
  39139. import { Nullable } from "babylonjs/types";
  39140. import { Vector3 } from "babylonjs/Maths/math.vector";
  39141. /**
  39142. * Defines the potential axis of a Joystick
  39143. */
  39144. export enum JoystickAxis {
  39145. /** X axis */
  39146. X = 0,
  39147. /** Y axis */
  39148. Y = 1,
  39149. /** Z axis */
  39150. Z = 2
  39151. }
  39152. /**
  39153. * Class used to define virtual joystick (used in touch mode)
  39154. */
  39155. export class VirtualJoystick {
  39156. /**
  39157. * Gets or sets a boolean indicating that left and right values must be inverted
  39158. */
  39159. reverseLeftRight: boolean;
  39160. /**
  39161. * Gets or sets a boolean indicating that up and down values must be inverted
  39162. */
  39163. reverseUpDown: boolean;
  39164. /**
  39165. * Gets the offset value for the position (ie. the change of the position value)
  39166. */
  39167. deltaPosition: Vector3;
  39168. /**
  39169. * Gets a boolean indicating if the virtual joystick was pressed
  39170. */
  39171. pressed: boolean;
  39172. /**
  39173. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39174. */
  39175. static Canvas: Nullable<HTMLCanvasElement>;
  39176. private static _globalJoystickIndex;
  39177. private static vjCanvasContext;
  39178. private static vjCanvasWidth;
  39179. private static vjCanvasHeight;
  39180. private static halfWidth;
  39181. private _action;
  39182. private _axisTargetedByLeftAndRight;
  39183. private _axisTargetedByUpAndDown;
  39184. private _joystickSensibility;
  39185. private _inversedSensibility;
  39186. private _joystickPointerID;
  39187. private _joystickColor;
  39188. private _joystickPointerPos;
  39189. private _joystickPreviousPointerPos;
  39190. private _joystickPointerStartPos;
  39191. private _deltaJoystickVector;
  39192. private _leftJoystick;
  39193. private _touches;
  39194. private _onPointerDownHandlerRef;
  39195. private _onPointerMoveHandlerRef;
  39196. private _onPointerUpHandlerRef;
  39197. private _onResize;
  39198. /**
  39199. * Creates a new virtual joystick
  39200. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39201. */
  39202. constructor(leftJoystick?: boolean);
  39203. /**
  39204. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39205. * @param newJoystickSensibility defines the new sensibility
  39206. */
  39207. setJoystickSensibility(newJoystickSensibility: number): void;
  39208. private _onPointerDown;
  39209. private _onPointerMove;
  39210. private _onPointerUp;
  39211. /**
  39212. * Change the color of the virtual joystick
  39213. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39214. */
  39215. setJoystickColor(newColor: string): void;
  39216. /**
  39217. * Defines a callback to call when the joystick is touched
  39218. * @param action defines the callback
  39219. */
  39220. setActionOnTouch(action: () => any): void;
  39221. /**
  39222. * Defines which axis you'd like to control for left & right
  39223. * @param axis defines the axis to use
  39224. */
  39225. setAxisForLeftRight(axis: JoystickAxis): void;
  39226. /**
  39227. * Defines which axis you'd like to control for up & down
  39228. * @param axis defines the axis to use
  39229. */
  39230. setAxisForUpDown(axis: JoystickAxis): void;
  39231. private _drawVirtualJoystick;
  39232. /**
  39233. * Release internal HTML canvas
  39234. */
  39235. releaseCanvas(): void;
  39236. }
  39237. }
  39238. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39239. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39240. import { Nullable } from "babylonjs/types";
  39241. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39242. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39243. module "babylonjs/Cameras/freeCameraInputsManager" {
  39244. interface FreeCameraInputsManager {
  39245. /**
  39246. * Add virtual joystick input support to the input manager.
  39247. * @returns the current input manager
  39248. */
  39249. addVirtualJoystick(): FreeCameraInputsManager;
  39250. }
  39251. }
  39252. /**
  39253. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39254. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39255. */
  39256. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39257. /**
  39258. * Defines the camera the input is attached to.
  39259. */
  39260. camera: FreeCamera;
  39261. private _leftjoystick;
  39262. private _rightjoystick;
  39263. /**
  39264. * Gets the left stick of the virtual joystick.
  39265. * @returns The virtual Joystick
  39266. */
  39267. getLeftJoystick(): VirtualJoystick;
  39268. /**
  39269. * Gets the right stick of the virtual joystick.
  39270. * @returns The virtual Joystick
  39271. */
  39272. getRightJoystick(): VirtualJoystick;
  39273. /**
  39274. * Update the current camera state depending on the inputs that have been used this frame.
  39275. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39276. */
  39277. checkInputs(): void;
  39278. /**
  39279. * Attach the input controls to a specific dom element to get the input from.
  39280. * @param element Defines the element the controls should be listened from
  39281. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39282. */
  39283. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39284. /**
  39285. * Detach the current controls from the specified dom element.
  39286. * @param element Defines the element to stop listening the inputs from
  39287. */
  39288. detachControl(element: Nullable<HTMLElement>): void;
  39289. /**
  39290. * Gets the class name of the current intput.
  39291. * @returns the class name
  39292. */
  39293. getClassName(): string;
  39294. /**
  39295. * Get the friendly name associated with the input class.
  39296. * @returns the input friendly name
  39297. */
  39298. getSimpleName(): string;
  39299. }
  39300. }
  39301. declare module "babylonjs/Cameras/Inputs/index" {
  39302. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39303. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39304. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39305. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39306. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39307. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39308. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39309. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39310. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39311. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39312. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39313. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39314. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39315. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39316. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39317. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39318. }
  39319. declare module "babylonjs/Cameras/touchCamera" {
  39320. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39321. import { Scene } from "babylonjs/scene";
  39322. import { Vector3 } from "babylonjs/Maths/math.vector";
  39323. /**
  39324. * This represents a FPS type of camera controlled by touch.
  39325. * This is like a universal camera minus the Gamepad controls.
  39326. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39327. */
  39328. export class TouchCamera extends FreeCamera {
  39329. /**
  39330. * Defines the touch sensibility for rotation.
  39331. * The higher the faster.
  39332. */
  39333. touchAngularSensibility: number;
  39334. /**
  39335. * Defines the touch sensibility for move.
  39336. * The higher the faster.
  39337. */
  39338. touchMoveSensibility: number;
  39339. /**
  39340. * Instantiates a new touch camera.
  39341. * This represents a FPS type of camera controlled by touch.
  39342. * This is like a universal camera minus the Gamepad controls.
  39343. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39344. * @param name Define the name of the camera in the scene
  39345. * @param position Define the start position of the camera in the scene
  39346. * @param scene Define the scene the camera belongs to
  39347. */
  39348. constructor(name: string, position: Vector3, scene: Scene);
  39349. /**
  39350. * Gets the current object class name.
  39351. * @return the class name
  39352. */
  39353. getClassName(): string;
  39354. /** @hidden */
  39355. _setupInputs(): void;
  39356. }
  39357. }
  39358. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39359. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39360. import { Scene } from "babylonjs/scene";
  39361. import { Vector3 } from "babylonjs/Maths/math.vector";
  39362. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39363. import { Axis } from "babylonjs/Maths/math.axis";
  39364. /**
  39365. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39366. * being tilted forward or back and left or right.
  39367. */
  39368. export class DeviceOrientationCamera extends FreeCamera {
  39369. private _initialQuaternion;
  39370. private _quaternionCache;
  39371. private _tmpDragQuaternion;
  39372. /**
  39373. * Creates a new device orientation camera
  39374. * @param name The name of the camera
  39375. * @param position The start position camera
  39376. * @param scene The scene the camera belongs to
  39377. */
  39378. constructor(name: string, position: Vector3, scene: Scene);
  39379. /**
  39380. * @hidden
  39381. * Disabled pointer input on first orientation sensor update (Default: true)
  39382. */
  39383. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  39384. private _dragFactor;
  39385. /**
  39386. * Enabled turning on the y axis when the orientation sensor is active
  39387. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39388. */
  39389. enableHorizontalDragging(dragFactor?: number): void;
  39390. /**
  39391. * Gets the current instance class name ("DeviceOrientationCamera").
  39392. * This helps avoiding instanceof at run time.
  39393. * @returns the class name
  39394. */
  39395. getClassName(): string;
  39396. /**
  39397. * @hidden
  39398. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39399. */
  39400. _checkInputs(): void;
  39401. /**
  39402. * Reset the camera to its default orientation on the specified axis only.
  39403. * @param axis The axis to reset
  39404. */
  39405. resetToCurrentRotation(axis?: Axis): void;
  39406. }
  39407. }
  39408. declare module "babylonjs/Gamepads/xboxGamepad" {
  39409. import { Observable } from "babylonjs/Misc/observable";
  39410. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39411. /**
  39412. * Defines supported buttons for XBox360 compatible gamepads
  39413. */
  39414. export enum Xbox360Button {
  39415. /** A */
  39416. A = 0,
  39417. /** B */
  39418. B = 1,
  39419. /** X */
  39420. X = 2,
  39421. /** Y */
  39422. Y = 3,
  39423. /** Start */
  39424. Start = 4,
  39425. /** Back */
  39426. Back = 5,
  39427. /** Left button */
  39428. LB = 6,
  39429. /** Right button */
  39430. RB = 7,
  39431. /** Left stick */
  39432. LeftStick = 8,
  39433. /** Right stick */
  39434. RightStick = 9
  39435. }
  39436. /** Defines values for XBox360 DPad */
  39437. export enum Xbox360Dpad {
  39438. /** Up */
  39439. Up = 0,
  39440. /** Down */
  39441. Down = 1,
  39442. /** Left */
  39443. Left = 2,
  39444. /** Right */
  39445. Right = 3
  39446. }
  39447. /**
  39448. * Defines a XBox360 gamepad
  39449. */
  39450. export class Xbox360Pad extends Gamepad {
  39451. private _leftTrigger;
  39452. private _rightTrigger;
  39453. private _onlefttriggerchanged;
  39454. private _onrighttriggerchanged;
  39455. private _onbuttondown;
  39456. private _onbuttonup;
  39457. private _ondpaddown;
  39458. private _ondpadup;
  39459. /** Observable raised when a button is pressed */
  39460. onButtonDownObservable: Observable<Xbox360Button>;
  39461. /** Observable raised when a button is released */
  39462. onButtonUpObservable: Observable<Xbox360Button>;
  39463. /** Observable raised when a pad is pressed */
  39464. onPadDownObservable: Observable<Xbox360Dpad>;
  39465. /** Observable raised when a pad is released */
  39466. onPadUpObservable: Observable<Xbox360Dpad>;
  39467. private _buttonA;
  39468. private _buttonB;
  39469. private _buttonX;
  39470. private _buttonY;
  39471. private _buttonBack;
  39472. private _buttonStart;
  39473. private _buttonLB;
  39474. private _buttonRB;
  39475. private _buttonLeftStick;
  39476. private _buttonRightStick;
  39477. private _dPadUp;
  39478. private _dPadDown;
  39479. private _dPadLeft;
  39480. private _dPadRight;
  39481. private _isXboxOnePad;
  39482. /**
  39483. * Creates a new XBox360 gamepad object
  39484. * @param id defines the id of this gamepad
  39485. * @param index defines its index
  39486. * @param gamepad defines the internal HTML gamepad object
  39487. * @param xboxOne defines if it is a XBox One gamepad
  39488. */
  39489. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39490. /**
  39491. * Defines the callback to call when left trigger is pressed
  39492. * @param callback defines the callback to use
  39493. */
  39494. onlefttriggerchanged(callback: (value: number) => void): void;
  39495. /**
  39496. * Defines the callback to call when right trigger is pressed
  39497. * @param callback defines the callback to use
  39498. */
  39499. onrighttriggerchanged(callback: (value: number) => void): void;
  39500. /**
  39501. * Gets the left trigger value
  39502. */
  39503. /**
  39504. * Sets the left trigger value
  39505. */
  39506. leftTrigger: number;
  39507. /**
  39508. * Gets the right trigger value
  39509. */
  39510. /**
  39511. * Sets the right trigger value
  39512. */
  39513. rightTrigger: number;
  39514. /**
  39515. * Defines the callback to call when a button is pressed
  39516. * @param callback defines the callback to use
  39517. */
  39518. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39519. /**
  39520. * Defines the callback to call when a button is released
  39521. * @param callback defines the callback to use
  39522. */
  39523. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39524. /**
  39525. * Defines the callback to call when a pad is pressed
  39526. * @param callback defines the callback to use
  39527. */
  39528. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39529. /**
  39530. * Defines the callback to call when a pad is released
  39531. * @param callback defines the callback to use
  39532. */
  39533. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39534. private _setButtonValue;
  39535. private _setDPadValue;
  39536. /**
  39537. * Gets the value of the `A` button
  39538. */
  39539. /**
  39540. * Sets the value of the `A` button
  39541. */
  39542. buttonA: number;
  39543. /**
  39544. * Gets the value of the `B` button
  39545. */
  39546. /**
  39547. * Sets the value of the `B` button
  39548. */
  39549. buttonB: number;
  39550. /**
  39551. * Gets the value of the `X` button
  39552. */
  39553. /**
  39554. * Sets the value of the `X` button
  39555. */
  39556. buttonX: number;
  39557. /**
  39558. * Gets the value of the `Y` button
  39559. */
  39560. /**
  39561. * Sets the value of the `Y` button
  39562. */
  39563. buttonY: number;
  39564. /**
  39565. * Gets the value of the `Start` button
  39566. */
  39567. /**
  39568. * Sets the value of the `Start` button
  39569. */
  39570. buttonStart: number;
  39571. /**
  39572. * Gets the value of the `Back` button
  39573. */
  39574. /**
  39575. * Sets the value of the `Back` button
  39576. */
  39577. buttonBack: number;
  39578. /**
  39579. * Gets the value of the `Left` button
  39580. */
  39581. /**
  39582. * Sets the value of the `Left` button
  39583. */
  39584. buttonLB: number;
  39585. /**
  39586. * Gets the value of the `Right` button
  39587. */
  39588. /**
  39589. * Sets the value of the `Right` button
  39590. */
  39591. buttonRB: number;
  39592. /**
  39593. * Gets the value of the Left joystick
  39594. */
  39595. /**
  39596. * Sets the value of the Left joystick
  39597. */
  39598. buttonLeftStick: number;
  39599. /**
  39600. * Gets the value of the Right joystick
  39601. */
  39602. /**
  39603. * Sets the value of the Right joystick
  39604. */
  39605. buttonRightStick: number;
  39606. /**
  39607. * Gets the value of D-pad up
  39608. */
  39609. /**
  39610. * Sets the value of D-pad up
  39611. */
  39612. dPadUp: number;
  39613. /**
  39614. * Gets the value of D-pad down
  39615. */
  39616. /**
  39617. * Sets the value of D-pad down
  39618. */
  39619. dPadDown: number;
  39620. /**
  39621. * Gets the value of D-pad left
  39622. */
  39623. /**
  39624. * Sets the value of D-pad left
  39625. */
  39626. dPadLeft: number;
  39627. /**
  39628. * Gets the value of D-pad right
  39629. */
  39630. /**
  39631. * Sets the value of D-pad right
  39632. */
  39633. dPadRight: number;
  39634. /**
  39635. * Force the gamepad to synchronize with device values
  39636. */
  39637. update(): void;
  39638. /**
  39639. * Disposes the gamepad
  39640. */
  39641. dispose(): void;
  39642. }
  39643. }
  39644. declare module "babylonjs/Gamepads/gamepadManager" {
  39645. import { Observable } from "babylonjs/Misc/observable";
  39646. import { Nullable } from "babylonjs/types";
  39647. import { Scene } from "babylonjs/scene";
  39648. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39649. /**
  39650. * Manager for handling gamepads
  39651. */
  39652. export class GamepadManager {
  39653. private _scene?;
  39654. private _babylonGamepads;
  39655. private _oneGamepadConnected;
  39656. /** @hidden */
  39657. _isMonitoring: boolean;
  39658. private _gamepadEventSupported;
  39659. private _gamepadSupport;
  39660. /**
  39661. * observable to be triggered when the gamepad controller has been connected
  39662. */
  39663. onGamepadConnectedObservable: Observable<Gamepad>;
  39664. /**
  39665. * observable to be triggered when the gamepad controller has been disconnected
  39666. */
  39667. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39668. private _onGamepadConnectedEvent;
  39669. private _onGamepadDisconnectedEvent;
  39670. /**
  39671. * Initializes the gamepad manager
  39672. * @param _scene BabylonJS scene
  39673. */
  39674. constructor(_scene?: Scene | undefined);
  39675. /**
  39676. * The gamepads in the game pad manager
  39677. */
  39678. readonly gamepads: Gamepad[];
  39679. /**
  39680. * Get the gamepad controllers based on type
  39681. * @param type The type of gamepad controller
  39682. * @returns Nullable gamepad
  39683. */
  39684. getGamepadByType(type?: number): Nullable<Gamepad>;
  39685. /**
  39686. * Disposes the gamepad manager
  39687. */
  39688. dispose(): void;
  39689. private _addNewGamepad;
  39690. private _startMonitoringGamepads;
  39691. private _stopMonitoringGamepads;
  39692. /** @hidden */
  39693. _checkGamepadsStatus(): void;
  39694. private _updateGamepadObjects;
  39695. }
  39696. }
  39697. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39698. import { Nullable } from "babylonjs/types";
  39699. import { Scene } from "babylonjs/scene";
  39700. import { ISceneComponent } from "babylonjs/sceneComponent";
  39701. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39702. module "babylonjs/scene" {
  39703. interface Scene {
  39704. /** @hidden */
  39705. _gamepadManager: Nullable<GamepadManager>;
  39706. /**
  39707. * Gets the gamepad manager associated with the scene
  39708. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39709. */
  39710. gamepadManager: GamepadManager;
  39711. }
  39712. }
  39713. module "babylonjs/Cameras/freeCameraInputsManager" {
  39714. /**
  39715. * Interface representing a free camera inputs manager
  39716. */
  39717. interface FreeCameraInputsManager {
  39718. /**
  39719. * Adds gamepad input support to the FreeCameraInputsManager.
  39720. * @returns the FreeCameraInputsManager
  39721. */
  39722. addGamepad(): FreeCameraInputsManager;
  39723. }
  39724. }
  39725. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39726. /**
  39727. * Interface representing an arc rotate camera inputs manager
  39728. */
  39729. interface ArcRotateCameraInputsManager {
  39730. /**
  39731. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39732. * @returns the camera inputs manager
  39733. */
  39734. addGamepad(): ArcRotateCameraInputsManager;
  39735. }
  39736. }
  39737. /**
  39738. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39739. */
  39740. export class GamepadSystemSceneComponent implements ISceneComponent {
  39741. /**
  39742. * The component name helpfull to identify the component in the list of scene components.
  39743. */
  39744. readonly name: string;
  39745. /**
  39746. * The scene the component belongs to.
  39747. */
  39748. scene: Scene;
  39749. /**
  39750. * Creates a new instance of the component for the given scene
  39751. * @param scene Defines the scene to register the component in
  39752. */
  39753. constructor(scene: Scene);
  39754. /**
  39755. * Registers the component in a given scene
  39756. */
  39757. register(): void;
  39758. /**
  39759. * Rebuilds the elements related to this component in case of
  39760. * context lost for instance.
  39761. */
  39762. rebuild(): void;
  39763. /**
  39764. * Disposes the component and the associated ressources
  39765. */
  39766. dispose(): void;
  39767. private _beforeCameraUpdate;
  39768. }
  39769. }
  39770. declare module "babylonjs/Cameras/universalCamera" {
  39771. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  39772. import { Scene } from "babylonjs/scene";
  39773. import { Vector3 } from "babylonjs/Maths/math.vector";
  39774. import "babylonjs/Gamepads/gamepadSceneComponent";
  39775. /**
  39776. * 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,
  39777. * which still works and will still be found in many Playgrounds.
  39778. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39779. */
  39780. export class UniversalCamera extends TouchCamera {
  39781. /**
  39782. * Defines the gamepad rotation sensiblity.
  39783. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39784. */
  39785. gamepadAngularSensibility: number;
  39786. /**
  39787. * Defines the gamepad move sensiblity.
  39788. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39789. */
  39790. gamepadMoveSensibility: number;
  39791. /**
  39792. * 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,
  39793. * which still works and will still be found in many Playgrounds.
  39794. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39795. * @param name Define the name of the camera in the scene
  39796. * @param position Define the start position of the camera in the scene
  39797. * @param scene Define the scene the camera belongs to
  39798. */
  39799. constructor(name: string, position: Vector3, scene: Scene);
  39800. /**
  39801. * Gets the current object class name.
  39802. * @return the class name
  39803. */
  39804. getClassName(): string;
  39805. }
  39806. }
  39807. declare module "babylonjs/Cameras/gamepadCamera" {
  39808. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39809. import { Scene } from "babylonjs/scene";
  39810. import { Vector3 } from "babylonjs/Maths/math.vector";
  39811. /**
  39812. * This represents a FPS type of camera. This is only here for back compat purpose.
  39813. * Please use the UniversalCamera instead as both are identical.
  39814. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39815. */
  39816. export class GamepadCamera extends UniversalCamera {
  39817. /**
  39818. * Instantiates a new Gamepad Camera
  39819. * This represents a FPS type of camera. This is only here for back compat purpose.
  39820. * Please use the UniversalCamera instead as both are identical.
  39821. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39822. * @param name Define the name of the camera in the scene
  39823. * @param position Define the start position of the camera in the scene
  39824. * @param scene Define the scene the camera belongs to
  39825. */
  39826. constructor(name: string, position: Vector3, scene: Scene);
  39827. /**
  39828. * Gets the current object class name.
  39829. * @return the class name
  39830. */
  39831. getClassName(): string;
  39832. }
  39833. }
  39834. declare module "babylonjs/Shaders/pass.fragment" {
  39835. /** @hidden */
  39836. export var passPixelShader: {
  39837. name: string;
  39838. shader: string;
  39839. };
  39840. }
  39841. declare module "babylonjs/Shaders/passCube.fragment" {
  39842. /** @hidden */
  39843. export var passCubePixelShader: {
  39844. name: string;
  39845. shader: string;
  39846. };
  39847. }
  39848. declare module "babylonjs/PostProcesses/passPostProcess" {
  39849. import { Nullable } from "babylonjs/types";
  39850. import { Camera } from "babylonjs/Cameras/camera";
  39851. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39852. import { Engine } from "babylonjs/Engines/engine";
  39853. import "babylonjs/Shaders/pass.fragment";
  39854. import "babylonjs/Shaders/passCube.fragment";
  39855. /**
  39856. * PassPostProcess which produces an output the same as it's input
  39857. */
  39858. export class PassPostProcess extends PostProcess {
  39859. /**
  39860. * Creates the PassPostProcess
  39861. * @param name The name of the effect.
  39862. * @param options The required width/height ratio to downsize to before computing the render pass.
  39863. * @param camera The camera to apply the render pass to.
  39864. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39865. * @param engine The engine which the post process will be applied. (default: current engine)
  39866. * @param reusable If the post process can be reused on the same frame. (default: false)
  39867. * @param textureType The type of texture to be used when performing the post processing.
  39868. * @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)
  39869. */
  39870. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39871. }
  39872. /**
  39873. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39874. */
  39875. export class PassCubePostProcess extends PostProcess {
  39876. private _face;
  39877. /**
  39878. * Gets or sets the cube face to display.
  39879. * * 0 is +X
  39880. * * 1 is -X
  39881. * * 2 is +Y
  39882. * * 3 is -Y
  39883. * * 4 is +Z
  39884. * * 5 is -Z
  39885. */
  39886. face: number;
  39887. /**
  39888. * Creates the PassCubePostProcess
  39889. * @param name The name of the effect.
  39890. * @param options The required width/height ratio to downsize to before computing the render pass.
  39891. * @param camera The camera to apply the render pass to.
  39892. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39893. * @param engine The engine which the post process will be applied. (default: current engine)
  39894. * @param reusable If the post process can be reused on the same frame. (default: false)
  39895. * @param textureType The type of texture to be used when performing the post processing.
  39896. * @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)
  39897. */
  39898. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39899. }
  39900. }
  39901. declare module "babylonjs/Shaders/anaglyph.fragment" {
  39902. /** @hidden */
  39903. export var anaglyphPixelShader: {
  39904. name: string;
  39905. shader: string;
  39906. };
  39907. }
  39908. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  39909. import { Engine } from "babylonjs/Engines/engine";
  39910. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39911. import { Camera } from "babylonjs/Cameras/camera";
  39912. import "babylonjs/Shaders/anaglyph.fragment";
  39913. /**
  39914. * Postprocess used to generate anaglyphic rendering
  39915. */
  39916. export class AnaglyphPostProcess extends PostProcess {
  39917. private _passedProcess;
  39918. /**
  39919. * Creates a new AnaglyphPostProcess
  39920. * @param name defines postprocess name
  39921. * @param options defines creation options or target ratio scale
  39922. * @param rigCameras defines cameras using this postprocess
  39923. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39924. * @param engine defines hosting engine
  39925. * @param reusable defines if the postprocess will be reused multiple times per frame
  39926. */
  39927. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39928. }
  39929. }
  39930. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  39931. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  39932. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39933. import { Scene } from "babylonjs/scene";
  39934. import { Vector3 } from "babylonjs/Maths/math.vector";
  39935. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39936. /**
  39937. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39938. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39939. */
  39940. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39941. /**
  39942. * Creates a new AnaglyphArcRotateCamera
  39943. * @param name defines camera name
  39944. * @param alpha defines alpha angle (in radians)
  39945. * @param beta defines beta angle (in radians)
  39946. * @param radius defines radius
  39947. * @param target defines camera target
  39948. * @param interaxialDistance defines distance between each color axis
  39949. * @param scene defines the hosting scene
  39950. */
  39951. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39952. /**
  39953. * Gets camera class name
  39954. * @returns AnaglyphArcRotateCamera
  39955. */
  39956. getClassName(): string;
  39957. }
  39958. }
  39959. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  39960. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39961. import { Scene } from "babylonjs/scene";
  39962. import { Vector3 } from "babylonjs/Maths/math.vector";
  39963. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39964. /**
  39965. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39966. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39967. */
  39968. export class AnaglyphFreeCamera extends FreeCamera {
  39969. /**
  39970. * Creates a new AnaglyphFreeCamera
  39971. * @param name defines camera name
  39972. * @param position defines initial position
  39973. * @param interaxialDistance defines distance between each color axis
  39974. * @param scene defines the hosting scene
  39975. */
  39976. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39977. /**
  39978. * Gets camera class name
  39979. * @returns AnaglyphFreeCamera
  39980. */
  39981. getClassName(): string;
  39982. }
  39983. }
  39984. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  39985. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39986. import { Scene } from "babylonjs/scene";
  39987. import { Vector3 } from "babylonjs/Maths/math.vector";
  39988. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39989. /**
  39990. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39991. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39992. */
  39993. export class AnaglyphGamepadCamera extends GamepadCamera {
  39994. /**
  39995. * Creates a new AnaglyphGamepadCamera
  39996. * @param name defines camera name
  39997. * @param position defines initial position
  39998. * @param interaxialDistance defines distance between each color axis
  39999. * @param scene defines the hosting scene
  40000. */
  40001. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40002. /**
  40003. * Gets camera class name
  40004. * @returns AnaglyphGamepadCamera
  40005. */
  40006. getClassName(): string;
  40007. }
  40008. }
  40009. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40010. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40011. import { Scene } from "babylonjs/scene";
  40012. import { Vector3 } from "babylonjs/Maths/math.vector";
  40013. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40014. /**
  40015. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40016. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40017. */
  40018. export class AnaglyphUniversalCamera extends UniversalCamera {
  40019. /**
  40020. * Creates a new AnaglyphUniversalCamera
  40021. * @param name defines camera name
  40022. * @param position defines initial position
  40023. * @param interaxialDistance defines distance between each color axis
  40024. * @param scene defines the hosting scene
  40025. */
  40026. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40027. /**
  40028. * Gets camera class name
  40029. * @returns AnaglyphUniversalCamera
  40030. */
  40031. getClassName(): string;
  40032. }
  40033. }
  40034. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40035. /** @hidden */
  40036. export var stereoscopicInterlacePixelShader: {
  40037. name: string;
  40038. shader: string;
  40039. };
  40040. }
  40041. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40042. import { Camera } from "babylonjs/Cameras/camera";
  40043. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40044. import { Engine } from "babylonjs/Engines/engine";
  40045. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40046. /**
  40047. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40048. */
  40049. export class StereoscopicInterlacePostProcess extends PostProcess {
  40050. private _stepSize;
  40051. private _passedProcess;
  40052. /**
  40053. * Initializes a StereoscopicInterlacePostProcess
  40054. * @param name The name of the effect.
  40055. * @param rigCameras The rig cameras to be appled to the post process
  40056. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40057. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40058. * @param engine The engine which the post process will be applied. (default: current engine)
  40059. * @param reusable If the post process can be reused on the same frame. (default: false)
  40060. */
  40061. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40062. }
  40063. }
  40064. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40065. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40066. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40067. import { Scene } from "babylonjs/scene";
  40068. import { Vector3 } from "babylonjs/Maths/math.vector";
  40069. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40070. /**
  40071. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40072. * @see http://doc.babylonjs.com/features/cameras
  40073. */
  40074. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40075. /**
  40076. * Creates a new StereoscopicArcRotateCamera
  40077. * @param name defines camera name
  40078. * @param alpha defines alpha angle (in radians)
  40079. * @param beta defines beta angle (in radians)
  40080. * @param radius defines radius
  40081. * @param target defines camera target
  40082. * @param interaxialDistance defines distance between each color axis
  40083. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40084. * @param scene defines the hosting scene
  40085. */
  40086. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40087. /**
  40088. * Gets camera class name
  40089. * @returns StereoscopicArcRotateCamera
  40090. */
  40091. getClassName(): string;
  40092. }
  40093. }
  40094. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40095. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40096. import { Scene } from "babylonjs/scene";
  40097. import { Vector3 } from "babylonjs/Maths/math.vector";
  40098. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40099. /**
  40100. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40101. * @see http://doc.babylonjs.com/features/cameras
  40102. */
  40103. export class StereoscopicFreeCamera extends FreeCamera {
  40104. /**
  40105. * Creates a new StereoscopicFreeCamera
  40106. * @param name defines camera name
  40107. * @param position defines initial position
  40108. * @param interaxialDistance defines distance between each color axis
  40109. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40110. * @param scene defines the hosting scene
  40111. */
  40112. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40113. /**
  40114. * Gets camera class name
  40115. * @returns StereoscopicFreeCamera
  40116. */
  40117. getClassName(): string;
  40118. }
  40119. }
  40120. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40121. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40122. import { Scene } from "babylonjs/scene";
  40123. import { Vector3 } from "babylonjs/Maths/math.vector";
  40124. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40125. /**
  40126. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40127. * @see http://doc.babylonjs.com/features/cameras
  40128. */
  40129. export class StereoscopicGamepadCamera extends GamepadCamera {
  40130. /**
  40131. * Creates a new StereoscopicGamepadCamera
  40132. * @param name defines camera name
  40133. * @param position defines initial position
  40134. * @param interaxialDistance defines distance between each color axis
  40135. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40136. * @param scene defines the hosting scene
  40137. */
  40138. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40139. /**
  40140. * Gets camera class name
  40141. * @returns StereoscopicGamepadCamera
  40142. */
  40143. getClassName(): string;
  40144. }
  40145. }
  40146. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40147. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40148. import { Scene } from "babylonjs/scene";
  40149. import { Vector3 } from "babylonjs/Maths/math.vector";
  40150. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40151. /**
  40152. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40153. * @see http://doc.babylonjs.com/features/cameras
  40154. */
  40155. export class StereoscopicUniversalCamera extends UniversalCamera {
  40156. /**
  40157. * Creates a new StereoscopicUniversalCamera
  40158. * @param name defines camera name
  40159. * @param position defines initial position
  40160. * @param interaxialDistance defines distance between each color axis
  40161. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40162. * @param scene defines the hosting scene
  40163. */
  40164. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40165. /**
  40166. * Gets camera class name
  40167. * @returns StereoscopicUniversalCamera
  40168. */
  40169. getClassName(): string;
  40170. }
  40171. }
  40172. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40173. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40174. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40175. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40176. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40177. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40178. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40179. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40180. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40181. }
  40182. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40183. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40184. import { Scene } from "babylonjs/scene";
  40185. import { Vector3 } from "babylonjs/Maths/math.vector";
  40186. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40187. /**
  40188. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40189. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40190. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40191. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40192. */
  40193. export class VirtualJoysticksCamera extends FreeCamera {
  40194. /**
  40195. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40196. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40197. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40198. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40199. * @param name Define the name of the camera in the scene
  40200. * @param position Define the start position of the camera in the scene
  40201. * @param scene Define the scene the camera belongs to
  40202. */
  40203. constructor(name: string, position: Vector3, scene: Scene);
  40204. /**
  40205. * Gets the current object class name.
  40206. * @return the class name
  40207. */
  40208. getClassName(): string;
  40209. }
  40210. }
  40211. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40212. import { Matrix } from "babylonjs/Maths/math.vector";
  40213. /**
  40214. * This represents all the required metrics to create a VR camera.
  40215. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40216. */
  40217. export class VRCameraMetrics {
  40218. /**
  40219. * Define the horizontal resolution off the screen.
  40220. */
  40221. hResolution: number;
  40222. /**
  40223. * Define the vertical resolution off the screen.
  40224. */
  40225. vResolution: number;
  40226. /**
  40227. * Define the horizontal screen size.
  40228. */
  40229. hScreenSize: number;
  40230. /**
  40231. * Define the vertical screen size.
  40232. */
  40233. vScreenSize: number;
  40234. /**
  40235. * Define the vertical screen center position.
  40236. */
  40237. vScreenCenter: number;
  40238. /**
  40239. * Define the distance of the eyes to the screen.
  40240. */
  40241. eyeToScreenDistance: number;
  40242. /**
  40243. * Define the distance between both lenses
  40244. */
  40245. lensSeparationDistance: number;
  40246. /**
  40247. * Define the distance between both viewer's eyes.
  40248. */
  40249. interpupillaryDistance: number;
  40250. /**
  40251. * Define the distortion factor of the VR postprocess.
  40252. * Please, touch with care.
  40253. */
  40254. distortionK: number[];
  40255. /**
  40256. * Define the chromatic aberration correction factors for the VR post process.
  40257. */
  40258. chromaAbCorrection: number[];
  40259. /**
  40260. * Define the scale factor of the post process.
  40261. * The smaller the better but the slower.
  40262. */
  40263. postProcessScaleFactor: number;
  40264. /**
  40265. * Define an offset for the lens center.
  40266. */
  40267. lensCenterOffset: number;
  40268. /**
  40269. * Define if the current vr camera should compensate the distortion of the lense or not.
  40270. */
  40271. compensateDistortion: boolean;
  40272. /**
  40273. * Defines if multiview should be enabled when rendering (Default: false)
  40274. */
  40275. multiviewEnabled: boolean;
  40276. /**
  40277. * Gets the rendering aspect ratio based on the provided resolutions.
  40278. */
  40279. readonly aspectRatio: number;
  40280. /**
  40281. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40282. */
  40283. readonly aspectRatioFov: number;
  40284. /**
  40285. * @hidden
  40286. */
  40287. readonly leftHMatrix: Matrix;
  40288. /**
  40289. * @hidden
  40290. */
  40291. readonly rightHMatrix: Matrix;
  40292. /**
  40293. * @hidden
  40294. */
  40295. readonly leftPreViewMatrix: Matrix;
  40296. /**
  40297. * @hidden
  40298. */
  40299. readonly rightPreViewMatrix: Matrix;
  40300. /**
  40301. * Get the default VRMetrics based on the most generic setup.
  40302. * @returns the default vr metrics
  40303. */
  40304. static GetDefault(): VRCameraMetrics;
  40305. }
  40306. }
  40307. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40308. /** @hidden */
  40309. export var vrDistortionCorrectionPixelShader: {
  40310. name: string;
  40311. shader: string;
  40312. };
  40313. }
  40314. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40315. import { Camera } from "babylonjs/Cameras/camera";
  40316. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40317. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40318. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40319. /**
  40320. * VRDistortionCorrectionPostProcess used for mobile VR
  40321. */
  40322. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40323. private _isRightEye;
  40324. private _distortionFactors;
  40325. private _postProcessScaleFactor;
  40326. private _lensCenterOffset;
  40327. private _scaleIn;
  40328. private _scaleFactor;
  40329. private _lensCenter;
  40330. /**
  40331. * Initializes the VRDistortionCorrectionPostProcess
  40332. * @param name The name of the effect.
  40333. * @param camera The camera to apply the render pass to.
  40334. * @param isRightEye If this is for the right eye distortion
  40335. * @param vrMetrics All the required metrics for the VR camera
  40336. */
  40337. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40338. }
  40339. }
  40340. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40341. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40342. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40343. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40344. import { Scene } from "babylonjs/scene";
  40345. import { Vector3 } from "babylonjs/Maths/math.vector";
  40346. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40347. import "babylonjs/Cameras/RigModes/vrRigMode";
  40348. /**
  40349. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40350. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40351. */
  40352. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40353. /**
  40354. * Creates a new VRDeviceOrientationArcRotateCamera
  40355. * @param name defines camera name
  40356. * @param alpha defines the camera rotation along the logitudinal axis
  40357. * @param beta defines the camera rotation along the latitudinal axis
  40358. * @param radius defines the camera distance from its target
  40359. * @param target defines the camera target
  40360. * @param scene defines the scene the camera belongs to
  40361. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40362. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40363. */
  40364. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40365. /**
  40366. * Gets camera class name
  40367. * @returns VRDeviceOrientationArcRotateCamera
  40368. */
  40369. getClassName(): string;
  40370. }
  40371. }
  40372. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40373. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40374. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40375. import { Scene } from "babylonjs/scene";
  40376. import { Vector3 } from "babylonjs/Maths/math.vector";
  40377. import "babylonjs/Cameras/RigModes/vrRigMode";
  40378. /**
  40379. * Camera used to simulate VR rendering (based on FreeCamera)
  40380. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40381. */
  40382. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40383. /**
  40384. * Creates a new VRDeviceOrientationFreeCamera
  40385. * @param name defines camera name
  40386. * @param position defines the start position of the camera
  40387. * @param scene defines the scene the camera belongs to
  40388. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40389. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40390. */
  40391. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40392. /**
  40393. * Gets camera class name
  40394. * @returns VRDeviceOrientationFreeCamera
  40395. */
  40396. getClassName(): string;
  40397. }
  40398. }
  40399. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40400. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40401. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40402. import { Scene } from "babylonjs/scene";
  40403. import { Vector3 } from "babylonjs/Maths/math.vector";
  40404. import "babylonjs/Gamepads/gamepadSceneComponent";
  40405. /**
  40406. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40407. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40408. */
  40409. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40410. /**
  40411. * Creates a new VRDeviceOrientationGamepadCamera
  40412. * @param name defines camera name
  40413. * @param position defines the start position of the camera
  40414. * @param scene defines the scene the camera belongs to
  40415. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40416. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40417. */
  40418. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40419. /**
  40420. * Gets camera class name
  40421. * @returns VRDeviceOrientationGamepadCamera
  40422. */
  40423. getClassName(): string;
  40424. }
  40425. }
  40426. declare module "babylonjs/Materials/pushMaterial" {
  40427. import { Nullable } from "babylonjs/types";
  40428. import { Scene } from "babylonjs/scene";
  40429. import { Matrix } from "babylonjs/Maths/math.vector";
  40430. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40431. import { Mesh } from "babylonjs/Meshes/mesh";
  40432. import { Material } from "babylonjs/Materials/material";
  40433. import { Effect } from "babylonjs/Materials/effect";
  40434. /**
  40435. * Base class of materials working in push mode in babylon JS
  40436. * @hidden
  40437. */
  40438. export class PushMaterial extends Material {
  40439. protected _activeEffect: Effect;
  40440. protected _normalMatrix: Matrix;
  40441. /**
  40442. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40443. * This means that the material can keep using a previous shader while a new one is being compiled.
  40444. * This is mostly used when shader parallel compilation is supported (true by default)
  40445. */
  40446. allowShaderHotSwapping: boolean;
  40447. constructor(name: string, scene: Scene);
  40448. getEffect(): Effect;
  40449. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40450. /**
  40451. * Binds the given world matrix to the active effect
  40452. *
  40453. * @param world the matrix to bind
  40454. */
  40455. bindOnlyWorldMatrix(world: Matrix): void;
  40456. /**
  40457. * Binds the given normal matrix to the active effect
  40458. *
  40459. * @param normalMatrix the matrix to bind
  40460. */
  40461. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40462. bind(world: Matrix, mesh?: Mesh): void;
  40463. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40464. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40465. }
  40466. }
  40467. declare module "babylonjs/Materials/materialFlags" {
  40468. /**
  40469. * This groups all the flags used to control the materials channel.
  40470. */
  40471. export class MaterialFlags {
  40472. private static _DiffuseTextureEnabled;
  40473. /**
  40474. * Are diffuse textures enabled in the application.
  40475. */
  40476. static DiffuseTextureEnabled: boolean;
  40477. private static _AmbientTextureEnabled;
  40478. /**
  40479. * Are ambient textures enabled in the application.
  40480. */
  40481. static AmbientTextureEnabled: boolean;
  40482. private static _OpacityTextureEnabled;
  40483. /**
  40484. * Are opacity textures enabled in the application.
  40485. */
  40486. static OpacityTextureEnabled: boolean;
  40487. private static _ReflectionTextureEnabled;
  40488. /**
  40489. * Are reflection textures enabled in the application.
  40490. */
  40491. static ReflectionTextureEnabled: boolean;
  40492. private static _EmissiveTextureEnabled;
  40493. /**
  40494. * Are emissive textures enabled in the application.
  40495. */
  40496. static EmissiveTextureEnabled: boolean;
  40497. private static _SpecularTextureEnabled;
  40498. /**
  40499. * Are specular textures enabled in the application.
  40500. */
  40501. static SpecularTextureEnabled: boolean;
  40502. private static _BumpTextureEnabled;
  40503. /**
  40504. * Are bump textures enabled in the application.
  40505. */
  40506. static BumpTextureEnabled: boolean;
  40507. private static _LightmapTextureEnabled;
  40508. /**
  40509. * Are lightmap textures enabled in the application.
  40510. */
  40511. static LightmapTextureEnabled: boolean;
  40512. private static _RefractionTextureEnabled;
  40513. /**
  40514. * Are refraction textures enabled in the application.
  40515. */
  40516. static RefractionTextureEnabled: boolean;
  40517. private static _ColorGradingTextureEnabled;
  40518. /**
  40519. * Are color grading textures enabled in the application.
  40520. */
  40521. static ColorGradingTextureEnabled: boolean;
  40522. private static _FresnelEnabled;
  40523. /**
  40524. * Are fresnels enabled in the application.
  40525. */
  40526. static FresnelEnabled: boolean;
  40527. private static _ClearCoatTextureEnabled;
  40528. /**
  40529. * Are clear coat textures enabled in the application.
  40530. */
  40531. static ClearCoatTextureEnabled: boolean;
  40532. private static _ClearCoatBumpTextureEnabled;
  40533. /**
  40534. * Are clear coat bump textures enabled in the application.
  40535. */
  40536. static ClearCoatBumpTextureEnabled: boolean;
  40537. private static _ClearCoatTintTextureEnabled;
  40538. /**
  40539. * Are clear coat tint textures enabled in the application.
  40540. */
  40541. static ClearCoatTintTextureEnabled: boolean;
  40542. private static _SheenTextureEnabled;
  40543. /**
  40544. * Are sheen textures enabled in the application.
  40545. */
  40546. static SheenTextureEnabled: boolean;
  40547. private static _AnisotropicTextureEnabled;
  40548. /**
  40549. * Are anisotropic textures enabled in the application.
  40550. */
  40551. static AnisotropicTextureEnabled: boolean;
  40552. private static _ThicknessTextureEnabled;
  40553. /**
  40554. * Are thickness textures enabled in the application.
  40555. */
  40556. static ThicknessTextureEnabled: boolean;
  40557. }
  40558. }
  40559. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40560. /** @hidden */
  40561. export var defaultFragmentDeclaration: {
  40562. name: string;
  40563. shader: string;
  40564. };
  40565. }
  40566. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40567. /** @hidden */
  40568. export var defaultUboDeclaration: {
  40569. name: string;
  40570. shader: string;
  40571. };
  40572. }
  40573. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40574. /** @hidden */
  40575. export var lightFragmentDeclaration: {
  40576. name: string;
  40577. shader: string;
  40578. };
  40579. }
  40580. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40581. /** @hidden */
  40582. export var lightUboDeclaration: {
  40583. name: string;
  40584. shader: string;
  40585. };
  40586. }
  40587. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40588. /** @hidden */
  40589. export var lightsFragmentFunctions: {
  40590. name: string;
  40591. shader: string;
  40592. };
  40593. }
  40594. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40595. /** @hidden */
  40596. export var shadowsFragmentFunctions: {
  40597. name: string;
  40598. shader: string;
  40599. };
  40600. }
  40601. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40602. /** @hidden */
  40603. export var fresnelFunction: {
  40604. name: string;
  40605. shader: string;
  40606. };
  40607. }
  40608. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40609. /** @hidden */
  40610. export var reflectionFunction: {
  40611. name: string;
  40612. shader: string;
  40613. };
  40614. }
  40615. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  40616. /** @hidden */
  40617. export var bumpFragmentFunctions: {
  40618. name: string;
  40619. shader: string;
  40620. };
  40621. }
  40622. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  40623. /** @hidden */
  40624. export var logDepthDeclaration: {
  40625. name: string;
  40626. shader: string;
  40627. };
  40628. }
  40629. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  40630. /** @hidden */
  40631. export var bumpFragment: {
  40632. name: string;
  40633. shader: string;
  40634. };
  40635. }
  40636. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  40637. /** @hidden */
  40638. export var depthPrePass: {
  40639. name: string;
  40640. shader: string;
  40641. };
  40642. }
  40643. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  40644. /** @hidden */
  40645. export var lightFragment: {
  40646. name: string;
  40647. shader: string;
  40648. };
  40649. }
  40650. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  40651. /** @hidden */
  40652. export var logDepthFragment: {
  40653. name: string;
  40654. shader: string;
  40655. };
  40656. }
  40657. declare module "babylonjs/Shaders/default.fragment" {
  40658. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  40659. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40660. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40661. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40662. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40663. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  40664. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  40665. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  40666. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  40667. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40668. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40669. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  40670. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  40671. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40672. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  40673. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  40674. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  40675. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  40676. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  40677. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  40678. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  40679. /** @hidden */
  40680. export var defaultPixelShader: {
  40681. name: string;
  40682. shader: string;
  40683. };
  40684. }
  40685. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  40686. /** @hidden */
  40687. export var defaultVertexDeclaration: {
  40688. name: string;
  40689. shader: string;
  40690. };
  40691. }
  40692. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  40693. /** @hidden */
  40694. export var bumpVertexDeclaration: {
  40695. name: string;
  40696. shader: string;
  40697. };
  40698. }
  40699. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  40700. /** @hidden */
  40701. export var bumpVertex: {
  40702. name: string;
  40703. shader: string;
  40704. };
  40705. }
  40706. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  40707. /** @hidden */
  40708. export var fogVertex: {
  40709. name: string;
  40710. shader: string;
  40711. };
  40712. }
  40713. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  40714. /** @hidden */
  40715. export var shadowsVertex: {
  40716. name: string;
  40717. shader: string;
  40718. };
  40719. }
  40720. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  40721. /** @hidden */
  40722. export var pointCloudVertex: {
  40723. name: string;
  40724. shader: string;
  40725. };
  40726. }
  40727. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  40728. /** @hidden */
  40729. export var logDepthVertex: {
  40730. name: string;
  40731. shader: string;
  40732. };
  40733. }
  40734. declare module "babylonjs/Shaders/default.vertex" {
  40735. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  40736. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40737. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40738. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  40739. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  40740. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  40741. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  40742. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  40743. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40744. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40745. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  40746. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  40747. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40748. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  40749. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  40750. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  40751. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  40752. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  40753. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  40754. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  40755. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  40756. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  40757. /** @hidden */
  40758. export var defaultVertexShader: {
  40759. name: string;
  40760. shader: string;
  40761. };
  40762. }
  40763. declare module "babylonjs/Materials/standardMaterial" {
  40764. import { SmartArray } from "babylonjs/Misc/smartArray";
  40765. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40766. import { Nullable } from "babylonjs/types";
  40767. import { Scene } from "babylonjs/scene";
  40768. import { Matrix } from "babylonjs/Maths/math.vector";
  40769. import { Color3 } from "babylonjs/Maths/math.color";
  40770. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40771. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40772. import { Mesh } from "babylonjs/Meshes/mesh";
  40773. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  40774. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40775. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  40776. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  40777. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  40778. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40779. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40780. import "babylonjs/Shaders/default.fragment";
  40781. import "babylonjs/Shaders/default.vertex";
  40782. /** @hidden */
  40783. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40784. MAINUV1: boolean;
  40785. MAINUV2: boolean;
  40786. DIFFUSE: boolean;
  40787. DIFFUSEDIRECTUV: number;
  40788. AMBIENT: boolean;
  40789. AMBIENTDIRECTUV: number;
  40790. OPACITY: boolean;
  40791. OPACITYDIRECTUV: number;
  40792. OPACITYRGB: boolean;
  40793. REFLECTION: boolean;
  40794. EMISSIVE: boolean;
  40795. EMISSIVEDIRECTUV: number;
  40796. SPECULAR: boolean;
  40797. SPECULARDIRECTUV: number;
  40798. BUMP: boolean;
  40799. BUMPDIRECTUV: number;
  40800. PARALLAX: boolean;
  40801. PARALLAXOCCLUSION: boolean;
  40802. SPECULAROVERALPHA: boolean;
  40803. CLIPPLANE: boolean;
  40804. CLIPPLANE2: boolean;
  40805. CLIPPLANE3: boolean;
  40806. CLIPPLANE4: boolean;
  40807. ALPHATEST: boolean;
  40808. DEPTHPREPASS: boolean;
  40809. ALPHAFROMDIFFUSE: boolean;
  40810. POINTSIZE: boolean;
  40811. FOG: boolean;
  40812. SPECULARTERM: boolean;
  40813. DIFFUSEFRESNEL: boolean;
  40814. OPACITYFRESNEL: boolean;
  40815. REFLECTIONFRESNEL: boolean;
  40816. REFRACTIONFRESNEL: boolean;
  40817. EMISSIVEFRESNEL: boolean;
  40818. FRESNEL: boolean;
  40819. NORMAL: boolean;
  40820. UV1: boolean;
  40821. UV2: boolean;
  40822. VERTEXCOLOR: boolean;
  40823. VERTEXALPHA: boolean;
  40824. NUM_BONE_INFLUENCERS: number;
  40825. BonesPerMesh: number;
  40826. BONETEXTURE: boolean;
  40827. INSTANCES: boolean;
  40828. GLOSSINESS: boolean;
  40829. ROUGHNESS: boolean;
  40830. EMISSIVEASILLUMINATION: boolean;
  40831. LINKEMISSIVEWITHDIFFUSE: boolean;
  40832. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40833. LIGHTMAP: boolean;
  40834. LIGHTMAPDIRECTUV: number;
  40835. OBJECTSPACE_NORMALMAP: boolean;
  40836. USELIGHTMAPASSHADOWMAP: boolean;
  40837. REFLECTIONMAP_3D: boolean;
  40838. REFLECTIONMAP_SPHERICAL: boolean;
  40839. REFLECTIONMAP_PLANAR: boolean;
  40840. REFLECTIONMAP_CUBIC: boolean;
  40841. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40842. REFLECTIONMAP_PROJECTION: boolean;
  40843. REFLECTIONMAP_SKYBOX: boolean;
  40844. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40845. REFLECTIONMAP_EXPLICIT: boolean;
  40846. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40847. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40848. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40849. INVERTCUBICMAP: boolean;
  40850. LOGARITHMICDEPTH: boolean;
  40851. REFRACTION: boolean;
  40852. REFRACTIONMAP_3D: boolean;
  40853. REFLECTIONOVERALPHA: boolean;
  40854. TWOSIDEDLIGHTING: boolean;
  40855. SHADOWFLOAT: boolean;
  40856. MORPHTARGETS: boolean;
  40857. MORPHTARGETS_NORMAL: boolean;
  40858. MORPHTARGETS_TANGENT: boolean;
  40859. MORPHTARGETS_UV: boolean;
  40860. NUM_MORPH_INFLUENCERS: number;
  40861. NONUNIFORMSCALING: boolean;
  40862. PREMULTIPLYALPHA: boolean;
  40863. IMAGEPROCESSING: boolean;
  40864. VIGNETTE: boolean;
  40865. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40866. VIGNETTEBLENDMODEOPAQUE: boolean;
  40867. TONEMAPPING: boolean;
  40868. TONEMAPPING_ACES: boolean;
  40869. CONTRAST: boolean;
  40870. COLORCURVES: boolean;
  40871. COLORGRADING: boolean;
  40872. COLORGRADING3D: boolean;
  40873. SAMPLER3DGREENDEPTH: boolean;
  40874. SAMPLER3DBGRMAP: boolean;
  40875. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40876. MULTIVIEW: boolean;
  40877. /**
  40878. * If the reflection texture on this material is in linear color space
  40879. * @hidden
  40880. */
  40881. IS_REFLECTION_LINEAR: boolean;
  40882. /**
  40883. * If the refraction texture on this material is in linear color space
  40884. * @hidden
  40885. */
  40886. IS_REFRACTION_LINEAR: boolean;
  40887. EXPOSURE: boolean;
  40888. constructor();
  40889. setReflectionMode(modeToEnable: string): void;
  40890. }
  40891. /**
  40892. * This is the default material used in Babylon. It is the best trade off between quality
  40893. * and performances.
  40894. * @see http://doc.babylonjs.com/babylon101/materials
  40895. */
  40896. export class StandardMaterial extends PushMaterial {
  40897. private _diffuseTexture;
  40898. /**
  40899. * The basic texture of the material as viewed under a light.
  40900. */
  40901. diffuseTexture: Nullable<BaseTexture>;
  40902. private _ambientTexture;
  40903. /**
  40904. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40905. */
  40906. ambientTexture: Nullable<BaseTexture>;
  40907. private _opacityTexture;
  40908. /**
  40909. * Define the transparency of the material from a texture.
  40910. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40911. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40912. */
  40913. opacityTexture: Nullable<BaseTexture>;
  40914. private _reflectionTexture;
  40915. /**
  40916. * Define the texture used to display the reflection.
  40917. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40918. */
  40919. reflectionTexture: Nullable<BaseTexture>;
  40920. private _emissiveTexture;
  40921. /**
  40922. * Define texture of the material as if self lit.
  40923. * This will be mixed in the final result even in the absence of light.
  40924. */
  40925. emissiveTexture: Nullable<BaseTexture>;
  40926. private _specularTexture;
  40927. /**
  40928. * Define how the color and intensity of the highlight given by the light in the material.
  40929. */
  40930. specularTexture: Nullable<BaseTexture>;
  40931. private _bumpTexture;
  40932. /**
  40933. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40934. * 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.
  40935. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40936. */
  40937. bumpTexture: Nullable<BaseTexture>;
  40938. private _lightmapTexture;
  40939. /**
  40940. * Complex lighting can be computationally expensive to compute at runtime.
  40941. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40942. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40943. */
  40944. lightmapTexture: Nullable<BaseTexture>;
  40945. private _refractionTexture;
  40946. /**
  40947. * Define the texture used to display the refraction.
  40948. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40949. */
  40950. refractionTexture: Nullable<BaseTexture>;
  40951. /**
  40952. * The color of the material lit by the environmental background lighting.
  40953. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40954. */
  40955. ambientColor: Color3;
  40956. /**
  40957. * The basic color of the material as viewed under a light.
  40958. */
  40959. diffuseColor: Color3;
  40960. /**
  40961. * Define how the color and intensity of the highlight given by the light in the material.
  40962. */
  40963. specularColor: Color3;
  40964. /**
  40965. * Define the color of the material as if self lit.
  40966. * This will be mixed in the final result even in the absence of light.
  40967. */
  40968. emissiveColor: Color3;
  40969. /**
  40970. * Defines how sharp are the highlights in the material.
  40971. * The bigger the value the sharper giving a more glossy feeling to the result.
  40972. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40973. */
  40974. specularPower: number;
  40975. private _useAlphaFromDiffuseTexture;
  40976. /**
  40977. * Does the transparency come from the diffuse texture alpha channel.
  40978. */
  40979. useAlphaFromDiffuseTexture: boolean;
  40980. private _useEmissiveAsIllumination;
  40981. /**
  40982. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40983. */
  40984. useEmissiveAsIllumination: boolean;
  40985. private _linkEmissiveWithDiffuse;
  40986. /**
  40987. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40988. * the emissive level when the final color is close to one.
  40989. */
  40990. linkEmissiveWithDiffuse: boolean;
  40991. private _useSpecularOverAlpha;
  40992. /**
  40993. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40994. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40995. */
  40996. useSpecularOverAlpha: boolean;
  40997. private _useReflectionOverAlpha;
  40998. /**
  40999. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41000. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41001. */
  41002. useReflectionOverAlpha: boolean;
  41003. private _disableLighting;
  41004. /**
  41005. * Does lights from the scene impacts this material.
  41006. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41007. */
  41008. disableLighting: boolean;
  41009. private _useObjectSpaceNormalMap;
  41010. /**
  41011. * Allows using an object space normal map (instead of tangent space).
  41012. */
  41013. useObjectSpaceNormalMap: boolean;
  41014. private _useParallax;
  41015. /**
  41016. * Is parallax enabled or not.
  41017. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41018. */
  41019. useParallax: boolean;
  41020. private _useParallaxOcclusion;
  41021. /**
  41022. * Is parallax occlusion enabled or not.
  41023. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41024. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41025. */
  41026. useParallaxOcclusion: boolean;
  41027. /**
  41028. * 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.
  41029. */
  41030. parallaxScaleBias: number;
  41031. private _roughness;
  41032. /**
  41033. * Helps to define how blurry the reflections should appears in the material.
  41034. */
  41035. roughness: number;
  41036. /**
  41037. * In case of refraction, define the value of the index of refraction.
  41038. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41039. */
  41040. indexOfRefraction: number;
  41041. /**
  41042. * Invert the refraction texture alongside the y axis.
  41043. * It can be useful with procedural textures or probe for instance.
  41044. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41045. */
  41046. invertRefractionY: boolean;
  41047. /**
  41048. * Defines the alpha limits in alpha test mode.
  41049. */
  41050. alphaCutOff: number;
  41051. private _useLightmapAsShadowmap;
  41052. /**
  41053. * In case of light mapping, define whether the map contains light or shadow informations.
  41054. */
  41055. useLightmapAsShadowmap: boolean;
  41056. private _diffuseFresnelParameters;
  41057. /**
  41058. * Define the diffuse fresnel parameters of the material.
  41059. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41060. */
  41061. diffuseFresnelParameters: FresnelParameters;
  41062. private _opacityFresnelParameters;
  41063. /**
  41064. * Define the opacity fresnel parameters of the material.
  41065. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41066. */
  41067. opacityFresnelParameters: FresnelParameters;
  41068. private _reflectionFresnelParameters;
  41069. /**
  41070. * Define the reflection fresnel parameters of the material.
  41071. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41072. */
  41073. reflectionFresnelParameters: FresnelParameters;
  41074. private _refractionFresnelParameters;
  41075. /**
  41076. * Define the refraction fresnel parameters of the material.
  41077. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41078. */
  41079. refractionFresnelParameters: FresnelParameters;
  41080. private _emissiveFresnelParameters;
  41081. /**
  41082. * Define the emissive fresnel parameters of the material.
  41083. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41084. */
  41085. emissiveFresnelParameters: FresnelParameters;
  41086. private _useReflectionFresnelFromSpecular;
  41087. /**
  41088. * If true automatically deducts the fresnels values from the material specularity.
  41089. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41090. */
  41091. useReflectionFresnelFromSpecular: boolean;
  41092. private _useGlossinessFromSpecularMapAlpha;
  41093. /**
  41094. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41095. */
  41096. useGlossinessFromSpecularMapAlpha: boolean;
  41097. private _maxSimultaneousLights;
  41098. /**
  41099. * Defines the maximum number of lights that can be used in the material
  41100. */
  41101. maxSimultaneousLights: number;
  41102. private _invertNormalMapX;
  41103. /**
  41104. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41105. */
  41106. invertNormalMapX: boolean;
  41107. private _invertNormalMapY;
  41108. /**
  41109. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41110. */
  41111. invertNormalMapY: boolean;
  41112. private _twoSidedLighting;
  41113. /**
  41114. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41115. */
  41116. twoSidedLighting: boolean;
  41117. /**
  41118. * Default configuration related to image processing available in the standard Material.
  41119. */
  41120. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41121. /**
  41122. * Gets the image processing configuration used either in this material.
  41123. */
  41124. /**
  41125. * Sets the Default image processing configuration used either in the this material.
  41126. *
  41127. * If sets to null, the scene one is in use.
  41128. */
  41129. imageProcessingConfiguration: ImageProcessingConfiguration;
  41130. /**
  41131. * Keep track of the image processing observer to allow dispose and replace.
  41132. */
  41133. private _imageProcessingObserver;
  41134. /**
  41135. * Attaches a new image processing configuration to the Standard Material.
  41136. * @param configuration
  41137. */
  41138. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41139. /**
  41140. * Gets wether the color curves effect is enabled.
  41141. */
  41142. /**
  41143. * Sets wether the color curves effect is enabled.
  41144. */
  41145. cameraColorCurvesEnabled: boolean;
  41146. /**
  41147. * Gets wether the color grading effect is enabled.
  41148. */
  41149. /**
  41150. * Gets wether the color grading effect is enabled.
  41151. */
  41152. cameraColorGradingEnabled: boolean;
  41153. /**
  41154. * Gets wether tonemapping is enabled or not.
  41155. */
  41156. /**
  41157. * Sets wether tonemapping is enabled or not
  41158. */
  41159. cameraToneMappingEnabled: boolean;
  41160. /**
  41161. * The camera exposure used on this material.
  41162. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41163. * This corresponds to a photographic exposure.
  41164. */
  41165. /**
  41166. * The camera exposure used on this material.
  41167. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41168. * This corresponds to a photographic exposure.
  41169. */
  41170. cameraExposure: number;
  41171. /**
  41172. * Gets The camera contrast used on this material.
  41173. */
  41174. /**
  41175. * Sets The camera contrast used on this material.
  41176. */
  41177. cameraContrast: number;
  41178. /**
  41179. * Gets the Color Grading 2D Lookup Texture.
  41180. */
  41181. /**
  41182. * Sets the Color Grading 2D Lookup Texture.
  41183. */
  41184. cameraColorGradingTexture: Nullable<BaseTexture>;
  41185. /**
  41186. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41187. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41188. * 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;
  41189. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41190. */
  41191. /**
  41192. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41193. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41194. * 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;
  41195. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41196. */
  41197. cameraColorCurves: Nullable<ColorCurves>;
  41198. /**
  41199. * Custom callback helping to override the default shader used in the material.
  41200. */
  41201. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41202. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41203. protected _worldViewProjectionMatrix: Matrix;
  41204. protected _globalAmbientColor: Color3;
  41205. protected _useLogarithmicDepth: boolean;
  41206. /**
  41207. * Instantiates a new standard material.
  41208. * This is the default material used in Babylon. It is the best trade off between quality
  41209. * and performances.
  41210. * @see http://doc.babylonjs.com/babylon101/materials
  41211. * @param name Define the name of the material in the scene
  41212. * @param scene Define the scene the material belong to
  41213. */
  41214. constructor(name: string, scene: Scene);
  41215. /**
  41216. * Gets a boolean indicating that current material needs to register RTT
  41217. */
  41218. readonly hasRenderTargetTextures: boolean;
  41219. /**
  41220. * Gets the current class name of the material e.g. "StandardMaterial"
  41221. * Mainly use in serialization.
  41222. * @returns the class name
  41223. */
  41224. getClassName(): string;
  41225. /**
  41226. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41227. * You can try switching to logarithmic depth.
  41228. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41229. */
  41230. useLogarithmicDepth: boolean;
  41231. /**
  41232. * Specifies if the material will require alpha blending
  41233. * @returns a boolean specifying if alpha blending is needed
  41234. */
  41235. needAlphaBlending(): boolean;
  41236. /**
  41237. * Specifies if this material should be rendered in alpha test mode
  41238. * @returns a boolean specifying if an alpha test is needed.
  41239. */
  41240. needAlphaTesting(): boolean;
  41241. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41242. /**
  41243. * Get the texture used for alpha test purpose.
  41244. * @returns the diffuse texture in case of the standard material.
  41245. */
  41246. getAlphaTestTexture(): Nullable<BaseTexture>;
  41247. /**
  41248. * Get if the submesh is ready to be used and all its information available.
  41249. * Child classes can use it to update shaders
  41250. * @param mesh defines the mesh to check
  41251. * @param subMesh defines which submesh to check
  41252. * @param useInstances specifies that instances should be used
  41253. * @returns a boolean indicating that the submesh is ready or not
  41254. */
  41255. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41256. /**
  41257. * Builds the material UBO layouts.
  41258. * Used internally during the effect preparation.
  41259. */
  41260. buildUniformLayout(): void;
  41261. /**
  41262. * Unbinds the material from the mesh
  41263. */
  41264. unbind(): void;
  41265. /**
  41266. * Binds the submesh to this material by preparing the effect and shader to draw
  41267. * @param world defines the world transformation matrix
  41268. * @param mesh defines the mesh containing the submesh
  41269. * @param subMesh defines the submesh to bind the material to
  41270. */
  41271. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41272. /**
  41273. * Get the list of animatables in the material.
  41274. * @returns the list of animatables object used in the material
  41275. */
  41276. getAnimatables(): IAnimatable[];
  41277. /**
  41278. * Gets the active textures from the material
  41279. * @returns an array of textures
  41280. */
  41281. getActiveTextures(): BaseTexture[];
  41282. /**
  41283. * Specifies if the material uses a texture
  41284. * @param texture defines the texture to check against the material
  41285. * @returns a boolean specifying if the material uses the texture
  41286. */
  41287. hasTexture(texture: BaseTexture): boolean;
  41288. /**
  41289. * Disposes the material
  41290. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41291. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41292. */
  41293. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41294. /**
  41295. * Makes a duplicate of the material, and gives it a new name
  41296. * @param name defines the new name for the duplicated material
  41297. * @returns the cloned material
  41298. */
  41299. clone(name: string): StandardMaterial;
  41300. /**
  41301. * Serializes this material in a JSON representation
  41302. * @returns the serialized material object
  41303. */
  41304. serialize(): any;
  41305. /**
  41306. * Creates a standard material from parsed material data
  41307. * @param source defines the JSON representation of the material
  41308. * @param scene defines the hosting scene
  41309. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41310. * @returns a new standard material
  41311. */
  41312. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41313. /**
  41314. * Are diffuse textures enabled in the application.
  41315. */
  41316. static DiffuseTextureEnabled: boolean;
  41317. /**
  41318. * Are ambient textures enabled in the application.
  41319. */
  41320. static AmbientTextureEnabled: boolean;
  41321. /**
  41322. * Are opacity textures enabled in the application.
  41323. */
  41324. static OpacityTextureEnabled: boolean;
  41325. /**
  41326. * Are reflection textures enabled in the application.
  41327. */
  41328. static ReflectionTextureEnabled: boolean;
  41329. /**
  41330. * Are emissive textures enabled in the application.
  41331. */
  41332. static EmissiveTextureEnabled: boolean;
  41333. /**
  41334. * Are specular textures enabled in the application.
  41335. */
  41336. static SpecularTextureEnabled: boolean;
  41337. /**
  41338. * Are bump textures enabled in the application.
  41339. */
  41340. static BumpTextureEnabled: boolean;
  41341. /**
  41342. * Are lightmap textures enabled in the application.
  41343. */
  41344. static LightmapTextureEnabled: boolean;
  41345. /**
  41346. * Are refraction textures enabled in the application.
  41347. */
  41348. static RefractionTextureEnabled: boolean;
  41349. /**
  41350. * Are color grading textures enabled in the application.
  41351. */
  41352. static ColorGradingTextureEnabled: boolean;
  41353. /**
  41354. * Are fresnels enabled in the application.
  41355. */
  41356. static FresnelEnabled: boolean;
  41357. }
  41358. }
  41359. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  41360. import { Scene } from "babylonjs/scene";
  41361. import { Texture } from "babylonjs/Materials/Textures/texture";
  41362. /**
  41363. * A class extending Texture allowing drawing on a texture
  41364. * @see http://doc.babylonjs.com/how_to/dynamictexture
  41365. */
  41366. export class DynamicTexture extends Texture {
  41367. private _generateMipMaps;
  41368. private _canvas;
  41369. private _context;
  41370. private _engine;
  41371. /**
  41372. * Creates a DynamicTexture
  41373. * @param name defines the name of the texture
  41374. * @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
  41375. * @param scene defines the scene where you want the texture
  41376. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  41377. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  41378. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  41379. */
  41380. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  41381. /**
  41382. * Get the current class name of the texture useful for serialization or dynamic coding.
  41383. * @returns "DynamicTexture"
  41384. */
  41385. getClassName(): string;
  41386. /**
  41387. * Gets the current state of canRescale
  41388. */
  41389. readonly canRescale: boolean;
  41390. private _recreate;
  41391. /**
  41392. * Scales the texture
  41393. * @param ratio the scale factor to apply to both width and height
  41394. */
  41395. scale(ratio: number): void;
  41396. /**
  41397. * Resizes the texture
  41398. * @param width the new width
  41399. * @param height the new height
  41400. */
  41401. scaleTo(width: number, height: number): void;
  41402. /**
  41403. * Gets the context of the canvas used by the texture
  41404. * @returns the canvas context of the dynamic texture
  41405. */
  41406. getContext(): CanvasRenderingContext2D;
  41407. /**
  41408. * Clears the texture
  41409. */
  41410. clear(): void;
  41411. /**
  41412. * Updates the texture
  41413. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41414. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41415. */
  41416. update(invertY?: boolean, premulAlpha?: boolean): void;
  41417. /**
  41418. * Draws text onto the texture
  41419. * @param text defines the text to be drawn
  41420. * @param x defines the placement of the text from the left
  41421. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41422. * @param font defines the font to be used with font-style, font-size, font-name
  41423. * @param color defines the color used for the text
  41424. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41425. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41426. * @param update defines whether texture is immediately update (default is true)
  41427. */
  41428. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41429. /**
  41430. * Clones the texture
  41431. * @returns the clone of the texture.
  41432. */
  41433. clone(): DynamicTexture;
  41434. /**
  41435. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41436. * @returns a serialized dynamic texture object
  41437. */
  41438. serialize(): any;
  41439. /** @hidden */
  41440. _rebuild(): void;
  41441. }
  41442. }
  41443. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41444. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41445. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41446. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41447. /** @hidden */
  41448. export var imageProcessingPixelShader: {
  41449. name: string;
  41450. shader: string;
  41451. };
  41452. }
  41453. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41454. import { Nullable } from "babylonjs/types";
  41455. import { Color4 } from "babylonjs/Maths/math.color";
  41456. import { Camera } from "babylonjs/Cameras/camera";
  41457. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41458. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41459. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41460. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41461. import { Engine } from "babylonjs/Engines/engine";
  41462. import "babylonjs/Shaders/imageProcessing.fragment";
  41463. import "babylonjs/Shaders/postprocess.vertex";
  41464. /**
  41465. * ImageProcessingPostProcess
  41466. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41467. */
  41468. export class ImageProcessingPostProcess extends PostProcess {
  41469. /**
  41470. * Default configuration related to image processing available in the PBR Material.
  41471. */
  41472. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41473. /**
  41474. * Gets the image processing configuration used either in this material.
  41475. */
  41476. /**
  41477. * Sets the Default image processing configuration used either in the this material.
  41478. *
  41479. * If sets to null, the scene one is in use.
  41480. */
  41481. imageProcessingConfiguration: ImageProcessingConfiguration;
  41482. /**
  41483. * Keep track of the image processing observer to allow dispose and replace.
  41484. */
  41485. private _imageProcessingObserver;
  41486. /**
  41487. * Attaches a new image processing configuration to the PBR Material.
  41488. * @param configuration
  41489. */
  41490. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41491. /**
  41492. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41493. */
  41494. /**
  41495. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41496. */
  41497. colorCurves: Nullable<ColorCurves>;
  41498. /**
  41499. * Gets wether the color curves effect is enabled.
  41500. */
  41501. /**
  41502. * Sets wether the color curves effect is enabled.
  41503. */
  41504. colorCurvesEnabled: boolean;
  41505. /**
  41506. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41507. */
  41508. /**
  41509. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41510. */
  41511. colorGradingTexture: Nullable<BaseTexture>;
  41512. /**
  41513. * Gets wether the color grading effect is enabled.
  41514. */
  41515. /**
  41516. * Gets wether the color grading effect is enabled.
  41517. */
  41518. colorGradingEnabled: boolean;
  41519. /**
  41520. * Gets exposure used in the effect.
  41521. */
  41522. /**
  41523. * Sets exposure used in the effect.
  41524. */
  41525. exposure: number;
  41526. /**
  41527. * Gets wether tonemapping is enabled or not.
  41528. */
  41529. /**
  41530. * Sets wether tonemapping is enabled or not
  41531. */
  41532. toneMappingEnabled: boolean;
  41533. /**
  41534. * Gets the type of tone mapping effect.
  41535. */
  41536. /**
  41537. * Sets the type of tone mapping effect.
  41538. */
  41539. toneMappingType: number;
  41540. /**
  41541. * Gets contrast used in the effect.
  41542. */
  41543. /**
  41544. * Sets contrast used in the effect.
  41545. */
  41546. contrast: number;
  41547. /**
  41548. * Gets Vignette stretch size.
  41549. */
  41550. /**
  41551. * Sets Vignette stretch size.
  41552. */
  41553. vignetteStretch: number;
  41554. /**
  41555. * Gets Vignette centre X Offset.
  41556. */
  41557. /**
  41558. * Sets Vignette centre X Offset.
  41559. */
  41560. vignetteCentreX: number;
  41561. /**
  41562. * Gets Vignette centre Y Offset.
  41563. */
  41564. /**
  41565. * Sets Vignette centre Y Offset.
  41566. */
  41567. vignetteCentreY: number;
  41568. /**
  41569. * Gets Vignette weight or intensity of the vignette effect.
  41570. */
  41571. /**
  41572. * Sets Vignette weight or intensity of the vignette effect.
  41573. */
  41574. vignetteWeight: number;
  41575. /**
  41576. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41577. * if vignetteEnabled is set to true.
  41578. */
  41579. /**
  41580. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41581. * if vignetteEnabled is set to true.
  41582. */
  41583. vignetteColor: Color4;
  41584. /**
  41585. * Gets Camera field of view used by the Vignette effect.
  41586. */
  41587. /**
  41588. * Sets Camera field of view used by the Vignette effect.
  41589. */
  41590. vignetteCameraFov: number;
  41591. /**
  41592. * Gets the vignette blend mode allowing different kind of effect.
  41593. */
  41594. /**
  41595. * Sets the vignette blend mode allowing different kind of effect.
  41596. */
  41597. vignetteBlendMode: number;
  41598. /**
  41599. * Gets wether the vignette effect is enabled.
  41600. */
  41601. /**
  41602. * Sets wether the vignette effect is enabled.
  41603. */
  41604. vignetteEnabled: boolean;
  41605. private _fromLinearSpace;
  41606. /**
  41607. * Gets wether the input of the processing is in Gamma or Linear Space.
  41608. */
  41609. /**
  41610. * Sets wether the input of the processing is in Gamma or Linear Space.
  41611. */
  41612. fromLinearSpace: boolean;
  41613. /**
  41614. * Defines cache preventing GC.
  41615. */
  41616. private _defines;
  41617. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41618. /**
  41619. * "ImageProcessingPostProcess"
  41620. * @returns "ImageProcessingPostProcess"
  41621. */
  41622. getClassName(): string;
  41623. protected _updateParameters(): void;
  41624. dispose(camera?: Camera): void;
  41625. }
  41626. }
  41627. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  41628. import { Scene } from "babylonjs/scene";
  41629. import { Color3 } from "babylonjs/Maths/math.color";
  41630. import { Mesh } from "babylonjs/Meshes/mesh";
  41631. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  41632. import { Nullable } from "babylonjs/types";
  41633. /**
  41634. * Class containing static functions to help procedurally build meshes
  41635. */
  41636. export class GroundBuilder {
  41637. /**
  41638. * Creates a ground mesh
  41639. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41640. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41642. * @param name defines the name of the mesh
  41643. * @param options defines the options used to create the mesh
  41644. * @param scene defines the hosting scene
  41645. * @returns the ground mesh
  41646. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41647. */
  41648. static CreateGround(name: string, options: {
  41649. width?: number;
  41650. height?: number;
  41651. subdivisions?: number;
  41652. subdivisionsX?: number;
  41653. subdivisionsY?: number;
  41654. updatable?: boolean;
  41655. }, scene: any): Mesh;
  41656. /**
  41657. * Creates a tiled ground mesh
  41658. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41659. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41660. * * 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
  41661. * * 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
  41662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41663. * @param name defines the name of the mesh
  41664. * @param options defines the options used to create the mesh
  41665. * @param scene defines the hosting scene
  41666. * @returns the tiled ground mesh
  41667. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41668. */
  41669. static CreateTiledGround(name: string, options: {
  41670. xmin: number;
  41671. zmin: number;
  41672. xmax: number;
  41673. zmax: number;
  41674. subdivisions?: {
  41675. w: number;
  41676. h: number;
  41677. };
  41678. precision?: {
  41679. w: number;
  41680. h: number;
  41681. };
  41682. updatable?: boolean;
  41683. }, scene?: Nullable<Scene>): Mesh;
  41684. /**
  41685. * Creates a ground mesh from a height map
  41686. * * The parameter `url` sets the URL of the height map image resource.
  41687. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41688. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41689. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41690. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41691. * * 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.
  41692. * * 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).
  41693. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41695. * @param name defines the name of the mesh
  41696. * @param url defines the url to the height map
  41697. * @param options defines the options used to create the mesh
  41698. * @param scene defines the hosting scene
  41699. * @returns the ground mesh
  41700. * @see https://doc.babylonjs.com/babylon101/height_map
  41701. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41702. */
  41703. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41704. width?: number;
  41705. height?: number;
  41706. subdivisions?: number;
  41707. minHeight?: number;
  41708. maxHeight?: number;
  41709. colorFilter?: Color3;
  41710. alphaFilter?: number;
  41711. updatable?: boolean;
  41712. onReady?: (mesh: GroundMesh) => void;
  41713. }, scene?: Nullable<Scene>): GroundMesh;
  41714. }
  41715. }
  41716. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  41717. import { Vector4 } from "babylonjs/Maths/math.vector";
  41718. import { Mesh } from "babylonjs/Meshes/mesh";
  41719. /**
  41720. * Class containing static functions to help procedurally build meshes
  41721. */
  41722. export class TorusBuilder {
  41723. /**
  41724. * Creates a torus mesh
  41725. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41726. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41727. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41728. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41729. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41731. * @param name defines the name of the mesh
  41732. * @param options defines the options used to create the mesh
  41733. * @param scene defines the hosting scene
  41734. * @returns the torus mesh
  41735. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41736. */
  41737. static CreateTorus(name: string, options: {
  41738. diameter?: number;
  41739. thickness?: number;
  41740. tessellation?: number;
  41741. updatable?: boolean;
  41742. sideOrientation?: number;
  41743. frontUVs?: Vector4;
  41744. backUVs?: Vector4;
  41745. }, scene: any): Mesh;
  41746. }
  41747. }
  41748. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  41749. import { Vector4 } from "babylonjs/Maths/math.vector";
  41750. import { Color4 } from "babylonjs/Maths/math.color";
  41751. import { Mesh } from "babylonjs/Meshes/mesh";
  41752. /**
  41753. * Class containing static functions to help procedurally build meshes
  41754. */
  41755. export class CylinderBuilder {
  41756. /**
  41757. * Creates a cylinder or a cone mesh
  41758. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41759. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41760. * * 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.
  41761. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41762. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41763. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41764. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41765. * * 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).
  41766. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41767. * * 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).
  41768. * * 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
  41769. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41770. * * 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
  41771. * * 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.
  41772. * * If `enclose` is false, a ring surface is one element.
  41773. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41774. * * 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
  41775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41776. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41778. * @param name defines the name of the mesh
  41779. * @param options defines the options used to create the mesh
  41780. * @param scene defines the hosting scene
  41781. * @returns the cylinder mesh
  41782. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41783. */
  41784. static CreateCylinder(name: string, options: {
  41785. height?: number;
  41786. diameterTop?: number;
  41787. diameterBottom?: number;
  41788. diameter?: number;
  41789. tessellation?: number;
  41790. subdivisions?: number;
  41791. arc?: number;
  41792. faceColors?: Color4[];
  41793. faceUV?: Vector4[];
  41794. updatable?: boolean;
  41795. hasRings?: boolean;
  41796. enclose?: boolean;
  41797. cap?: number;
  41798. sideOrientation?: number;
  41799. frontUVs?: Vector4;
  41800. backUVs?: Vector4;
  41801. }, scene: any): Mesh;
  41802. }
  41803. }
  41804. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  41805. import { Observable } from "babylonjs/Misc/observable";
  41806. import { Nullable } from "babylonjs/types";
  41807. import { Camera } from "babylonjs/Cameras/camera";
  41808. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41809. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41810. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  41811. import { Scene } from "babylonjs/scene";
  41812. import { Vector3 } from "babylonjs/Maths/math.vector";
  41813. import { Color3 } from "babylonjs/Maths/math.color";
  41814. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  41815. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41816. import { Mesh } from "babylonjs/Meshes/mesh";
  41817. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  41818. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41819. import "babylonjs/Meshes/Builders/groundBuilder";
  41820. import "babylonjs/Meshes/Builders/torusBuilder";
  41821. import "babylonjs/Meshes/Builders/cylinderBuilder";
  41822. import "babylonjs/Gamepads/gamepadSceneComponent";
  41823. import "babylonjs/Animations/animatable";
  41824. /**
  41825. * Options to modify the vr teleportation behavior.
  41826. */
  41827. export interface VRTeleportationOptions {
  41828. /**
  41829. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41830. */
  41831. floorMeshName?: string;
  41832. /**
  41833. * A list of meshes to be used as the teleportation floor. (default: empty)
  41834. */
  41835. floorMeshes?: Mesh[];
  41836. }
  41837. /**
  41838. * Options to modify the vr experience helper's behavior.
  41839. */
  41840. export interface VRExperienceHelperOptions extends WebVROptions {
  41841. /**
  41842. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41843. */
  41844. createDeviceOrientationCamera?: boolean;
  41845. /**
  41846. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41847. */
  41848. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41849. /**
  41850. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41851. */
  41852. laserToggle?: boolean;
  41853. /**
  41854. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41855. */
  41856. floorMeshes?: Mesh[];
  41857. /**
  41858. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41859. */
  41860. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41861. }
  41862. /**
  41863. * Event containing information after VR has been entered
  41864. */
  41865. export class OnAfterEnteringVRObservableEvent {
  41866. /**
  41867. * If entering vr was successful
  41868. */
  41869. success: boolean;
  41870. }
  41871. /**
  41872. * Helps to quickly add VR support to an existing scene.
  41873. * See http://doc.babylonjs.com/how_to/webvr_helper
  41874. */
  41875. export class VRExperienceHelper {
  41876. /** Options to modify the vr experience helper's behavior. */
  41877. webVROptions: VRExperienceHelperOptions;
  41878. private _scene;
  41879. private _position;
  41880. private _btnVR;
  41881. private _btnVRDisplayed;
  41882. private _webVRsupported;
  41883. private _webVRready;
  41884. private _webVRrequesting;
  41885. private _webVRpresenting;
  41886. private _hasEnteredVR;
  41887. private _fullscreenVRpresenting;
  41888. private _canvas;
  41889. private _webVRCamera;
  41890. private _vrDeviceOrientationCamera;
  41891. private _deviceOrientationCamera;
  41892. private _existingCamera;
  41893. private _onKeyDown;
  41894. private _onVrDisplayPresentChange;
  41895. private _onVRDisplayChanged;
  41896. private _onVRRequestPresentStart;
  41897. private _onVRRequestPresentComplete;
  41898. /**
  41899. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  41900. */
  41901. enableGazeEvenWhenNoPointerLock: boolean;
  41902. /**
  41903. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  41904. */
  41905. exitVROnDoubleTap: boolean;
  41906. /**
  41907. * Observable raised right before entering VR.
  41908. */
  41909. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41910. /**
  41911. * Observable raised when entering VR has completed.
  41912. */
  41913. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41914. /**
  41915. * Observable raised when exiting VR.
  41916. */
  41917. onExitingVRObservable: Observable<VRExperienceHelper>;
  41918. /**
  41919. * Observable raised when controller mesh is loaded.
  41920. */
  41921. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41922. /** Return this.onEnteringVRObservable
  41923. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41924. */
  41925. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41926. /** Return this.onExitingVRObservable
  41927. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41928. */
  41929. readonly onExitingVR: Observable<VRExperienceHelper>;
  41930. /** Return this.onControllerMeshLoadedObservable
  41931. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41932. */
  41933. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41934. private _rayLength;
  41935. private _useCustomVRButton;
  41936. private _teleportationRequested;
  41937. private _teleportActive;
  41938. private _floorMeshName;
  41939. private _floorMeshesCollection;
  41940. private _rotationAllowed;
  41941. private _teleportBackwardsVector;
  41942. private _teleportationTarget;
  41943. private _isDefaultTeleportationTarget;
  41944. private _postProcessMove;
  41945. private _teleportationFillColor;
  41946. private _teleportationBorderColor;
  41947. private _rotationAngle;
  41948. private _haloCenter;
  41949. private _cameraGazer;
  41950. private _padSensibilityUp;
  41951. private _padSensibilityDown;
  41952. private _leftController;
  41953. private _rightController;
  41954. /**
  41955. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41956. */
  41957. onNewMeshSelected: Observable<AbstractMesh>;
  41958. /**
  41959. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41960. */
  41961. onNewMeshPicked: Observable<PickingInfo>;
  41962. private _circleEase;
  41963. /**
  41964. * Observable raised before camera teleportation
  41965. */
  41966. onBeforeCameraTeleport: Observable<Vector3>;
  41967. /**
  41968. * Observable raised after camera teleportation
  41969. */
  41970. onAfterCameraTeleport: Observable<Vector3>;
  41971. /**
  41972. * Observable raised when current selected mesh gets unselected
  41973. */
  41974. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41975. private _raySelectionPredicate;
  41976. /**
  41977. * To be optionaly changed by user to define custom ray selection
  41978. */
  41979. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41980. /**
  41981. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41982. */
  41983. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41984. /**
  41985. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41986. */
  41987. teleportationEnabled: boolean;
  41988. private _defaultHeight;
  41989. private _teleportationInitialized;
  41990. private _interactionsEnabled;
  41991. private _interactionsRequested;
  41992. private _displayGaze;
  41993. private _displayLaserPointer;
  41994. /**
  41995. * The mesh used to display where the user is going to teleport.
  41996. */
  41997. /**
  41998. * Sets the mesh to be used to display where the user is going to teleport.
  41999. */
  42000. teleportationTarget: Mesh;
  42001. /**
  42002. * 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
  42003. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42004. * See http://doc.babylonjs.com/resources/baking_transformations
  42005. */
  42006. gazeTrackerMesh: Mesh;
  42007. /**
  42008. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42009. */
  42010. updateGazeTrackerScale: boolean;
  42011. /**
  42012. * If the gaze trackers color should be updated when selecting meshes
  42013. */
  42014. updateGazeTrackerColor: boolean;
  42015. /**
  42016. * The gaze tracking mesh corresponding to the left controller
  42017. */
  42018. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42019. /**
  42020. * The gaze tracking mesh corresponding to the right controller
  42021. */
  42022. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42023. /**
  42024. * If the ray of the gaze should be displayed.
  42025. */
  42026. /**
  42027. * Sets if the ray of the gaze should be displayed.
  42028. */
  42029. displayGaze: boolean;
  42030. /**
  42031. * If the ray of the LaserPointer should be displayed.
  42032. */
  42033. /**
  42034. * Sets if the ray of the LaserPointer should be displayed.
  42035. */
  42036. displayLaserPointer: boolean;
  42037. /**
  42038. * The deviceOrientationCamera used as the camera when not in VR.
  42039. */
  42040. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42041. /**
  42042. * Based on the current WebVR support, returns the current VR camera used.
  42043. */
  42044. readonly currentVRCamera: Nullable<Camera>;
  42045. /**
  42046. * The webVRCamera which is used when in VR.
  42047. */
  42048. readonly webVRCamera: WebVRFreeCamera;
  42049. /**
  42050. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42051. */
  42052. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42053. /**
  42054. * The html button that is used to trigger entering into VR.
  42055. */
  42056. readonly vrButton: Nullable<HTMLButtonElement>;
  42057. private readonly _teleportationRequestInitiated;
  42058. /**
  42059. * Defines wether or not Pointer lock should be requested when switching to
  42060. * full screen.
  42061. */
  42062. requestPointerLockOnFullScreen: boolean;
  42063. /**
  42064. * Instantiates a VRExperienceHelper.
  42065. * Helps to quickly add VR support to an existing scene.
  42066. * @param scene The scene the VRExperienceHelper belongs to.
  42067. * @param webVROptions Options to modify the vr experience helper's behavior.
  42068. */
  42069. constructor(scene: Scene,
  42070. /** Options to modify the vr experience helper's behavior. */
  42071. webVROptions?: VRExperienceHelperOptions);
  42072. private _onDefaultMeshLoaded;
  42073. private _onResize;
  42074. private _onFullscreenChange;
  42075. /**
  42076. * Gets a value indicating if we are currently in VR mode.
  42077. */
  42078. readonly isInVRMode: boolean;
  42079. private onVrDisplayPresentChange;
  42080. private onVRDisplayChanged;
  42081. private moveButtonToBottomRight;
  42082. private displayVRButton;
  42083. private updateButtonVisibility;
  42084. private _cachedAngularSensibility;
  42085. /**
  42086. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42087. * Otherwise, will use the fullscreen API.
  42088. */
  42089. enterVR(): void;
  42090. /**
  42091. * Attempt to exit VR, or fullscreen.
  42092. */
  42093. exitVR(): void;
  42094. /**
  42095. * The position of the vr experience helper.
  42096. */
  42097. /**
  42098. * Sets the position of the vr experience helper.
  42099. */
  42100. position: Vector3;
  42101. /**
  42102. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42103. */
  42104. enableInteractions(): void;
  42105. private readonly _noControllerIsActive;
  42106. private beforeRender;
  42107. private _isTeleportationFloor;
  42108. /**
  42109. * Adds a floor mesh to be used for teleportation.
  42110. * @param floorMesh the mesh to be used for teleportation.
  42111. */
  42112. addFloorMesh(floorMesh: Mesh): void;
  42113. /**
  42114. * Removes a floor mesh from being used for teleportation.
  42115. * @param floorMesh the mesh to be removed.
  42116. */
  42117. removeFloorMesh(floorMesh: Mesh): void;
  42118. /**
  42119. * Enables interactions and teleportation using the VR controllers and gaze.
  42120. * @param vrTeleportationOptions options to modify teleportation behavior.
  42121. */
  42122. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42123. private _onNewGamepadConnected;
  42124. private _tryEnableInteractionOnController;
  42125. private _onNewGamepadDisconnected;
  42126. private _enableInteractionOnController;
  42127. private _checkTeleportWithRay;
  42128. private _checkRotate;
  42129. private _checkTeleportBackwards;
  42130. private _enableTeleportationOnController;
  42131. private _createTeleportationCircles;
  42132. private _displayTeleportationTarget;
  42133. private _hideTeleportationTarget;
  42134. private _rotateCamera;
  42135. private _moveTeleportationSelectorTo;
  42136. private _workingVector;
  42137. private _workingQuaternion;
  42138. private _workingMatrix;
  42139. /**
  42140. * Teleports the users feet to the desired location
  42141. * @param location The location where the user's feet should be placed
  42142. */
  42143. teleportCamera(location: Vector3): void;
  42144. private _convertNormalToDirectionOfRay;
  42145. private _castRayAndSelectObject;
  42146. private _notifySelectedMeshUnselected;
  42147. /**
  42148. * Sets the color of the laser ray from the vr controllers.
  42149. * @param color new color for the ray.
  42150. */
  42151. changeLaserColor(color: Color3): void;
  42152. /**
  42153. * Sets the color of the ray from the vr headsets gaze.
  42154. * @param color new color for the ray.
  42155. */
  42156. changeGazeColor(color: Color3): void;
  42157. /**
  42158. * Exits VR and disposes of the vr experience helper
  42159. */
  42160. dispose(): void;
  42161. /**
  42162. * Gets the name of the VRExperienceHelper class
  42163. * @returns "VRExperienceHelper"
  42164. */
  42165. getClassName(): string;
  42166. }
  42167. }
  42168. declare module "babylonjs/Cameras/VR/index" {
  42169. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42170. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42171. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42172. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42173. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42174. export * from "babylonjs/Cameras/VR/webVRCamera";
  42175. }
  42176. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42177. import { Observable } from "babylonjs/Misc/observable";
  42178. import { Nullable } from "babylonjs/types";
  42179. import { IDisposable, Scene } from "babylonjs/scene";
  42180. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42181. /**
  42182. * Manages an XRSession to work with Babylon's engine
  42183. * @see https://doc.babylonjs.com/how_to/webxr
  42184. */
  42185. export class WebXRSessionManager implements IDisposable {
  42186. private scene;
  42187. /**
  42188. * Fires every time a new xrFrame arrives which can be used to update the camera
  42189. */
  42190. onXRFrameObservable: Observable<any>;
  42191. /**
  42192. * Fires when the xr session is ended either by the device or manually done
  42193. */
  42194. onXRSessionEnded: Observable<any>;
  42195. /**
  42196. * Underlying xr session
  42197. */
  42198. session: XRSession;
  42199. /**
  42200. * Type of reference space used when creating the session
  42201. */
  42202. referenceSpace: XRReferenceSpace;
  42203. /** @hidden */
  42204. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42205. /**
  42206. * Current XR frame
  42207. */
  42208. currentFrame: Nullable<XRFrame>;
  42209. private _xrNavigator;
  42210. private baseLayer;
  42211. /**
  42212. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42213. * @param scene The scene which the session should be created for
  42214. */
  42215. constructor(scene: Scene);
  42216. /**
  42217. * Initializes the manager
  42218. * After initialization enterXR can be called to start an XR session
  42219. * @returns Promise which resolves after it is initialized
  42220. */
  42221. initializeAsync(): Promise<void>;
  42222. /**
  42223. * Initializes an xr session
  42224. * @param xrSessionMode mode to initialize
  42225. * @returns a promise which will resolve once the session has been initialized
  42226. */
  42227. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42228. /**
  42229. * Sets the reference space on the xr session
  42230. * @param referenceSpace space to set
  42231. * @returns a promise that will resolve once the reference space has been set
  42232. */
  42233. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42234. /**
  42235. * Updates the render state of the session
  42236. * @param state state to set
  42237. * @returns a promise that resolves once the render state has been updated
  42238. */
  42239. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42240. /**
  42241. * Starts rendering to the xr layer
  42242. * @returns a promise that will resolve once rendering has started
  42243. */
  42244. startRenderingToXRAsync(): Promise<void>;
  42245. /**
  42246. * Stops the xrSession and restores the renderloop
  42247. * @returns Promise which resolves after it exits XR
  42248. */
  42249. exitXRAsync(): Promise<unknown>;
  42250. /**
  42251. * Checks if a session would be supported for the creation options specified
  42252. * @param sessionMode session mode to check if supported eg. immersive-vr
  42253. * @returns true if supported
  42254. */
  42255. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42256. /**
  42257. * @hidden
  42258. * Converts the render layer of xrSession to a render target
  42259. * @param session session to create render target for
  42260. * @param scene scene the new render target should be created for
  42261. */
  42262. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42263. /**
  42264. * Disposes of the session manager
  42265. */
  42266. dispose(): void;
  42267. }
  42268. }
  42269. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42270. import { Scene } from "babylonjs/scene";
  42271. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42272. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42273. /**
  42274. * WebXR Camera which holds the views for the xrSession
  42275. * @see https://doc.babylonjs.com/how_to/webxr
  42276. */
  42277. export class WebXRCamera extends FreeCamera {
  42278. private static _TmpMatrix;
  42279. /**
  42280. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42281. * @param name the name of the camera
  42282. * @param scene the scene to add the camera to
  42283. */
  42284. constructor(name: string, scene: Scene);
  42285. private _updateNumberOfRigCameras;
  42286. /** @hidden */
  42287. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42288. /**
  42289. * Updates the cameras position from the current pose information of the XR session
  42290. * @param xrSessionManager the session containing pose information
  42291. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42292. */
  42293. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42294. }
  42295. }
  42296. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42297. import { Nullable } from "babylonjs/types";
  42298. import { IDisposable } from "babylonjs/scene";
  42299. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42300. /**
  42301. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42302. */
  42303. export class WebXRManagedOutputCanvas implements IDisposable {
  42304. private helper;
  42305. private _canvas;
  42306. /**
  42307. * xrpresent context of the canvas which can be used to display/mirror xr content
  42308. */
  42309. canvasContext: WebGLRenderingContext;
  42310. /**
  42311. * xr layer for the canvas
  42312. */
  42313. xrLayer: Nullable<XRWebGLLayer>;
  42314. /**
  42315. * Initializes the xr layer for the session
  42316. * @param xrSession xr session
  42317. * @returns a promise that will resolve once the XR Layer has been created
  42318. */
  42319. initializeXRLayerAsync(xrSession: any): any;
  42320. /**
  42321. * Initializes the canvas to be added/removed upon entering/exiting xr
  42322. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42323. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42324. */
  42325. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42326. /**
  42327. * Disposes of the object
  42328. */
  42329. dispose(): void;
  42330. private _setManagedOutputCanvas;
  42331. private _addCanvas;
  42332. private _removeCanvas;
  42333. }
  42334. }
  42335. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42336. import { Observable } from "babylonjs/Misc/observable";
  42337. import { IDisposable, Scene } from "babylonjs/scene";
  42338. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42339. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42340. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42341. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42342. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42343. /**
  42344. * States of the webXR experience
  42345. */
  42346. export enum WebXRState {
  42347. /**
  42348. * Transitioning to being in XR mode
  42349. */
  42350. ENTERING_XR = 0,
  42351. /**
  42352. * Transitioning to non XR mode
  42353. */
  42354. EXITING_XR = 1,
  42355. /**
  42356. * In XR mode and presenting
  42357. */
  42358. IN_XR = 2,
  42359. /**
  42360. * Not entered XR mode
  42361. */
  42362. NOT_IN_XR = 3
  42363. }
  42364. /**
  42365. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42366. * @see https://doc.babylonjs.com/how_to/webxr
  42367. */
  42368. export class WebXRExperienceHelper implements IDisposable {
  42369. private scene;
  42370. /**
  42371. * 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
  42372. */
  42373. container: AbstractMesh;
  42374. /**
  42375. * Camera used to render xr content
  42376. */
  42377. camera: WebXRCamera;
  42378. /**
  42379. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42380. */
  42381. state: WebXRState;
  42382. private _setState;
  42383. private static _TmpVector;
  42384. /**
  42385. * Fires when the state of the experience helper has changed
  42386. */
  42387. onStateChangedObservable: Observable<WebXRState>;
  42388. /** Session manager used to keep track of xr session */
  42389. sessionManager: WebXRSessionManager;
  42390. private _nonVRCamera;
  42391. private _originalSceneAutoClear;
  42392. private _supported;
  42393. /**
  42394. * Creates the experience helper
  42395. * @param scene the scene to attach the experience helper to
  42396. * @returns a promise for the experience helper
  42397. */
  42398. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42399. /**
  42400. * Creates a WebXRExperienceHelper
  42401. * @param scene The scene the helper should be created in
  42402. */
  42403. private constructor();
  42404. /**
  42405. * Exits XR mode and returns the scene to its original state
  42406. * @returns promise that resolves after xr mode has exited
  42407. */
  42408. exitXRAsync(): Promise<unknown>;
  42409. /**
  42410. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42411. * @param sessionCreationOptions options for the XR session
  42412. * @param referenceSpaceType frame of reference of the XR session
  42413. * @param outputCanvas the output canvas that will be used to enter XR mode
  42414. * @returns promise that resolves after xr mode has entered
  42415. */
  42416. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42417. /**
  42418. * Updates the global position of the camera by moving the camera's container
  42419. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42420. * @param position The desired global position of the camera
  42421. */
  42422. setPositionOfCameraUsingContainer(position: Vector3): void;
  42423. /**
  42424. * Rotates the xr camera by rotating the camera's container around the camera's position
  42425. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42426. * @param rotation the desired quaternion rotation to apply to the camera
  42427. */
  42428. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42429. /**
  42430. * Disposes of the experience helper
  42431. */
  42432. dispose(): void;
  42433. }
  42434. }
  42435. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42436. import { Nullable } from "babylonjs/types";
  42437. import { Observable } from "babylonjs/Misc/observable";
  42438. import { IDisposable, Scene } from "babylonjs/scene";
  42439. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42440. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42441. /**
  42442. * Button which can be used to enter a different mode of XR
  42443. */
  42444. export class WebXREnterExitUIButton {
  42445. /** button element */
  42446. element: HTMLElement;
  42447. /** XR initialization options for the button */
  42448. sessionMode: XRSessionMode;
  42449. /** Reference space type */
  42450. referenceSpaceType: XRReferenceSpaceType;
  42451. /**
  42452. * Creates a WebXREnterExitUIButton
  42453. * @param element button element
  42454. * @param sessionMode XR initialization session mode
  42455. * @param referenceSpaceType the type of reference space to be used
  42456. */
  42457. constructor(
  42458. /** button element */
  42459. element: HTMLElement,
  42460. /** XR initialization options for the button */
  42461. sessionMode: XRSessionMode,
  42462. /** Reference space type */
  42463. referenceSpaceType: XRReferenceSpaceType);
  42464. /**
  42465. * Overwritable function which can be used to update the button's visuals when the state changes
  42466. * @param activeButton the current active button in the UI
  42467. */
  42468. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42469. }
  42470. /**
  42471. * Options to create the webXR UI
  42472. */
  42473. export class WebXREnterExitUIOptions {
  42474. /**
  42475. * Context to enter xr with
  42476. */
  42477. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42478. /**
  42479. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42480. */
  42481. customButtons?: Array<WebXREnterExitUIButton>;
  42482. }
  42483. /**
  42484. * UI to allow the user to enter/exit XR mode
  42485. */
  42486. export class WebXREnterExitUI implements IDisposable {
  42487. private scene;
  42488. private _overlay;
  42489. private _buttons;
  42490. private _activeButton;
  42491. /**
  42492. * Fired every time the active button is changed.
  42493. *
  42494. * When xr is entered via a button that launches xr that button will be the callback parameter
  42495. *
  42496. * When exiting xr the callback parameter will be null)
  42497. */
  42498. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42499. /**
  42500. * Creates UI to allow the user to enter/exit XR mode
  42501. * @param scene the scene to add the ui to
  42502. * @param helper the xr experience helper to enter/exit xr with
  42503. * @param options options to configure the UI
  42504. * @returns the created ui
  42505. */
  42506. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42507. private constructor();
  42508. private _updateButtons;
  42509. /**
  42510. * Disposes of the object
  42511. */
  42512. dispose(): void;
  42513. }
  42514. }
  42515. declare module "babylonjs/Cameras/XR/webXRController" {
  42516. import { Nullable } from "babylonjs/types";
  42517. import { Observable } from "babylonjs/Misc/observable";
  42518. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42519. import { Ray } from "babylonjs/Culling/ray";
  42520. import { Scene } from "babylonjs/scene";
  42521. /**
  42522. * Represents an XR input
  42523. */
  42524. export class WebXRController {
  42525. private scene;
  42526. /** The underlying input source for the controller */
  42527. inputSource: XRInputSource;
  42528. private parentContainer;
  42529. /**
  42530. * 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
  42531. */
  42532. grip?: AbstractMesh;
  42533. /**
  42534. * Pointer which can be used to select objects or attach a visible laser to
  42535. */
  42536. pointer: AbstractMesh;
  42537. /**
  42538. * Event that fires when the controller is removed/disposed
  42539. */
  42540. onDisposeObservable: Observable<{}>;
  42541. private _tmpMatrix;
  42542. private _tmpQuaternion;
  42543. private _tmpVector;
  42544. /**
  42545. * Creates the controller
  42546. * @see https://doc.babylonjs.com/how_to/webxr
  42547. * @param scene the scene which the controller should be associated to
  42548. * @param inputSource the underlying input source for the controller
  42549. * @param parentContainer parent that the controller meshes should be children of
  42550. */
  42551. constructor(scene: Scene,
  42552. /** The underlying input source for the controller */
  42553. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42554. /**
  42555. * Updates the controller pose based on the given XRFrame
  42556. * @param xrFrame xr frame to update the pose with
  42557. * @param referenceSpace reference space to use
  42558. */
  42559. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42560. /**
  42561. * Gets a world space ray coming from the controller
  42562. * @param result the resulting ray
  42563. */
  42564. getWorldPointerRayToRef(result: Ray): void;
  42565. /**
  42566. * Disposes of the object
  42567. */
  42568. dispose(): void;
  42569. }
  42570. }
  42571. declare module "babylonjs/Cameras/XR/webXRInput" {
  42572. import { Observable } from "babylonjs/Misc/observable";
  42573. import { IDisposable } from "babylonjs/scene";
  42574. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42575. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  42576. /**
  42577. * XR input used to track XR inputs such as controllers/rays
  42578. */
  42579. export class WebXRInput implements IDisposable {
  42580. /**
  42581. * Base experience the input listens to
  42582. */
  42583. baseExperience: WebXRExperienceHelper;
  42584. /**
  42585. * XR controllers being tracked
  42586. */
  42587. controllers: Array<WebXRController>;
  42588. private _frameObserver;
  42589. private _stateObserver;
  42590. /**
  42591. * Event when a controller has been connected/added
  42592. */
  42593. onControllerAddedObservable: Observable<WebXRController>;
  42594. /**
  42595. * Event when a controller has been removed/disconnected
  42596. */
  42597. onControllerRemovedObservable: Observable<WebXRController>;
  42598. /**
  42599. * Initializes the WebXRInput
  42600. * @param baseExperience experience helper which the input should be created for
  42601. */
  42602. constructor(
  42603. /**
  42604. * Base experience the input listens to
  42605. */
  42606. baseExperience: WebXRExperienceHelper);
  42607. private _onInputSourcesChange;
  42608. private _addAndRemoveControllers;
  42609. /**
  42610. * Disposes of the object
  42611. */
  42612. dispose(): void;
  42613. }
  42614. }
  42615. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  42616. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42617. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  42618. /**
  42619. * Enables teleportation
  42620. */
  42621. export class WebXRControllerTeleportation {
  42622. private _teleportationFillColor;
  42623. private _teleportationBorderColor;
  42624. private _tmpRay;
  42625. private _tmpVector;
  42626. /**
  42627. * Creates a WebXRControllerTeleportation
  42628. * @param input input manager to add teleportation to
  42629. * @param floorMeshes floormeshes which can be teleported to
  42630. */
  42631. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  42632. }
  42633. }
  42634. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  42635. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  42636. /**
  42637. * Handles pointer input automatically for the pointer of XR controllers
  42638. */
  42639. export class WebXRControllerPointerSelection {
  42640. private static _idCounter;
  42641. private _tmpRay;
  42642. /**
  42643. * Creates a WebXRControllerPointerSelection
  42644. * @param input input manager to setup pointer selection
  42645. */
  42646. constructor(input: WebXRInput);
  42647. private _convertNormalToDirectionOfRay;
  42648. private _updatePointerDistance;
  42649. }
  42650. }
  42651. declare module "babylonjs/Loading/sceneLoader" {
  42652. import { Observable } from "babylonjs/Misc/observable";
  42653. import { Nullable } from "babylonjs/types";
  42654. import { Scene } from "babylonjs/scene";
  42655. import { Engine } from "babylonjs/Engines/engine";
  42656. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42657. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42658. import { AssetContainer } from "babylonjs/assetContainer";
  42659. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42660. import { Skeleton } from "babylonjs/Bones/skeleton";
  42661. /**
  42662. * Class used to represent data loading progression
  42663. */
  42664. export class SceneLoaderProgressEvent {
  42665. /** defines if data length to load can be evaluated */
  42666. readonly lengthComputable: boolean;
  42667. /** defines the loaded data length */
  42668. readonly loaded: number;
  42669. /** defines the data length to load */
  42670. readonly total: number;
  42671. /**
  42672. * Create a new progress event
  42673. * @param lengthComputable defines if data length to load can be evaluated
  42674. * @param loaded defines the loaded data length
  42675. * @param total defines the data length to load
  42676. */
  42677. constructor(
  42678. /** defines if data length to load can be evaluated */
  42679. lengthComputable: boolean,
  42680. /** defines the loaded data length */
  42681. loaded: number,
  42682. /** defines the data length to load */
  42683. total: number);
  42684. /**
  42685. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42686. * @param event defines the source event
  42687. * @returns a new SceneLoaderProgressEvent
  42688. */
  42689. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42690. }
  42691. /**
  42692. * Interface used by SceneLoader plugins to define supported file extensions
  42693. */
  42694. export interface ISceneLoaderPluginExtensions {
  42695. /**
  42696. * Defines the list of supported extensions
  42697. */
  42698. [extension: string]: {
  42699. isBinary: boolean;
  42700. };
  42701. }
  42702. /**
  42703. * Interface used by SceneLoader plugin factory
  42704. */
  42705. export interface ISceneLoaderPluginFactory {
  42706. /**
  42707. * Defines the name of the factory
  42708. */
  42709. name: string;
  42710. /**
  42711. * Function called to create a new plugin
  42712. * @return the new plugin
  42713. */
  42714. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42715. /**
  42716. * Boolean indicating if the plugin can direct load specific data
  42717. */
  42718. canDirectLoad?: (data: string) => boolean;
  42719. }
  42720. /**
  42721. * Interface used to define a SceneLoader plugin
  42722. */
  42723. export interface ISceneLoaderPlugin {
  42724. /**
  42725. * The friendly name of this plugin.
  42726. */
  42727. name: string;
  42728. /**
  42729. * The file extensions supported by this plugin.
  42730. */
  42731. extensions: string | ISceneLoaderPluginExtensions;
  42732. /**
  42733. * Import meshes into a scene.
  42734. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42735. * @param scene The scene to import into
  42736. * @param data The data to import
  42737. * @param rootUrl The root url for scene and resources
  42738. * @param meshes The meshes array to import into
  42739. * @param particleSystems The particle systems array to import into
  42740. * @param skeletons The skeletons array to import into
  42741. * @param onError The callback when import fails
  42742. * @returns True if successful or false otherwise
  42743. */
  42744. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42745. /**
  42746. * Load into a scene.
  42747. * @param scene The scene to load into
  42748. * @param data The data to import
  42749. * @param rootUrl The root url for scene and resources
  42750. * @param onError The callback when import fails
  42751. * @returns true if successful or false otherwise
  42752. */
  42753. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42754. /**
  42755. * The callback that returns true if the data can be directly loaded.
  42756. */
  42757. canDirectLoad?: (data: string) => boolean;
  42758. /**
  42759. * The callback that allows custom handling of the root url based on the response url.
  42760. */
  42761. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42762. /**
  42763. * Load into an asset container.
  42764. * @param scene The scene to load into
  42765. * @param data The data to import
  42766. * @param rootUrl The root url for scene and resources
  42767. * @param onError The callback when import fails
  42768. * @returns The loaded asset container
  42769. */
  42770. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42771. }
  42772. /**
  42773. * Interface used to define an async SceneLoader plugin
  42774. */
  42775. export interface ISceneLoaderPluginAsync {
  42776. /**
  42777. * The friendly name of this plugin.
  42778. */
  42779. name: string;
  42780. /**
  42781. * The file extensions supported by this plugin.
  42782. */
  42783. extensions: string | ISceneLoaderPluginExtensions;
  42784. /**
  42785. * Import meshes into a scene.
  42786. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42787. * @param scene The scene to import into
  42788. * @param data The data to import
  42789. * @param rootUrl The root url for scene and resources
  42790. * @param onProgress The callback when the load progresses
  42791. * @param fileName Defines the name of the file to load
  42792. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42793. */
  42794. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42795. meshes: AbstractMesh[];
  42796. particleSystems: IParticleSystem[];
  42797. skeletons: Skeleton[];
  42798. animationGroups: AnimationGroup[];
  42799. }>;
  42800. /**
  42801. * Load into a scene.
  42802. * @param scene The scene to load into
  42803. * @param data The data to import
  42804. * @param rootUrl The root url for scene and resources
  42805. * @param onProgress The callback when the load progresses
  42806. * @param fileName Defines the name of the file to load
  42807. * @returns Nothing
  42808. */
  42809. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42810. /**
  42811. * The callback that returns true if the data can be directly loaded.
  42812. */
  42813. canDirectLoad?: (data: string) => boolean;
  42814. /**
  42815. * The callback that allows custom handling of the root url based on the response url.
  42816. */
  42817. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42818. /**
  42819. * Load into an asset container.
  42820. * @param scene The scene to load into
  42821. * @param data The data to import
  42822. * @param rootUrl The root url for scene and resources
  42823. * @param onProgress The callback when the load progresses
  42824. * @param fileName Defines the name of the file to load
  42825. * @returns The loaded asset container
  42826. */
  42827. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42828. }
  42829. /**
  42830. * Class used to load scene from various file formats using registered plugins
  42831. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42832. */
  42833. export class SceneLoader {
  42834. /**
  42835. * No logging while loading
  42836. */
  42837. static readonly NO_LOGGING: number;
  42838. /**
  42839. * Minimal logging while loading
  42840. */
  42841. static readonly MINIMAL_LOGGING: number;
  42842. /**
  42843. * Summary logging while loading
  42844. */
  42845. static readonly SUMMARY_LOGGING: number;
  42846. /**
  42847. * Detailled logging while loading
  42848. */
  42849. static readonly DETAILED_LOGGING: number;
  42850. /**
  42851. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42852. */
  42853. static ForceFullSceneLoadingForIncremental: boolean;
  42854. /**
  42855. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42856. */
  42857. static ShowLoadingScreen: boolean;
  42858. /**
  42859. * Defines the current logging level (while loading the scene)
  42860. * @ignorenaming
  42861. */
  42862. static loggingLevel: number;
  42863. /**
  42864. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42865. */
  42866. static CleanBoneMatrixWeights: boolean;
  42867. /**
  42868. * Event raised when a plugin is used to load a scene
  42869. */
  42870. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42871. private static _registeredPlugins;
  42872. private static _getDefaultPlugin;
  42873. private static _getPluginForExtension;
  42874. private static _getPluginForDirectLoad;
  42875. private static _getPluginForFilename;
  42876. private static _getDirectLoad;
  42877. private static _loadData;
  42878. private static _getFileInfo;
  42879. /**
  42880. * Gets a plugin that can load the given extension
  42881. * @param extension defines the extension to load
  42882. * @returns a plugin or null if none works
  42883. */
  42884. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42885. /**
  42886. * Gets a boolean indicating that the given extension can be loaded
  42887. * @param extension defines the extension to load
  42888. * @returns true if the extension is supported
  42889. */
  42890. static IsPluginForExtensionAvailable(extension: string): boolean;
  42891. /**
  42892. * Adds a new plugin to the list of registered plugins
  42893. * @param plugin defines the plugin to add
  42894. */
  42895. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42896. /**
  42897. * Import meshes into a scene
  42898. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42899. * @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)
  42900. * @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)
  42901. * @param scene the instance of BABYLON.Scene to append to
  42902. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42903. * @param onProgress a callback with a progress event for each file being loaded
  42904. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42905. * @param pluginExtension the extension used to determine the plugin
  42906. * @returns The loaded plugin
  42907. */
  42908. 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>;
  42909. /**
  42910. * Import meshes into a scene
  42911. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42912. * @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)
  42913. * @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)
  42914. * @param scene the instance of BABYLON.Scene to append to
  42915. * @param onProgress a callback with a progress event for each file being loaded
  42916. * @param pluginExtension the extension used to determine the plugin
  42917. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42918. */
  42919. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42920. meshes: AbstractMesh[];
  42921. particleSystems: IParticleSystem[];
  42922. skeletons: Skeleton[];
  42923. animationGroups: AnimationGroup[];
  42924. }>;
  42925. /**
  42926. * Load a scene
  42927. * @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)
  42928. * @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)
  42929. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42930. * @param onSuccess a callback with the scene when import succeeds
  42931. * @param onProgress a callback with a progress event for each file being loaded
  42932. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42933. * @param pluginExtension the extension used to determine the plugin
  42934. * @returns The loaded plugin
  42935. */
  42936. 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>;
  42937. /**
  42938. * Load a scene
  42939. * @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)
  42940. * @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)
  42941. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42942. * @param onProgress a callback with a progress event for each file being loaded
  42943. * @param pluginExtension the extension used to determine the plugin
  42944. * @returns The loaded scene
  42945. */
  42946. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42947. /**
  42948. * Append a scene
  42949. * @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)
  42950. * @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)
  42951. * @param scene is the instance of BABYLON.Scene to append to
  42952. * @param onSuccess a callback with the scene when import succeeds
  42953. * @param onProgress a callback with a progress event for each file being loaded
  42954. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42955. * @param pluginExtension the extension used to determine the plugin
  42956. * @returns The loaded plugin
  42957. */
  42958. 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>;
  42959. /**
  42960. * Append a scene
  42961. * @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)
  42962. * @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)
  42963. * @param scene is the instance of BABYLON.Scene to append to
  42964. * @param onProgress a callback with a progress event for each file being loaded
  42965. * @param pluginExtension the extension used to determine the plugin
  42966. * @returns The given scene
  42967. */
  42968. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42969. /**
  42970. * Load a scene into an asset container
  42971. * @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)
  42972. * @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)
  42973. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42974. * @param onSuccess a callback with the scene when import succeeds
  42975. * @param onProgress a callback with a progress event for each file being loaded
  42976. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42977. * @param pluginExtension the extension used to determine the plugin
  42978. * @returns The loaded plugin
  42979. */
  42980. 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>;
  42981. /**
  42982. * Load a scene into an asset container
  42983. * @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)
  42984. * @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)
  42985. * @param scene is the instance of Scene to append to
  42986. * @param onProgress a callback with a progress event for each file being loaded
  42987. * @param pluginExtension the extension used to determine the plugin
  42988. * @returns The loaded asset container
  42989. */
  42990. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42991. }
  42992. }
  42993. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42994. import { Scene } from "babylonjs/scene";
  42995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42996. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42997. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42998. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42999. /**
  43000. * Generic Controller
  43001. */
  43002. export class GenericController extends WebVRController {
  43003. /**
  43004. * Base Url for the controller model.
  43005. */
  43006. static readonly MODEL_BASE_URL: string;
  43007. /**
  43008. * File name for the controller model.
  43009. */
  43010. static readonly MODEL_FILENAME: string;
  43011. /**
  43012. * Creates a new GenericController from a gamepad
  43013. * @param vrGamepad the gamepad that the controller should be created from
  43014. */
  43015. constructor(vrGamepad: any);
  43016. /**
  43017. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43018. * @param scene scene in which to add meshes
  43019. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43020. */
  43021. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43022. /**
  43023. * Called once for each button that changed state since the last frame
  43024. * @param buttonIdx Which button index changed
  43025. * @param state New state of the button
  43026. * @param changes Which properties on the state changed since last frame
  43027. */
  43028. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43029. }
  43030. }
  43031. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43032. import { Observable } from "babylonjs/Misc/observable";
  43033. import { Scene } from "babylonjs/scene";
  43034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43035. import { Ray } from "babylonjs/Culling/ray";
  43036. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43037. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43038. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43039. /**
  43040. * Defines the WindowsMotionController object that the state of the windows motion controller
  43041. */
  43042. export class WindowsMotionController extends WebVRController {
  43043. /**
  43044. * The base url used to load the left and right controller models
  43045. */
  43046. static MODEL_BASE_URL: string;
  43047. /**
  43048. * The name of the left controller model file
  43049. */
  43050. static MODEL_LEFT_FILENAME: string;
  43051. /**
  43052. * The name of the right controller model file
  43053. */
  43054. static MODEL_RIGHT_FILENAME: string;
  43055. /**
  43056. * The controller name prefix for this controller type
  43057. */
  43058. static readonly GAMEPAD_ID_PREFIX: string;
  43059. /**
  43060. * The controller id pattern for this controller type
  43061. */
  43062. private static readonly GAMEPAD_ID_PATTERN;
  43063. private _loadedMeshInfo;
  43064. private readonly _mapping;
  43065. /**
  43066. * Fired when the trackpad on this controller is clicked
  43067. */
  43068. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43069. /**
  43070. * Fired when the trackpad on this controller is modified
  43071. */
  43072. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43073. /**
  43074. * The current x and y values of this controller's trackpad
  43075. */
  43076. trackpad: StickValues;
  43077. /**
  43078. * Creates a new WindowsMotionController from a gamepad
  43079. * @param vrGamepad the gamepad that the controller should be created from
  43080. */
  43081. constructor(vrGamepad: any);
  43082. /**
  43083. * Fired when the trigger on this controller is modified
  43084. */
  43085. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43086. /**
  43087. * Fired when the menu button on this controller is modified
  43088. */
  43089. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43090. /**
  43091. * Fired when the grip button on this controller is modified
  43092. */
  43093. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43094. /**
  43095. * Fired when the thumbstick button on this controller is modified
  43096. */
  43097. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43098. /**
  43099. * Fired when the touchpad button on this controller is modified
  43100. */
  43101. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43102. /**
  43103. * Fired when the touchpad values on this controller are modified
  43104. */
  43105. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43106. private _updateTrackpad;
  43107. /**
  43108. * Called once per frame by the engine.
  43109. */
  43110. update(): void;
  43111. /**
  43112. * Called once for each button that changed state since the last frame
  43113. * @param buttonIdx Which button index changed
  43114. * @param state New state of the button
  43115. * @param changes Which properties on the state changed since last frame
  43116. */
  43117. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43118. /**
  43119. * Moves the buttons on the controller mesh based on their current state
  43120. * @param buttonName the name of the button to move
  43121. * @param buttonValue the value of the button which determines the buttons new position
  43122. */
  43123. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43124. /**
  43125. * Moves the axis on the controller mesh based on its current state
  43126. * @param axis the index of the axis
  43127. * @param axisValue the value of the axis which determines the meshes new position
  43128. * @hidden
  43129. */
  43130. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43131. /**
  43132. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43133. * @param scene scene in which to add meshes
  43134. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43135. */
  43136. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43137. /**
  43138. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43139. * can be transformed by button presses and axes values, based on this._mapping.
  43140. *
  43141. * @param scene scene in which the meshes exist
  43142. * @param meshes list of meshes that make up the controller model to process
  43143. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43144. */
  43145. private processModel;
  43146. private createMeshInfo;
  43147. /**
  43148. * Gets the ray of the controller in the direction the controller is pointing
  43149. * @param length the length the resulting ray should be
  43150. * @returns a ray in the direction the controller is pointing
  43151. */
  43152. getForwardRay(length?: number): Ray;
  43153. /**
  43154. * Disposes of the controller
  43155. */
  43156. dispose(): void;
  43157. }
  43158. }
  43159. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43160. import { Observable } from "babylonjs/Misc/observable";
  43161. import { Scene } from "babylonjs/scene";
  43162. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43163. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43164. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43165. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43166. /**
  43167. * Oculus Touch Controller
  43168. */
  43169. export class OculusTouchController extends WebVRController {
  43170. /**
  43171. * Base Url for the controller model.
  43172. */
  43173. static MODEL_BASE_URL: string;
  43174. /**
  43175. * File name for the left controller model.
  43176. */
  43177. static MODEL_LEFT_FILENAME: string;
  43178. /**
  43179. * File name for the right controller model.
  43180. */
  43181. static MODEL_RIGHT_FILENAME: string;
  43182. /**
  43183. * Base Url for the Quest controller model.
  43184. */
  43185. static QUEST_MODEL_BASE_URL: string;
  43186. /**
  43187. * @hidden
  43188. * If the controllers are running on a device that needs the updated Quest controller models
  43189. */
  43190. static _IsQuest: boolean;
  43191. /**
  43192. * Fired when the secondary trigger on this controller is modified
  43193. */
  43194. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43195. /**
  43196. * Fired when the thumb rest on this controller is modified
  43197. */
  43198. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43199. /**
  43200. * Creates a new OculusTouchController from a gamepad
  43201. * @param vrGamepad the gamepad that the controller should be created from
  43202. */
  43203. constructor(vrGamepad: any);
  43204. /**
  43205. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43206. * @param scene scene in which to add meshes
  43207. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43208. */
  43209. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43210. /**
  43211. * Fired when the A button on this controller is modified
  43212. */
  43213. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43214. /**
  43215. * Fired when the B button on this controller is modified
  43216. */
  43217. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43218. /**
  43219. * Fired when the X button on this controller is modified
  43220. */
  43221. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43222. /**
  43223. * Fired when the Y button on this controller is modified
  43224. */
  43225. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43226. /**
  43227. * Called once for each button that changed state since the last frame
  43228. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43229. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43230. * 2) secondary trigger (same)
  43231. * 3) A (right) X (left), touch, pressed = value
  43232. * 4) B / Y
  43233. * 5) thumb rest
  43234. * @param buttonIdx Which button index changed
  43235. * @param state New state of the button
  43236. * @param changes Which properties on the state changed since last frame
  43237. */
  43238. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43239. }
  43240. }
  43241. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43242. import { Scene } from "babylonjs/scene";
  43243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43244. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43245. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43246. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43247. import { Observable } from "babylonjs/Misc/observable";
  43248. /**
  43249. * Vive Controller
  43250. */
  43251. export class ViveController extends WebVRController {
  43252. /**
  43253. * Base Url for the controller model.
  43254. */
  43255. static MODEL_BASE_URL: string;
  43256. /**
  43257. * File name for the controller model.
  43258. */
  43259. static MODEL_FILENAME: string;
  43260. /**
  43261. * Creates a new ViveController from a gamepad
  43262. * @param vrGamepad the gamepad that the controller should be created from
  43263. */
  43264. constructor(vrGamepad: any);
  43265. /**
  43266. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43267. * @param scene scene in which to add meshes
  43268. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43269. */
  43270. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43271. /**
  43272. * Fired when the left button on this controller is modified
  43273. */
  43274. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43275. /**
  43276. * Fired when the right button on this controller is modified
  43277. */
  43278. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43279. /**
  43280. * Fired when the menu button on this controller is modified
  43281. */
  43282. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43283. /**
  43284. * Called once for each button that changed state since the last frame
  43285. * Vive mapping:
  43286. * 0: touchpad
  43287. * 1: trigger
  43288. * 2: left AND right buttons
  43289. * 3: menu button
  43290. * @param buttonIdx Which button index changed
  43291. * @param state New state of the button
  43292. * @param changes Which properties on the state changed since last frame
  43293. */
  43294. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43295. }
  43296. }
  43297. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43298. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43299. /**
  43300. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43301. */
  43302. export class WebXRControllerModelLoader {
  43303. /**
  43304. * Creates the WebXRControllerModelLoader
  43305. * @param input xr input that creates the controllers
  43306. */
  43307. constructor(input: WebXRInput);
  43308. }
  43309. }
  43310. declare module "babylonjs/Cameras/XR/index" {
  43311. export * from "babylonjs/Cameras/XR/webXRCamera";
  43312. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43313. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43314. export * from "babylonjs/Cameras/XR/webXRInput";
  43315. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43316. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43317. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43318. export * from "babylonjs/Cameras/XR/webXRController";
  43319. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43320. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43321. }
  43322. declare module "babylonjs/Cameras/RigModes/index" {
  43323. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43324. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43325. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43326. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43327. }
  43328. declare module "babylonjs/Cameras/index" {
  43329. export * from "babylonjs/Cameras/Inputs/index";
  43330. export * from "babylonjs/Cameras/cameraInputsManager";
  43331. export * from "babylonjs/Cameras/camera";
  43332. export * from "babylonjs/Cameras/targetCamera";
  43333. export * from "babylonjs/Cameras/freeCamera";
  43334. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43335. export * from "babylonjs/Cameras/touchCamera";
  43336. export * from "babylonjs/Cameras/arcRotateCamera";
  43337. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43338. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43339. export * from "babylonjs/Cameras/flyCamera";
  43340. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43341. export * from "babylonjs/Cameras/followCamera";
  43342. export * from "babylonjs/Cameras/gamepadCamera";
  43343. export * from "babylonjs/Cameras/Stereoscopic/index";
  43344. export * from "babylonjs/Cameras/universalCamera";
  43345. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43346. export * from "babylonjs/Cameras/VR/index";
  43347. export * from "babylonjs/Cameras/XR/index";
  43348. export * from "babylonjs/Cameras/RigModes/index";
  43349. }
  43350. declare module "babylonjs/Collisions/index" {
  43351. export * from "babylonjs/Collisions/collider";
  43352. export * from "babylonjs/Collisions/collisionCoordinator";
  43353. export * from "babylonjs/Collisions/pickingInfo";
  43354. export * from "babylonjs/Collisions/intersectionInfo";
  43355. export * from "babylonjs/Collisions/meshCollisionData";
  43356. }
  43357. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43358. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43359. import { Vector3 } from "babylonjs/Maths/math.vector";
  43360. import { Ray } from "babylonjs/Culling/ray";
  43361. import { Plane } from "babylonjs/Maths/math.plane";
  43362. /**
  43363. * Contains an array of blocks representing the octree
  43364. */
  43365. export interface IOctreeContainer<T> {
  43366. /**
  43367. * Blocks within the octree
  43368. */
  43369. blocks: Array<OctreeBlock<T>>;
  43370. }
  43371. /**
  43372. * Class used to store a cell in an octree
  43373. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43374. */
  43375. export class OctreeBlock<T> {
  43376. /**
  43377. * Gets the content of the current block
  43378. */
  43379. entries: T[];
  43380. /**
  43381. * Gets the list of block children
  43382. */
  43383. blocks: Array<OctreeBlock<T>>;
  43384. private _depth;
  43385. private _maxDepth;
  43386. private _capacity;
  43387. private _minPoint;
  43388. private _maxPoint;
  43389. private _boundingVectors;
  43390. private _creationFunc;
  43391. /**
  43392. * Creates a new block
  43393. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43394. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43395. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43396. * @param depth defines the current depth of this block in the octree
  43397. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43398. * @param creationFunc defines a callback to call when an element is added to the block
  43399. */
  43400. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43401. /**
  43402. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43403. */
  43404. readonly capacity: number;
  43405. /**
  43406. * Gets the minimum vector (in world space) of the block's bounding box
  43407. */
  43408. readonly minPoint: Vector3;
  43409. /**
  43410. * Gets the maximum vector (in world space) of the block's bounding box
  43411. */
  43412. readonly maxPoint: Vector3;
  43413. /**
  43414. * Add a new element to this block
  43415. * @param entry defines the element to add
  43416. */
  43417. addEntry(entry: T): void;
  43418. /**
  43419. * Remove an element from this block
  43420. * @param entry defines the element to remove
  43421. */
  43422. removeEntry(entry: T): void;
  43423. /**
  43424. * Add an array of elements to this block
  43425. * @param entries defines the array of elements to add
  43426. */
  43427. addEntries(entries: T[]): void;
  43428. /**
  43429. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43430. * @param frustumPlanes defines the frustum planes to test
  43431. * @param selection defines the array to store current content if selection is positive
  43432. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43433. */
  43434. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43435. /**
  43436. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43437. * @param sphereCenter defines the bounding sphere center
  43438. * @param sphereRadius defines the bounding sphere radius
  43439. * @param selection defines the array to store current content if selection is positive
  43440. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43441. */
  43442. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43443. /**
  43444. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43445. * @param ray defines the ray to test with
  43446. * @param selection defines the array to store current content if selection is positive
  43447. */
  43448. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43449. /**
  43450. * Subdivide the content into child blocks (this block will then be empty)
  43451. */
  43452. createInnerBlocks(): void;
  43453. /**
  43454. * @hidden
  43455. */
  43456. 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;
  43457. }
  43458. }
  43459. declare module "babylonjs/Culling/Octrees/octree" {
  43460. import { SmartArray } from "babylonjs/Misc/smartArray";
  43461. import { Vector3 } from "babylonjs/Maths/math.vector";
  43462. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43463. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43464. import { Ray } from "babylonjs/Culling/ray";
  43465. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43466. import { Plane } from "babylonjs/Maths/math.plane";
  43467. /**
  43468. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43469. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43470. */
  43471. export class Octree<T> {
  43472. /** 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.) */
  43473. maxDepth: number;
  43474. /**
  43475. * Blocks within the octree containing objects
  43476. */
  43477. blocks: Array<OctreeBlock<T>>;
  43478. /**
  43479. * Content stored in the octree
  43480. */
  43481. dynamicContent: T[];
  43482. private _maxBlockCapacity;
  43483. private _selectionContent;
  43484. private _creationFunc;
  43485. /**
  43486. * Creates a octree
  43487. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43488. * @param creationFunc function to be used to instatiate the octree
  43489. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43490. * @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.)
  43491. */
  43492. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43493. /** 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.) */
  43494. maxDepth?: number);
  43495. /**
  43496. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43497. * @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);
  43498. * @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);
  43499. * @param entries meshes to be added to the octree blocks
  43500. */
  43501. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43502. /**
  43503. * Adds a mesh to the octree
  43504. * @param entry Mesh to add to the octree
  43505. */
  43506. addMesh(entry: T): void;
  43507. /**
  43508. * Remove an element from the octree
  43509. * @param entry defines the element to remove
  43510. */
  43511. removeMesh(entry: T): void;
  43512. /**
  43513. * Selects an array of meshes within the frustum
  43514. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43515. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43516. * @returns array of meshes within the frustum
  43517. */
  43518. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43519. /**
  43520. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43521. * @param sphereCenter defines the bounding sphere center
  43522. * @param sphereRadius defines the bounding sphere radius
  43523. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43524. * @returns an array of objects that intersect the sphere
  43525. */
  43526. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43527. /**
  43528. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43529. * @param ray defines the ray to test with
  43530. * @returns array of intersected objects
  43531. */
  43532. intersectsRay(ray: Ray): SmartArray<T>;
  43533. /**
  43534. * Adds a mesh into the octree block if it intersects the block
  43535. */
  43536. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43537. /**
  43538. * Adds a submesh into the octree block if it intersects the block
  43539. */
  43540. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43541. }
  43542. }
  43543. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  43544. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43545. import { Scene } from "babylonjs/scene";
  43546. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43548. import { Ray } from "babylonjs/Culling/ray";
  43549. import { Octree } from "babylonjs/Culling/Octrees/octree";
  43550. import { Collider } from "babylonjs/Collisions/collider";
  43551. module "babylonjs/scene" {
  43552. interface Scene {
  43553. /**
  43554. * @hidden
  43555. * Backing Filed
  43556. */
  43557. _selectionOctree: Octree<AbstractMesh>;
  43558. /**
  43559. * Gets the octree used to boost mesh selection (picking)
  43560. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43561. */
  43562. selectionOctree: Octree<AbstractMesh>;
  43563. /**
  43564. * Creates or updates the octree used to boost selection (picking)
  43565. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43566. * @param maxCapacity defines the maximum capacity per leaf
  43567. * @param maxDepth defines the maximum depth of the octree
  43568. * @returns an octree of AbstractMesh
  43569. */
  43570. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43571. }
  43572. }
  43573. module "babylonjs/Meshes/abstractMesh" {
  43574. interface AbstractMesh {
  43575. /**
  43576. * @hidden
  43577. * Backing Field
  43578. */
  43579. _submeshesOctree: Octree<SubMesh>;
  43580. /**
  43581. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43582. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43583. * @param maxCapacity defines the maximum size of each block (64 by default)
  43584. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43585. * @returns the new octree
  43586. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43587. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43588. */
  43589. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43590. }
  43591. }
  43592. /**
  43593. * Defines the octree scene component responsible to manage any octrees
  43594. * in a given scene.
  43595. */
  43596. export class OctreeSceneComponent {
  43597. /**
  43598. * The component name help to identify the component in the list of scene components.
  43599. */
  43600. readonly name: string;
  43601. /**
  43602. * The scene the component belongs to.
  43603. */
  43604. scene: Scene;
  43605. /**
  43606. * Indicates if the meshes have been checked to make sure they are isEnabled()
  43607. */
  43608. readonly checksIsEnabled: boolean;
  43609. /**
  43610. * Creates a new instance of the component for the given scene
  43611. * @param scene Defines the scene to register the component in
  43612. */
  43613. constructor(scene: Scene);
  43614. /**
  43615. * Registers the component in a given scene
  43616. */
  43617. register(): void;
  43618. /**
  43619. * Return the list of active meshes
  43620. * @returns the list of active meshes
  43621. */
  43622. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43623. /**
  43624. * Return the list of active sub meshes
  43625. * @param mesh The mesh to get the candidates sub meshes from
  43626. * @returns the list of active sub meshes
  43627. */
  43628. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43629. private _tempRay;
  43630. /**
  43631. * Return the list of sub meshes intersecting with a given local ray
  43632. * @param mesh defines the mesh to find the submesh for
  43633. * @param localRay defines the ray in local space
  43634. * @returns the list of intersecting sub meshes
  43635. */
  43636. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43637. /**
  43638. * Return the list of sub meshes colliding with a collider
  43639. * @param mesh defines the mesh to find the submesh for
  43640. * @param collider defines the collider to evaluate the collision against
  43641. * @returns the list of colliding sub meshes
  43642. */
  43643. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  43644. /**
  43645. * Rebuilds the elements related to this component in case of
  43646. * context lost for instance.
  43647. */
  43648. rebuild(): void;
  43649. /**
  43650. * Disposes the component and the associated ressources.
  43651. */
  43652. dispose(): void;
  43653. }
  43654. }
  43655. declare module "babylonjs/Culling/Octrees/index" {
  43656. export * from "babylonjs/Culling/Octrees/octree";
  43657. export * from "babylonjs/Culling/Octrees/octreeBlock";
  43658. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  43659. }
  43660. declare module "babylonjs/Culling/index" {
  43661. export * from "babylonjs/Culling/boundingBox";
  43662. export * from "babylonjs/Culling/boundingInfo";
  43663. export * from "babylonjs/Culling/boundingSphere";
  43664. export * from "babylonjs/Culling/Octrees/index";
  43665. export * from "babylonjs/Culling/ray";
  43666. }
  43667. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  43668. import { IDisposable, Scene } from "babylonjs/scene";
  43669. import { Nullable } from "babylonjs/types";
  43670. import { Observable } from "babylonjs/Misc/observable";
  43671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43672. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  43673. import { Camera } from "babylonjs/Cameras/camera";
  43674. /**
  43675. * Renders a layer on top of an existing scene
  43676. */
  43677. export class UtilityLayerRenderer implements IDisposable {
  43678. /** the original scene that will be rendered on top of */
  43679. originalScene: Scene;
  43680. private _pointerCaptures;
  43681. private _lastPointerEvents;
  43682. private static _DefaultUtilityLayer;
  43683. private static _DefaultKeepDepthUtilityLayer;
  43684. private _sharedGizmoLight;
  43685. private _renderCamera;
  43686. /**
  43687. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  43688. * @returns the camera that is used when rendering the utility layer
  43689. */
  43690. getRenderCamera(): Nullable<Camera>;
  43691. /**
  43692. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  43693. * @param cam the camera that should be used when rendering the utility layer
  43694. */
  43695. setRenderCamera(cam: Nullable<Camera>): void;
  43696. /**
  43697. * @hidden
  43698. * Light which used by gizmos to get light shading
  43699. */
  43700. _getSharedGizmoLight(): HemisphericLight;
  43701. /**
  43702. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  43703. */
  43704. pickUtilitySceneFirst: boolean;
  43705. /**
  43706. * 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)
  43707. */
  43708. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  43709. /**
  43710. * 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)
  43711. */
  43712. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  43713. /**
  43714. * The scene that is rendered on top of the original scene
  43715. */
  43716. utilityLayerScene: Scene;
  43717. /**
  43718. * If the utility layer should automatically be rendered on top of existing scene
  43719. */
  43720. shouldRender: boolean;
  43721. /**
  43722. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  43723. */
  43724. onlyCheckPointerDownEvents: boolean;
  43725. /**
  43726. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  43727. */
  43728. processAllEvents: boolean;
  43729. /**
  43730. * Observable raised when the pointer move from the utility layer scene to the main scene
  43731. */
  43732. onPointerOutObservable: Observable<number>;
  43733. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  43734. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  43735. private _afterRenderObserver;
  43736. private _sceneDisposeObserver;
  43737. private _originalPointerObserver;
  43738. /**
  43739. * Instantiates a UtilityLayerRenderer
  43740. * @param originalScene the original scene that will be rendered on top of
  43741. * @param handleEvents boolean indicating if the utility layer should handle events
  43742. */
  43743. constructor(
  43744. /** the original scene that will be rendered on top of */
  43745. originalScene: Scene, handleEvents?: boolean);
  43746. private _notifyObservers;
  43747. /**
  43748. * Renders the utility layers scene on top of the original scene
  43749. */
  43750. render(): void;
  43751. /**
  43752. * Disposes of the renderer
  43753. */
  43754. dispose(): void;
  43755. private _updateCamera;
  43756. }
  43757. }
  43758. declare module "babylonjs/Gizmos/gizmo" {
  43759. import { Nullable } from "babylonjs/types";
  43760. import { IDisposable } from "babylonjs/scene";
  43761. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43762. import { Mesh } from "babylonjs/Meshes/mesh";
  43763. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43764. /**
  43765. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  43766. */
  43767. export class Gizmo implements IDisposable {
  43768. /** The utility layer the gizmo will be added to */
  43769. gizmoLayer: UtilityLayerRenderer;
  43770. /**
  43771. * The root mesh of the gizmo
  43772. */
  43773. _rootMesh: Mesh;
  43774. private _attachedMesh;
  43775. /**
  43776. * Ratio for the scale of the gizmo (Default: 1)
  43777. */
  43778. scaleRatio: number;
  43779. /**
  43780. * If a custom mesh has been set (Default: false)
  43781. */
  43782. protected _customMeshSet: boolean;
  43783. /**
  43784. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  43785. * * When set, interactions will be enabled
  43786. */
  43787. attachedMesh: Nullable<AbstractMesh>;
  43788. /**
  43789. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43790. * @param mesh The mesh to replace the default mesh of the gizmo
  43791. */
  43792. setCustomMesh(mesh: Mesh): void;
  43793. /**
  43794. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  43795. */
  43796. updateGizmoRotationToMatchAttachedMesh: boolean;
  43797. /**
  43798. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  43799. */
  43800. updateGizmoPositionToMatchAttachedMesh: boolean;
  43801. /**
  43802. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  43803. */
  43804. updateScale: boolean;
  43805. protected _interactionsEnabled: boolean;
  43806. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43807. private _beforeRenderObserver;
  43808. private _tempVector;
  43809. /**
  43810. * Creates a gizmo
  43811. * @param gizmoLayer The utility layer the gizmo will be added to
  43812. */
  43813. constructor(
  43814. /** The utility layer the gizmo will be added to */
  43815. gizmoLayer?: UtilityLayerRenderer);
  43816. /**
  43817. * Updates the gizmo to match the attached mesh's position/rotation
  43818. */
  43819. protected _update(): void;
  43820. /**
  43821. * Disposes of the gizmo
  43822. */
  43823. dispose(): void;
  43824. }
  43825. }
  43826. declare module "babylonjs/Gizmos/planeDragGizmo" {
  43827. import { Observable } from "babylonjs/Misc/observable";
  43828. import { Nullable } from "babylonjs/types";
  43829. import { Vector3 } from "babylonjs/Maths/math.vector";
  43830. import { Color3 } from "babylonjs/Maths/math.color";
  43831. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43833. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43834. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43835. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43836. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  43837. import { Scene } from "babylonjs/scene";
  43838. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43839. /**
  43840. * Single plane drag gizmo
  43841. */
  43842. export class PlaneDragGizmo extends Gizmo {
  43843. /**
  43844. * Drag behavior responsible for the gizmos dragging interactions
  43845. */
  43846. dragBehavior: PointerDragBehavior;
  43847. private _pointerObserver;
  43848. /**
  43849. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43850. */
  43851. snapDistance: number;
  43852. /**
  43853. * Event that fires each time the gizmo snaps to a new location.
  43854. * * snapDistance is the the change in distance
  43855. */
  43856. onSnapObservable: Observable<{
  43857. snapDistance: number;
  43858. }>;
  43859. private _plane;
  43860. private _coloredMaterial;
  43861. private _hoverMaterial;
  43862. private _isEnabled;
  43863. private _parent;
  43864. /** @hidden */
  43865. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  43866. /** @hidden */
  43867. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43868. /**
  43869. * Creates a PlaneDragGizmo
  43870. * @param gizmoLayer The utility layer the gizmo will be added to
  43871. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  43872. * @param color The color of the gizmo
  43873. */
  43874. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43875. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43876. /**
  43877. * If the gizmo is enabled
  43878. */
  43879. isEnabled: boolean;
  43880. /**
  43881. * Disposes of the gizmo
  43882. */
  43883. dispose(): void;
  43884. }
  43885. }
  43886. declare module "babylonjs/Gizmos/positionGizmo" {
  43887. import { Observable } from "babylonjs/Misc/observable";
  43888. import { Nullable } from "babylonjs/types";
  43889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43890. import { Mesh } from "babylonjs/Meshes/mesh";
  43891. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43892. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43893. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  43894. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43895. /**
  43896. * Gizmo that enables dragging a mesh along 3 axis
  43897. */
  43898. export class PositionGizmo extends Gizmo {
  43899. /**
  43900. * Internal gizmo used for interactions on the x axis
  43901. */
  43902. xGizmo: AxisDragGizmo;
  43903. /**
  43904. * Internal gizmo used for interactions on the y axis
  43905. */
  43906. yGizmo: AxisDragGizmo;
  43907. /**
  43908. * Internal gizmo used for interactions on the z axis
  43909. */
  43910. zGizmo: AxisDragGizmo;
  43911. /**
  43912. * Internal gizmo used for interactions on the yz plane
  43913. */
  43914. xPlaneGizmo: PlaneDragGizmo;
  43915. /**
  43916. * Internal gizmo used for interactions on the xz plane
  43917. */
  43918. yPlaneGizmo: PlaneDragGizmo;
  43919. /**
  43920. * Internal gizmo used for interactions on the xy plane
  43921. */
  43922. zPlaneGizmo: PlaneDragGizmo;
  43923. /**
  43924. * private variables
  43925. */
  43926. private _meshAttached;
  43927. private _updateGizmoRotationToMatchAttachedMesh;
  43928. private _snapDistance;
  43929. private _scaleRatio;
  43930. /** Fires an event when any of it's sub gizmos are dragged */
  43931. onDragStartObservable: Observable<unknown>;
  43932. /** Fires an event when any of it's sub gizmos are released from dragging */
  43933. onDragEndObservable: Observable<unknown>;
  43934. /**
  43935. * If set to true, planar drag is enabled
  43936. */
  43937. private _planarGizmoEnabled;
  43938. attachedMesh: Nullable<AbstractMesh>;
  43939. /**
  43940. * Creates a PositionGizmo
  43941. * @param gizmoLayer The utility layer the gizmo will be added to
  43942. */
  43943. constructor(gizmoLayer?: UtilityLayerRenderer);
  43944. /**
  43945. * If the planar drag gizmo is enabled
  43946. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  43947. */
  43948. planarGizmoEnabled: boolean;
  43949. updateGizmoRotationToMatchAttachedMesh: boolean;
  43950. /**
  43951. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43952. */
  43953. snapDistance: number;
  43954. /**
  43955. * Ratio for the scale of the gizmo (Default: 1)
  43956. */
  43957. scaleRatio: number;
  43958. /**
  43959. * Disposes of the gizmo
  43960. */
  43961. dispose(): void;
  43962. /**
  43963. * CustomMeshes are not supported by this gizmo
  43964. * @param mesh The mesh to replace the default mesh of the gizmo
  43965. */
  43966. setCustomMesh(mesh: Mesh): void;
  43967. }
  43968. }
  43969. declare module "babylonjs/Gizmos/axisDragGizmo" {
  43970. import { Observable } from "babylonjs/Misc/observable";
  43971. import { Nullable } from "babylonjs/types";
  43972. import { Vector3 } from "babylonjs/Maths/math.vector";
  43973. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43975. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43976. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43977. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43978. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  43979. import { Scene } from "babylonjs/scene";
  43980. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43981. import { Color3 } from "babylonjs/Maths/math.color";
  43982. /**
  43983. * Single axis drag gizmo
  43984. */
  43985. export class AxisDragGizmo extends Gizmo {
  43986. /**
  43987. * Drag behavior responsible for the gizmos dragging interactions
  43988. */
  43989. dragBehavior: PointerDragBehavior;
  43990. private _pointerObserver;
  43991. /**
  43992. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43993. */
  43994. snapDistance: number;
  43995. /**
  43996. * Event that fires each time the gizmo snaps to a new location.
  43997. * * snapDistance is the the change in distance
  43998. */
  43999. onSnapObservable: Observable<{
  44000. snapDistance: number;
  44001. }>;
  44002. private _isEnabled;
  44003. private _parent;
  44004. private _arrow;
  44005. private _coloredMaterial;
  44006. private _hoverMaterial;
  44007. /** @hidden */
  44008. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44009. /** @hidden */
  44010. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44011. /**
  44012. * Creates an AxisDragGizmo
  44013. * @param gizmoLayer The utility layer the gizmo will be added to
  44014. * @param dragAxis The axis which the gizmo will be able to drag on
  44015. * @param color The color of the gizmo
  44016. */
  44017. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44018. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44019. /**
  44020. * If the gizmo is enabled
  44021. */
  44022. isEnabled: boolean;
  44023. /**
  44024. * Disposes of the gizmo
  44025. */
  44026. dispose(): void;
  44027. }
  44028. }
  44029. declare module "babylonjs/Debug/axesViewer" {
  44030. import { Vector3 } from "babylonjs/Maths/math.vector";
  44031. import { Nullable } from "babylonjs/types";
  44032. import { Scene } from "babylonjs/scene";
  44033. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44034. /**
  44035. * The Axes viewer will show 3 axes in a specific point in space
  44036. */
  44037. export class AxesViewer {
  44038. private _xAxis;
  44039. private _yAxis;
  44040. private _zAxis;
  44041. private _scaleLinesFactor;
  44042. private _instanced;
  44043. /**
  44044. * Gets the hosting scene
  44045. */
  44046. scene: Scene;
  44047. /**
  44048. * Gets or sets a number used to scale line length
  44049. */
  44050. scaleLines: number;
  44051. /** Gets the node hierarchy used to render x-axis */
  44052. readonly xAxis: TransformNode;
  44053. /** Gets the node hierarchy used to render y-axis */
  44054. readonly yAxis: TransformNode;
  44055. /** Gets the node hierarchy used to render z-axis */
  44056. readonly zAxis: TransformNode;
  44057. /**
  44058. * Creates a new AxesViewer
  44059. * @param scene defines the hosting scene
  44060. * @param scaleLines defines a number used to scale line length (1 by default)
  44061. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44062. * @param xAxis defines the node hierarchy used to render the x-axis
  44063. * @param yAxis defines the node hierarchy used to render the y-axis
  44064. * @param zAxis defines the node hierarchy used to render the z-axis
  44065. */
  44066. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44067. /**
  44068. * Force the viewer to update
  44069. * @param position defines the position of the viewer
  44070. * @param xaxis defines the x axis of the viewer
  44071. * @param yaxis defines the y axis of the viewer
  44072. * @param zaxis defines the z axis of the viewer
  44073. */
  44074. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44075. /**
  44076. * Creates an instance of this axes viewer.
  44077. * @returns a new axes viewer with instanced meshes
  44078. */
  44079. createInstance(): AxesViewer;
  44080. /** Releases resources */
  44081. dispose(): void;
  44082. private static _SetRenderingGroupId;
  44083. }
  44084. }
  44085. declare module "babylonjs/Debug/boneAxesViewer" {
  44086. import { Nullable } from "babylonjs/types";
  44087. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44088. import { Vector3 } from "babylonjs/Maths/math.vector";
  44089. import { Mesh } from "babylonjs/Meshes/mesh";
  44090. import { Bone } from "babylonjs/Bones/bone";
  44091. import { Scene } from "babylonjs/scene";
  44092. /**
  44093. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44094. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44095. */
  44096. export class BoneAxesViewer extends AxesViewer {
  44097. /**
  44098. * Gets or sets the target mesh where to display the axes viewer
  44099. */
  44100. mesh: Nullable<Mesh>;
  44101. /**
  44102. * Gets or sets the target bone where to display the axes viewer
  44103. */
  44104. bone: Nullable<Bone>;
  44105. /** Gets current position */
  44106. pos: Vector3;
  44107. /** Gets direction of X axis */
  44108. xaxis: Vector3;
  44109. /** Gets direction of Y axis */
  44110. yaxis: Vector3;
  44111. /** Gets direction of Z axis */
  44112. zaxis: Vector3;
  44113. /**
  44114. * Creates a new BoneAxesViewer
  44115. * @param scene defines the hosting scene
  44116. * @param bone defines the target bone
  44117. * @param mesh defines the target mesh
  44118. * @param scaleLines defines a scaling factor for line length (1 by default)
  44119. */
  44120. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44121. /**
  44122. * Force the viewer to update
  44123. */
  44124. update(): void;
  44125. /** Releases resources */
  44126. dispose(): void;
  44127. }
  44128. }
  44129. declare module "babylonjs/Debug/debugLayer" {
  44130. import { Scene } from "babylonjs/scene";
  44131. /**
  44132. * Interface used to define scene explorer extensibility option
  44133. */
  44134. export interface IExplorerExtensibilityOption {
  44135. /**
  44136. * Define the option label
  44137. */
  44138. label: string;
  44139. /**
  44140. * Defines the action to execute on click
  44141. */
  44142. action: (entity: any) => void;
  44143. }
  44144. /**
  44145. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44146. */
  44147. export interface IExplorerExtensibilityGroup {
  44148. /**
  44149. * Defines a predicate to test if a given type mut be extended
  44150. */
  44151. predicate: (entity: any) => boolean;
  44152. /**
  44153. * Gets the list of options added to a type
  44154. */
  44155. entries: IExplorerExtensibilityOption[];
  44156. }
  44157. /**
  44158. * Interface used to define the options to use to create the Inspector
  44159. */
  44160. export interface IInspectorOptions {
  44161. /**
  44162. * Display in overlay mode (default: false)
  44163. */
  44164. overlay?: boolean;
  44165. /**
  44166. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44167. */
  44168. globalRoot?: HTMLElement;
  44169. /**
  44170. * Display the Scene explorer
  44171. */
  44172. showExplorer?: boolean;
  44173. /**
  44174. * Display the property inspector
  44175. */
  44176. showInspector?: boolean;
  44177. /**
  44178. * Display in embed mode (both panes on the right)
  44179. */
  44180. embedMode?: boolean;
  44181. /**
  44182. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44183. */
  44184. handleResize?: boolean;
  44185. /**
  44186. * Allow the panes to popup (default: true)
  44187. */
  44188. enablePopup?: boolean;
  44189. /**
  44190. * Allow the panes to be closed by users (default: true)
  44191. */
  44192. enableClose?: boolean;
  44193. /**
  44194. * Optional list of extensibility entries
  44195. */
  44196. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44197. /**
  44198. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44199. */
  44200. inspectorURL?: string;
  44201. }
  44202. module "babylonjs/scene" {
  44203. interface Scene {
  44204. /**
  44205. * @hidden
  44206. * Backing field
  44207. */
  44208. _debugLayer: DebugLayer;
  44209. /**
  44210. * Gets the debug layer (aka Inspector) associated with the scene
  44211. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44212. */
  44213. debugLayer: DebugLayer;
  44214. }
  44215. }
  44216. /**
  44217. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44218. * what is happening in your scene
  44219. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44220. */
  44221. export class DebugLayer {
  44222. /**
  44223. * Define the url to get the inspector script from.
  44224. * By default it uses the babylonjs CDN.
  44225. * @ignoreNaming
  44226. */
  44227. static InspectorURL: string;
  44228. private _scene;
  44229. private BJSINSPECTOR;
  44230. private _onPropertyChangedObservable?;
  44231. /**
  44232. * Observable triggered when a property is changed through the inspector.
  44233. */
  44234. readonly onPropertyChangedObservable: any;
  44235. /**
  44236. * Instantiates a new debug layer.
  44237. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44238. * what is happening in your scene
  44239. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44240. * @param scene Defines the scene to inspect
  44241. */
  44242. constructor(scene: Scene);
  44243. /** Creates the inspector window. */
  44244. private _createInspector;
  44245. /**
  44246. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44247. * @param entity defines the entity to select
  44248. * @param lineContainerTitle defines the specific block to highlight
  44249. */
  44250. select(entity: any, lineContainerTitle?: string): void;
  44251. /** Get the inspector from bundle or global */
  44252. private _getGlobalInspector;
  44253. /**
  44254. * Get if the inspector is visible or not.
  44255. * @returns true if visible otherwise, false
  44256. */
  44257. isVisible(): boolean;
  44258. /**
  44259. * Hide the inspector and close its window.
  44260. */
  44261. hide(): void;
  44262. /**
  44263. * Launch the debugLayer.
  44264. * @param config Define the configuration of the inspector
  44265. * @return a promise fulfilled when the debug layer is visible
  44266. */
  44267. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44268. }
  44269. }
  44270. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44271. import { Nullable } from "babylonjs/types";
  44272. import { Scene } from "babylonjs/scene";
  44273. import { Vector4 } from "babylonjs/Maths/math.vector";
  44274. import { Color4 } from "babylonjs/Maths/math.color";
  44275. import { Mesh } from "babylonjs/Meshes/mesh";
  44276. /**
  44277. * Class containing static functions to help procedurally build meshes
  44278. */
  44279. export class BoxBuilder {
  44280. /**
  44281. * Creates a box mesh
  44282. * * The parameter `size` sets the size (float) of each box side (default 1)
  44283. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44284. * * 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)
  44285. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44286. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44287. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44289. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44290. * @param name defines the name of the mesh
  44291. * @param options defines the options used to create the mesh
  44292. * @param scene defines the hosting scene
  44293. * @returns the box mesh
  44294. */
  44295. static CreateBox(name: string, options: {
  44296. size?: number;
  44297. width?: number;
  44298. height?: number;
  44299. depth?: number;
  44300. faceUV?: Vector4[];
  44301. faceColors?: Color4[];
  44302. sideOrientation?: number;
  44303. frontUVs?: Vector4;
  44304. backUVs?: Vector4;
  44305. wrap?: boolean;
  44306. topBaseAt?: number;
  44307. bottomBaseAt?: number;
  44308. updatable?: boolean;
  44309. }, scene?: Nullable<Scene>): Mesh;
  44310. }
  44311. }
  44312. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44313. import { Vector4 } from "babylonjs/Maths/math.vector";
  44314. import { Mesh } from "babylonjs/Meshes/mesh";
  44315. /**
  44316. * Class containing static functions to help procedurally build meshes
  44317. */
  44318. export class SphereBuilder {
  44319. /**
  44320. * Creates a sphere mesh
  44321. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44322. * * 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`)
  44323. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44324. * * 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
  44325. * * 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)
  44326. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44327. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44329. * @param name defines the name of the mesh
  44330. * @param options defines the options used to create the mesh
  44331. * @param scene defines the hosting scene
  44332. * @returns the sphere mesh
  44333. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44334. */
  44335. static CreateSphere(name: string, options: {
  44336. segments?: number;
  44337. diameter?: number;
  44338. diameterX?: number;
  44339. diameterY?: number;
  44340. diameterZ?: number;
  44341. arc?: number;
  44342. slice?: number;
  44343. sideOrientation?: number;
  44344. frontUVs?: Vector4;
  44345. backUVs?: Vector4;
  44346. updatable?: boolean;
  44347. }, scene: any): Mesh;
  44348. }
  44349. }
  44350. declare module "babylonjs/Debug/physicsViewer" {
  44351. import { Nullable } from "babylonjs/types";
  44352. import { Scene } from "babylonjs/scene";
  44353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44354. import { Mesh } from "babylonjs/Meshes/mesh";
  44355. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44356. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44357. /**
  44358. * Used to show the physics impostor around the specific mesh
  44359. */
  44360. export class PhysicsViewer {
  44361. /** @hidden */
  44362. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44363. /** @hidden */
  44364. protected _meshes: Array<Nullable<AbstractMesh>>;
  44365. /** @hidden */
  44366. protected _scene: Nullable<Scene>;
  44367. /** @hidden */
  44368. protected _numMeshes: number;
  44369. /** @hidden */
  44370. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44371. private _renderFunction;
  44372. private _utilityLayer;
  44373. private _debugBoxMesh;
  44374. private _debugSphereMesh;
  44375. private _debugCylinderMesh;
  44376. private _debugMaterial;
  44377. private _debugMeshMeshes;
  44378. /**
  44379. * Creates a new PhysicsViewer
  44380. * @param scene defines the hosting scene
  44381. */
  44382. constructor(scene: Scene);
  44383. /** @hidden */
  44384. protected _updateDebugMeshes(): void;
  44385. /**
  44386. * Renders a specified physic impostor
  44387. * @param impostor defines the impostor to render
  44388. * @param targetMesh defines the mesh represented by the impostor
  44389. * @returns the new debug mesh used to render the impostor
  44390. */
  44391. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44392. /**
  44393. * Hides a specified physic impostor
  44394. * @param impostor defines the impostor to hide
  44395. */
  44396. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44397. private _getDebugMaterial;
  44398. private _getDebugBoxMesh;
  44399. private _getDebugSphereMesh;
  44400. private _getDebugCylinderMesh;
  44401. private _getDebugMeshMesh;
  44402. private _getDebugMesh;
  44403. /** Releases all resources */
  44404. dispose(): void;
  44405. }
  44406. }
  44407. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44408. import { Vector3 } from "babylonjs/Maths/math.vector";
  44409. import { Color4 } from "babylonjs/Maths/math.color";
  44410. import { Nullable } from "babylonjs/types";
  44411. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44412. import { Scene } from "babylonjs/scene";
  44413. /**
  44414. * Class containing static functions to help procedurally build meshes
  44415. */
  44416. export class LinesBuilder {
  44417. /**
  44418. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44419. * * 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
  44420. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44421. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44422. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44423. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44424. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44425. * * 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
  44426. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44428. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44429. * @param name defines the name of the new line system
  44430. * @param options defines the options used to create the line system
  44431. * @param scene defines the hosting scene
  44432. * @returns a new line system mesh
  44433. */
  44434. static CreateLineSystem(name: string, options: {
  44435. lines: Vector3[][];
  44436. updatable?: boolean;
  44437. instance?: Nullable<LinesMesh>;
  44438. colors?: Nullable<Color4[][]>;
  44439. useVertexAlpha?: boolean;
  44440. }, scene: Nullable<Scene>): LinesMesh;
  44441. /**
  44442. * Creates a line mesh
  44443. * 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
  44444. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44445. * * The parameter `points` is an array successive Vector3
  44446. * * 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
  44447. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44448. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44449. * * When updating an instance, remember that only point positions can change, not the number of points
  44450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44451. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44452. * @param name defines the name of the new line system
  44453. * @param options defines the options used to create the line system
  44454. * @param scene defines the hosting scene
  44455. * @returns a new line mesh
  44456. */
  44457. static CreateLines(name: string, options: {
  44458. points: Vector3[];
  44459. updatable?: boolean;
  44460. instance?: Nullable<LinesMesh>;
  44461. colors?: Color4[];
  44462. useVertexAlpha?: boolean;
  44463. }, scene?: Nullable<Scene>): LinesMesh;
  44464. /**
  44465. * Creates a dashed line mesh
  44466. * * 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
  44467. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44468. * * The parameter `points` is an array successive Vector3
  44469. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44470. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44471. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44472. * * 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
  44473. * * When updating an instance, remember that only point positions can change, not the number of points
  44474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44475. * @param name defines the name of the mesh
  44476. * @param options defines the options used to create the mesh
  44477. * @param scene defines the hosting scene
  44478. * @returns the dashed line mesh
  44479. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44480. */
  44481. static CreateDashedLines(name: string, options: {
  44482. points: Vector3[];
  44483. dashSize?: number;
  44484. gapSize?: number;
  44485. dashNb?: number;
  44486. updatable?: boolean;
  44487. instance?: LinesMesh;
  44488. }, scene?: Nullable<Scene>): LinesMesh;
  44489. }
  44490. }
  44491. declare module "babylonjs/Debug/rayHelper" {
  44492. import { Nullable } from "babylonjs/types";
  44493. import { Ray } from "babylonjs/Culling/ray";
  44494. import { Vector3 } from "babylonjs/Maths/math.vector";
  44495. import { Color3 } from "babylonjs/Maths/math.color";
  44496. import { Scene } from "babylonjs/scene";
  44497. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44498. import "babylonjs/Meshes/Builders/linesBuilder";
  44499. /**
  44500. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44501. * in order to better appreciate the issue one might have.
  44502. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44503. */
  44504. export class RayHelper {
  44505. /**
  44506. * Defines the ray we are currently tryin to visualize.
  44507. */
  44508. ray: Nullable<Ray>;
  44509. private _renderPoints;
  44510. private _renderLine;
  44511. private _renderFunction;
  44512. private _scene;
  44513. private _updateToMeshFunction;
  44514. private _attachedToMesh;
  44515. private _meshSpaceDirection;
  44516. private _meshSpaceOrigin;
  44517. /**
  44518. * Helper function to create a colored helper in a scene in one line.
  44519. * @param ray Defines the ray we are currently tryin to visualize
  44520. * @param scene Defines the scene the ray is used in
  44521. * @param color Defines the color we want to see the ray in
  44522. * @returns The newly created ray helper.
  44523. */
  44524. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44525. /**
  44526. * Instantiate a new ray helper.
  44527. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44528. * in order to better appreciate the issue one might have.
  44529. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44530. * @param ray Defines the ray we are currently tryin to visualize
  44531. */
  44532. constructor(ray: Ray);
  44533. /**
  44534. * Shows the ray we are willing to debug.
  44535. * @param scene Defines the scene the ray needs to be rendered in
  44536. * @param color Defines the color the ray needs to be rendered in
  44537. */
  44538. show(scene: Scene, color?: Color3): void;
  44539. /**
  44540. * Hides the ray we are debugging.
  44541. */
  44542. hide(): void;
  44543. private _render;
  44544. /**
  44545. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44546. * @param mesh Defines the mesh we want the helper attached to
  44547. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44548. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44549. * @param length Defines the length of the ray
  44550. */
  44551. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  44552. /**
  44553. * Detach the ray helper from the mesh it has previously been attached to.
  44554. */
  44555. detachFromMesh(): void;
  44556. private _updateToMesh;
  44557. /**
  44558. * Dispose the helper and release its associated resources.
  44559. */
  44560. dispose(): void;
  44561. }
  44562. }
  44563. declare module "babylonjs/Debug/skeletonViewer" {
  44564. import { Color3 } from "babylonjs/Maths/math.color";
  44565. import { Scene } from "babylonjs/scene";
  44566. import { Nullable } from "babylonjs/types";
  44567. import { Skeleton } from "babylonjs/Bones/skeleton";
  44568. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44569. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44570. /**
  44571. * Class used to render a debug view of a given skeleton
  44572. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  44573. */
  44574. export class SkeletonViewer {
  44575. /** defines the skeleton to render */
  44576. skeleton: Skeleton;
  44577. /** defines the mesh attached to the skeleton */
  44578. mesh: AbstractMesh;
  44579. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44580. autoUpdateBonesMatrices: boolean;
  44581. /** defines the rendering group id to use with the viewer */
  44582. renderingGroupId: number;
  44583. /** Gets or sets the color used to render the skeleton */
  44584. color: Color3;
  44585. private _scene;
  44586. private _debugLines;
  44587. private _debugMesh;
  44588. private _isEnabled;
  44589. private _renderFunction;
  44590. private _utilityLayer;
  44591. /**
  44592. * Returns the mesh used to render the bones
  44593. */
  44594. readonly debugMesh: Nullable<LinesMesh>;
  44595. /**
  44596. * Creates a new SkeletonViewer
  44597. * @param skeleton defines the skeleton to render
  44598. * @param mesh defines the mesh attached to the skeleton
  44599. * @param scene defines the hosting scene
  44600. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  44601. * @param renderingGroupId defines the rendering group id to use with the viewer
  44602. */
  44603. constructor(
  44604. /** defines the skeleton to render */
  44605. skeleton: Skeleton,
  44606. /** defines the mesh attached to the skeleton */
  44607. mesh: AbstractMesh, scene: Scene,
  44608. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44609. autoUpdateBonesMatrices?: boolean,
  44610. /** defines the rendering group id to use with the viewer */
  44611. renderingGroupId?: number);
  44612. /** Gets or sets a boolean indicating if the viewer is enabled */
  44613. isEnabled: boolean;
  44614. private _getBonePosition;
  44615. private _getLinesForBonesWithLength;
  44616. private _getLinesForBonesNoLength;
  44617. /** Update the viewer to sync with current skeleton state */
  44618. update(): void;
  44619. /** Release associated resources */
  44620. dispose(): void;
  44621. }
  44622. }
  44623. declare module "babylonjs/Debug/index" {
  44624. export * from "babylonjs/Debug/axesViewer";
  44625. export * from "babylonjs/Debug/boneAxesViewer";
  44626. export * from "babylonjs/Debug/debugLayer";
  44627. export * from "babylonjs/Debug/physicsViewer";
  44628. export * from "babylonjs/Debug/rayHelper";
  44629. export * from "babylonjs/Debug/skeletonViewer";
  44630. }
  44631. declare module "babylonjs/Engines/nullEngine" {
  44632. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  44633. import { Scene } from "babylonjs/scene";
  44634. import { Engine } from "babylonjs/Engines/engine";
  44635. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  44636. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  44637. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  44638. import { Effect } from "babylonjs/Materials/effect";
  44639. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  44640. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  44641. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  44642. /**
  44643. * Options to create the null engine
  44644. */
  44645. export class NullEngineOptions {
  44646. /**
  44647. * Render width (Default: 512)
  44648. */
  44649. renderWidth: number;
  44650. /**
  44651. * Render height (Default: 256)
  44652. */
  44653. renderHeight: number;
  44654. /**
  44655. * Texture size (Default: 512)
  44656. */
  44657. textureSize: number;
  44658. /**
  44659. * If delta time between frames should be constant
  44660. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44661. */
  44662. deterministicLockstep: boolean;
  44663. /**
  44664. * Maximum about of steps between frames (Default: 4)
  44665. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44666. */
  44667. lockstepMaxSteps: number;
  44668. }
  44669. /**
  44670. * The null engine class provides support for headless version of babylon.js.
  44671. * This can be used in server side scenario or for testing purposes
  44672. */
  44673. export class NullEngine extends Engine {
  44674. private _options;
  44675. /**
  44676. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44677. */
  44678. isDeterministicLockStep(): boolean;
  44679. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  44680. getLockstepMaxSteps(): number;
  44681. /**
  44682. * Sets hardware scaling, used to save performance if needed
  44683. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  44684. */
  44685. getHardwareScalingLevel(): number;
  44686. constructor(options?: NullEngineOptions);
  44687. createVertexBuffer(vertices: FloatArray): DataBuffer;
  44688. createIndexBuffer(indices: IndicesArray): DataBuffer;
  44689. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44690. getRenderWidth(useScreen?: boolean): number;
  44691. getRenderHeight(useScreen?: boolean): number;
  44692. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  44693. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  44694. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  44695. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44696. bindSamplers(effect: Effect): void;
  44697. enableEffect(effect: Effect): void;
  44698. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44699. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44700. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44701. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44702. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44703. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44704. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44705. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44706. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44707. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44708. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44709. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44710. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44711. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44712. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44713. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44714. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44715. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44716. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44717. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44718. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44719. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44720. bindBuffers(vertexBuffers: {
  44721. [key: string]: VertexBuffer;
  44722. }, indexBuffer: DataBuffer, effect: Effect): void;
  44723. wipeCaches(bruteForce?: boolean): void;
  44724. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  44725. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44726. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44727. /** @hidden */
  44728. _createTexture(): WebGLTexture;
  44729. /** @hidden */
  44730. _releaseTexture(texture: InternalTexture): void;
  44731. 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;
  44732. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44733. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44734. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44735. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44736. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  44737. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  44738. areAllEffectsReady(): boolean;
  44739. /**
  44740. * @hidden
  44741. * Get the current error code of the webGL context
  44742. * @returns the error code
  44743. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  44744. */
  44745. getError(): number;
  44746. /** @hidden */
  44747. _getUnpackAlignement(): number;
  44748. /** @hidden */
  44749. _unpackFlipY(value: boolean): void;
  44750. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  44751. /**
  44752. * Updates a dynamic vertex buffer.
  44753. * @param vertexBuffer the vertex buffer to update
  44754. * @param data the data used to update the vertex buffer
  44755. * @param byteOffset the byte offset of the data (optional)
  44756. * @param byteLength the byte length of the data (optional)
  44757. */
  44758. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  44759. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  44760. /** @hidden */
  44761. _bindTexture(channel: number, texture: InternalTexture): void;
  44762. /** @hidden */
  44763. _releaseBuffer(buffer: DataBuffer): boolean;
  44764. releaseEffects(): void;
  44765. displayLoadingUI(): void;
  44766. hideLoadingUI(): void;
  44767. /** @hidden */
  44768. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44769. /** @hidden */
  44770. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44771. /** @hidden */
  44772. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44773. /** @hidden */
  44774. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44775. }
  44776. }
  44777. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  44778. import { Nullable, int } from "babylonjs/types";
  44779. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  44780. /** @hidden */
  44781. export class _OcclusionDataStorage {
  44782. /** @hidden */
  44783. occlusionInternalRetryCounter: number;
  44784. /** @hidden */
  44785. isOcclusionQueryInProgress: boolean;
  44786. /** @hidden */
  44787. isOccluded: boolean;
  44788. /** @hidden */
  44789. occlusionRetryCount: number;
  44790. /** @hidden */
  44791. occlusionType: number;
  44792. /** @hidden */
  44793. occlusionQueryAlgorithmType: number;
  44794. }
  44795. module "babylonjs/Engines/engine" {
  44796. interface Engine {
  44797. /**
  44798. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  44799. * @return the new query
  44800. */
  44801. createQuery(): WebGLQuery;
  44802. /**
  44803. * Delete and release a webGL query
  44804. * @param query defines the query to delete
  44805. * @return the current engine
  44806. */
  44807. deleteQuery(query: WebGLQuery): Engine;
  44808. /**
  44809. * Check if a given query has resolved and got its value
  44810. * @param query defines the query to check
  44811. * @returns true if the query got its value
  44812. */
  44813. isQueryResultAvailable(query: WebGLQuery): boolean;
  44814. /**
  44815. * Gets the value of a given query
  44816. * @param query defines the query to check
  44817. * @returns the value of the query
  44818. */
  44819. getQueryResult(query: WebGLQuery): number;
  44820. /**
  44821. * Initiates an occlusion query
  44822. * @param algorithmType defines the algorithm to use
  44823. * @param query defines the query to use
  44824. * @returns the current engine
  44825. * @see http://doc.babylonjs.com/features/occlusionquery
  44826. */
  44827. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  44828. /**
  44829. * Ends an occlusion query
  44830. * @see http://doc.babylonjs.com/features/occlusionquery
  44831. * @param algorithmType defines the algorithm to use
  44832. * @returns the current engine
  44833. */
  44834. endOcclusionQuery(algorithmType: number): Engine;
  44835. /**
  44836. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  44837. * Please note that only one query can be issued at a time
  44838. * @returns a time token used to track the time span
  44839. */
  44840. startTimeQuery(): Nullable<_TimeToken>;
  44841. /**
  44842. * Ends a time query
  44843. * @param token defines the token used to measure the time span
  44844. * @returns the time spent (in ns)
  44845. */
  44846. endTimeQuery(token: _TimeToken): int;
  44847. /** @hidden */
  44848. _currentNonTimestampToken: Nullable<_TimeToken>;
  44849. /** @hidden */
  44850. _createTimeQuery(): WebGLQuery;
  44851. /** @hidden */
  44852. _deleteTimeQuery(query: WebGLQuery): void;
  44853. /** @hidden */
  44854. _getGlAlgorithmType(algorithmType: number): number;
  44855. /** @hidden */
  44856. _getTimeQueryResult(query: WebGLQuery): any;
  44857. /** @hidden */
  44858. _getTimeQueryAvailability(query: WebGLQuery): any;
  44859. }
  44860. }
  44861. module "babylonjs/Meshes/abstractMesh" {
  44862. interface AbstractMesh {
  44863. /**
  44864. * Backing filed
  44865. * @hidden
  44866. */
  44867. __occlusionDataStorage: _OcclusionDataStorage;
  44868. /**
  44869. * Access property
  44870. * @hidden
  44871. */
  44872. _occlusionDataStorage: _OcclusionDataStorage;
  44873. /**
  44874. * 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.
  44875. * The default value is -1 which means don't break the query and wait till the result
  44876. * @see http://doc.babylonjs.com/features/occlusionquery
  44877. */
  44878. occlusionRetryCount: number;
  44879. /**
  44880. * 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:
  44881. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  44882. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  44883. * * 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.
  44884. * @see http://doc.babylonjs.com/features/occlusionquery
  44885. */
  44886. occlusionType: number;
  44887. /**
  44888. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  44889. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  44890. * * 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.
  44891. * @see http://doc.babylonjs.com/features/occlusionquery
  44892. */
  44893. occlusionQueryAlgorithmType: number;
  44894. /**
  44895. * 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
  44896. * @see http://doc.babylonjs.com/features/occlusionquery
  44897. */
  44898. isOccluded: boolean;
  44899. /**
  44900. * Flag to check the progress status of the query
  44901. * @see http://doc.babylonjs.com/features/occlusionquery
  44902. */
  44903. isOcclusionQueryInProgress: boolean;
  44904. }
  44905. }
  44906. }
  44907. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  44908. import { Nullable } from "babylonjs/types";
  44909. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  44910. /** @hidden */
  44911. export var _forceTransformFeedbackToBundle: boolean;
  44912. module "babylonjs/Engines/engine" {
  44913. interface Engine {
  44914. /**
  44915. * Creates a webGL transform feedback object
  44916. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  44917. * @returns the webGL transform feedback object
  44918. */
  44919. createTransformFeedback(): WebGLTransformFeedback;
  44920. /**
  44921. * Delete a webGL transform feedback object
  44922. * @param value defines the webGL transform feedback object to delete
  44923. */
  44924. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  44925. /**
  44926. * Bind a webGL transform feedback object to the webgl context
  44927. * @param value defines the webGL transform feedback object to bind
  44928. */
  44929. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  44930. /**
  44931. * Begins a transform feedback operation
  44932. * @param usePoints defines if points or triangles must be used
  44933. */
  44934. beginTransformFeedback(usePoints: boolean): void;
  44935. /**
  44936. * Ends a transform feedback operation
  44937. */
  44938. endTransformFeedback(): void;
  44939. /**
  44940. * Specify the varyings to use with transform feedback
  44941. * @param program defines the associated webGL program
  44942. * @param value defines the list of strings representing the varying names
  44943. */
  44944. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  44945. /**
  44946. * Bind a webGL buffer for a transform feedback operation
  44947. * @param value defines the webGL buffer to bind
  44948. */
  44949. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  44950. }
  44951. }
  44952. }
  44953. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  44954. import { Scene } from "babylonjs/scene";
  44955. import { Engine } from "babylonjs/Engines/engine";
  44956. import { Texture } from "babylonjs/Materials/Textures/texture";
  44957. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44958. import "babylonjs/Engines/Extensions/engine.multiRender";
  44959. /**
  44960. * Creation options of the multi render target texture.
  44961. */
  44962. export interface IMultiRenderTargetOptions {
  44963. /**
  44964. * Define if the texture needs to create mip maps after render.
  44965. */
  44966. generateMipMaps?: boolean;
  44967. /**
  44968. * Define the types of all the draw buffers we want to create
  44969. */
  44970. types?: number[];
  44971. /**
  44972. * Define the sampling modes of all the draw buffers we want to create
  44973. */
  44974. samplingModes?: number[];
  44975. /**
  44976. * Define if a depth buffer is required
  44977. */
  44978. generateDepthBuffer?: boolean;
  44979. /**
  44980. * Define if a stencil buffer is required
  44981. */
  44982. generateStencilBuffer?: boolean;
  44983. /**
  44984. * Define if a depth texture is required instead of a depth buffer
  44985. */
  44986. generateDepthTexture?: boolean;
  44987. /**
  44988. * Define the number of desired draw buffers
  44989. */
  44990. textureCount?: number;
  44991. /**
  44992. * Define if aspect ratio should be adapted to the texture or stay the scene one
  44993. */
  44994. doNotChangeAspectRatio?: boolean;
  44995. /**
  44996. * Define the default type of the buffers we are creating
  44997. */
  44998. defaultType?: number;
  44999. }
  45000. /**
  45001. * A multi render target, like a render target provides the ability to render to a texture.
  45002. * Unlike the render target, it can render to several draw buffers in one draw.
  45003. * This is specially interesting in deferred rendering or for any effects requiring more than
  45004. * just one color from a single pass.
  45005. */
  45006. export class MultiRenderTarget extends RenderTargetTexture {
  45007. private _internalTextures;
  45008. private _textures;
  45009. private _multiRenderTargetOptions;
  45010. /**
  45011. * Get if draw buffers are currently supported by the used hardware and browser.
  45012. */
  45013. readonly isSupported: boolean;
  45014. /**
  45015. * Get the list of textures generated by the multi render target.
  45016. */
  45017. readonly textures: Texture[];
  45018. /**
  45019. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45020. */
  45021. readonly depthTexture: Texture;
  45022. /**
  45023. * Set the wrapping mode on U of all the textures we are rendering to.
  45024. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45025. */
  45026. wrapU: number;
  45027. /**
  45028. * Set the wrapping mode on V of all the textures we are rendering to.
  45029. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45030. */
  45031. wrapV: number;
  45032. /**
  45033. * Instantiate a new multi render target texture.
  45034. * A multi render target, like a render target provides the ability to render to a texture.
  45035. * Unlike the render target, it can render to several draw buffers in one draw.
  45036. * This is specially interesting in deferred rendering or for any effects requiring more than
  45037. * just one color from a single pass.
  45038. * @param name Define the name of the texture
  45039. * @param size Define the size of the buffers to render to
  45040. * @param count Define the number of target we are rendering into
  45041. * @param scene Define the scene the texture belongs to
  45042. * @param options Define the options used to create the multi render target
  45043. */
  45044. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45045. /** @hidden */
  45046. _rebuild(): void;
  45047. private _createInternalTextures;
  45048. private _createTextures;
  45049. /**
  45050. * Define the number of samples used if MSAA is enabled.
  45051. */
  45052. samples: number;
  45053. /**
  45054. * Resize all the textures in the multi render target.
  45055. * Be carrefull as it will recreate all the data in the new texture.
  45056. * @param size Define the new size
  45057. */
  45058. resize(size: any): void;
  45059. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45060. /**
  45061. * Dispose the render targets and their associated resources
  45062. */
  45063. dispose(): void;
  45064. /**
  45065. * Release all the underlying texture used as draw buffers.
  45066. */
  45067. releaseInternalTextures(): void;
  45068. }
  45069. }
  45070. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45071. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45072. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45073. import { Nullable } from "babylonjs/types";
  45074. module "babylonjs/Engines/engine" {
  45075. interface Engine {
  45076. /**
  45077. * Unbind a list of render target textures from the webGL context
  45078. * This is used only when drawBuffer extension or webGL2 are active
  45079. * @param textures defines the render target textures to unbind
  45080. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45081. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45082. */
  45083. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45084. /**
  45085. * Create a multi render target texture
  45086. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45087. * @param size defines the size of the texture
  45088. * @param options defines the creation options
  45089. * @returns the cube texture as an InternalTexture
  45090. */
  45091. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45092. /**
  45093. * Update the sample count for a given multiple render target texture
  45094. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45095. * @param textures defines the textures to update
  45096. * @param samples defines the sample count to set
  45097. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45098. */
  45099. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45100. }
  45101. }
  45102. }
  45103. declare module "babylonjs/Engines/Extensions/index" {
  45104. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  45105. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  45106. export * from "babylonjs/Engines/Extensions/engine.multiview";
  45107. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  45108. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  45109. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  45110. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  45111. export * from "babylonjs/Engines/Extensions/engine.webVR";
  45112. }
  45113. declare module "babylonjs/Engines/index" {
  45114. export * from "babylonjs/Engines/constants";
  45115. export * from "babylonjs/Engines/engine";
  45116. export * from "babylonjs/Engines/engineStore";
  45117. export * from "babylonjs/Engines/nullEngine";
  45118. export * from "babylonjs/Engines/Extensions/index";
  45119. export * from "babylonjs/Engines/IPipelineContext";
  45120. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  45121. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  45122. }
  45123. declare module "babylonjs/Events/clipboardEvents" {
  45124. /**
  45125. * Gather the list of clipboard event types as constants.
  45126. */
  45127. export class ClipboardEventTypes {
  45128. /**
  45129. * The clipboard event is fired when a copy command is active (pressed).
  45130. */
  45131. static readonly COPY: number;
  45132. /**
  45133. * The clipboard event is fired when a cut command is active (pressed).
  45134. */
  45135. static readonly CUT: number;
  45136. /**
  45137. * The clipboard event is fired when a paste command is active (pressed).
  45138. */
  45139. static readonly PASTE: number;
  45140. }
  45141. /**
  45142. * This class is used to store clipboard related info for the onClipboardObservable event.
  45143. */
  45144. export class ClipboardInfo {
  45145. /**
  45146. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45147. */
  45148. type: number;
  45149. /**
  45150. * Defines the related dom event
  45151. */
  45152. event: ClipboardEvent;
  45153. /**
  45154. *Creates an instance of ClipboardInfo.
  45155. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  45156. * @param event Defines the related dom event
  45157. */
  45158. constructor(
  45159. /**
  45160. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45161. */
  45162. type: number,
  45163. /**
  45164. * Defines the related dom event
  45165. */
  45166. event: ClipboardEvent);
  45167. /**
  45168. * Get the clipboard event's type from the keycode.
  45169. * @param keyCode Defines the keyCode for the current keyboard event.
  45170. * @return {number}
  45171. */
  45172. static GetTypeFromCharacter(keyCode: number): number;
  45173. }
  45174. }
  45175. declare module "babylonjs/Events/index" {
  45176. export * from "babylonjs/Events/keyboardEvents";
  45177. export * from "babylonjs/Events/pointerEvents";
  45178. export * from "babylonjs/Events/clipboardEvents";
  45179. }
  45180. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  45181. import { Scene } from "babylonjs/scene";
  45182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45183. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45184. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45185. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45186. /**
  45187. * Google Daydream controller
  45188. */
  45189. export class DaydreamController extends WebVRController {
  45190. /**
  45191. * Base Url for the controller model.
  45192. */
  45193. static MODEL_BASE_URL: string;
  45194. /**
  45195. * File name for the controller model.
  45196. */
  45197. static MODEL_FILENAME: string;
  45198. /**
  45199. * Gamepad Id prefix used to identify Daydream Controller.
  45200. */
  45201. static readonly GAMEPAD_ID_PREFIX: string;
  45202. /**
  45203. * Creates a new DaydreamController from a gamepad
  45204. * @param vrGamepad the gamepad that the controller should be created from
  45205. */
  45206. constructor(vrGamepad: any);
  45207. /**
  45208. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45209. * @param scene scene in which to add meshes
  45210. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45211. */
  45212. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45213. /**
  45214. * Called once for each button that changed state since the last frame
  45215. * @param buttonIdx Which button index changed
  45216. * @param state New state of the button
  45217. * @param changes Which properties on the state changed since last frame
  45218. */
  45219. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45220. }
  45221. }
  45222. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  45223. import { Scene } from "babylonjs/scene";
  45224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45225. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45226. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45227. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45228. /**
  45229. * Gear VR Controller
  45230. */
  45231. export class GearVRController extends WebVRController {
  45232. /**
  45233. * Base Url for the controller model.
  45234. */
  45235. static MODEL_BASE_URL: string;
  45236. /**
  45237. * File name for the controller model.
  45238. */
  45239. static MODEL_FILENAME: string;
  45240. /**
  45241. * Gamepad Id prefix used to identify this controller.
  45242. */
  45243. static readonly GAMEPAD_ID_PREFIX: string;
  45244. private readonly _buttonIndexToObservableNameMap;
  45245. /**
  45246. * Creates a new GearVRController from a gamepad
  45247. * @param vrGamepad the gamepad that the controller should be created from
  45248. */
  45249. constructor(vrGamepad: any);
  45250. /**
  45251. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45252. * @param scene scene in which to add meshes
  45253. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45254. */
  45255. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45256. /**
  45257. * Called once for each button that changed state since the last frame
  45258. * @param buttonIdx Which button index changed
  45259. * @param state New state of the button
  45260. * @param changes Which properties on the state changed since last frame
  45261. */
  45262. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45263. }
  45264. }
  45265. declare module "babylonjs/Gamepads/Controllers/index" {
  45266. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  45267. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  45268. export * from "babylonjs/Gamepads/Controllers/genericController";
  45269. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  45270. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45271. export * from "babylonjs/Gamepads/Controllers/viveController";
  45272. export * from "babylonjs/Gamepads/Controllers/webVRController";
  45273. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  45274. }
  45275. declare module "babylonjs/Gamepads/index" {
  45276. export * from "babylonjs/Gamepads/Controllers/index";
  45277. export * from "babylonjs/Gamepads/gamepad";
  45278. export * from "babylonjs/Gamepads/gamepadManager";
  45279. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  45280. export * from "babylonjs/Gamepads/xboxGamepad";
  45281. }
  45282. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  45283. import { Scene } from "babylonjs/scene";
  45284. import { Vector4 } from "babylonjs/Maths/math.vector";
  45285. import { Color4 } from "babylonjs/Maths/math.color";
  45286. import { Mesh } from "babylonjs/Meshes/mesh";
  45287. import { Nullable } from "babylonjs/types";
  45288. /**
  45289. * Class containing static functions to help procedurally build meshes
  45290. */
  45291. export class PolyhedronBuilder {
  45292. /**
  45293. * Creates a polyhedron mesh
  45294. * * 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
  45295. * * The parameter `size` (positive float, default 1) sets the polygon size
  45296. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  45297. * * 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`
  45298. * * 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
  45299. * * 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)`)
  45300. * * 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
  45301. * * 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
  45302. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45303. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45304. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45305. * @param name defines the name of the mesh
  45306. * @param options defines the options used to create the mesh
  45307. * @param scene defines the hosting scene
  45308. * @returns the polyhedron mesh
  45309. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  45310. */
  45311. static CreatePolyhedron(name: string, options: {
  45312. type?: number;
  45313. size?: number;
  45314. sizeX?: number;
  45315. sizeY?: number;
  45316. sizeZ?: number;
  45317. custom?: any;
  45318. faceUV?: Vector4[];
  45319. faceColors?: Color4[];
  45320. flat?: boolean;
  45321. updatable?: boolean;
  45322. sideOrientation?: number;
  45323. frontUVs?: Vector4;
  45324. backUVs?: Vector4;
  45325. }, scene?: Nullable<Scene>): Mesh;
  45326. }
  45327. }
  45328. declare module "babylonjs/Gizmos/scaleGizmo" {
  45329. import { Observable } from "babylonjs/Misc/observable";
  45330. import { Nullable } from "babylonjs/types";
  45331. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45332. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45333. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  45334. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45335. /**
  45336. * Gizmo that enables scaling a mesh along 3 axis
  45337. */
  45338. export class ScaleGizmo extends Gizmo {
  45339. /**
  45340. * Internal gizmo used for interactions on the x axis
  45341. */
  45342. xGizmo: AxisScaleGizmo;
  45343. /**
  45344. * Internal gizmo used for interactions on the y axis
  45345. */
  45346. yGizmo: AxisScaleGizmo;
  45347. /**
  45348. * Internal gizmo used for interactions on the z axis
  45349. */
  45350. zGizmo: AxisScaleGizmo;
  45351. /**
  45352. * Internal gizmo used to scale all axis equally
  45353. */
  45354. uniformScaleGizmo: AxisScaleGizmo;
  45355. private _meshAttached;
  45356. private _updateGizmoRotationToMatchAttachedMesh;
  45357. private _snapDistance;
  45358. private _scaleRatio;
  45359. private _uniformScalingMesh;
  45360. private _octahedron;
  45361. /** Fires an event when any of it's sub gizmos are dragged */
  45362. onDragStartObservable: Observable<unknown>;
  45363. /** Fires an event when any of it's sub gizmos are released from dragging */
  45364. onDragEndObservable: Observable<unknown>;
  45365. attachedMesh: Nullable<AbstractMesh>;
  45366. /**
  45367. * Creates a ScaleGizmo
  45368. * @param gizmoLayer The utility layer the gizmo will be added to
  45369. */
  45370. constructor(gizmoLayer?: UtilityLayerRenderer);
  45371. updateGizmoRotationToMatchAttachedMesh: boolean;
  45372. /**
  45373. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45374. */
  45375. snapDistance: number;
  45376. /**
  45377. * Ratio for the scale of the gizmo (Default: 1)
  45378. */
  45379. scaleRatio: number;
  45380. /**
  45381. * Disposes of the gizmo
  45382. */
  45383. dispose(): void;
  45384. }
  45385. }
  45386. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  45387. import { Observable } from "babylonjs/Misc/observable";
  45388. import { Nullable } from "babylonjs/types";
  45389. import { Vector3 } from "babylonjs/Maths/math.vector";
  45390. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45391. import { Mesh } from "babylonjs/Meshes/mesh";
  45392. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45393. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45394. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45395. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45396. import { Color3 } from "babylonjs/Maths/math.color";
  45397. /**
  45398. * Single axis scale gizmo
  45399. */
  45400. export class AxisScaleGizmo extends Gizmo {
  45401. /**
  45402. * Drag behavior responsible for the gizmos dragging interactions
  45403. */
  45404. dragBehavior: PointerDragBehavior;
  45405. private _pointerObserver;
  45406. /**
  45407. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45408. */
  45409. snapDistance: number;
  45410. /**
  45411. * Event that fires each time the gizmo snaps to a new location.
  45412. * * snapDistance is the the change in distance
  45413. */
  45414. onSnapObservable: Observable<{
  45415. snapDistance: number;
  45416. }>;
  45417. /**
  45418. * If the scaling operation should be done on all axis (default: false)
  45419. */
  45420. uniformScaling: boolean;
  45421. private _isEnabled;
  45422. private _parent;
  45423. private _arrow;
  45424. private _coloredMaterial;
  45425. private _hoverMaterial;
  45426. /**
  45427. * Creates an AxisScaleGizmo
  45428. * @param gizmoLayer The utility layer the gizmo will be added to
  45429. * @param dragAxis The axis which the gizmo will be able to scale on
  45430. * @param color The color of the gizmo
  45431. */
  45432. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45433. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45434. /**
  45435. * If the gizmo is enabled
  45436. */
  45437. isEnabled: boolean;
  45438. /**
  45439. * Disposes of the gizmo
  45440. */
  45441. dispose(): void;
  45442. /**
  45443. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45444. * @param mesh The mesh to replace the default mesh of the gizmo
  45445. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45446. */
  45447. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45448. }
  45449. }
  45450. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  45451. import { Observable } from "babylonjs/Misc/observable";
  45452. import { Nullable } from "babylonjs/types";
  45453. import { Vector3 } from "babylonjs/Maths/math.vector";
  45454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45455. import { Mesh } from "babylonjs/Meshes/mesh";
  45456. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45457. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45458. import { Color3 } from "babylonjs/Maths/math.color";
  45459. import "babylonjs/Meshes/Builders/boxBuilder";
  45460. /**
  45461. * Bounding box gizmo
  45462. */
  45463. export class BoundingBoxGizmo extends Gizmo {
  45464. private _lineBoundingBox;
  45465. private _rotateSpheresParent;
  45466. private _scaleBoxesParent;
  45467. private _boundingDimensions;
  45468. private _renderObserver;
  45469. private _pointerObserver;
  45470. private _scaleDragSpeed;
  45471. private _tmpQuaternion;
  45472. private _tmpVector;
  45473. private _tmpRotationMatrix;
  45474. /**
  45475. * 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)
  45476. */
  45477. ignoreChildren: boolean;
  45478. /**
  45479. * 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)
  45480. */
  45481. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45482. /**
  45483. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45484. */
  45485. rotationSphereSize: number;
  45486. /**
  45487. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45488. */
  45489. scaleBoxSize: number;
  45490. /**
  45491. * 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)
  45492. */
  45493. fixedDragMeshScreenSize: boolean;
  45494. /**
  45495. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45496. */
  45497. fixedDragMeshScreenSizeDistanceFactor: number;
  45498. /**
  45499. * Fired when a rotation sphere or scale box is dragged
  45500. */
  45501. onDragStartObservable: Observable<{}>;
  45502. /**
  45503. * Fired when a scale box is dragged
  45504. */
  45505. onScaleBoxDragObservable: Observable<{}>;
  45506. /**
  45507. * Fired when a scale box drag is ended
  45508. */
  45509. onScaleBoxDragEndObservable: Observable<{}>;
  45510. /**
  45511. * Fired when a rotation sphere is dragged
  45512. */
  45513. onRotationSphereDragObservable: Observable<{}>;
  45514. /**
  45515. * Fired when a rotation sphere drag is ended
  45516. */
  45517. onRotationSphereDragEndObservable: Observable<{}>;
  45518. /**
  45519. * 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)
  45520. */
  45521. scalePivot: Nullable<Vector3>;
  45522. /**
  45523. * Mesh used as a pivot to rotate the attached mesh
  45524. */
  45525. private _anchorMesh;
  45526. private _existingMeshScale;
  45527. private _dragMesh;
  45528. private pointerDragBehavior;
  45529. private coloredMaterial;
  45530. private hoverColoredMaterial;
  45531. /**
  45532. * Sets the color of the bounding box gizmo
  45533. * @param color the color to set
  45534. */
  45535. setColor(color: Color3): void;
  45536. /**
  45537. * Creates an BoundingBoxGizmo
  45538. * @param gizmoLayer The utility layer the gizmo will be added to
  45539. * @param color The color of the gizmo
  45540. */
  45541. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45542. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45543. private _selectNode;
  45544. /**
  45545. * Updates the bounding box information for the Gizmo
  45546. */
  45547. updateBoundingBox(): void;
  45548. private _updateRotationSpheres;
  45549. private _updateScaleBoxes;
  45550. /**
  45551. * Enables rotation on the specified axis and disables rotation on the others
  45552. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45553. */
  45554. setEnabledRotationAxis(axis: string): void;
  45555. /**
  45556. * Enables/disables scaling
  45557. * @param enable if scaling should be enabled
  45558. */
  45559. setEnabledScaling(enable: boolean): void;
  45560. private _updateDummy;
  45561. /**
  45562. * Enables a pointer drag behavior on the bounding box of the gizmo
  45563. */
  45564. enableDragBehavior(): void;
  45565. /**
  45566. * Disposes of the gizmo
  45567. */
  45568. dispose(): void;
  45569. /**
  45570. * 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)
  45571. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45572. * @returns the bounding box mesh with the passed in mesh as a child
  45573. */
  45574. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45575. /**
  45576. * CustomMeshes are not supported by this gizmo
  45577. * @param mesh The mesh to replace the default mesh of the gizmo
  45578. */
  45579. setCustomMesh(mesh: Mesh): void;
  45580. }
  45581. }
  45582. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  45583. import { Observable } from "babylonjs/Misc/observable";
  45584. import { Nullable } from "babylonjs/types";
  45585. import { Vector3 } from "babylonjs/Maths/math.vector";
  45586. import { Color3 } from "babylonjs/Maths/math.color";
  45587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45588. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45589. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45590. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45591. import "babylonjs/Meshes/Builders/linesBuilder";
  45592. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45593. /**
  45594. * Single plane rotation gizmo
  45595. */
  45596. export class PlaneRotationGizmo extends Gizmo {
  45597. /**
  45598. * Drag behavior responsible for the gizmos dragging interactions
  45599. */
  45600. dragBehavior: PointerDragBehavior;
  45601. private _pointerObserver;
  45602. /**
  45603. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45604. */
  45605. snapDistance: number;
  45606. /**
  45607. * Event that fires each time the gizmo snaps to a new location.
  45608. * * snapDistance is the the change in distance
  45609. */
  45610. onSnapObservable: Observable<{
  45611. snapDistance: number;
  45612. }>;
  45613. private _isEnabled;
  45614. private _parent;
  45615. /**
  45616. * Creates a PlaneRotationGizmo
  45617. * @param gizmoLayer The utility layer the gizmo will be added to
  45618. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45619. * @param color The color of the gizmo
  45620. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45621. */
  45622. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  45623. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45624. /**
  45625. * If the gizmo is enabled
  45626. */
  45627. isEnabled: boolean;
  45628. /**
  45629. * Disposes of the gizmo
  45630. */
  45631. dispose(): void;
  45632. }
  45633. }
  45634. declare module "babylonjs/Gizmos/rotationGizmo" {
  45635. import { Observable } from "babylonjs/Misc/observable";
  45636. import { Nullable } from "babylonjs/types";
  45637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45638. import { Mesh } from "babylonjs/Meshes/mesh";
  45639. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45640. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  45641. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45642. /**
  45643. * Gizmo that enables rotating a mesh along 3 axis
  45644. */
  45645. export class RotationGizmo extends Gizmo {
  45646. /**
  45647. * Internal gizmo used for interactions on the x axis
  45648. */
  45649. xGizmo: PlaneRotationGizmo;
  45650. /**
  45651. * Internal gizmo used for interactions on the y axis
  45652. */
  45653. yGizmo: PlaneRotationGizmo;
  45654. /**
  45655. * Internal gizmo used for interactions on the z axis
  45656. */
  45657. zGizmo: PlaneRotationGizmo;
  45658. /** Fires an event when any of it's sub gizmos are dragged */
  45659. onDragStartObservable: Observable<unknown>;
  45660. /** Fires an event when any of it's sub gizmos are released from dragging */
  45661. onDragEndObservable: Observable<unknown>;
  45662. private _meshAttached;
  45663. attachedMesh: Nullable<AbstractMesh>;
  45664. /**
  45665. * Creates a RotationGizmo
  45666. * @param gizmoLayer The utility layer the gizmo will be added to
  45667. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45668. */
  45669. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  45670. updateGizmoRotationToMatchAttachedMesh: boolean;
  45671. /**
  45672. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45673. */
  45674. snapDistance: number;
  45675. /**
  45676. * Ratio for the scale of the gizmo (Default: 1)
  45677. */
  45678. scaleRatio: number;
  45679. /**
  45680. * Disposes of the gizmo
  45681. */
  45682. dispose(): void;
  45683. /**
  45684. * CustomMeshes are not supported by this gizmo
  45685. * @param mesh The mesh to replace the default mesh of the gizmo
  45686. */
  45687. setCustomMesh(mesh: Mesh): void;
  45688. }
  45689. }
  45690. declare module "babylonjs/Gizmos/gizmoManager" {
  45691. import { Observable } from "babylonjs/Misc/observable";
  45692. import { Nullable } from "babylonjs/types";
  45693. import { Scene, IDisposable } from "babylonjs/scene";
  45694. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45695. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45696. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45697. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45698. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45699. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45700. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  45701. /**
  45702. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45703. */
  45704. export class GizmoManager implements IDisposable {
  45705. private scene;
  45706. /**
  45707. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45708. */
  45709. gizmos: {
  45710. positionGizmo: Nullable<PositionGizmo>;
  45711. rotationGizmo: Nullable<RotationGizmo>;
  45712. scaleGizmo: Nullable<ScaleGizmo>;
  45713. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45714. };
  45715. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45716. clearGizmoOnEmptyPointerEvent: boolean;
  45717. /** Fires an event when the manager is attached to a mesh */
  45718. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45719. private _gizmosEnabled;
  45720. private _pointerObserver;
  45721. private _attachedMesh;
  45722. private _boundingBoxColor;
  45723. private _defaultUtilityLayer;
  45724. private _defaultKeepDepthUtilityLayer;
  45725. /**
  45726. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45727. */
  45728. boundingBoxDragBehavior: SixDofDragBehavior;
  45729. /**
  45730. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45731. */
  45732. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45733. /**
  45734. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45735. */
  45736. usePointerToAttachGizmos: boolean;
  45737. /**
  45738. * Utility layer that the bounding box gizmo belongs to
  45739. */
  45740. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45741. /**
  45742. * Utility layer that all gizmos besides bounding box belong to
  45743. */
  45744. readonly utilityLayer: UtilityLayerRenderer;
  45745. /**
  45746. * Instatiates a gizmo manager
  45747. * @param scene the scene to overlay the gizmos on top of
  45748. */
  45749. constructor(scene: Scene);
  45750. /**
  45751. * Attaches a set of gizmos to the specified mesh
  45752. * @param mesh The mesh the gizmo's should be attached to
  45753. */
  45754. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45755. /**
  45756. * If the position gizmo is enabled
  45757. */
  45758. positionGizmoEnabled: boolean;
  45759. /**
  45760. * If the rotation gizmo is enabled
  45761. */
  45762. rotationGizmoEnabled: boolean;
  45763. /**
  45764. * If the scale gizmo is enabled
  45765. */
  45766. scaleGizmoEnabled: boolean;
  45767. /**
  45768. * If the boundingBox gizmo is enabled
  45769. */
  45770. boundingBoxGizmoEnabled: boolean;
  45771. /**
  45772. * Disposes of the gizmo manager
  45773. */
  45774. dispose(): void;
  45775. }
  45776. }
  45777. declare module "babylonjs/Lights/directionalLight" {
  45778. import { Camera } from "babylonjs/Cameras/camera";
  45779. import { Scene } from "babylonjs/scene";
  45780. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  45781. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45782. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45783. import { Effect } from "babylonjs/Materials/effect";
  45784. /**
  45785. * A directional light is defined by a direction (what a surprise!).
  45786. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45787. * 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.
  45788. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45789. */
  45790. export class DirectionalLight extends ShadowLight {
  45791. private _shadowFrustumSize;
  45792. /**
  45793. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45794. */
  45795. /**
  45796. * Specifies a fix frustum size for the shadow generation.
  45797. */
  45798. shadowFrustumSize: number;
  45799. private _shadowOrthoScale;
  45800. /**
  45801. * Gets the shadow projection scale against the optimal computed one.
  45802. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45803. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45804. */
  45805. /**
  45806. * Sets the shadow projection scale against the optimal computed one.
  45807. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45808. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45809. */
  45810. shadowOrthoScale: number;
  45811. /**
  45812. * Automatically compute the projection matrix to best fit (including all the casters)
  45813. * on each frame.
  45814. */
  45815. autoUpdateExtends: boolean;
  45816. private _orthoLeft;
  45817. private _orthoRight;
  45818. private _orthoTop;
  45819. private _orthoBottom;
  45820. /**
  45821. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45822. * The directional light is emitted from everywhere in the given direction.
  45823. * It can cast shadows.
  45824. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45825. * @param name The friendly name of the light
  45826. * @param direction The direction of the light
  45827. * @param scene The scene the light belongs to
  45828. */
  45829. constructor(name: string, direction: Vector3, scene: Scene);
  45830. /**
  45831. * Returns the string "DirectionalLight".
  45832. * @return The class name
  45833. */
  45834. getClassName(): string;
  45835. /**
  45836. * Returns the integer 1.
  45837. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45838. */
  45839. getTypeID(): number;
  45840. /**
  45841. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45842. * Returns the DirectionalLight Shadow projection matrix.
  45843. */
  45844. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45845. /**
  45846. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45847. * Returns the DirectionalLight Shadow projection matrix.
  45848. */
  45849. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45850. /**
  45851. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45852. * Returns the DirectionalLight Shadow projection matrix.
  45853. */
  45854. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45855. protected _buildUniformLayout(): void;
  45856. /**
  45857. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45858. * @param effect The effect to update
  45859. * @param lightIndex The index of the light in the effect to update
  45860. * @returns The directional light
  45861. */
  45862. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45863. /**
  45864. * Gets the minZ used for shadow according to both the scene and the light.
  45865. *
  45866. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45867. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45868. * @param activeCamera The camera we are returning the min for
  45869. * @returns the depth min z
  45870. */
  45871. getDepthMinZ(activeCamera: Camera): number;
  45872. /**
  45873. * Gets the maxZ used for shadow according to both the scene and the light.
  45874. *
  45875. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45876. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45877. * @param activeCamera The camera we are returning the max for
  45878. * @returns the depth max z
  45879. */
  45880. getDepthMaxZ(activeCamera: Camera): number;
  45881. /**
  45882. * Prepares the list of defines specific to the light type.
  45883. * @param defines the list of defines
  45884. * @param lightIndex defines the index of the light for the effect
  45885. */
  45886. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45887. }
  45888. }
  45889. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  45890. import { Mesh } from "babylonjs/Meshes/mesh";
  45891. /**
  45892. * Class containing static functions to help procedurally build meshes
  45893. */
  45894. export class HemisphereBuilder {
  45895. /**
  45896. * Creates a hemisphere mesh
  45897. * @param name defines the name of the mesh
  45898. * @param options defines the options used to create the mesh
  45899. * @param scene defines the hosting scene
  45900. * @returns the hemisphere mesh
  45901. */
  45902. static CreateHemisphere(name: string, options: {
  45903. segments?: number;
  45904. diameter?: number;
  45905. sideOrientation?: number;
  45906. }, scene: any): Mesh;
  45907. }
  45908. }
  45909. declare module "babylonjs/Lights/spotLight" {
  45910. import { Nullable } from "babylonjs/types";
  45911. import { Scene } from "babylonjs/scene";
  45912. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  45913. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45914. import { Effect } from "babylonjs/Materials/effect";
  45915. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45916. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45917. /**
  45918. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45919. * These values define a cone of light starting from the position, emitting toward the direction.
  45920. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45921. * and the exponent defines the speed of the decay of the light with distance (reach).
  45922. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45923. */
  45924. export class SpotLight extends ShadowLight {
  45925. private _angle;
  45926. private _innerAngle;
  45927. private _cosHalfAngle;
  45928. private _lightAngleScale;
  45929. private _lightAngleOffset;
  45930. /**
  45931. * Gets the cone angle of the spot light in Radians.
  45932. */
  45933. /**
  45934. * Sets the cone angle of the spot light in Radians.
  45935. */
  45936. angle: number;
  45937. /**
  45938. * Only used in gltf falloff mode, this defines the angle where
  45939. * the directional falloff will start before cutting at angle which could be seen
  45940. * as outer angle.
  45941. */
  45942. /**
  45943. * Only used in gltf falloff mode, this defines the angle where
  45944. * the directional falloff will start before cutting at angle which could be seen
  45945. * as outer angle.
  45946. */
  45947. innerAngle: number;
  45948. private _shadowAngleScale;
  45949. /**
  45950. * Allows scaling the angle of the light for shadow generation only.
  45951. */
  45952. /**
  45953. * Allows scaling the angle of the light for shadow generation only.
  45954. */
  45955. shadowAngleScale: number;
  45956. /**
  45957. * The light decay speed with the distance from the emission spot.
  45958. */
  45959. exponent: number;
  45960. private _projectionTextureMatrix;
  45961. /**
  45962. * Allows reading the projecton texture
  45963. */
  45964. readonly projectionTextureMatrix: Matrix;
  45965. protected _projectionTextureLightNear: number;
  45966. /**
  45967. * Gets the near clip of the Spotlight for texture projection.
  45968. */
  45969. /**
  45970. * Sets the near clip of the Spotlight for texture projection.
  45971. */
  45972. projectionTextureLightNear: number;
  45973. protected _projectionTextureLightFar: number;
  45974. /**
  45975. * Gets the far clip of the Spotlight for texture projection.
  45976. */
  45977. /**
  45978. * Sets the far clip of the Spotlight for texture projection.
  45979. */
  45980. projectionTextureLightFar: number;
  45981. protected _projectionTextureUpDirection: Vector3;
  45982. /**
  45983. * Gets the Up vector of the Spotlight for texture projection.
  45984. */
  45985. /**
  45986. * Sets the Up vector of the Spotlight for texture projection.
  45987. */
  45988. projectionTextureUpDirection: Vector3;
  45989. private _projectionTexture;
  45990. /**
  45991. * Gets the projection texture of the light.
  45992. */
  45993. /**
  45994. * Sets the projection texture of the light.
  45995. */
  45996. projectionTexture: Nullable<BaseTexture>;
  45997. private _projectionTextureViewLightDirty;
  45998. private _projectionTextureProjectionLightDirty;
  45999. private _projectionTextureDirty;
  46000. private _projectionTextureViewTargetVector;
  46001. private _projectionTextureViewLightMatrix;
  46002. private _projectionTextureProjectionLightMatrix;
  46003. private _projectionTextureScalingMatrix;
  46004. /**
  46005. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46006. * It can cast shadows.
  46007. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46008. * @param name The light friendly name
  46009. * @param position The position of the spot light in the scene
  46010. * @param direction The direction of the light in the scene
  46011. * @param angle The cone angle of the light in Radians
  46012. * @param exponent The light decay speed with the distance from the emission spot
  46013. * @param scene The scene the lights belongs to
  46014. */
  46015. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46016. /**
  46017. * Returns the string "SpotLight".
  46018. * @returns the class name
  46019. */
  46020. getClassName(): string;
  46021. /**
  46022. * Returns the integer 2.
  46023. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46024. */
  46025. getTypeID(): number;
  46026. /**
  46027. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46028. */
  46029. protected _setDirection(value: Vector3): void;
  46030. /**
  46031. * Overrides the position setter to recompute the projection texture view light Matrix.
  46032. */
  46033. protected _setPosition(value: Vector3): void;
  46034. /**
  46035. * 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.
  46036. * Returns the SpotLight.
  46037. */
  46038. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46039. protected _computeProjectionTextureViewLightMatrix(): void;
  46040. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46041. /**
  46042. * Main function for light texture projection matrix computing.
  46043. */
  46044. protected _computeProjectionTextureMatrix(): void;
  46045. protected _buildUniformLayout(): void;
  46046. private _computeAngleValues;
  46047. /**
  46048. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46049. * @param effect The effect to update
  46050. * @param lightIndex The index of the light in the effect to update
  46051. * @returns The spot light
  46052. */
  46053. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46054. /**
  46055. * Disposes the light and the associated resources.
  46056. */
  46057. dispose(): void;
  46058. /**
  46059. * Prepares the list of defines specific to the light type.
  46060. * @param defines the list of defines
  46061. * @param lightIndex defines the index of the light for the effect
  46062. */
  46063. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46064. }
  46065. }
  46066. declare module "babylonjs/Gizmos/lightGizmo" {
  46067. import { Nullable } from "babylonjs/types";
  46068. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46069. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46070. import { Light } from "babylonjs/Lights/light";
  46071. /**
  46072. * Gizmo that enables viewing a light
  46073. */
  46074. export class LightGizmo extends Gizmo {
  46075. private _lightMesh;
  46076. private _material;
  46077. private cachedPosition;
  46078. private cachedForward;
  46079. /**
  46080. * Creates a LightGizmo
  46081. * @param gizmoLayer The utility layer the gizmo will be added to
  46082. */
  46083. constructor(gizmoLayer?: UtilityLayerRenderer);
  46084. private _light;
  46085. /**
  46086. * The light that the gizmo is attached to
  46087. */
  46088. light: Nullable<Light>;
  46089. /**
  46090. * @hidden
  46091. * Updates the gizmo to match the attached mesh's position/rotation
  46092. */
  46093. protected _update(): void;
  46094. private static _Scale;
  46095. /**
  46096. * Creates the lines for a light mesh
  46097. */
  46098. private static _createLightLines;
  46099. /**
  46100. * Disposes of the light gizmo
  46101. */
  46102. dispose(): void;
  46103. private static _CreateHemisphericLightMesh;
  46104. private static _CreatePointLightMesh;
  46105. private static _CreateSpotLightMesh;
  46106. private static _CreateDirectionalLightMesh;
  46107. }
  46108. }
  46109. declare module "babylonjs/Gizmos/index" {
  46110. export * from "babylonjs/Gizmos/axisDragGizmo";
  46111. export * from "babylonjs/Gizmos/axisScaleGizmo";
  46112. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  46113. export * from "babylonjs/Gizmos/gizmo";
  46114. export * from "babylonjs/Gizmos/gizmoManager";
  46115. export * from "babylonjs/Gizmos/planeRotationGizmo";
  46116. export * from "babylonjs/Gizmos/positionGizmo";
  46117. export * from "babylonjs/Gizmos/rotationGizmo";
  46118. export * from "babylonjs/Gizmos/scaleGizmo";
  46119. export * from "babylonjs/Gizmos/lightGizmo";
  46120. export * from "babylonjs/Gizmos/planeDragGizmo";
  46121. }
  46122. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  46123. /** @hidden */
  46124. export var backgroundFragmentDeclaration: {
  46125. name: string;
  46126. shader: string;
  46127. };
  46128. }
  46129. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  46130. /** @hidden */
  46131. export var backgroundUboDeclaration: {
  46132. name: string;
  46133. shader: string;
  46134. };
  46135. }
  46136. declare module "babylonjs/Shaders/background.fragment" {
  46137. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  46138. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46139. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46140. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46141. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46142. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46143. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46144. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  46145. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46146. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46147. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46148. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46149. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46150. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46151. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46152. /** @hidden */
  46153. export var backgroundPixelShader: {
  46154. name: string;
  46155. shader: string;
  46156. };
  46157. }
  46158. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  46159. /** @hidden */
  46160. export var backgroundVertexDeclaration: {
  46161. name: string;
  46162. shader: string;
  46163. };
  46164. }
  46165. declare module "babylonjs/Shaders/background.vertex" {
  46166. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  46167. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46168. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46169. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46170. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46171. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46172. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46173. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46174. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46175. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46176. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46177. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46178. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46179. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46180. /** @hidden */
  46181. export var backgroundVertexShader: {
  46182. name: string;
  46183. shader: string;
  46184. };
  46185. }
  46186. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  46187. import { Nullable, int, float } from "babylonjs/types";
  46188. import { Scene } from "babylonjs/scene";
  46189. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46190. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46192. import { Mesh } from "babylonjs/Meshes/mesh";
  46193. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46194. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46195. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46196. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46197. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  46198. import { Color3 } from "babylonjs/Maths/math.color";
  46199. import "babylonjs/Shaders/background.fragment";
  46200. import "babylonjs/Shaders/background.vertex";
  46201. /**
  46202. * Background material used to create an efficient environement around your scene.
  46203. */
  46204. export class BackgroundMaterial extends PushMaterial {
  46205. /**
  46206. * Standard reflectance value at parallel view angle.
  46207. */
  46208. static StandardReflectance0: number;
  46209. /**
  46210. * Standard reflectance value at grazing angle.
  46211. */
  46212. static StandardReflectance90: number;
  46213. protected _primaryColor: Color3;
  46214. /**
  46215. * Key light Color (multiply against the environement texture)
  46216. */
  46217. primaryColor: Color3;
  46218. protected __perceptualColor: Nullable<Color3>;
  46219. /**
  46220. * Experimental Internal Use Only.
  46221. *
  46222. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  46223. * This acts as a helper to set the primary color to a more "human friendly" value.
  46224. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  46225. * output color as close as possible from the chosen value.
  46226. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  46227. * part of lighting setup.)
  46228. */
  46229. _perceptualColor: Nullable<Color3>;
  46230. protected _primaryColorShadowLevel: float;
  46231. /**
  46232. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  46233. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  46234. */
  46235. primaryColorShadowLevel: float;
  46236. protected _primaryColorHighlightLevel: float;
  46237. /**
  46238. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  46239. * The primary color is used at the level chosen to define what the white area would look.
  46240. */
  46241. primaryColorHighlightLevel: float;
  46242. protected _reflectionTexture: Nullable<BaseTexture>;
  46243. /**
  46244. * Reflection Texture used in the material.
  46245. * Should be author in a specific way for the best result (refer to the documentation).
  46246. */
  46247. reflectionTexture: Nullable<BaseTexture>;
  46248. protected _reflectionBlur: float;
  46249. /**
  46250. * Reflection Texture level of blur.
  46251. *
  46252. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  46253. * texture twice.
  46254. */
  46255. reflectionBlur: float;
  46256. protected _diffuseTexture: Nullable<BaseTexture>;
  46257. /**
  46258. * Diffuse Texture used in the material.
  46259. * Should be author in a specific way for the best result (refer to the documentation).
  46260. */
  46261. diffuseTexture: Nullable<BaseTexture>;
  46262. protected _shadowLights: Nullable<IShadowLight[]>;
  46263. /**
  46264. * Specify the list of lights casting shadow on the material.
  46265. * All scene shadow lights will be included if null.
  46266. */
  46267. shadowLights: Nullable<IShadowLight[]>;
  46268. protected _shadowLevel: float;
  46269. /**
  46270. * Helps adjusting the shadow to a softer level if required.
  46271. * 0 means black shadows and 1 means no shadows.
  46272. */
  46273. shadowLevel: float;
  46274. protected _sceneCenter: Vector3;
  46275. /**
  46276. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  46277. * It is usually zero but might be interesting to modify according to your setup.
  46278. */
  46279. sceneCenter: Vector3;
  46280. protected _opacityFresnel: boolean;
  46281. /**
  46282. * This helps specifying that the material is falling off to the sky box at grazing angle.
  46283. * This helps ensuring a nice transition when the camera goes under the ground.
  46284. */
  46285. opacityFresnel: boolean;
  46286. protected _reflectionFresnel: boolean;
  46287. /**
  46288. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  46289. * This helps adding a mirror texture on the ground.
  46290. */
  46291. reflectionFresnel: boolean;
  46292. protected _reflectionFalloffDistance: number;
  46293. /**
  46294. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  46295. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  46296. */
  46297. reflectionFalloffDistance: number;
  46298. protected _reflectionAmount: number;
  46299. /**
  46300. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  46301. */
  46302. reflectionAmount: number;
  46303. protected _reflectionReflectance0: number;
  46304. /**
  46305. * This specifies the weight of the reflection at grazing angle.
  46306. */
  46307. reflectionReflectance0: number;
  46308. protected _reflectionReflectance90: number;
  46309. /**
  46310. * This specifies the weight of the reflection at a perpendicular point of view.
  46311. */
  46312. reflectionReflectance90: number;
  46313. /**
  46314. * Sets the reflection reflectance fresnel values according to the default standard
  46315. * empirically know to work well :-)
  46316. */
  46317. reflectionStandardFresnelWeight: number;
  46318. protected _useRGBColor: boolean;
  46319. /**
  46320. * Helps to directly use the maps channels instead of their level.
  46321. */
  46322. useRGBColor: boolean;
  46323. protected _enableNoise: boolean;
  46324. /**
  46325. * This helps reducing the banding effect that could occur on the background.
  46326. */
  46327. enableNoise: boolean;
  46328. /**
  46329. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46330. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  46331. * Recommended to be keep at 1.0 except for special cases.
  46332. */
  46333. fovMultiplier: number;
  46334. private _fovMultiplier;
  46335. /**
  46336. * Enable the FOV adjustment feature controlled by fovMultiplier.
  46337. */
  46338. useEquirectangularFOV: boolean;
  46339. private _maxSimultaneousLights;
  46340. /**
  46341. * Number of Simultaneous lights allowed on the material.
  46342. */
  46343. maxSimultaneousLights: int;
  46344. /**
  46345. * Default configuration related to image processing available in the Background Material.
  46346. */
  46347. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46348. /**
  46349. * Keep track of the image processing observer to allow dispose and replace.
  46350. */
  46351. private _imageProcessingObserver;
  46352. /**
  46353. * Attaches a new image processing configuration to the PBR Material.
  46354. * @param configuration (if null the scene configuration will be use)
  46355. */
  46356. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46357. /**
  46358. * Gets the image processing configuration used either in this material.
  46359. */
  46360. /**
  46361. * Sets the Default image processing configuration used either in the this material.
  46362. *
  46363. * If sets to null, the scene one is in use.
  46364. */
  46365. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  46366. /**
  46367. * Gets wether the color curves effect is enabled.
  46368. */
  46369. /**
  46370. * Sets wether the color curves effect is enabled.
  46371. */
  46372. cameraColorCurvesEnabled: boolean;
  46373. /**
  46374. * Gets wether the color grading effect is enabled.
  46375. */
  46376. /**
  46377. * Gets wether the color grading effect is enabled.
  46378. */
  46379. cameraColorGradingEnabled: boolean;
  46380. /**
  46381. * Gets wether tonemapping is enabled or not.
  46382. */
  46383. /**
  46384. * Sets wether tonemapping is enabled or not
  46385. */
  46386. cameraToneMappingEnabled: boolean;
  46387. /**
  46388. * The camera exposure used on this material.
  46389. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46390. * This corresponds to a photographic exposure.
  46391. */
  46392. /**
  46393. * The camera exposure used on this material.
  46394. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46395. * This corresponds to a photographic exposure.
  46396. */
  46397. cameraExposure: float;
  46398. /**
  46399. * Gets The camera contrast used on this material.
  46400. */
  46401. /**
  46402. * Sets The camera contrast used on this material.
  46403. */
  46404. cameraContrast: float;
  46405. /**
  46406. * Gets the Color Grading 2D Lookup Texture.
  46407. */
  46408. /**
  46409. * Sets the Color Grading 2D Lookup Texture.
  46410. */
  46411. cameraColorGradingTexture: Nullable<BaseTexture>;
  46412. /**
  46413. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46414. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46415. * 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;
  46416. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46417. */
  46418. /**
  46419. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46420. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46421. * 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;
  46422. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46423. */
  46424. cameraColorCurves: Nullable<ColorCurves>;
  46425. /**
  46426. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  46427. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  46428. */
  46429. switchToBGR: boolean;
  46430. private _renderTargets;
  46431. private _reflectionControls;
  46432. private _white;
  46433. private _primaryShadowColor;
  46434. private _primaryHighlightColor;
  46435. /**
  46436. * Instantiates a Background Material in the given scene
  46437. * @param name The friendly name of the material
  46438. * @param scene The scene to add the material to
  46439. */
  46440. constructor(name: string, scene: Scene);
  46441. /**
  46442. * Gets a boolean indicating that current material needs to register RTT
  46443. */
  46444. readonly hasRenderTargetTextures: boolean;
  46445. /**
  46446. * The entire material has been created in order to prevent overdraw.
  46447. * @returns false
  46448. */
  46449. needAlphaTesting(): boolean;
  46450. /**
  46451. * The entire material has been created in order to prevent overdraw.
  46452. * @returns true if blending is enable
  46453. */
  46454. needAlphaBlending(): boolean;
  46455. /**
  46456. * Checks wether the material is ready to be rendered for a given mesh.
  46457. * @param mesh The mesh to render
  46458. * @param subMesh The submesh to check against
  46459. * @param useInstances Specify wether or not the material is used with instances
  46460. * @returns true if all the dependencies are ready (Textures, Effects...)
  46461. */
  46462. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46463. /**
  46464. * Compute the primary color according to the chosen perceptual color.
  46465. */
  46466. private _computePrimaryColorFromPerceptualColor;
  46467. /**
  46468. * Compute the highlights and shadow colors according to their chosen levels.
  46469. */
  46470. private _computePrimaryColors;
  46471. /**
  46472. * Build the uniform buffer used in the material.
  46473. */
  46474. buildUniformLayout(): void;
  46475. /**
  46476. * Unbind the material.
  46477. */
  46478. unbind(): void;
  46479. /**
  46480. * Bind only the world matrix to the material.
  46481. * @param world The world matrix to bind.
  46482. */
  46483. bindOnlyWorldMatrix(world: Matrix): void;
  46484. /**
  46485. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46486. * @param world The world matrix to bind.
  46487. * @param subMesh The submesh to bind for.
  46488. */
  46489. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46490. /**
  46491. * Dispose the material.
  46492. * @param forceDisposeEffect Force disposal of the associated effect.
  46493. * @param forceDisposeTextures Force disposal of the associated textures.
  46494. */
  46495. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46496. /**
  46497. * Clones the material.
  46498. * @param name The cloned name.
  46499. * @returns The cloned material.
  46500. */
  46501. clone(name: string): BackgroundMaterial;
  46502. /**
  46503. * Serializes the current material to its JSON representation.
  46504. * @returns The JSON representation.
  46505. */
  46506. serialize(): any;
  46507. /**
  46508. * Gets the class name of the material
  46509. * @returns "BackgroundMaterial"
  46510. */
  46511. getClassName(): string;
  46512. /**
  46513. * Parse a JSON input to create back a background material.
  46514. * @param source The JSON data to parse
  46515. * @param scene The scene to create the parsed material in
  46516. * @param rootUrl The root url of the assets the material depends upon
  46517. * @returns the instantiated BackgroundMaterial.
  46518. */
  46519. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46520. }
  46521. }
  46522. declare module "babylonjs/Helpers/environmentHelper" {
  46523. import { Observable } from "babylonjs/Misc/observable";
  46524. import { Nullable } from "babylonjs/types";
  46525. import { Scene } from "babylonjs/scene";
  46526. import { Vector3 } from "babylonjs/Maths/math.vector";
  46527. import { Color3 } from "babylonjs/Maths/math.color";
  46528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46529. import { Mesh } from "babylonjs/Meshes/mesh";
  46530. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46531. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  46532. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46533. import "babylonjs/Meshes/Builders/planeBuilder";
  46534. import "babylonjs/Meshes/Builders/boxBuilder";
  46535. /**
  46536. * Represents the different options available during the creation of
  46537. * a Environment helper.
  46538. *
  46539. * This can control the default ground, skybox and image processing setup of your scene.
  46540. */
  46541. export interface IEnvironmentHelperOptions {
  46542. /**
  46543. * Specifies wether or not to create a ground.
  46544. * True by default.
  46545. */
  46546. createGround: boolean;
  46547. /**
  46548. * Specifies the ground size.
  46549. * 15 by default.
  46550. */
  46551. groundSize: number;
  46552. /**
  46553. * The texture used on the ground for the main color.
  46554. * Comes from the BabylonJS CDN by default.
  46555. *
  46556. * Remarks: Can be either a texture or a url.
  46557. */
  46558. groundTexture: string | BaseTexture;
  46559. /**
  46560. * The color mixed in the ground texture by default.
  46561. * BabylonJS clearColor by default.
  46562. */
  46563. groundColor: Color3;
  46564. /**
  46565. * Specifies the ground opacity.
  46566. * 1 by default.
  46567. */
  46568. groundOpacity: number;
  46569. /**
  46570. * Enables the ground to receive shadows.
  46571. * True by default.
  46572. */
  46573. enableGroundShadow: boolean;
  46574. /**
  46575. * Helps preventing the shadow to be fully black on the ground.
  46576. * 0.5 by default.
  46577. */
  46578. groundShadowLevel: number;
  46579. /**
  46580. * Creates a mirror texture attach to the ground.
  46581. * false by default.
  46582. */
  46583. enableGroundMirror: boolean;
  46584. /**
  46585. * Specifies the ground mirror size ratio.
  46586. * 0.3 by default as the default kernel is 64.
  46587. */
  46588. groundMirrorSizeRatio: number;
  46589. /**
  46590. * Specifies the ground mirror blur kernel size.
  46591. * 64 by default.
  46592. */
  46593. groundMirrorBlurKernel: number;
  46594. /**
  46595. * Specifies the ground mirror visibility amount.
  46596. * 1 by default
  46597. */
  46598. groundMirrorAmount: number;
  46599. /**
  46600. * Specifies the ground mirror reflectance weight.
  46601. * This uses the standard weight of the background material to setup the fresnel effect
  46602. * of the mirror.
  46603. * 1 by default.
  46604. */
  46605. groundMirrorFresnelWeight: number;
  46606. /**
  46607. * Specifies the ground mirror Falloff distance.
  46608. * This can helps reducing the size of the reflection.
  46609. * 0 by Default.
  46610. */
  46611. groundMirrorFallOffDistance: number;
  46612. /**
  46613. * Specifies the ground mirror texture type.
  46614. * Unsigned Int by Default.
  46615. */
  46616. groundMirrorTextureType: number;
  46617. /**
  46618. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46619. * the shown objects.
  46620. */
  46621. groundYBias: number;
  46622. /**
  46623. * Specifies wether or not to create a skybox.
  46624. * True by default.
  46625. */
  46626. createSkybox: boolean;
  46627. /**
  46628. * Specifies the skybox size.
  46629. * 20 by default.
  46630. */
  46631. skyboxSize: number;
  46632. /**
  46633. * The texture used on the skybox for the main color.
  46634. * Comes from the BabylonJS CDN by default.
  46635. *
  46636. * Remarks: Can be either a texture or a url.
  46637. */
  46638. skyboxTexture: string | BaseTexture;
  46639. /**
  46640. * The color mixed in the skybox texture by default.
  46641. * BabylonJS clearColor by default.
  46642. */
  46643. skyboxColor: Color3;
  46644. /**
  46645. * The background rotation around the Y axis of the scene.
  46646. * This helps aligning the key lights of your scene with the background.
  46647. * 0 by default.
  46648. */
  46649. backgroundYRotation: number;
  46650. /**
  46651. * Compute automatically the size of the elements to best fit with the scene.
  46652. */
  46653. sizeAuto: boolean;
  46654. /**
  46655. * Default position of the rootMesh if autoSize is not true.
  46656. */
  46657. rootPosition: Vector3;
  46658. /**
  46659. * Sets up the image processing in the scene.
  46660. * true by default.
  46661. */
  46662. setupImageProcessing: boolean;
  46663. /**
  46664. * The texture used as your environment texture in the scene.
  46665. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46666. *
  46667. * Remarks: Can be either a texture or a url.
  46668. */
  46669. environmentTexture: string | BaseTexture;
  46670. /**
  46671. * The value of the exposure to apply to the scene.
  46672. * 0.6 by default if setupImageProcessing is true.
  46673. */
  46674. cameraExposure: number;
  46675. /**
  46676. * The value of the contrast to apply to the scene.
  46677. * 1.6 by default if setupImageProcessing is true.
  46678. */
  46679. cameraContrast: number;
  46680. /**
  46681. * Specifies wether or not tonemapping should be enabled in the scene.
  46682. * true by default if setupImageProcessing is true.
  46683. */
  46684. toneMappingEnabled: boolean;
  46685. }
  46686. /**
  46687. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46688. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46689. * It also helps with the default setup of your imageProcessing configuration.
  46690. */
  46691. export class EnvironmentHelper {
  46692. /**
  46693. * Default ground texture URL.
  46694. */
  46695. private static _groundTextureCDNUrl;
  46696. /**
  46697. * Default skybox texture URL.
  46698. */
  46699. private static _skyboxTextureCDNUrl;
  46700. /**
  46701. * Default environment texture URL.
  46702. */
  46703. private static _environmentTextureCDNUrl;
  46704. /**
  46705. * Creates the default options for the helper.
  46706. */
  46707. private static _getDefaultOptions;
  46708. private _rootMesh;
  46709. /**
  46710. * Gets the root mesh created by the helper.
  46711. */
  46712. readonly rootMesh: Mesh;
  46713. private _skybox;
  46714. /**
  46715. * Gets the skybox created by the helper.
  46716. */
  46717. readonly skybox: Nullable<Mesh>;
  46718. private _skyboxTexture;
  46719. /**
  46720. * Gets the skybox texture created by the helper.
  46721. */
  46722. readonly skyboxTexture: Nullable<BaseTexture>;
  46723. private _skyboxMaterial;
  46724. /**
  46725. * Gets the skybox material created by the helper.
  46726. */
  46727. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46728. private _ground;
  46729. /**
  46730. * Gets the ground mesh created by the helper.
  46731. */
  46732. readonly ground: Nullable<Mesh>;
  46733. private _groundTexture;
  46734. /**
  46735. * Gets the ground texture created by the helper.
  46736. */
  46737. readonly groundTexture: Nullable<BaseTexture>;
  46738. private _groundMirror;
  46739. /**
  46740. * Gets the ground mirror created by the helper.
  46741. */
  46742. readonly groundMirror: Nullable<MirrorTexture>;
  46743. /**
  46744. * Gets the ground mirror render list to helps pushing the meshes
  46745. * you wish in the ground reflection.
  46746. */
  46747. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46748. private _groundMaterial;
  46749. /**
  46750. * Gets the ground material created by the helper.
  46751. */
  46752. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46753. /**
  46754. * Stores the creation options.
  46755. */
  46756. private readonly _scene;
  46757. private _options;
  46758. /**
  46759. * This observable will be notified with any error during the creation of the environment,
  46760. * mainly texture creation errors.
  46761. */
  46762. onErrorObservable: Observable<{
  46763. message?: string;
  46764. exception?: any;
  46765. }>;
  46766. /**
  46767. * constructor
  46768. * @param options Defines the options we want to customize the helper
  46769. * @param scene The scene to add the material to
  46770. */
  46771. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46772. /**
  46773. * Updates the background according to the new options
  46774. * @param options
  46775. */
  46776. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46777. /**
  46778. * Sets the primary color of all the available elements.
  46779. * @param color the main color to affect to the ground and the background
  46780. */
  46781. setMainColor(color: Color3): void;
  46782. /**
  46783. * Setup the image processing according to the specified options.
  46784. */
  46785. private _setupImageProcessing;
  46786. /**
  46787. * Setup the environment texture according to the specified options.
  46788. */
  46789. private _setupEnvironmentTexture;
  46790. /**
  46791. * Setup the background according to the specified options.
  46792. */
  46793. private _setupBackground;
  46794. /**
  46795. * Get the scene sizes according to the setup.
  46796. */
  46797. private _getSceneSize;
  46798. /**
  46799. * Setup the ground according to the specified options.
  46800. */
  46801. private _setupGround;
  46802. /**
  46803. * Setup the ground material according to the specified options.
  46804. */
  46805. private _setupGroundMaterial;
  46806. /**
  46807. * Setup the ground diffuse texture according to the specified options.
  46808. */
  46809. private _setupGroundDiffuseTexture;
  46810. /**
  46811. * Setup the ground mirror texture according to the specified options.
  46812. */
  46813. private _setupGroundMirrorTexture;
  46814. /**
  46815. * Setup the ground to receive the mirror texture.
  46816. */
  46817. private _setupMirrorInGroundMaterial;
  46818. /**
  46819. * Setup the skybox according to the specified options.
  46820. */
  46821. private _setupSkybox;
  46822. /**
  46823. * Setup the skybox material according to the specified options.
  46824. */
  46825. private _setupSkyboxMaterial;
  46826. /**
  46827. * Setup the skybox reflection texture according to the specified options.
  46828. */
  46829. private _setupSkyboxReflectionTexture;
  46830. private _errorHandler;
  46831. /**
  46832. * Dispose all the elements created by the Helper.
  46833. */
  46834. dispose(): void;
  46835. }
  46836. }
  46837. declare module "babylonjs/Helpers/photoDome" {
  46838. import { Observable } from "babylonjs/Misc/observable";
  46839. import { Nullable } from "babylonjs/types";
  46840. import { Scene } from "babylonjs/scene";
  46841. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46842. import { Mesh } from "babylonjs/Meshes/mesh";
  46843. import { Texture } from "babylonjs/Materials/Textures/texture";
  46844. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46845. import "babylonjs/Meshes/Builders/sphereBuilder";
  46846. /**
  46847. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46848. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46849. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46850. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46851. */
  46852. export class PhotoDome extends TransformNode {
  46853. /**
  46854. * Define the image as a Monoscopic panoramic 360 image.
  46855. */
  46856. static readonly MODE_MONOSCOPIC: number;
  46857. /**
  46858. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46859. */
  46860. static readonly MODE_TOPBOTTOM: number;
  46861. /**
  46862. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46863. */
  46864. static readonly MODE_SIDEBYSIDE: number;
  46865. private _useDirectMapping;
  46866. /**
  46867. * The texture being displayed on the sphere
  46868. */
  46869. protected _photoTexture: Texture;
  46870. /**
  46871. * Gets or sets the texture being displayed on the sphere
  46872. */
  46873. photoTexture: Texture;
  46874. /**
  46875. * Observable raised when an error occured while loading the 360 image
  46876. */
  46877. onLoadErrorObservable: Observable<string>;
  46878. /**
  46879. * The skybox material
  46880. */
  46881. protected _material: BackgroundMaterial;
  46882. /**
  46883. * The surface used for the skybox
  46884. */
  46885. protected _mesh: Mesh;
  46886. /**
  46887. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46888. * Also see the options.resolution property.
  46889. */
  46890. fovMultiplier: number;
  46891. private _imageMode;
  46892. /**
  46893. * Gets or set the current video mode for the video. It can be:
  46894. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46895. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46896. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46897. */
  46898. imageMode: number;
  46899. /**
  46900. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46901. * @param name Element's name, child elements will append suffixes for their own names.
  46902. * @param urlsOfPhoto defines the url of the photo to display
  46903. * @param options defines an object containing optional or exposed sub element properties
  46904. * @param onError defines a callback called when an error occured while loading the texture
  46905. */
  46906. constructor(name: string, urlOfPhoto: string, options: {
  46907. resolution?: number;
  46908. size?: number;
  46909. useDirectMapping?: boolean;
  46910. faceForward?: boolean;
  46911. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46912. private _onBeforeCameraRenderObserver;
  46913. private _changeImageMode;
  46914. /**
  46915. * Releases resources associated with this node.
  46916. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46917. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46918. */
  46919. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46920. }
  46921. }
  46922. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46923. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46924. /** @hidden */
  46925. export var rgbdDecodePixelShader: {
  46926. name: string;
  46927. shader: string;
  46928. };
  46929. }
  46930. declare module "babylonjs/Misc/brdfTextureTools" {
  46931. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46932. import { Scene } from "babylonjs/scene";
  46933. import "babylonjs/Shaders/rgbdDecode.fragment";
  46934. /**
  46935. * Class used to host texture specific utilities
  46936. */
  46937. export class BRDFTextureTools {
  46938. /**
  46939. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  46940. * @param texture the texture to expand.
  46941. */
  46942. private static _ExpandDefaultBRDFTexture;
  46943. /**
  46944. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46945. * @param scene defines the hosting scene
  46946. * @returns the environment BRDF texture
  46947. */
  46948. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46949. private static _environmentBRDFBase64Texture;
  46950. }
  46951. }
  46952. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  46953. import { Nullable } from "babylonjs/types";
  46954. import { Color3 } from "babylonjs/Maths/math.color";
  46955. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46956. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46957. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46958. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  46959. import { Engine } from "babylonjs/Engines/engine";
  46960. import { Scene } from "babylonjs/scene";
  46961. /**
  46962. * @hidden
  46963. */
  46964. export interface IMaterialClearCoatDefines {
  46965. CLEARCOAT: boolean;
  46966. CLEARCOAT_DEFAULTIOR: boolean;
  46967. CLEARCOAT_TEXTURE: boolean;
  46968. CLEARCOAT_TEXTUREDIRECTUV: number;
  46969. CLEARCOAT_BUMP: boolean;
  46970. CLEARCOAT_BUMPDIRECTUV: number;
  46971. CLEARCOAT_TINT: boolean;
  46972. CLEARCOAT_TINT_TEXTURE: boolean;
  46973. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46974. /** @hidden */
  46975. _areTexturesDirty: boolean;
  46976. }
  46977. /**
  46978. * Define the code related to the clear coat parameters of the pbr material.
  46979. */
  46980. export class PBRClearCoatConfiguration {
  46981. /**
  46982. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46983. * The default fits with a polyurethane material.
  46984. */
  46985. private static readonly _DefaultIndexOfRefraction;
  46986. private _isEnabled;
  46987. /**
  46988. * Defines if the clear coat is enabled in the material.
  46989. */
  46990. isEnabled: boolean;
  46991. /**
  46992. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46993. */
  46994. intensity: number;
  46995. /**
  46996. * Defines the clear coat layer roughness.
  46997. */
  46998. roughness: number;
  46999. private _indexOfRefraction;
  47000. /**
  47001. * Defines the index of refraction of the clear coat.
  47002. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47003. * The default fits with a polyurethane material.
  47004. * Changing the default value is more performance intensive.
  47005. */
  47006. indexOfRefraction: number;
  47007. private _texture;
  47008. /**
  47009. * Stores the clear coat values in a texture.
  47010. */
  47011. texture: Nullable<BaseTexture>;
  47012. private _bumpTexture;
  47013. /**
  47014. * Define the clear coat specific bump texture.
  47015. */
  47016. bumpTexture: Nullable<BaseTexture>;
  47017. private _isTintEnabled;
  47018. /**
  47019. * Defines if the clear coat tint is enabled in the material.
  47020. */
  47021. isTintEnabled: boolean;
  47022. /**
  47023. * Defines the clear coat tint of the material.
  47024. * This is only use if tint is enabled
  47025. */
  47026. tintColor: Color3;
  47027. /**
  47028. * Defines the distance at which the tint color should be found in the
  47029. * clear coat media.
  47030. * This is only use if tint is enabled
  47031. */
  47032. tintColorAtDistance: number;
  47033. /**
  47034. * Defines the clear coat layer thickness.
  47035. * This is only use if tint is enabled
  47036. */
  47037. tintThickness: number;
  47038. private _tintTexture;
  47039. /**
  47040. * Stores the clear tint values in a texture.
  47041. * rgb is tint
  47042. * a is a thickness factor
  47043. */
  47044. tintTexture: Nullable<BaseTexture>;
  47045. /** @hidden */
  47046. private _internalMarkAllSubMeshesAsTexturesDirty;
  47047. /** @hidden */
  47048. _markAllSubMeshesAsTexturesDirty(): void;
  47049. /**
  47050. * Instantiate a new istance of clear coat configuration.
  47051. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47052. */
  47053. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47054. /**
  47055. * Gets wehter the submesh is ready to be used or not.
  47056. * @param defines the list of "defines" to update.
  47057. * @param scene defines the scene the material belongs to.
  47058. * @param engine defines the engine the material belongs to.
  47059. * @param disableBumpMap defines wether the material disables bump or not.
  47060. * @returns - boolean indicating that the submesh is ready or not.
  47061. */
  47062. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47063. /**
  47064. * Checks to see if a texture is used in the material.
  47065. * @param defines the list of "defines" to update.
  47066. * @param scene defines the scene to the material belongs to.
  47067. */
  47068. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47069. /**
  47070. * Binds the material data.
  47071. * @param uniformBuffer defines the Uniform buffer to fill in.
  47072. * @param scene defines the scene the material belongs to.
  47073. * @param engine defines the engine the material belongs to.
  47074. * @param disableBumpMap defines wether the material disables bump or not.
  47075. * @param isFrozen defines wether the material is frozen or not.
  47076. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47077. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47078. */
  47079. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  47080. /**
  47081. * Checks to see if a texture is used in the material.
  47082. * @param texture - Base texture to use.
  47083. * @returns - Boolean specifying if a texture is used in the material.
  47084. */
  47085. hasTexture(texture: BaseTexture): boolean;
  47086. /**
  47087. * Returns an array of the actively used textures.
  47088. * @param activeTextures Array of BaseTextures
  47089. */
  47090. getActiveTextures(activeTextures: BaseTexture[]): void;
  47091. /**
  47092. * Returns the animatable textures.
  47093. * @param animatables Array of animatable textures.
  47094. */
  47095. getAnimatables(animatables: IAnimatable[]): void;
  47096. /**
  47097. * Disposes the resources of the material.
  47098. * @param forceDisposeTextures - Forces the disposal of all textures.
  47099. */
  47100. dispose(forceDisposeTextures?: boolean): void;
  47101. /**
  47102. * Get the current class name of the texture useful for serialization or dynamic coding.
  47103. * @returns "PBRClearCoatConfiguration"
  47104. */
  47105. getClassName(): string;
  47106. /**
  47107. * Add fallbacks to the effect fallbacks list.
  47108. * @param defines defines the Base texture to use.
  47109. * @param fallbacks defines the current fallback list.
  47110. * @param currentRank defines the current fallback rank.
  47111. * @returns the new fallback rank.
  47112. */
  47113. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47114. /**
  47115. * Add the required uniforms to the current list.
  47116. * @param uniforms defines the current uniform list.
  47117. */
  47118. static AddUniforms(uniforms: string[]): void;
  47119. /**
  47120. * Add the required samplers to the current list.
  47121. * @param samplers defines the current sampler list.
  47122. */
  47123. static AddSamplers(samplers: string[]): void;
  47124. /**
  47125. * Add the required uniforms to the current buffer.
  47126. * @param uniformBuffer defines the current uniform buffer.
  47127. */
  47128. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47129. /**
  47130. * Makes a duplicate of the current configuration into another one.
  47131. * @param clearCoatConfiguration define the config where to copy the info
  47132. */
  47133. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  47134. /**
  47135. * Serializes this clear coat configuration.
  47136. * @returns - An object with the serialized config.
  47137. */
  47138. serialize(): any;
  47139. /**
  47140. * Parses a anisotropy Configuration from a serialized object.
  47141. * @param source - Serialized object.
  47142. * @param scene Defines the scene we are parsing for
  47143. * @param rootUrl Defines the rootUrl to load from
  47144. */
  47145. parse(source: any, scene: Scene, rootUrl: string): void;
  47146. }
  47147. }
  47148. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  47149. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47150. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47152. import { Vector2 } from "babylonjs/Maths/math.vector";
  47153. import { Scene } from "babylonjs/scene";
  47154. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47155. import { Nullable } from "babylonjs/types";
  47156. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47157. /**
  47158. * @hidden
  47159. */
  47160. export interface IMaterialAnisotropicDefines {
  47161. ANISOTROPIC: boolean;
  47162. ANISOTROPIC_TEXTURE: boolean;
  47163. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47164. MAINUV1: boolean;
  47165. _areTexturesDirty: boolean;
  47166. _needUVs: boolean;
  47167. }
  47168. /**
  47169. * Define the code related to the anisotropic parameters of the pbr material.
  47170. */
  47171. export class PBRAnisotropicConfiguration {
  47172. private _isEnabled;
  47173. /**
  47174. * Defines if the anisotropy is enabled in the material.
  47175. */
  47176. isEnabled: boolean;
  47177. /**
  47178. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  47179. */
  47180. intensity: number;
  47181. /**
  47182. * Defines if the effect is along the tangents, bitangents or in between.
  47183. * By default, the effect is "strectching" the highlights along the tangents.
  47184. */
  47185. direction: Vector2;
  47186. private _texture;
  47187. /**
  47188. * Stores the anisotropy values in a texture.
  47189. * rg is direction (like normal from -1 to 1)
  47190. * b is a intensity
  47191. */
  47192. texture: Nullable<BaseTexture>;
  47193. /** @hidden */
  47194. private _internalMarkAllSubMeshesAsTexturesDirty;
  47195. /** @hidden */
  47196. _markAllSubMeshesAsTexturesDirty(): void;
  47197. /**
  47198. * Instantiate a new istance of anisotropy configuration.
  47199. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47200. */
  47201. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47202. /**
  47203. * Specifies that the submesh is ready to be used.
  47204. * @param defines the list of "defines" to update.
  47205. * @param scene defines the scene the material belongs to.
  47206. * @returns - boolean indicating that the submesh is ready or not.
  47207. */
  47208. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  47209. /**
  47210. * Checks to see if a texture is used in the material.
  47211. * @param defines the list of "defines" to update.
  47212. * @param mesh the mesh we are preparing the defines for.
  47213. * @param scene defines the scene the material belongs to.
  47214. */
  47215. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  47216. /**
  47217. * Binds the material data.
  47218. * @param uniformBuffer defines the Uniform buffer to fill in.
  47219. * @param scene defines the scene the material belongs to.
  47220. * @param isFrozen defines wether the material is frozen or not.
  47221. */
  47222. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47223. /**
  47224. * Checks to see if a texture is used in the material.
  47225. * @param texture - Base texture to use.
  47226. * @returns - Boolean specifying if a texture is used in the material.
  47227. */
  47228. hasTexture(texture: BaseTexture): boolean;
  47229. /**
  47230. * Returns an array of the actively used textures.
  47231. * @param activeTextures Array of BaseTextures
  47232. */
  47233. getActiveTextures(activeTextures: BaseTexture[]): void;
  47234. /**
  47235. * Returns the animatable textures.
  47236. * @param animatables Array of animatable textures.
  47237. */
  47238. getAnimatables(animatables: IAnimatable[]): void;
  47239. /**
  47240. * Disposes the resources of the material.
  47241. * @param forceDisposeTextures - Forces the disposal of all textures.
  47242. */
  47243. dispose(forceDisposeTextures?: boolean): void;
  47244. /**
  47245. * Get the current class name of the texture useful for serialization or dynamic coding.
  47246. * @returns "PBRAnisotropicConfiguration"
  47247. */
  47248. getClassName(): string;
  47249. /**
  47250. * Add fallbacks to the effect fallbacks list.
  47251. * @param defines defines the Base texture to use.
  47252. * @param fallbacks defines the current fallback list.
  47253. * @param currentRank defines the current fallback rank.
  47254. * @returns the new fallback rank.
  47255. */
  47256. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47257. /**
  47258. * Add the required uniforms to the current list.
  47259. * @param uniforms defines the current uniform list.
  47260. */
  47261. static AddUniforms(uniforms: string[]): void;
  47262. /**
  47263. * Add the required uniforms to the current buffer.
  47264. * @param uniformBuffer defines the current uniform buffer.
  47265. */
  47266. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47267. /**
  47268. * Add the required samplers to the current list.
  47269. * @param samplers defines the current sampler list.
  47270. */
  47271. static AddSamplers(samplers: string[]): void;
  47272. /**
  47273. * Makes a duplicate of the current configuration into another one.
  47274. * @param anisotropicConfiguration define the config where to copy the info
  47275. */
  47276. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  47277. /**
  47278. * Serializes this anisotropy configuration.
  47279. * @returns - An object with the serialized config.
  47280. */
  47281. serialize(): any;
  47282. /**
  47283. * Parses a anisotropy Configuration from a serialized object.
  47284. * @param source - Serialized object.
  47285. * @param scene Defines the scene we are parsing for
  47286. * @param rootUrl Defines the rootUrl to load from
  47287. */
  47288. parse(source: any, scene: Scene, rootUrl: string): void;
  47289. }
  47290. }
  47291. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  47292. import { Scene } from "babylonjs/scene";
  47293. /**
  47294. * @hidden
  47295. */
  47296. export interface IMaterialBRDFDefines {
  47297. BRDF_V_HEIGHT_CORRELATED: boolean;
  47298. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47299. SPHERICAL_HARMONICS: boolean;
  47300. /** @hidden */
  47301. _areMiscDirty: boolean;
  47302. }
  47303. /**
  47304. * Define the code related to the BRDF parameters of the pbr material.
  47305. */
  47306. export class PBRBRDFConfiguration {
  47307. /**
  47308. * Default value used for the energy conservation.
  47309. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47310. */
  47311. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  47312. /**
  47313. * Default value used for the Smith Visibility Height Correlated mode.
  47314. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47315. */
  47316. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  47317. /**
  47318. * Default value used for the IBL diffuse part.
  47319. * This can help switching back to the polynomials mode globally which is a tiny bit
  47320. * less GPU intensive at the drawback of a lower quality.
  47321. */
  47322. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  47323. private _useEnergyConservation;
  47324. /**
  47325. * Defines if the material uses energy conservation.
  47326. */
  47327. useEnergyConservation: boolean;
  47328. private _useSmithVisibilityHeightCorrelated;
  47329. /**
  47330. * LEGACY Mode set to false
  47331. * Defines if the material uses height smith correlated visibility term.
  47332. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  47333. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47334. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  47335. * Not relying on height correlated will also disable energy conservation.
  47336. */
  47337. useSmithVisibilityHeightCorrelated: boolean;
  47338. private _useSphericalHarmonics;
  47339. /**
  47340. * LEGACY Mode set to false
  47341. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  47342. * diffuse part of the IBL.
  47343. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  47344. * to the ground truth.
  47345. */
  47346. useSphericalHarmonics: boolean;
  47347. /** @hidden */
  47348. private _internalMarkAllSubMeshesAsMiscDirty;
  47349. /** @hidden */
  47350. _markAllSubMeshesAsMiscDirty(): void;
  47351. /**
  47352. * Instantiate a new istance of clear coat configuration.
  47353. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  47354. */
  47355. constructor(markAllSubMeshesAsMiscDirty: () => void);
  47356. /**
  47357. * Checks to see if a texture is used in the material.
  47358. * @param defines the list of "defines" to update.
  47359. */
  47360. prepareDefines(defines: IMaterialBRDFDefines): void;
  47361. /**
  47362. * Get the current class name of the texture useful for serialization or dynamic coding.
  47363. * @returns "PBRClearCoatConfiguration"
  47364. */
  47365. getClassName(): string;
  47366. /**
  47367. * Makes a duplicate of the current configuration into another one.
  47368. * @param brdfConfiguration define the config where to copy the info
  47369. */
  47370. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  47371. /**
  47372. * Serializes this BRDF configuration.
  47373. * @returns - An object with the serialized config.
  47374. */
  47375. serialize(): any;
  47376. /**
  47377. * Parses a anisotropy Configuration from a serialized object.
  47378. * @param source - Serialized object.
  47379. * @param scene Defines the scene we are parsing for
  47380. * @param rootUrl Defines the rootUrl to load from
  47381. */
  47382. parse(source: any, scene: Scene, rootUrl: string): void;
  47383. }
  47384. }
  47385. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  47386. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47387. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47388. import { Color3 } from "babylonjs/Maths/math.color";
  47389. import { Scene } from "babylonjs/scene";
  47390. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47391. import { Nullable } from "babylonjs/types";
  47392. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47393. /**
  47394. * @hidden
  47395. */
  47396. export interface IMaterialSheenDefines {
  47397. SHEEN: boolean;
  47398. SHEEN_TEXTURE: boolean;
  47399. SHEEN_TEXTUREDIRECTUV: number;
  47400. SHEEN_LINKWITHALBEDO: boolean;
  47401. /** @hidden */
  47402. _areTexturesDirty: boolean;
  47403. }
  47404. /**
  47405. * Define the code related to the Sheen parameters of the pbr material.
  47406. */
  47407. export class PBRSheenConfiguration {
  47408. private _isEnabled;
  47409. /**
  47410. * Defines if the material uses sheen.
  47411. */
  47412. isEnabled: boolean;
  47413. private _linkSheenWithAlbedo;
  47414. /**
  47415. * Defines if the sheen is linked to the sheen color.
  47416. */
  47417. linkSheenWithAlbedo: boolean;
  47418. /**
  47419. * Defines the sheen intensity.
  47420. */
  47421. intensity: number;
  47422. /**
  47423. * Defines the sheen color.
  47424. */
  47425. color: Color3;
  47426. private _texture;
  47427. /**
  47428. * Stores the sheen tint values in a texture.
  47429. * rgb is tint
  47430. * a is a intensity
  47431. */
  47432. texture: Nullable<BaseTexture>;
  47433. /** @hidden */
  47434. private _internalMarkAllSubMeshesAsTexturesDirty;
  47435. /** @hidden */
  47436. _markAllSubMeshesAsTexturesDirty(): void;
  47437. /**
  47438. * Instantiate a new istance of clear coat configuration.
  47439. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47440. */
  47441. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47442. /**
  47443. * Specifies that the submesh is ready to be used.
  47444. * @param defines the list of "defines" to update.
  47445. * @param scene defines the scene the material belongs to.
  47446. * @returns - boolean indicating that the submesh is ready or not.
  47447. */
  47448. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  47449. /**
  47450. * Checks to see if a texture is used in the material.
  47451. * @param defines the list of "defines" to update.
  47452. * @param scene defines the scene the material belongs to.
  47453. */
  47454. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  47455. /**
  47456. * Binds the material data.
  47457. * @param uniformBuffer defines the Uniform buffer to fill in.
  47458. * @param scene defines the scene the material belongs to.
  47459. * @param isFrozen defines wether the material is frozen or not.
  47460. */
  47461. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47462. /**
  47463. * Checks to see if a texture is used in the material.
  47464. * @param texture - Base texture to use.
  47465. * @returns - Boolean specifying if a texture is used in the material.
  47466. */
  47467. hasTexture(texture: BaseTexture): boolean;
  47468. /**
  47469. * Returns an array of the actively used textures.
  47470. * @param activeTextures Array of BaseTextures
  47471. */
  47472. getActiveTextures(activeTextures: BaseTexture[]): void;
  47473. /**
  47474. * Returns the animatable textures.
  47475. * @param animatables Array of animatable textures.
  47476. */
  47477. getAnimatables(animatables: IAnimatable[]): void;
  47478. /**
  47479. * Disposes the resources of the material.
  47480. * @param forceDisposeTextures - Forces the disposal of all textures.
  47481. */
  47482. dispose(forceDisposeTextures?: boolean): void;
  47483. /**
  47484. * Get the current class name of the texture useful for serialization or dynamic coding.
  47485. * @returns "PBRSheenConfiguration"
  47486. */
  47487. getClassName(): string;
  47488. /**
  47489. * Add fallbacks to the effect fallbacks list.
  47490. * @param defines defines the Base texture to use.
  47491. * @param fallbacks defines the current fallback list.
  47492. * @param currentRank defines the current fallback rank.
  47493. * @returns the new fallback rank.
  47494. */
  47495. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47496. /**
  47497. * Add the required uniforms to the current list.
  47498. * @param uniforms defines the current uniform list.
  47499. */
  47500. static AddUniforms(uniforms: string[]): void;
  47501. /**
  47502. * Add the required uniforms to the current buffer.
  47503. * @param uniformBuffer defines the current uniform buffer.
  47504. */
  47505. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47506. /**
  47507. * Add the required samplers to the current list.
  47508. * @param samplers defines the current sampler list.
  47509. */
  47510. static AddSamplers(samplers: string[]): void;
  47511. /**
  47512. * Makes a duplicate of the current configuration into another one.
  47513. * @param sheenConfiguration define the config where to copy the info
  47514. */
  47515. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47516. /**
  47517. * Serializes this BRDF configuration.
  47518. * @returns - An object with the serialized config.
  47519. */
  47520. serialize(): any;
  47521. /**
  47522. * Parses a anisotropy Configuration from a serialized object.
  47523. * @param source - Serialized object.
  47524. * @param scene Defines the scene we are parsing for
  47525. * @param rootUrl Defines the rootUrl to load from
  47526. */
  47527. parse(source: any, scene: Scene, rootUrl: string): void;
  47528. }
  47529. }
  47530. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  47531. import { Nullable } from "babylonjs/types";
  47532. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47533. import { Color3 } from "babylonjs/Maths/math.color";
  47534. import { SmartArray } from "babylonjs/Misc/smartArray";
  47535. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47536. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47537. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  47538. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47539. import { Engine } from "babylonjs/Engines/engine";
  47540. import { Scene } from "babylonjs/scene";
  47541. /**
  47542. * @hidden
  47543. */
  47544. export interface IMaterialSubSurfaceDefines {
  47545. SUBSURFACE: boolean;
  47546. SS_REFRACTION: boolean;
  47547. SS_TRANSLUCENCY: boolean;
  47548. SS_SCATERRING: boolean;
  47549. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47550. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47551. SS_REFRACTIONMAP_3D: boolean;
  47552. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47553. SS_LODINREFRACTIONALPHA: boolean;
  47554. SS_GAMMAREFRACTION: boolean;
  47555. SS_RGBDREFRACTION: boolean;
  47556. SS_LINEARSPECULARREFRACTION: boolean;
  47557. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47558. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47559. /** @hidden */
  47560. _areTexturesDirty: boolean;
  47561. }
  47562. /**
  47563. * Define the code related to the sub surface parameters of the pbr material.
  47564. */
  47565. export class PBRSubSurfaceConfiguration {
  47566. private _isRefractionEnabled;
  47567. /**
  47568. * Defines if the refraction is enabled in the material.
  47569. */
  47570. isRefractionEnabled: boolean;
  47571. private _isTranslucencyEnabled;
  47572. /**
  47573. * Defines if the translucency is enabled in the material.
  47574. */
  47575. isTranslucencyEnabled: boolean;
  47576. private _isScatteringEnabled;
  47577. /**
  47578. * Defines the refraction intensity of the material.
  47579. * The refraction when enabled replaces the Diffuse part of the material.
  47580. * The intensity helps transitionning between diffuse and refraction.
  47581. */
  47582. refractionIntensity: number;
  47583. /**
  47584. * Defines the translucency intensity of the material.
  47585. * When translucency has been enabled, this defines how much of the "translucency"
  47586. * is addded to the diffuse part of the material.
  47587. */
  47588. translucencyIntensity: number;
  47589. /**
  47590. * Defines the scattering intensity of the material.
  47591. * When scattering has been enabled, this defines how much of the "scattered light"
  47592. * is addded to the diffuse part of the material.
  47593. */
  47594. scatteringIntensity: number;
  47595. private _thicknessTexture;
  47596. /**
  47597. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47598. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47599. * 0 would mean minimumThickness
  47600. * 1 would mean maximumThickness
  47601. * The other channels might be use as a mask to vary the different effects intensity.
  47602. */
  47603. thicknessTexture: Nullable<BaseTexture>;
  47604. private _refractionTexture;
  47605. /**
  47606. * Defines the texture to use for refraction.
  47607. */
  47608. refractionTexture: Nullable<BaseTexture>;
  47609. private _indexOfRefraction;
  47610. /**
  47611. * Defines the index of refraction used in the material.
  47612. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47613. */
  47614. indexOfRefraction: number;
  47615. private _invertRefractionY;
  47616. /**
  47617. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47618. */
  47619. invertRefractionY: boolean;
  47620. private _linkRefractionWithTransparency;
  47621. /**
  47622. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47623. * Materials half opaque for instance using refraction could benefit from this control.
  47624. */
  47625. linkRefractionWithTransparency: boolean;
  47626. /**
  47627. * Defines the minimum thickness stored in the thickness map.
  47628. * If no thickness map is defined, this value will be used to simulate thickness.
  47629. */
  47630. minimumThickness: number;
  47631. /**
  47632. * Defines the maximum thickness stored in the thickness map.
  47633. */
  47634. maximumThickness: number;
  47635. /**
  47636. * Defines the volume tint of the material.
  47637. * This is used for both translucency and scattering.
  47638. */
  47639. tintColor: Color3;
  47640. /**
  47641. * Defines the distance at which the tint color should be found in the media.
  47642. * This is used for refraction only.
  47643. */
  47644. tintColorAtDistance: number;
  47645. /**
  47646. * Defines how far each channel transmit through the media.
  47647. * It is defined as a color to simplify it selection.
  47648. */
  47649. diffusionDistance: Color3;
  47650. private _useMaskFromThicknessTexture;
  47651. /**
  47652. * Stores the intensity of the different subsurface effects in the thickness texture.
  47653. * * the green channel is the translucency intensity.
  47654. * * the blue channel is the scattering intensity.
  47655. * * the alpha channel is the refraction intensity.
  47656. */
  47657. useMaskFromThicknessTexture: boolean;
  47658. /** @hidden */
  47659. private _internalMarkAllSubMeshesAsTexturesDirty;
  47660. /** @hidden */
  47661. _markAllSubMeshesAsTexturesDirty(): void;
  47662. /**
  47663. * Instantiate a new istance of sub surface configuration.
  47664. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47665. */
  47666. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47667. /**
  47668. * Gets wehter the submesh is ready to be used or not.
  47669. * @param defines the list of "defines" to update.
  47670. * @param scene defines the scene the material belongs to.
  47671. * @returns - boolean indicating that the submesh is ready or not.
  47672. */
  47673. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47674. /**
  47675. * Checks to see if a texture is used in the material.
  47676. * @param defines the list of "defines" to update.
  47677. * @param scene defines the scene to the material belongs to.
  47678. */
  47679. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47680. /**
  47681. * Binds the material data.
  47682. * @param uniformBuffer defines the Uniform buffer to fill in.
  47683. * @param scene defines the scene the material belongs to.
  47684. * @param engine defines the engine the material belongs to.
  47685. * @param isFrozen defines wether the material is frozen or not.
  47686. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47687. */
  47688. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47689. /**
  47690. * Unbinds the material from the mesh.
  47691. * @param activeEffect defines the effect that should be unbound from.
  47692. * @returns true if unbound, otherwise false
  47693. */
  47694. unbind(activeEffect: Effect): boolean;
  47695. /**
  47696. * Returns the texture used for refraction or null if none is used.
  47697. * @param scene defines the scene the material belongs to.
  47698. * @returns - Refraction texture if present. If no refraction texture and refraction
  47699. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47700. */
  47701. private _getRefractionTexture;
  47702. /**
  47703. * Returns true if alpha blending should be disabled.
  47704. */
  47705. readonly disableAlphaBlending: boolean;
  47706. /**
  47707. * Fills the list of render target textures.
  47708. * @param renderTargets the list of render targets to update
  47709. */
  47710. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47711. /**
  47712. * Checks to see if a texture is used in the material.
  47713. * @param texture - Base texture to use.
  47714. * @returns - Boolean specifying if a texture is used in the material.
  47715. */
  47716. hasTexture(texture: BaseTexture): boolean;
  47717. /**
  47718. * Gets a boolean indicating that current material needs to register RTT
  47719. * @returns true if this uses a render target otherwise false.
  47720. */
  47721. hasRenderTargetTextures(): boolean;
  47722. /**
  47723. * Returns an array of the actively used textures.
  47724. * @param activeTextures Array of BaseTextures
  47725. */
  47726. getActiveTextures(activeTextures: BaseTexture[]): void;
  47727. /**
  47728. * Returns the animatable textures.
  47729. * @param animatables Array of animatable textures.
  47730. */
  47731. getAnimatables(animatables: IAnimatable[]): void;
  47732. /**
  47733. * Disposes the resources of the material.
  47734. * @param forceDisposeTextures - Forces the disposal of all textures.
  47735. */
  47736. dispose(forceDisposeTextures?: boolean): void;
  47737. /**
  47738. * Get the current class name of the texture useful for serialization or dynamic coding.
  47739. * @returns "PBRSubSurfaceConfiguration"
  47740. */
  47741. getClassName(): string;
  47742. /**
  47743. * Add fallbacks to the effect fallbacks list.
  47744. * @param defines defines the Base texture to use.
  47745. * @param fallbacks defines the current fallback list.
  47746. * @param currentRank defines the current fallback rank.
  47747. * @returns the new fallback rank.
  47748. */
  47749. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47750. /**
  47751. * Add the required uniforms to the current list.
  47752. * @param uniforms defines the current uniform list.
  47753. */
  47754. static AddUniforms(uniforms: string[]): void;
  47755. /**
  47756. * Add the required samplers to the current list.
  47757. * @param samplers defines the current sampler list.
  47758. */
  47759. static AddSamplers(samplers: string[]): void;
  47760. /**
  47761. * Add the required uniforms to the current buffer.
  47762. * @param uniformBuffer defines the current uniform buffer.
  47763. */
  47764. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47765. /**
  47766. * Makes a duplicate of the current configuration into another one.
  47767. * @param configuration define the config where to copy the info
  47768. */
  47769. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47770. /**
  47771. * Serializes this Sub Surface configuration.
  47772. * @returns - An object with the serialized config.
  47773. */
  47774. serialize(): any;
  47775. /**
  47776. * Parses a anisotropy Configuration from a serialized object.
  47777. * @param source - Serialized object.
  47778. * @param scene Defines the scene we are parsing for
  47779. * @param rootUrl Defines the rootUrl to load from
  47780. */
  47781. parse(source: any, scene: Scene, rootUrl: string): void;
  47782. }
  47783. }
  47784. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  47785. /** @hidden */
  47786. export var pbrFragmentDeclaration: {
  47787. name: string;
  47788. shader: string;
  47789. };
  47790. }
  47791. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  47792. /** @hidden */
  47793. export var pbrUboDeclaration: {
  47794. name: string;
  47795. shader: string;
  47796. };
  47797. }
  47798. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  47799. /** @hidden */
  47800. export var pbrFragmentExtraDeclaration: {
  47801. name: string;
  47802. shader: string;
  47803. };
  47804. }
  47805. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  47806. /** @hidden */
  47807. export var pbrFragmentSamplersDeclaration: {
  47808. name: string;
  47809. shader: string;
  47810. };
  47811. }
  47812. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  47813. /** @hidden */
  47814. export var pbrHelperFunctions: {
  47815. name: string;
  47816. shader: string;
  47817. };
  47818. }
  47819. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  47820. /** @hidden */
  47821. export var harmonicsFunctions: {
  47822. name: string;
  47823. shader: string;
  47824. };
  47825. }
  47826. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  47827. /** @hidden */
  47828. export var pbrDirectLightingSetupFunctions: {
  47829. name: string;
  47830. shader: string;
  47831. };
  47832. }
  47833. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  47834. /** @hidden */
  47835. export var pbrDirectLightingFalloffFunctions: {
  47836. name: string;
  47837. shader: string;
  47838. };
  47839. }
  47840. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  47841. /** @hidden */
  47842. export var pbrBRDFFunctions: {
  47843. name: string;
  47844. shader: string;
  47845. };
  47846. }
  47847. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  47848. /** @hidden */
  47849. export var pbrDirectLightingFunctions: {
  47850. name: string;
  47851. shader: string;
  47852. };
  47853. }
  47854. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  47855. /** @hidden */
  47856. export var pbrIBLFunctions: {
  47857. name: string;
  47858. shader: string;
  47859. };
  47860. }
  47861. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  47862. /** @hidden */
  47863. export var pbrDebug: {
  47864. name: string;
  47865. shader: string;
  47866. };
  47867. }
  47868. declare module "babylonjs/Shaders/pbr.fragment" {
  47869. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  47870. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47871. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  47872. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47873. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47874. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  47875. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47876. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47877. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47878. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47879. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47880. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  47881. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47882. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47883. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47884. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  47885. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  47886. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  47887. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  47888. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  47889. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  47890. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47891. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47892. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  47893. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  47894. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47895. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  47896. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47897. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  47898. /** @hidden */
  47899. export var pbrPixelShader: {
  47900. name: string;
  47901. shader: string;
  47902. };
  47903. }
  47904. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  47905. /** @hidden */
  47906. export var pbrVertexDeclaration: {
  47907. name: string;
  47908. shader: string;
  47909. };
  47910. }
  47911. declare module "babylonjs/Shaders/pbr.vertex" {
  47912. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  47913. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47914. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47915. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47916. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47917. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47918. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  47919. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47920. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47921. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47922. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47923. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47924. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47925. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47926. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47927. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47928. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47929. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  47930. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47931. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47932. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47933. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  47934. /** @hidden */
  47935. export var pbrVertexShader: {
  47936. name: string;
  47937. shader: string;
  47938. };
  47939. }
  47940. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  47941. import { Nullable } from "babylonjs/types";
  47942. import { Scene } from "babylonjs/scene";
  47943. import { Matrix } from "babylonjs/Maths/math.vector";
  47944. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47946. import { Mesh } from "babylonjs/Meshes/mesh";
  47947. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  47948. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  47949. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  47950. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  47951. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  47952. import { Color3 } from "babylonjs/Maths/math.color";
  47953. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  47954. import { Material } from "babylonjs/Materials/material";
  47955. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  47956. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47957. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47958. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47959. import "babylonjs/Shaders/pbr.fragment";
  47960. import "babylonjs/Shaders/pbr.vertex";
  47961. /**
  47962. * Manages the defines for the PBR Material.
  47963. * @hidden
  47964. */
  47965. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47966. PBR: boolean;
  47967. MAINUV1: boolean;
  47968. MAINUV2: boolean;
  47969. UV1: boolean;
  47970. UV2: boolean;
  47971. ALBEDO: boolean;
  47972. ALBEDODIRECTUV: number;
  47973. VERTEXCOLOR: boolean;
  47974. AMBIENT: boolean;
  47975. AMBIENTDIRECTUV: number;
  47976. AMBIENTINGRAYSCALE: boolean;
  47977. OPACITY: boolean;
  47978. VERTEXALPHA: boolean;
  47979. OPACITYDIRECTUV: number;
  47980. OPACITYRGB: boolean;
  47981. ALPHATEST: boolean;
  47982. DEPTHPREPASS: boolean;
  47983. ALPHABLEND: boolean;
  47984. ALPHAFROMALBEDO: boolean;
  47985. ALPHATESTVALUE: string;
  47986. SPECULAROVERALPHA: boolean;
  47987. RADIANCEOVERALPHA: boolean;
  47988. ALPHAFRESNEL: boolean;
  47989. LINEARALPHAFRESNEL: boolean;
  47990. PREMULTIPLYALPHA: boolean;
  47991. EMISSIVE: boolean;
  47992. EMISSIVEDIRECTUV: number;
  47993. REFLECTIVITY: boolean;
  47994. REFLECTIVITYDIRECTUV: number;
  47995. SPECULARTERM: boolean;
  47996. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47997. MICROSURFACEAUTOMATIC: boolean;
  47998. LODBASEDMICROSFURACE: boolean;
  47999. MICROSURFACEMAP: boolean;
  48000. MICROSURFACEMAPDIRECTUV: number;
  48001. METALLICWORKFLOW: boolean;
  48002. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48003. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48004. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48005. AOSTOREINMETALMAPRED: boolean;
  48006. ENVIRONMENTBRDF: boolean;
  48007. ENVIRONMENTBRDF_RGBD: boolean;
  48008. NORMAL: boolean;
  48009. TANGENT: boolean;
  48010. BUMP: boolean;
  48011. BUMPDIRECTUV: number;
  48012. OBJECTSPACE_NORMALMAP: boolean;
  48013. PARALLAX: boolean;
  48014. PARALLAXOCCLUSION: boolean;
  48015. NORMALXYSCALE: boolean;
  48016. LIGHTMAP: boolean;
  48017. LIGHTMAPDIRECTUV: number;
  48018. USELIGHTMAPASSHADOWMAP: boolean;
  48019. GAMMALIGHTMAP: boolean;
  48020. REFLECTION: boolean;
  48021. REFLECTIONMAP_3D: boolean;
  48022. REFLECTIONMAP_SPHERICAL: boolean;
  48023. REFLECTIONMAP_PLANAR: boolean;
  48024. REFLECTIONMAP_CUBIC: boolean;
  48025. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  48026. REFLECTIONMAP_PROJECTION: boolean;
  48027. REFLECTIONMAP_SKYBOX: boolean;
  48028. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  48029. REFLECTIONMAP_EXPLICIT: boolean;
  48030. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  48031. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  48032. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  48033. INVERTCUBICMAP: boolean;
  48034. USESPHERICALFROMREFLECTIONMAP: boolean;
  48035. USEIRRADIANCEMAP: boolean;
  48036. SPHERICAL_HARMONICS: boolean;
  48037. USESPHERICALINVERTEX: boolean;
  48038. REFLECTIONMAP_OPPOSITEZ: boolean;
  48039. LODINREFLECTIONALPHA: boolean;
  48040. GAMMAREFLECTION: boolean;
  48041. RGBDREFLECTION: boolean;
  48042. LINEARSPECULARREFLECTION: boolean;
  48043. RADIANCEOCCLUSION: boolean;
  48044. HORIZONOCCLUSION: boolean;
  48045. INSTANCES: boolean;
  48046. NUM_BONE_INFLUENCERS: number;
  48047. BonesPerMesh: number;
  48048. BONETEXTURE: boolean;
  48049. NONUNIFORMSCALING: boolean;
  48050. MORPHTARGETS: boolean;
  48051. MORPHTARGETS_NORMAL: boolean;
  48052. MORPHTARGETS_TANGENT: boolean;
  48053. MORPHTARGETS_UV: boolean;
  48054. NUM_MORPH_INFLUENCERS: number;
  48055. IMAGEPROCESSING: boolean;
  48056. VIGNETTE: boolean;
  48057. VIGNETTEBLENDMODEMULTIPLY: boolean;
  48058. VIGNETTEBLENDMODEOPAQUE: boolean;
  48059. TONEMAPPING: boolean;
  48060. TONEMAPPING_ACES: boolean;
  48061. CONTRAST: boolean;
  48062. COLORCURVES: boolean;
  48063. COLORGRADING: boolean;
  48064. COLORGRADING3D: boolean;
  48065. SAMPLER3DGREENDEPTH: boolean;
  48066. SAMPLER3DBGRMAP: boolean;
  48067. IMAGEPROCESSINGPOSTPROCESS: boolean;
  48068. EXPOSURE: boolean;
  48069. MULTIVIEW: boolean;
  48070. USEPHYSICALLIGHTFALLOFF: boolean;
  48071. USEGLTFLIGHTFALLOFF: boolean;
  48072. TWOSIDEDLIGHTING: boolean;
  48073. SHADOWFLOAT: boolean;
  48074. CLIPPLANE: boolean;
  48075. CLIPPLANE2: boolean;
  48076. CLIPPLANE3: boolean;
  48077. CLIPPLANE4: boolean;
  48078. POINTSIZE: boolean;
  48079. FOG: boolean;
  48080. LOGARITHMICDEPTH: boolean;
  48081. FORCENORMALFORWARD: boolean;
  48082. SPECULARAA: boolean;
  48083. CLEARCOAT: boolean;
  48084. CLEARCOAT_DEFAULTIOR: boolean;
  48085. CLEARCOAT_TEXTURE: boolean;
  48086. CLEARCOAT_TEXTUREDIRECTUV: number;
  48087. CLEARCOAT_BUMP: boolean;
  48088. CLEARCOAT_BUMPDIRECTUV: number;
  48089. CLEARCOAT_TINT: boolean;
  48090. CLEARCOAT_TINT_TEXTURE: boolean;
  48091. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48092. ANISOTROPIC: boolean;
  48093. ANISOTROPIC_TEXTURE: boolean;
  48094. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48095. BRDF_V_HEIGHT_CORRELATED: boolean;
  48096. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48097. SHEEN: boolean;
  48098. SHEEN_TEXTURE: boolean;
  48099. SHEEN_TEXTUREDIRECTUV: number;
  48100. SHEEN_LINKWITHALBEDO: boolean;
  48101. SUBSURFACE: boolean;
  48102. SS_REFRACTION: boolean;
  48103. SS_TRANSLUCENCY: boolean;
  48104. SS_SCATERRING: boolean;
  48105. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48106. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48107. SS_REFRACTIONMAP_3D: boolean;
  48108. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48109. SS_LODINREFRACTIONALPHA: boolean;
  48110. SS_GAMMAREFRACTION: boolean;
  48111. SS_RGBDREFRACTION: boolean;
  48112. SS_LINEARSPECULARREFRACTION: boolean;
  48113. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48114. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48115. UNLIT: boolean;
  48116. DEBUGMODE: number;
  48117. /**
  48118. * Initializes the PBR Material defines.
  48119. */
  48120. constructor();
  48121. /**
  48122. * Resets the PBR Material defines.
  48123. */
  48124. reset(): void;
  48125. }
  48126. /**
  48127. * The Physically based material base class of BJS.
  48128. *
  48129. * This offers the main features of a standard PBR material.
  48130. * For more information, please refer to the documentation :
  48131. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48132. */
  48133. export abstract class PBRBaseMaterial extends PushMaterial {
  48134. /**
  48135. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48136. */
  48137. static readonly PBRMATERIAL_OPAQUE: number;
  48138. /**
  48139. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48140. */
  48141. static readonly PBRMATERIAL_ALPHATEST: number;
  48142. /**
  48143. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48144. */
  48145. static readonly PBRMATERIAL_ALPHABLEND: number;
  48146. /**
  48147. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48148. * They are also discarded below the alpha cutoff threshold to improve performances.
  48149. */
  48150. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48151. /**
  48152. * Defines the default value of how much AO map is occluding the analytical lights
  48153. * (point spot...).
  48154. */
  48155. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48156. /**
  48157. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  48158. */
  48159. static readonly LIGHTFALLOFF_PHYSICAL: number;
  48160. /**
  48161. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  48162. * to enhance interoperability with other engines.
  48163. */
  48164. static readonly LIGHTFALLOFF_GLTF: number;
  48165. /**
  48166. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  48167. * to enhance interoperability with other materials.
  48168. */
  48169. static readonly LIGHTFALLOFF_STANDARD: number;
  48170. /**
  48171. * Intensity of the direct lights e.g. the four lights available in your scene.
  48172. * This impacts both the direct diffuse and specular highlights.
  48173. */
  48174. protected _directIntensity: number;
  48175. /**
  48176. * Intensity of the emissive part of the material.
  48177. * This helps controlling the emissive effect without modifying the emissive color.
  48178. */
  48179. protected _emissiveIntensity: number;
  48180. /**
  48181. * Intensity of the environment e.g. how much the environment will light the object
  48182. * either through harmonics for rough material or through the refelction for shiny ones.
  48183. */
  48184. protected _environmentIntensity: number;
  48185. /**
  48186. * This is a special control allowing the reduction of the specular highlights coming from the
  48187. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48188. */
  48189. protected _specularIntensity: number;
  48190. /**
  48191. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  48192. */
  48193. private _lightingInfos;
  48194. /**
  48195. * Debug Control allowing disabling the bump map on this material.
  48196. */
  48197. protected _disableBumpMap: boolean;
  48198. /**
  48199. * AKA Diffuse Texture in standard nomenclature.
  48200. */
  48201. protected _albedoTexture: Nullable<BaseTexture>;
  48202. /**
  48203. * AKA Occlusion Texture in other nomenclature.
  48204. */
  48205. protected _ambientTexture: Nullable<BaseTexture>;
  48206. /**
  48207. * AKA Occlusion Texture Intensity in other nomenclature.
  48208. */
  48209. protected _ambientTextureStrength: number;
  48210. /**
  48211. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48212. * 1 means it completely occludes it
  48213. * 0 mean it has no impact
  48214. */
  48215. protected _ambientTextureImpactOnAnalyticalLights: number;
  48216. /**
  48217. * Stores the alpha values in a texture.
  48218. */
  48219. protected _opacityTexture: Nullable<BaseTexture>;
  48220. /**
  48221. * Stores the reflection values in a texture.
  48222. */
  48223. protected _reflectionTexture: Nullable<BaseTexture>;
  48224. /**
  48225. * Stores the emissive values in a texture.
  48226. */
  48227. protected _emissiveTexture: Nullable<BaseTexture>;
  48228. /**
  48229. * AKA Specular texture in other nomenclature.
  48230. */
  48231. protected _reflectivityTexture: Nullable<BaseTexture>;
  48232. /**
  48233. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48234. */
  48235. protected _metallicTexture: Nullable<BaseTexture>;
  48236. /**
  48237. * Specifies the metallic scalar of the metallic/roughness workflow.
  48238. * Can also be used to scale the metalness values of the metallic texture.
  48239. */
  48240. protected _metallic: Nullable<number>;
  48241. /**
  48242. * Specifies the roughness scalar of the metallic/roughness workflow.
  48243. * Can also be used to scale the roughness values of the metallic texture.
  48244. */
  48245. protected _roughness: Nullable<number>;
  48246. /**
  48247. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48248. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48249. */
  48250. protected _microSurfaceTexture: Nullable<BaseTexture>;
  48251. /**
  48252. * Stores surface normal data used to displace a mesh in a texture.
  48253. */
  48254. protected _bumpTexture: Nullable<BaseTexture>;
  48255. /**
  48256. * Stores the pre-calculated light information of a mesh in a texture.
  48257. */
  48258. protected _lightmapTexture: Nullable<BaseTexture>;
  48259. /**
  48260. * The color of a material in ambient lighting.
  48261. */
  48262. protected _ambientColor: Color3;
  48263. /**
  48264. * AKA Diffuse Color in other nomenclature.
  48265. */
  48266. protected _albedoColor: Color3;
  48267. /**
  48268. * AKA Specular Color in other nomenclature.
  48269. */
  48270. protected _reflectivityColor: Color3;
  48271. /**
  48272. * The color applied when light is reflected from a material.
  48273. */
  48274. protected _reflectionColor: Color3;
  48275. /**
  48276. * The color applied when light is emitted from a material.
  48277. */
  48278. protected _emissiveColor: Color3;
  48279. /**
  48280. * AKA Glossiness in other nomenclature.
  48281. */
  48282. protected _microSurface: number;
  48283. /**
  48284. * Specifies that the material will use the light map as a show map.
  48285. */
  48286. protected _useLightmapAsShadowmap: boolean;
  48287. /**
  48288. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48289. * makes the reflect vector face the model (under horizon).
  48290. */
  48291. protected _useHorizonOcclusion: boolean;
  48292. /**
  48293. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48294. * too much the area relying on ambient texture to define their ambient occlusion.
  48295. */
  48296. protected _useRadianceOcclusion: boolean;
  48297. /**
  48298. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48299. */
  48300. protected _useAlphaFromAlbedoTexture: boolean;
  48301. /**
  48302. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  48303. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48304. */
  48305. protected _useSpecularOverAlpha: boolean;
  48306. /**
  48307. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48308. */
  48309. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48310. /**
  48311. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48312. */
  48313. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  48314. /**
  48315. * Specifies if the metallic texture contains the roughness information in its green channel.
  48316. */
  48317. protected _useRoughnessFromMetallicTextureGreen: boolean;
  48318. /**
  48319. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48320. */
  48321. protected _useMetallnessFromMetallicTextureBlue: boolean;
  48322. /**
  48323. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48324. */
  48325. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  48326. /**
  48327. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48328. */
  48329. protected _useAmbientInGrayScale: boolean;
  48330. /**
  48331. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48332. * The material will try to infer what glossiness each pixel should be.
  48333. */
  48334. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  48335. /**
  48336. * Defines the falloff type used in this material.
  48337. * It by default is Physical.
  48338. */
  48339. protected _lightFalloff: number;
  48340. /**
  48341. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48342. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48343. */
  48344. protected _useRadianceOverAlpha: boolean;
  48345. /**
  48346. * Allows using an object space normal map (instead of tangent space).
  48347. */
  48348. protected _useObjectSpaceNormalMap: boolean;
  48349. /**
  48350. * Allows using the bump map in parallax mode.
  48351. */
  48352. protected _useParallax: boolean;
  48353. /**
  48354. * Allows using the bump map in parallax occlusion mode.
  48355. */
  48356. protected _useParallaxOcclusion: boolean;
  48357. /**
  48358. * Controls the scale bias of the parallax mode.
  48359. */
  48360. protected _parallaxScaleBias: number;
  48361. /**
  48362. * If sets to true, disables all the lights affecting the material.
  48363. */
  48364. protected _disableLighting: boolean;
  48365. /**
  48366. * Number of Simultaneous lights allowed on the material.
  48367. */
  48368. protected _maxSimultaneousLights: number;
  48369. /**
  48370. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48371. */
  48372. protected _invertNormalMapX: boolean;
  48373. /**
  48374. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48375. */
  48376. protected _invertNormalMapY: boolean;
  48377. /**
  48378. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48379. */
  48380. protected _twoSidedLighting: boolean;
  48381. /**
  48382. * Defines the alpha limits in alpha test mode.
  48383. */
  48384. protected _alphaCutOff: number;
  48385. /**
  48386. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48387. */
  48388. protected _forceAlphaTest: boolean;
  48389. /**
  48390. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48391. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48392. */
  48393. protected _useAlphaFresnel: boolean;
  48394. /**
  48395. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48396. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48397. */
  48398. protected _useLinearAlphaFresnel: boolean;
  48399. /**
  48400. * The transparency mode of the material.
  48401. */
  48402. protected _transparencyMode: Nullable<number>;
  48403. /**
  48404. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  48405. * from cos thetav and roughness:
  48406. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  48407. */
  48408. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  48409. /**
  48410. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48411. */
  48412. protected _forceIrradianceInFragment: boolean;
  48413. /**
  48414. * Force normal to face away from face.
  48415. */
  48416. protected _forceNormalForward: boolean;
  48417. /**
  48418. * Enables specular anti aliasing in the PBR shader.
  48419. * It will both interacts on the Geometry for analytical and IBL lighting.
  48420. * It also prefilter the roughness map based on the bump values.
  48421. */
  48422. protected _enableSpecularAntiAliasing: boolean;
  48423. /**
  48424. * Default configuration related to image processing available in the PBR Material.
  48425. */
  48426. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48427. /**
  48428. * Keep track of the image processing observer to allow dispose and replace.
  48429. */
  48430. private _imageProcessingObserver;
  48431. /**
  48432. * Attaches a new image processing configuration to the PBR Material.
  48433. * @param configuration
  48434. */
  48435. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48436. /**
  48437. * Stores the available render targets.
  48438. */
  48439. private _renderTargets;
  48440. /**
  48441. * Sets the global ambient color for the material used in lighting calculations.
  48442. */
  48443. private _globalAmbientColor;
  48444. /**
  48445. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  48446. */
  48447. private _useLogarithmicDepth;
  48448. /**
  48449. * If set to true, no lighting calculations will be applied.
  48450. */
  48451. private _unlit;
  48452. private _debugMode;
  48453. /**
  48454. * @hidden
  48455. * This is reserved for the inspector.
  48456. * Defines the material debug mode.
  48457. * It helps seeing only some components of the material while troubleshooting.
  48458. */
  48459. debugMode: number;
  48460. /**
  48461. * @hidden
  48462. * This is reserved for the inspector.
  48463. * Specify from where on screen the debug mode should start.
  48464. * The value goes from -1 (full screen) to 1 (not visible)
  48465. * It helps with side by side comparison against the final render
  48466. * This defaults to -1
  48467. */
  48468. private debugLimit;
  48469. /**
  48470. * @hidden
  48471. * This is reserved for the inspector.
  48472. * As the default viewing range might not be enough (if the ambient is really small for instance)
  48473. * You can use the factor to better multiply the final value.
  48474. */
  48475. private debugFactor;
  48476. /**
  48477. * Defines the clear coat layer parameters for the material.
  48478. */
  48479. readonly clearCoat: PBRClearCoatConfiguration;
  48480. /**
  48481. * Defines the anisotropic parameters for the material.
  48482. */
  48483. readonly anisotropy: PBRAnisotropicConfiguration;
  48484. /**
  48485. * Defines the BRDF parameters for the material.
  48486. */
  48487. readonly brdf: PBRBRDFConfiguration;
  48488. /**
  48489. * Defines the Sheen parameters for the material.
  48490. */
  48491. readonly sheen: PBRSheenConfiguration;
  48492. /**
  48493. * Defines the SubSurface parameters for the material.
  48494. */
  48495. readonly subSurface: PBRSubSurfaceConfiguration;
  48496. /**
  48497. * Custom callback helping to override the default shader used in the material.
  48498. */
  48499. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48500. /**
  48501. * Instantiates a new PBRMaterial instance.
  48502. *
  48503. * @param name The material name
  48504. * @param scene The scene the material will be use in.
  48505. */
  48506. constructor(name: string, scene: Scene);
  48507. /**
  48508. * Gets a boolean indicating that current material needs to register RTT
  48509. */
  48510. readonly hasRenderTargetTextures: boolean;
  48511. /**
  48512. * Gets the name of the material class.
  48513. */
  48514. getClassName(): string;
  48515. /**
  48516. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48517. */
  48518. /**
  48519. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48520. */
  48521. useLogarithmicDepth: boolean;
  48522. /**
  48523. * Gets the current transparency mode.
  48524. */
  48525. /**
  48526. * Sets the transparency mode of the material.
  48527. *
  48528. * | Value | Type | Description |
  48529. * | ----- | ----------------------------------- | ----------- |
  48530. * | 0 | OPAQUE | |
  48531. * | 1 | ALPHATEST | |
  48532. * | 2 | ALPHABLEND | |
  48533. * | 3 | ALPHATESTANDBLEND | |
  48534. *
  48535. */
  48536. transparencyMode: Nullable<number>;
  48537. /**
  48538. * Returns true if alpha blending should be disabled.
  48539. */
  48540. private readonly _disableAlphaBlending;
  48541. /**
  48542. * Specifies whether or not this material should be rendered in alpha blend mode.
  48543. */
  48544. needAlphaBlending(): boolean;
  48545. /**
  48546. * Specifies if the mesh will require alpha blending.
  48547. * @param mesh - BJS mesh.
  48548. */
  48549. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48550. /**
  48551. * Specifies whether or not this material should be rendered in alpha test mode.
  48552. */
  48553. needAlphaTesting(): boolean;
  48554. /**
  48555. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48556. */
  48557. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48558. /**
  48559. * Gets the texture used for the alpha test.
  48560. */
  48561. getAlphaTestTexture(): Nullable<BaseTexture>;
  48562. /**
  48563. * Specifies that the submesh is ready to be used.
  48564. * @param mesh - BJS mesh.
  48565. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48566. * @param useInstances - Specifies that instances should be used.
  48567. * @returns - boolean indicating that the submesh is ready or not.
  48568. */
  48569. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48570. /**
  48571. * Specifies if the material uses metallic roughness workflow.
  48572. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48573. */
  48574. isMetallicWorkflow(): boolean;
  48575. private _prepareEffect;
  48576. private _prepareDefines;
  48577. /**
  48578. * Force shader compilation
  48579. */
  48580. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  48581. clipPlane: boolean;
  48582. }>): void;
  48583. /**
  48584. * Initializes the uniform buffer layout for the shader.
  48585. */
  48586. buildUniformLayout(): void;
  48587. /**
  48588. * Unbinds the material from the mesh
  48589. */
  48590. unbind(): void;
  48591. /**
  48592. * Binds the submesh data.
  48593. * @param world - The world matrix.
  48594. * @param mesh - The BJS mesh.
  48595. * @param subMesh - A submesh of the BJS mesh.
  48596. */
  48597. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48598. /**
  48599. * Returns the animatable textures.
  48600. * @returns - Array of animatable textures.
  48601. */
  48602. getAnimatables(): IAnimatable[];
  48603. /**
  48604. * Returns the texture used for reflections.
  48605. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48606. */
  48607. private _getReflectionTexture;
  48608. /**
  48609. * Returns an array of the actively used textures.
  48610. * @returns - Array of BaseTextures
  48611. */
  48612. getActiveTextures(): BaseTexture[];
  48613. /**
  48614. * Checks to see if a texture is used in the material.
  48615. * @param texture - Base texture to use.
  48616. * @returns - Boolean specifying if a texture is used in the material.
  48617. */
  48618. hasTexture(texture: BaseTexture): boolean;
  48619. /**
  48620. * Disposes the resources of the material.
  48621. * @param forceDisposeEffect - Forces the disposal of effects.
  48622. * @param forceDisposeTextures - Forces the disposal of all textures.
  48623. */
  48624. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48625. }
  48626. }
  48627. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  48628. import { Nullable } from "babylonjs/types";
  48629. import { Scene } from "babylonjs/scene";
  48630. import { Color3 } from "babylonjs/Maths/math.color";
  48631. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48632. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48633. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48634. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48635. /**
  48636. * The Physically based material of BJS.
  48637. *
  48638. * This offers the main features of a standard PBR material.
  48639. * For more information, please refer to the documentation :
  48640. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48641. */
  48642. export class PBRMaterial extends PBRBaseMaterial {
  48643. /**
  48644. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48645. */
  48646. static readonly PBRMATERIAL_OPAQUE: number;
  48647. /**
  48648. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48649. */
  48650. static readonly PBRMATERIAL_ALPHATEST: number;
  48651. /**
  48652. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48653. */
  48654. static readonly PBRMATERIAL_ALPHABLEND: number;
  48655. /**
  48656. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48657. * They are also discarded below the alpha cutoff threshold to improve performances.
  48658. */
  48659. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48660. /**
  48661. * Defines the default value of how much AO map is occluding the analytical lights
  48662. * (point spot...).
  48663. */
  48664. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48665. /**
  48666. * Intensity of the direct lights e.g. the four lights available in your scene.
  48667. * This impacts both the direct diffuse and specular highlights.
  48668. */
  48669. directIntensity: number;
  48670. /**
  48671. * Intensity of the emissive part of the material.
  48672. * This helps controlling the emissive effect without modifying the emissive color.
  48673. */
  48674. emissiveIntensity: number;
  48675. /**
  48676. * Intensity of the environment e.g. how much the environment will light the object
  48677. * either through harmonics for rough material or through the refelction for shiny ones.
  48678. */
  48679. environmentIntensity: number;
  48680. /**
  48681. * This is a special control allowing the reduction of the specular highlights coming from the
  48682. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48683. */
  48684. specularIntensity: number;
  48685. /**
  48686. * Debug Control allowing disabling the bump map on this material.
  48687. */
  48688. disableBumpMap: boolean;
  48689. /**
  48690. * AKA Diffuse Texture in standard nomenclature.
  48691. */
  48692. albedoTexture: BaseTexture;
  48693. /**
  48694. * AKA Occlusion Texture in other nomenclature.
  48695. */
  48696. ambientTexture: BaseTexture;
  48697. /**
  48698. * AKA Occlusion Texture Intensity in other nomenclature.
  48699. */
  48700. ambientTextureStrength: number;
  48701. /**
  48702. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48703. * 1 means it completely occludes it
  48704. * 0 mean it has no impact
  48705. */
  48706. ambientTextureImpactOnAnalyticalLights: number;
  48707. /**
  48708. * Stores the alpha values in a texture.
  48709. */
  48710. opacityTexture: BaseTexture;
  48711. /**
  48712. * Stores the reflection values in a texture.
  48713. */
  48714. reflectionTexture: Nullable<BaseTexture>;
  48715. /**
  48716. * Stores the emissive values in a texture.
  48717. */
  48718. emissiveTexture: BaseTexture;
  48719. /**
  48720. * AKA Specular texture in other nomenclature.
  48721. */
  48722. reflectivityTexture: BaseTexture;
  48723. /**
  48724. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48725. */
  48726. metallicTexture: BaseTexture;
  48727. /**
  48728. * Specifies the metallic scalar of the metallic/roughness workflow.
  48729. * Can also be used to scale the metalness values of the metallic texture.
  48730. */
  48731. metallic: Nullable<number>;
  48732. /**
  48733. * Specifies the roughness scalar of the metallic/roughness workflow.
  48734. * Can also be used to scale the roughness values of the metallic texture.
  48735. */
  48736. roughness: Nullable<number>;
  48737. /**
  48738. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48739. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48740. */
  48741. microSurfaceTexture: BaseTexture;
  48742. /**
  48743. * Stores surface normal data used to displace a mesh in a texture.
  48744. */
  48745. bumpTexture: BaseTexture;
  48746. /**
  48747. * Stores the pre-calculated light information of a mesh in a texture.
  48748. */
  48749. lightmapTexture: BaseTexture;
  48750. /**
  48751. * Stores the refracted light information in a texture.
  48752. */
  48753. refractionTexture: Nullable<BaseTexture>;
  48754. /**
  48755. * The color of a material in ambient lighting.
  48756. */
  48757. ambientColor: Color3;
  48758. /**
  48759. * AKA Diffuse Color in other nomenclature.
  48760. */
  48761. albedoColor: Color3;
  48762. /**
  48763. * AKA Specular Color in other nomenclature.
  48764. */
  48765. reflectivityColor: Color3;
  48766. /**
  48767. * The color reflected from the material.
  48768. */
  48769. reflectionColor: Color3;
  48770. /**
  48771. * The color emitted from the material.
  48772. */
  48773. emissiveColor: Color3;
  48774. /**
  48775. * AKA Glossiness in other nomenclature.
  48776. */
  48777. microSurface: number;
  48778. /**
  48779. * source material index of refraction (IOR)' / 'destination material IOR.
  48780. */
  48781. indexOfRefraction: number;
  48782. /**
  48783. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48784. */
  48785. invertRefractionY: boolean;
  48786. /**
  48787. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48788. * Materials half opaque for instance using refraction could benefit from this control.
  48789. */
  48790. linkRefractionWithTransparency: boolean;
  48791. /**
  48792. * If true, the light map contains occlusion information instead of lighting info.
  48793. */
  48794. useLightmapAsShadowmap: boolean;
  48795. /**
  48796. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48797. */
  48798. useAlphaFromAlbedoTexture: boolean;
  48799. /**
  48800. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48801. */
  48802. forceAlphaTest: boolean;
  48803. /**
  48804. * Defines the alpha limits in alpha test mode.
  48805. */
  48806. alphaCutOff: number;
  48807. /**
  48808. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48809. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48810. */
  48811. useSpecularOverAlpha: boolean;
  48812. /**
  48813. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48814. */
  48815. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48816. /**
  48817. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48818. */
  48819. useRoughnessFromMetallicTextureAlpha: boolean;
  48820. /**
  48821. * Specifies if the metallic texture contains the roughness information in its green channel.
  48822. */
  48823. useRoughnessFromMetallicTextureGreen: boolean;
  48824. /**
  48825. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48826. */
  48827. useMetallnessFromMetallicTextureBlue: boolean;
  48828. /**
  48829. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48830. */
  48831. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48832. /**
  48833. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48834. */
  48835. useAmbientInGrayScale: boolean;
  48836. /**
  48837. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48838. * The material will try to infer what glossiness each pixel should be.
  48839. */
  48840. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48841. /**
  48842. * BJS is using an harcoded light falloff based on a manually sets up range.
  48843. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48844. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48845. */
  48846. /**
  48847. * BJS is using an harcoded light falloff based on a manually sets up range.
  48848. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48849. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48850. */
  48851. usePhysicalLightFalloff: boolean;
  48852. /**
  48853. * In order to support the falloff compatibility with gltf, a special mode has been added
  48854. * to reproduce the gltf light falloff.
  48855. */
  48856. /**
  48857. * In order to support the falloff compatibility with gltf, a special mode has been added
  48858. * to reproduce the gltf light falloff.
  48859. */
  48860. useGLTFLightFalloff: boolean;
  48861. /**
  48862. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48863. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48864. */
  48865. useRadianceOverAlpha: boolean;
  48866. /**
  48867. * Allows using an object space normal map (instead of tangent space).
  48868. */
  48869. useObjectSpaceNormalMap: boolean;
  48870. /**
  48871. * Allows using the bump map in parallax mode.
  48872. */
  48873. useParallax: boolean;
  48874. /**
  48875. * Allows using the bump map in parallax occlusion mode.
  48876. */
  48877. useParallaxOcclusion: boolean;
  48878. /**
  48879. * Controls the scale bias of the parallax mode.
  48880. */
  48881. parallaxScaleBias: number;
  48882. /**
  48883. * If sets to true, disables all the lights affecting the material.
  48884. */
  48885. disableLighting: boolean;
  48886. /**
  48887. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48888. */
  48889. forceIrradianceInFragment: boolean;
  48890. /**
  48891. * Number of Simultaneous lights allowed on the material.
  48892. */
  48893. maxSimultaneousLights: number;
  48894. /**
  48895. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48896. */
  48897. invertNormalMapX: boolean;
  48898. /**
  48899. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48900. */
  48901. invertNormalMapY: boolean;
  48902. /**
  48903. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48904. */
  48905. twoSidedLighting: boolean;
  48906. /**
  48907. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48908. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48909. */
  48910. useAlphaFresnel: boolean;
  48911. /**
  48912. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48913. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48914. */
  48915. useLinearAlphaFresnel: boolean;
  48916. /**
  48917. * Let user defines the brdf lookup texture used for IBL.
  48918. * A default 8bit version is embedded but you could point at :
  48919. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48920. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48921. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48922. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48923. */
  48924. environmentBRDFTexture: Nullable<BaseTexture>;
  48925. /**
  48926. * Force normal to face away from face.
  48927. */
  48928. forceNormalForward: boolean;
  48929. /**
  48930. * Enables specular anti aliasing in the PBR shader.
  48931. * It will both interacts on the Geometry for analytical and IBL lighting.
  48932. * It also prefilter the roughness map based on the bump values.
  48933. */
  48934. enableSpecularAntiAliasing: boolean;
  48935. /**
  48936. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48937. * makes the reflect vector face the model (under horizon).
  48938. */
  48939. useHorizonOcclusion: boolean;
  48940. /**
  48941. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48942. * too much the area relying on ambient texture to define their ambient occlusion.
  48943. */
  48944. useRadianceOcclusion: boolean;
  48945. /**
  48946. * If set to true, no lighting calculations will be applied.
  48947. */
  48948. unlit: boolean;
  48949. /**
  48950. * Gets the image processing configuration used either in this material.
  48951. */
  48952. /**
  48953. * Sets the Default image processing configuration used either in the this material.
  48954. *
  48955. * If sets to null, the scene one is in use.
  48956. */
  48957. imageProcessingConfiguration: ImageProcessingConfiguration;
  48958. /**
  48959. * Gets wether the color curves effect is enabled.
  48960. */
  48961. /**
  48962. * Sets wether the color curves effect is enabled.
  48963. */
  48964. cameraColorCurvesEnabled: boolean;
  48965. /**
  48966. * Gets wether the color grading effect is enabled.
  48967. */
  48968. /**
  48969. * Gets wether the color grading effect is enabled.
  48970. */
  48971. cameraColorGradingEnabled: boolean;
  48972. /**
  48973. * Gets wether tonemapping is enabled or not.
  48974. */
  48975. /**
  48976. * Sets wether tonemapping is enabled or not
  48977. */
  48978. cameraToneMappingEnabled: boolean;
  48979. /**
  48980. * The camera exposure used on this material.
  48981. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48982. * This corresponds to a photographic exposure.
  48983. */
  48984. /**
  48985. * The camera exposure used on this material.
  48986. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48987. * This corresponds to a photographic exposure.
  48988. */
  48989. cameraExposure: number;
  48990. /**
  48991. * Gets The camera contrast used on this material.
  48992. */
  48993. /**
  48994. * Sets The camera contrast used on this material.
  48995. */
  48996. cameraContrast: number;
  48997. /**
  48998. * Gets the Color Grading 2D Lookup Texture.
  48999. */
  49000. /**
  49001. * Sets the Color Grading 2D Lookup Texture.
  49002. */
  49003. cameraColorGradingTexture: Nullable<BaseTexture>;
  49004. /**
  49005. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49006. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49007. * 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;
  49008. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49009. */
  49010. /**
  49011. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49012. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49013. * 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;
  49014. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49015. */
  49016. cameraColorCurves: Nullable<ColorCurves>;
  49017. /**
  49018. * Instantiates a new PBRMaterial instance.
  49019. *
  49020. * @param name The material name
  49021. * @param scene The scene the material will be use in.
  49022. */
  49023. constructor(name: string, scene: Scene);
  49024. /**
  49025. * Returns the name of this material class.
  49026. */
  49027. getClassName(): string;
  49028. /**
  49029. * Makes a duplicate of the current material.
  49030. * @param name - name to use for the new material.
  49031. */
  49032. clone(name: string): PBRMaterial;
  49033. /**
  49034. * Serializes this PBR Material.
  49035. * @returns - An object with the serialized material.
  49036. */
  49037. serialize(): any;
  49038. /**
  49039. * Parses a PBR Material from a serialized object.
  49040. * @param source - Serialized object.
  49041. * @param scene - BJS scene instance.
  49042. * @param rootUrl - url for the scene object
  49043. * @returns - PBRMaterial
  49044. */
  49045. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49046. }
  49047. }
  49048. declare module "babylonjs/Misc/dds" {
  49049. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49050. import { Engine } from "babylonjs/Engines/engine";
  49051. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49052. import { Nullable } from "babylonjs/types";
  49053. import { Scene } from "babylonjs/scene";
  49054. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  49055. /**
  49056. * Direct draw surface info
  49057. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  49058. */
  49059. export interface DDSInfo {
  49060. /**
  49061. * Width of the texture
  49062. */
  49063. width: number;
  49064. /**
  49065. * Width of the texture
  49066. */
  49067. height: number;
  49068. /**
  49069. * Number of Mipmaps for the texture
  49070. * @see https://en.wikipedia.org/wiki/Mipmap
  49071. */
  49072. mipmapCount: number;
  49073. /**
  49074. * If the textures format is a known fourCC format
  49075. * @see https://www.fourcc.org/
  49076. */
  49077. isFourCC: boolean;
  49078. /**
  49079. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  49080. */
  49081. isRGB: boolean;
  49082. /**
  49083. * If the texture is a lumincance format
  49084. */
  49085. isLuminance: boolean;
  49086. /**
  49087. * If this is a cube texture
  49088. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  49089. */
  49090. isCube: boolean;
  49091. /**
  49092. * If the texture is a compressed format eg. FOURCC_DXT1
  49093. */
  49094. isCompressed: boolean;
  49095. /**
  49096. * The dxgiFormat of the texture
  49097. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  49098. */
  49099. dxgiFormat: number;
  49100. /**
  49101. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  49102. */
  49103. textureType: number;
  49104. /**
  49105. * Sphericle polynomial created for the dds texture
  49106. */
  49107. sphericalPolynomial?: SphericalPolynomial;
  49108. }
  49109. /**
  49110. * Class used to provide DDS decompression tools
  49111. */
  49112. export class DDSTools {
  49113. /**
  49114. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  49115. */
  49116. static StoreLODInAlphaChannel: boolean;
  49117. /**
  49118. * Gets DDS information from an array buffer
  49119. * @param arrayBuffer defines the array buffer to read data from
  49120. * @returns the DDS information
  49121. */
  49122. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  49123. private static _FloatView;
  49124. private static _Int32View;
  49125. private static _ToHalfFloat;
  49126. private static _FromHalfFloat;
  49127. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  49128. private static _GetHalfFloatRGBAArrayBuffer;
  49129. private static _GetFloatRGBAArrayBuffer;
  49130. private static _GetFloatAsUIntRGBAArrayBuffer;
  49131. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  49132. private static _GetRGBAArrayBuffer;
  49133. private static _ExtractLongWordOrder;
  49134. private static _GetRGBArrayBuffer;
  49135. private static _GetLuminanceArrayBuffer;
  49136. /**
  49137. * Uploads DDS Levels to a Babylon Texture
  49138. * @hidden
  49139. */
  49140. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  49141. }
  49142. module "babylonjs/Engines/engine" {
  49143. interface Engine {
  49144. /**
  49145. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  49146. * @param rootUrl defines the url where the file to load is located
  49147. * @param scene defines the current scene
  49148. * @param lodScale defines scale to apply to the mip map selection
  49149. * @param lodOffset defines offset to apply to the mip map selection
  49150. * @param onLoad defines an optional callback raised when the texture is loaded
  49151. * @param onError defines an optional callback raised if there is an issue to load the texture
  49152. * @param format defines the format of the data
  49153. * @param forcedExtension defines the extension to use to pick the right loader
  49154. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  49155. * @returns the cube texture as an InternalTexture
  49156. */
  49157. 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;
  49158. }
  49159. }
  49160. }
  49161. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  49162. import { Nullable } from "babylonjs/types";
  49163. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49164. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49165. /**
  49166. * Implementation of the DDS Texture Loader.
  49167. * @hidden
  49168. */
  49169. export class _DDSTextureLoader implements IInternalTextureLoader {
  49170. /**
  49171. * Defines wether the loader supports cascade loading the different faces.
  49172. */
  49173. readonly supportCascades: boolean;
  49174. /**
  49175. * This returns if the loader support the current file information.
  49176. * @param extension defines the file extension of the file being loaded
  49177. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49178. * @param fallback defines the fallback internal texture if any
  49179. * @param isBase64 defines whether the texture is encoded as a base64
  49180. * @param isBuffer defines whether the texture data are stored as a buffer
  49181. * @returns true if the loader can load the specified file
  49182. */
  49183. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49184. /**
  49185. * Transform the url before loading if required.
  49186. * @param rootUrl the url of the texture
  49187. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49188. * @returns the transformed texture
  49189. */
  49190. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49191. /**
  49192. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49193. * @param rootUrl the url of the texture
  49194. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49195. * @returns the fallback texture
  49196. */
  49197. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49198. /**
  49199. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49200. * @param data contains the texture data
  49201. * @param texture defines the BabylonJS internal texture
  49202. * @param createPolynomials will be true if polynomials have been requested
  49203. * @param onLoad defines the callback to trigger once the texture is ready
  49204. * @param onError defines the callback to trigger in case of error
  49205. */
  49206. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49207. /**
  49208. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49209. * @param data contains the texture data
  49210. * @param texture defines the BabylonJS internal texture
  49211. * @param callback defines the method to call once ready to upload
  49212. */
  49213. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49214. }
  49215. }
  49216. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49217. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49218. /** @hidden */
  49219. export var rgbdEncodePixelShader: {
  49220. name: string;
  49221. shader: string;
  49222. };
  49223. }
  49224. declare module "babylonjs/Misc/environmentTextureTools" {
  49225. import { Nullable } from "babylonjs/types";
  49226. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49227. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49228. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49229. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49230. import "babylonjs/Shaders/rgbdEncode.fragment";
  49231. import "babylonjs/Shaders/rgbdDecode.fragment";
  49232. /**
  49233. * Raw texture data and descriptor sufficient for WebGL texture upload
  49234. */
  49235. export interface EnvironmentTextureInfo {
  49236. /**
  49237. * Version of the environment map
  49238. */
  49239. version: number;
  49240. /**
  49241. * Width of image
  49242. */
  49243. width: number;
  49244. /**
  49245. * Irradiance information stored in the file.
  49246. */
  49247. irradiance: any;
  49248. /**
  49249. * Specular information stored in the file.
  49250. */
  49251. specular: any;
  49252. }
  49253. /**
  49254. * Sets of helpers addressing the serialization and deserialization of environment texture
  49255. * stored in a BabylonJS env file.
  49256. * Those files are usually stored as .env files.
  49257. */
  49258. export class EnvironmentTextureTools {
  49259. /**
  49260. * Magic number identifying the env file.
  49261. */
  49262. private static _MagicBytes;
  49263. /**
  49264. * Gets the environment info from an env file.
  49265. * @param data The array buffer containing the .env bytes.
  49266. * @returns the environment file info (the json header) if successfully parsed.
  49267. */
  49268. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  49269. /**
  49270. * Creates an environment texture from a loaded cube texture.
  49271. * @param texture defines the cube texture to convert in env file
  49272. * @return a promise containing the environment data if succesfull.
  49273. */
  49274. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49275. /**
  49276. * Creates a JSON representation of the spherical data.
  49277. * @param texture defines the texture containing the polynomials
  49278. * @return the JSON representation of the spherical info
  49279. */
  49280. private static _CreateEnvTextureIrradiance;
  49281. /**
  49282. * Uploads the texture info contained in the env file to the GPU.
  49283. * @param texture defines the internal texture to upload to
  49284. * @param arrayBuffer defines the buffer cotaining the data to load
  49285. * @param info defines the texture info retrieved through the GetEnvInfo method
  49286. * @returns a promise
  49287. */
  49288. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  49289. /**
  49290. * Uploads the levels of image data to the GPU.
  49291. * @param texture defines the internal texture to upload to
  49292. * @param imageData defines the array buffer views of image data [mipmap][face]
  49293. * @returns a promise
  49294. */
  49295. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49296. /**
  49297. * Uploads spherical polynomials information to the texture.
  49298. * @param texture defines the texture we are trying to upload the information to
  49299. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49300. */
  49301. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49302. /** @hidden */
  49303. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49304. }
  49305. }
  49306. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  49307. import { Nullable } from "babylonjs/types";
  49308. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49309. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49310. /**
  49311. * Implementation of the ENV Texture Loader.
  49312. * @hidden
  49313. */
  49314. export class _ENVTextureLoader implements IInternalTextureLoader {
  49315. /**
  49316. * Defines wether the loader supports cascade loading the different faces.
  49317. */
  49318. readonly supportCascades: boolean;
  49319. /**
  49320. * This returns if the loader support the current file information.
  49321. * @param extension defines the file extension of the file being loaded
  49322. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49323. * @param fallback defines the fallback internal texture if any
  49324. * @param isBase64 defines whether the texture is encoded as a base64
  49325. * @param isBuffer defines whether the texture data are stored as a buffer
  49326. * @returns true if the loader can load the specified file
  49327. */
  49328. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49329. /**
  49330. * Transform the url before loading if required.
  49331. * @param rootUrl the url of the texture
  49332. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49333. * @returns the transformed texture
  49334. */
  49335. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49336. /**
  49337. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49338. * @param rootUrl the url of the texture
  49339. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49340. * @returns the fallback texture
  49341. */
  49342. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49343. /**
  49344. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49345. * @param data contains the texture data
  49346. * @param texture defines the BabylonJS internal texture
  49347. * @param createPolynomials will be true if polynomials have been requested
  49348. * @param onLoad defines the callback to trigger once the texture is ready
  49349. * @param onError defines the callback to trigger in case of error
  49350. */
  49351. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49352. /**
  49353. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49354. * @param data contains the texture data
  49355. * @param texture defines the BabylonJS internal texture
  49356. * @param callback defines the method to call once ready to upload
  49357. */
  49358. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49359. }
  49360. }
  49361. declare module "babylonjs/Misc/khronosTextureContainer" {
  49362. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49363. /**
  49364. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49365. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49366. */
  49367. export class KhronosTextureContainer {
  49368. /** contents of the KTX container file */
  49369. arrayBuffer: any;
  49370. private static HEADER_LEN;
  49371. private static COMPRESSED_2D;
  49372. private static COMPRESSED_3D;
  49373. private static TEX_2D;
  49374. private static TEX_3D;
  49375. /**
  49376. * Gets the openGL type
  49377. */
  49378. glType: number;
  49379. /**
  49380. * Gets the openGL type size
  49381. */
  49382. glTypeSize: number;
  49383. /**
  49384. * Gets the openGL format
  49385. */
  49386. glFormat: number;
  49387. /**
  49388. * Gets the openGL internal format
  49389. */
  49390. glInternalFormat: number;
  49391. /**
  49392. * Gets the base internal format
  49393. */
  49394. glBaseInternalFormat: number;
  49395. /**
  49396. * Gets image width in pixel
  49397. */
  49398. pixelWidth: number;
  49399. /**
  49400. * Gets image height in pixel
  49401. */
  49402. pixelHeight: number;
  49403. /**
  49404. * Gets image depth in pixels
  49405. */
  49406. pixelDepth: number;
  49407. /**
  49408. * Gets the number of array elements
  49409. */
  49410. numberOfArrayElements: number;
  49411. /**
  49412. * Gets the number of faces
  49413. */
  49414. numberOfFaces: number;
  49415. /**
  49416. * Gets the number of mipmap levels
  49417. */
  49418. numberOfMipmapLevels: number;
  49419. /**
  49420. * Gets the bytes of key value data
  49421. */
  49422. bytesOfKeyValueData: number;
  49423. /**
  49424. * Gets the load type
  49425. */
  49426. loadType: number;
  49427. /**
  49428. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  49429. */
  49430. isInvalid: boolean;
  49431. /**
  49432. * Creates a new KhronosTextureContainer
  49433. * @param arrayBuffer contents of the KTX container file
  49434. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  49435. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  49436. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  49437. */
  49438. constructor(
  49439. /** contents of the KTX container file */
  49440. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  49441. /**
  49442. * Uploads KTX content to a Babylon Texture.
  49443. * It is assumed that the texture has already been created & is currently bound
  49444. * @hidden
  49445. */
  49446. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  49447. private _upload2DCompressedLevels;
  49448. }
  49449. }
  49450. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  49451. import { Nullable } from "babylonjs/types";
  49452. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49453. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49454. /**
  49455. * Implementation of the KTX Texture Loader.
  49456. * @hidden
  49457. */
  49458. export class _KTXTextureLoader implements IInternalTextureLoader {
  49459. /**
  49460. * Defines wether the loader supports cascade loading the different faces.
  49461. */
  49462. readonly supportCascades: boolean;
  49463. /**
  49464. * This returns if the loader support the current file information.
  49465. * @param extension defines the file extension of the file being loaded
  49466. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49467. * @param fallback defines the fallback internal texture if any
  49468. * @param isBase64 defines whether the texture is encoded as a base64
  49469. * @param isBuffer defines whether the texture data are stored as a buffer
  49470. * @returns true if the loader can load the specified file
  49471. */
  49472. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49473. /**
  49474. * Transform the url before loading if required.
  49475. * @param rootUrl the url of the texture
  49476. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49477. * @returns the transformed texture
  49478. */
  49479. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49480. /**
  49481. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49482. * @param rootUrl the url of the texture
  49483. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49484. * @returns the fallback texture
  49485. */
  49486. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49487. /**
  49488. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49489. * @param data contains the texture data
  49490. * @param texture defines the BabylonJS internal texture
  49491. * @param createPolynomials will be true if polynomials have been requested
  49492. * @param onLoad defines the callback to trigger once the texture is ready
  49493. * @param onError defines the callback to trigger in case of error
  49494. */
  49495. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49496. /**
  49497. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49498. * @param data contains the texture data
  49499. * @param texture defines the BabylonJS internal texture
  49500. * @param callback defines the method to call once ready to upload
  49501. */
  49502. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49503. }
  49504. }
  49505. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  49506. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  49507. import { Scene } from "babylonjs/scene";
  49508. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  49509. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  49510. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  49511. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  49512. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  49513. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  49514. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49515. /**
  49516. * Options for the default xr helper
  49517. */
  49518. export class WebXRDefaultExperienceOptions {
  49519. /**
  49520. * Floor meshes that should be used for teleporting
  49521. */
  49522. floorMeshes: Array<AbstractMesh>;
  49523. }
  49524. /**
  49525. * Default experience which provides a similar setup to the previous webVRExperience
  49526. */
  49527. export class WebXRDefaultExperience {
  49528. /**
  49529. * Base experience
  49530. */
  49531. baseExperience: WebXRExperienceHelper;
  49532. /**
  49533. * Input experience extension
  49534. */
  49535. input: WebXRInput;
  49536. /**
  49537. * Loads the controller models
  49538. */
  49539. controllerModelLoader: WebXRControllerModelLoader;
  49540. /**
  49541. * Enables laser pointer and selection
  49542. */
  49543. pointerSelection: WebXRControllerPointerSelection;
  49544. /**
  49545. * Enables teleportation
  49546. */
  49547. teleportation: WebXRControllerTeleportation;
  49548. /**
  49549. * Enables ui for enetering/exiting xr
  49550. */
  49551. enterExitUI: WebXREnterExitUI;
  49552. /**
  49553. * Default output canvas xr should render to
  49554. */
  49555. outputCanvas: WebXRManagedOutputCanvas;
  49556. /**
  49557. * Creates the default xr experience
  49558. * @param scene scene
  49559. * @param options options for basic configuration
  49560. * @returns resulting WebXRDefaultExperience
  49561. */
  49562. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49563. private constructor();
  49564. /**
  49565. * DIsposes of the experience helper
  49566. */
  49567. dispose(): void;
  49568. }
  49569. }
  49570. declare module "babylonjs/Helpers/sceneHelpers" {
  49571. import { Nullable } from "babylonjs/types";
  49572. import { Mesh } from "babylonjs/Meshes/mesh";
  49573. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49574. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  49575. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  49576. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49577. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49578. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49579. import "babylonjs/Meshes/Builders/boxBuilder";
  49580. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  49581. /** @hidden */
  49582. export var _forceSceneHelpersToBundle: boolean;
  49583. module "babylonjs/scene" {
  49584. interface Scene {
  49585. /**
  49586. * Creates a default light for the scene.
  49587. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  49588. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  49589. */
  49590. createDefaultLight(replace?: boolean): void;
  49591. /**
  49592. * Creates a default camera for the scene.
  49593. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49594. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49595. * @param replace has default false, when true replaces the active camera in the scene
  49596. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49597. */
  49598. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49599. /**
  49600. * Creates a default camera and a default light.
  49601. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49602. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49603. * @param replace has the default false, when true replaces the active camera/light in the scene
  49604. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49605. */
  49606. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49607. /**
  49608. * Creates a new sky box
  49609. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49610. * @param environmentTexture defines the texture to use as environment texture
  49611. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49612. * @param scale defines the overall scale of the skybox
  49613. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49614. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49615. * @returns a new mesh holding the sky box
  49616. */
  49617. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49618. /**
  49619. * Creates a new environment
  49620. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49621. * @param options defines the options you can use to configure the environment
  49622. * @returns the new EnvironmentHelper
  49623. */
  49624. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49625. /**
  49626. * Creates a new VREXperienceHelper
  49627. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49628. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49629. * @returns a new VREXperienceHelper
  49630. */
  49631. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49632. /**
  49633. * Creates a new WebXRDefaultExperience
  49634. * @see http://doc.babylonjs.com/how_to/webxr
  49635. * @param options experience options
  49636. * @returns a promise for a new WebXRDefaultExperience
  49637. */
  49638. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49639. }
  49640. }
  49641. }
  49642. declare module "babylonjs/Helpers/videoDome" {
  49643. import { Scene } from "babylonjs/scene";
  49644. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49645. import { Mesh } from "babylonjs/Meshes/mesh";
  49646. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  49647. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49648. import "babylonjs/Meshes/Builders/sphereBuilder";
  49649. /**
  49650. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  49651. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  49652. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  49653. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49654. */
  49655. export class VideoDome extends TransformNode {
  49656. /**
  49657. * Define the video source as a Monoscopic panoramic 360 video.
  49658. */
  49659. static readonly MODE_MONOSCOPIC: number;
  49660. /**
  49661. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49662. */
  49663. static readonly MODE_TOPBOTTOM: number;
  49664. /**
  49665. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49666. */
  49667. static readonly MODE_SIDEBYSIDE: number;
  49668. private _useDirectMapping;
  49669. /**
  49670. * The video texture being displayed on the sphere
  49671. */
  49672. protected _videoTexture: VideoTexture;
  49673. /**
  49674. * Gets the video texture being displayed on the sphere
  49675. */
  49676. readonly videoTexture: VideoTexture;
  49677. /**
  49678. * The skybox material
  49679. */
  49680. protected _material: BackgroundMaterial;
  49681. /**
  49682. * The surface used for the skybox
  49683. */
  49684. protected _mesh: Mesh;
  49685. /**
  49686. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49687. * Also see the options.resolution property.
  49688. */
  49689. fovMultiplier: number;
  49690. private _videoMode;
  49691. /**
  49692. * Gets or set the current video mode for the video. It can be:
  49693. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  49694. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49695. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49696. */
  49697. videoMode: number;
  49698. /**
  49699. * Oberserver used in Stereoscopic VR Mode.
  49700. */
  49701. private _onBeforeCameraRenderObserver;
  49702. /**
  49703. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  49704. * @param name Element's name, child elements will append suffixes for their own names.
  49705. * @param urlsOrVideo defines the url(s) or the video element to use
  49706. * @param options An object containing optional or exposed sub element properties
  49707. */
  49708. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  49709. resolution?: number;
  49710. clickToPlay?: boolean;
  49711. autoPlay?: boolean;
  49712. loop?: boolean;
  49713. size?: number;
  49714. poster?: string;
  49715. faceForward?: boolean;
  49716. useDirectMapping?: boolean;
  49717. }, scene: Scene);
  49718. private _changeVideoMode;
  49719. /**
  49720. * Releases resources associated with this node.
  49721. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49722. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49723. */
  49724. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49725. }
  49726. }
  49727. declare module "babylonjs/Helpers/index" {
  49728. export * from "babylonjs/Helpers/environmentHelper";
  49729. export * from "babylonjs/Helpers/photoDome";
  49730. export * from "babylonjs/Helpers/sceneHelpers";
  49731. export * from "babylonjs/Helpers/videoDome";
  49732. }
  49733. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  49734. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  49735. import { IDisposable } from "babylonjs/scene";
  49736. import { Engine } from "babylonjs/Engines/engine";
  49737. /**
  49738. * This class can be used to get instrumentation data from a Babylon engine
  49739. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49740. */
  49741. export class EngineInstrumentation implements IDisposable {
  49742. /**
  49743. * Define the instrumented engine.
  49744. */
  49745. engine: Engine;
  49746. private _captureGPUFrameTime;
  49747. private _gpuFrameTimeToken;
  49748. private _gpuFrameTime;
  49749. private _captureShaderCompilationTime;
  49750. private _shaderCompilationTime;
  49751. private _onBeginFrameObserver;
  49752. private _onEndFrameObserver;
  49753. private _onBeforeShaderCompilationObserver;
  49754. private _onAfterShaderCompilationObserver;
  49755. /**
  49756. * Gets the perf counter used for GPU frame time
  49757. */
  49758. readonly gpuFrameTimeCounter: PerfCounter;
  49759. /**
  49760. * Gets the GPU frame time capture status
  49761. */
  49762. /**
  49763. * Enable or disable the GPU frame time capture
  49764. */
  49765. captureGPUFrameTime: boolean;
  49766. /**
  49767. * Gets the perf counter used for shader compilation time
  49768. */
  49769. readonly shaderCompilationTimeCounter: PerfCounter;
  49770. /**
  49771. * Gets the shader compilation time capture status
  49772. */
  49773. /**
  49774. * Enable or disable the shader compilation time capture
  49775. */
  49776. captureShaderCompilationTime: boolean;
  49777. /**
  49778. * Instantiates a new engine instrumentation.
  49779. * This class can be used to get instrumentation data from a Babylon engine
  49780. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49781. * @param engine Defines the engine to instrument
  49782. */
  49783. constructor(
  49784. /**
  49785. * Define the instrumented engine.
  49786. */
  49787. engine: Engine);
  49788. /**
  49789. * Dispose and release associated resources.
  49790. */
  49791. dispose(): void;
  49792. }
  49793. }
  49794. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  49795. import { Scene, IDisposable } from "babylonjs/scene";
  49796. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  49797. /**
  49798. * This class can be used to get instrumentation data from a Babylon engine
  49799. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49800. */
  49801. export class SceneInstrumentation implements IDisposable {
  49802. /**
  49803. * Defines the scene to instrument
  49804. */
  49805. scene: Scene;
  49806. private _captureActiveMeshesEvaluationTime;
  49807. private _activeMeshesEvaluationTime;
  49808. private _captureRenderTargetsRenderTime;
  49809. private _renderTargetsRenderTime;
  49810. private _captureFrameTime;
  49811. private _frameTime;
  49812. private _captureRenderTime;
  49813. private _renderTime;
  49814. private _captureInterFrameTime;
  49815. private _interFrameTime;
  49816. private _captureParticlesRenderTime;
  49817. private _particlesRenderTime;
  49818. private _captureSpritesRenderTime;
  49819. private _spritesRenderTime;
  49820. private _capturePhysicsTime;
  49821. private _physicsTime;
  49822. private _captureAnimationsTime;
  49823. private _animationsTime;
  49824. private _captureCameraRenderTime;
  49825. private _cameraRenderTime;
  49826. private _onBeforeActiveMeshesEvaluationObserver;
  49827. private _onAfterActiveMeshesEvaluationObserver;
  49828. private _onBeforeRenderTargetsRenderObserver;
  49829. private _onAfterRenderTargetsRenderObserver;
  49830. private _onAfterRenderObserver;
  49831. private _onBeforeDrawPhaseObserver;
  49832. private _onAfterDrawPhaseObserver;
  49833. private _onBeforeAnimationsObserver;
  49834. private _onBeforeParticlesRenderingObserver;
  49835. private _onAfterParticlesRenderingObserver;
  49836. private _onBeforeSpritesRenderingObserver;
  49837. private _onAfterSpritesRenderingObserver;
  49838. private _onBeforePhysicsObserver;
  49839. private _onAfterPhysicsObserver;
  49840. private _onAfterAnimationsObserver;
  49841. private _onBeforeCameraRenderObserver;
  49842. private _onAfterCameraRenderObserver;
  49843. /**
  49844. * Gets the perf counter used for active meshes evaluation time
  49845. */
  49846. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49847. /**
  49848. * Gets the active meshes evaluation time capture status
  49849. */
  49850. /**
  49851. * Enable or disable the active meshes evaluation time capture
  49852. */
  49853. captureActiveMeshesEvaluationTime: boolean;
  49854. /**
  49855. * Gets the perf counter used for render targets render time
  49856. */
  49857. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49858. /**
  49859. * Gets the render targets render time capture status
  49860. */
  49861. /**
  49862. * Enable or disable the render targets render time capture
  49863. */
  49864. captureRenderTargetsRenderTime: boolean;
  49865. /**
  49866. * Gets the perf counter used for particles render time
  49867. */
  49868. readonly particlesRenderTimeCounter: PerfCounter;
  49869. /**
  49870. * Gets the particles render time capture status
  49871. */
  49872. /**
  49873. * Enable or disable the particles render time capture
  49874. */
  49875. captureParticlesRenderTime: boolean;
  49876. /**
  49877. * Gets the perf counter used for sprites render time
  49878. */
  49879. readonly spritesRenderTimeCounter: PerfCounter;
  49880. /**
  49881. * Gets the sprites render time capture status
  49882. */
  49883. /**
  49884. * Enable or disable the sprites render time capture
  49885. */
  49886. captureSpritesRenderTime: boolean;
  49887. /**
  49888. * Gets the perf counter used for physics time
  49889. */
  49890. readonly physicsTimeCounter: PerfCounter;
  49891. /**
  49892. * Gets the physics time capture status
  49893. */
  49894. /**
  49895. * Enable or disable the physics time capture
  49896. */
  49897. capturePhysicsTime: boolean;
  49898. /**
  49899. * Gets the perf counter used for animations time
  49900. */
  49901. readonly animationsTimeCounter: PerfCounter;
  49902. /**
  49903. * Gets the animations time capture status
  49904. */
  49905. /**
  49906. * Enable or disable the animations time capture
  49907. */
  49908. captureAnimationsTime: boolean;
  49909. /**
  49910. * Gets the perf counter used for frame time capture
  49911. */
  49912. readonly frameTimeCounter: PerfCounter;
  49913. /**
  49914. * Gets the frame time capture status
  49915. */
  49916. /**
  49917. * Enable or disable the frame time capture
  49918. */
  49919. captureFrameTime: boolean;
  49920. /**
  49921. * Gets the perf counter used for inter-frames time capture
  49922. */
  49923. readonly interFrameTimeCounter: PerfCounter;
  49924. /**
  49925. * Gets the inter-frames time capture status
  49926. */
  49927. /**
  49928. * Enable or disable the inter-frames time capture
  49929. */
  49930. captureInterFrameTime: boolean;
  49931. /**
  49932. * Gets the perf counter used for render time capture
  49933. */
  49934. readonly renderTimeCounter: PerfCounter;
  49935. /**
  49936. * Gets the render time capture status
  49937. */
  49938. /**
  49939. * Enable or disable the render time capture
  49940. */
  49941. captureRenderTime: boolean;
  49942. /**
  49943. * Gets the perf counter used for camera render time capture
  49944. */
  49945. readonly cameraRenderTimeCounter: PerfCounter;
  49946. /**
  49947. * Gets the camera render time capture status
  49948. */
  49949. /**
  49950. * Enable or disable the camera render time capture
  49951. */
  49952. captureCameraRenderTime: boolean;
  49953. /**
  49954. * Gets the perf counter used for draw calls
  49955. */
  49956. readonly drawCallsCounter: PerfCounter;
  49957. /**
  49958. * Instantiates a new scene instrumentation.
  49959. * This class can be used to get instrumentation data from a Babylon engine
  49960. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49961. * @param scene Defines the scene to instrument
  49962. */
  49963. constructor(
  49964. /**
  49965. * Defines the scene to instrument
  49966. */
  49967. scene: Scene);
  49968. /**
  49969. * Dispose and release associated resources.
  49970. */
  49971. dispose(): void;
  49972. }
  49973. }
  49974. declare module "babylonjs/Instrumentation/index" {
  49975. export * from "babylonjs/Instrumentation/engineInstrumentation";
  49976. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  49977. export * from "babylonjs/Instrumentation/timeToken";
  49978. }
  49979. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  49980. /** @hidden */
  49981. export var glowMapGenerationPixelShader: {
  49982. name: string;
  49983. shader: string;
  49984. };
  49985. }
  49986. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  49987. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49988. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49989. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49990. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49991. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49992. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49993. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49994. /** @hidden */
  49995. export var glowMapGenerationVertexShader: {
  49996. name: string;
  49997. shader: string;
  49998. };
  49999. }
  50000. declare module "babylonjs/Layers/effectLayer" {
  50001. import { Observable } from "babylonjs/Misc/observable";
  50002. import { Nullable } from "babylonjs/types";
  50003. import { Camera } from "babylonjs/Cameras/camera";
  50004. import { Scene } from "babylonjs/scene";
  50005. import { ISize } from "babylonjs/Maths/math.size";
  50006. import { Color4 } from "babylonjs/Maths/math.color";
  50007. import { Engine } from "babylonjs/Engines/engine";
  50008. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50010. import { Mesh } from "babylonjs/Meshes/mesh";
  50011. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50012. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50013. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50014. import { Effect } from "babylonjs/Materials/effect";
  50015. import { Material } from "babylonjs/Materials/material";
  50016. import "babylonjs/Shaders/glowMapGeneration.fragment";
  50017. import "babylonjs/Shaders/glowMapGeneration.vertex";
  50018. /**
  50019. * Effect layer options. This helps customizing the behaviour
  50020. * of the effect layer.
  50021. */
  50022. export interface IEffectLayerOptions {
  50023. /**
  50024. * Multiplication factor apply to the canvas size to compute the render target size
  50025. * used to generated the objects (the smaller the faster).
  50026. */
  50027. mainTextureRatio: number;
  50028. /**
  50029. * Enforces a fixed size texture to ensure effect stability across devices.
  50030. */
  50031. mainTextureFixedSize?: number;
  50032. /**
  50033. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50034. */
  50035. alphaBlendingMode: number;
  50036. /**
  50037. * The camera attached to the layer.
  50038. */
  50039. camera: Nullable<Camera>;
  50040. /**
  50041. * The rendering group to draw the layer in.
  50042. */
  50043. renderingGroupId: number;
  50044. }
  50045. /**
  50046. * The effect layer Helps adding post process effect blended with the main pass.
  50047. *
  50048. * This can be for instance use to generate glow or higlight effects on the scene.
  50049. *
  50050. * The effect layer class can not be used directly and is intented to inherited from to be
  50051. * customized per effects.
  50052. */
  50053. export abstract class EffectLayer {
  50054. private _vertexBuffers;
  50055. private _indexBuffer;
  50056. private _cachedDefines;
  50057. private _effectLayerMapGenerationEffect;
  50058. private _effectLayerOptions;
  50059. private _mergeEffect;
  50060. protected _scene: Scene;
  50061. protected _engine: Engine;
  50062. protected _maxSize: number;
  50063. protected _mainTextureDesiredSize: ISize;
  50064. protected _mainTexture: RenderTargetTexture;
  50065. protected _shouldRender: boolean;
  50066. protected _postProcesses: PostProcess[];
  50067. protected _textures: BaseTexture[];
  50068. protected _emissiveTextureAndColor: {
  50069. texture: Nullable<BaseTexture>;
  50070. color: Color4;
  50071. };
  50072. /**
  50073. * The name of the layer
  50074. */
  50075. name: string;
  50076. /**
  50077. * The clear color of the texture used to generate the glow map.
  50078. */
  50079. neutralColor: Color4;
  50080. /**
  50081. * Specifies wether the highlight layer is enabled or not.
  50082. */
  50083. isEnabled: boolean;
  50084. /**
  50085. * Gets the camera attached to the layer.
  50086. */
  50087. readonly camera: Nullable<Camera>;
  50088. /**
  50089. * Gets the rendering group id the layer should render in.
  50090. */
  50091. renderingGroupId: number;
  50092. /**
  50093. * An event triggered when the effect layer has been disposed.
  50094. */
  50095. onDisposeObservable: Observable<EffectLayer>;
  50096. /**
  50097. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50098. */
  50099. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50100. /**
  50101. * An event triggered when the generated texture is being merged in the scene.
  50102. */
  50103. onBeforeComposeObservable: Observable<EffectLayer>;
  50104. /**
  50105. * An event triggered when the generated texture has been merged in the scene.
  50106. */
  50107. onAfterComposeObservable: Observable<EffectLayer>;
  50108. /**
  50109. * An event triggered when the efffect layer changes its size.
  50110. */
  50111. onSizeChangedObservable: Observable<EffectLayer>;
  50112. /** @hidden */
  50113. static _SceneComponentInitialization: (scene: Scene) => void;
  50114. /**
  50115. * Instantiates a new effect Layer and references it in the scene.
  50116. * @param name The name of the layer
  50117. * @param scene The scene to use the layer in
  50118. */
  50119. constructor(
  50120. /** The Friendly of the effect in the scene */
  50121. name: string, scene: Scene);
  50122. /**
  50123. * Get the effect name of the layer.
  50124. * @return The effect name
  50125. */
  50126. abstract getEffectName(): string;
  50127. /**
  50128. * Checks for the readiness of the element composing the layer.
  50129. * @param subMesh the mesh to check for
  50130. * @param useInstances specify wether or not to use instances to render the mesh
  50131. * @return true if ready otherwise, false
  50132. */
  50133. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50134. /**
  50135. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50136. * @returns true if the effect requires stencil during the main canvas render pass.
  50137. */
  50138. abstract needStencil(): boolean;
  50139. /**
  50140. * Create the merge effect. This is the shader use to blit the information back
  50141. * to the main canvas at the end of the scene rendering.
  50142. * @returns The effect containing the shader used to merge the effect on the main canvas
  50143. */
  50144. protected abstract _createMergeEffect(): Effect;
  50145. /**
  50146. * Creates the render target textures and post processes used in the effect layer.
  50147. */
  50148. protected abstract _createTextureAndPostProcesses(): void;
  50149. /**
  50150. * Implementation specific of rendering the generating effect on the main canvas.
  50151. * @param effect The effect used to render through
  50152. */
  50153. protected abstract _internalRender(effect: Effect): void;
  50154. /**
  50155. * Sets the required values for both the emissive texture and and the main color.
  50156. */
  50157. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50158. /**
  50159. * Free any resources and references associated to a mesh.
  50160. * Internal use
  50161. * @param mesh The mesh to free.
  50162. */
  50163. abstract _disposeMesh(mesh: Mesh): void;
  50164. /**
  50165. * Serializes this layer (Glow or Highlight for example)
  50166. * @returns a serialized layer object
  50167. */
  50168. abstract serialize?(): any;
  50169. /**
  50170. * Initializes the effect layer with the required options.
  50171. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  50172. */
  50173. protected _init(options: Partial<IEffectLayerOptions>): void;
  50174. /**
  50175. * Generates the index buffer of the full screen quad blending to the main canvas.
  50176. */
  50177. private _generateIndexBuffer;
  50178. /**
  50179. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  50180. */
  50181. private _generateVertexBuffer;
  50182. /**
  50183. * Sets the main texture desired size which is the closest power of two
  50184. * of the engine canvas size.
  50185. */
  50186. private _setMainTextureSize;
  50187. /**
  50188. * Creates the main texture for the effect layer.
  50189. */
  50190. protected _createMainTexture(): void;
  50191. /**
  50192. * Adds specific effects defines.
  50193. * @param defines The defines to add specifics to.
  50194. */
  50195. protected _addCustomEffectDefines(defines: string[]): void;
  50196. /**
  50197. * Checks for the readiness of the element composing the layer.
  50198. * @param subMesh the mesh to check for
  50199. * @param useInstances specify wether or not to use instances to render the mesh
  50200. * @param emissiveTexture the associated emissive texture used to generate the glow
  50201. * @return true if ready otherwise, false
  50202. */
  50203. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  50204. /**
  50205. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  50206. */
  50207. render(): void;
  50208. /**
  50209. * Determine if a given mesh will be used in the current effect.
  50210. * @param mesh mesh to test
  50211. * @returns true if the mesh will be used
  50212. */
  50213. hasMesh(mesh: AbstractMesh): boolean;
  50214. /**
  50215. * Returns true if the layer contains information to display, otherwise false.
  50216. * @returns true if the glow layer should be rendered
  50217. */
  50218. shouldRender(): boolean;
  50219. /**
  50220. * Returns true if the mesh should render, otherwise false.
  50221. * @param mesh The mesh to render
  50222. * @returns true if it should render otherwise false
  50223. */
  50224. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  50225. /**
  50226. * Returns true if the mesh can be rendered, otherwise false.
  50227. * @param mesh The mesh to render
  50228. * @param material The material used on the mesh
  50229. * @returns true if it can be rendered otherwise false
  50230. */
  50231. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50232. /**
  50233. * Returns true if the mesh should render, otherwise false.
  50234. * @param mesh The mesh to render
  50235. * @returns true if it should render otherwise false
  50236. */
  50237. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  50238. /**
  50239. * Renders the submesh passed in parameter to the generation map.
  50240. */
  50241. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  50242. /**
  50243. * Rebuild the required buffers.
  50244. * @hidden Internal use only.
  50245. */
  50246. _rebuild(): void;
  50247. /**
  50248. * Dispose only the render target textures and post process.
  50249. */
  50250. private _disposeTextureAndPostProcesses;
  50251. /**
  50252. * Dispose the highlight layer and free resources.
  50253. */
  50254. dispose(): void;
  50255. /**
  50256. * Gets the class name of the effect layer
  50257. * @returns the string with the class name of the effect layer
  50258. */
  50259. getClassName(): string;
  50260. /**
  50261. * Creates an effect layer from parsed effect layer data
  50262. * @param parsedEffectLayer defines effect layer data
  50263. * @param scene defines the current scene
  50264. * @param rootUrl defines the root URL containing the effect layer information
  50265. * @returns a parsed effect Layer
  50266. */
  50267. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  50268. }
  50269. }
  50270. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  50271. import { Scene } from "babylonjs/scene";
  50272. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50273. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50274. import { AbstractScene } from "babylonjs/abstractScene";
  50275. module "babylonjs/abstractScene" {
  50276. interface AbstractScene {
  50277. /**
  50278. * The list of effect layers (highlights/glow) added to the scene
  50279. * @see http://doc.babylonjs.com/how_to/highlight_layer
  50280. * @see http://doc.babylonjs.com/how_to/glow_layer
  50281. */
  50282. effectLayers: Array<EffectLayer>;
  50283. /**
  50284. * Removes the given effect layer from this scene.
  50285. * @param toRemove defines the effect layer to remove
  50286. * @returns the index of the removed effect layer
  50287. */
  50288. removeEffectLayer(toRemove: EffectLayer): number;
  50289. /**
  50290. * Adds the given effect layer to this scene
  50291. * @param newEffectLayer defines the effect layer to add
  50292. */
  50293. addEffectLayer(newEffectLayer: EffectLayer): void;
  50294. }
  50295. }
  50296. /**
  50297. * Defines the layer scene component responsible to manage any effect layers
  50298. * in a given scene.
  50299. */
  50300. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  50301. /**
  50302. * The component name helpfull to identify the component in the list of scene components.
  50303. */
  50304. readonly name: string;
  50305. /**
  50306. * The scene the component belongs to.
  50307. */
  50308. scene: Scene;
  50309. private _engine;
  50310. private _renderEffects;
  50311. private _needStencil;
  50312. private _previousStencilState;
  50313. /**
  50314. * Creates a new instance of the component for the given scene
  50315. * @param scene Defines the scene to register the component in
  50316. */
  50317. constructor(scene: Scene);
  50318. /**
  50319. * Registers the component in a given scene
  50320. */
  50321. register(): void;
  50322. /**
  50323. * Rebuilds the elements related to this component in case of
  50324. * context lost for instance.
  50325. */
  50326. rebuild(): void;
  50327. /**
  50328. * Serializes the component data to the specified json object
  50329. * @param serializationObject The object to serialize to
  50330. */
  50331. serialize(serializationObject: any): void;
  50332. /**
  50333. * Adds all the elements from the container to the scene
  50334. * @param container the container holding the elements
  50335. */
  50336. addFromContainer(container: AbstractScene): void;
  50337. /**
  50338. * Removes all the elements in the container from the scene
  50339. * @param container contains the elements to remove
  50340. * @param dispose if the removed element should be disposed (default: false)
  50341. */
  50342. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50343. /**
  50344. * Disposes the component and the associated ressources.
  50345. */
  50346. dispose(): void;
  50347. private _isReadyForMesh;
  50348. private _renderMainTexture;
  50349. private _setStencil;
  50350. private _setStencilBack;
  50351. private _draw;
  50352. private _drawCamera;
  50353. private _drawRenderingGroup;
  50354. }
  50355. }
  50356. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  50357. /** @hidden */
  50358. export var glowMapMergePixelShader: {
  50359. name: string;
  50360. shader: string;
  50361. };
  50362. }
  50363. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  50364. /** @hidden */
  50365. export var glowMapMergeVertexShader: {
  50366. name: string;
  50367. shader: string;
  50368. };
  50369. }
  50370. declare module "babylonjs/Layers/glowLayer" {
  50371. import { Nullable } from "babylonjs/types";
  50372. import { Camera } from "babylonjs/Cameras/camera";
  50373. import { Scene } from "babylonjs/scene";
  50374. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50376. import { Mesh } from "babylonjs/Meshes/mesh";
  50377. import { Texture } from "babylonjs/Materials/Textures/texture";
  50378. import { Effect } from "babylonjs/Materials/effect";
  50379. import { Material } from "babylonjs/Materials/material";
  50380. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50381. import { Color4 } from "babylonjs/Maths/math.color";
  50382. import "babylonjs/Shaders/glowMapMerge.fragment";
  50383. import "babylonjs/Shaders/glowMapMerge.vertex";
  50384. import "babylonjs/Layers/effectLayerSceneComponent";
  50385. module "babylonjs/abstractScene" {
  50386. interface AbstractScene {
  50387. /**
  50388. * Return a the first highlight layer of the scene with a given name.
  50389. * @param name The name of the highlight layer to look for.
  50390. * @return The highlight layer if found otherwise null.
  50391. */
  50392. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  50393. }
  50394. }
  50395. /**
  50396. * Glow layer options. This helps customizing the behaviour
  50397. * of the glow layer.
  50398. */
  50399. export interface IGlowLayerOptions {
  50400. /**
  50401. * Multiplication factor apply to the canvas size to compute the render target size
  50402. * used to generated the glowing objects (the smaller the faster).
  50403. */
  50404. mainTextureRatio: number;
  50405. /**
  50406. * Enforces a fixed size texture to ensure resize independant blur.
  50407. */
  50408. mainTextureFixedSize?: number;
  50409. /**
  50410. * How big is the kernel of the blur texture.
  50411. */
  50412. blurKernelSize: number;
  50413. /**
  50414. * The camera attached to the layer.
  50415. */
  50416. camera: Nullable<Camera>;
  50417. /**
  50418. * Enable MSAA by chosing the number of samples.
  50419. */
  50420. mainTextureSamples?: number;
  50421. /**
  50422. * The rendering group to draw the layer in.
  50423. */
  50424. renderingGroupId: number;
  50425. }
  50426. /**
  50427. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  50428. *
  50429. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50430. * glowy meshes to your scene.
  50431. *
  50432. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  50433. */
  50434. export class GlowLayer extends EffectLayer {
  50435. /**
  50436. * Effect Name of the layer.
  50437. */
  50438. static readonly EffectName: string;
  50439. /**
  50440. * The default blur kernel size used for the glow.
  50441. */
  50442. static DefaultBlurKernelSize: number;
  50443. /**
  50444. * The default texture size ratio used for the glow.
  50445. */
  50446. static DefaultTextureRatio: number;
  50447. /**
  50448. * Sets the kernel size of the blur.
  50449. */
  50450. /**
  50451. * Gets the kernel size of the blur.
  50452. */
  50453. blurKernelSize: number;
  50454. /**
  50455. * Sets the glow intensity.
  50456. */
  50457. /**
  50458. * Gets the glow intensity.
  50459. */
  50460. intensity: number;
  50461. private _options;
  50462. private _intensity;
  50463. private _horizontalBlurPostprocess1;
  50464. private _verticalBlurPostprocess1;
  50465. private _horizontalBlurPostprocess2;
  50466. private _verticalBlurPostprocess2;
  50467. private _blurTexture1;
  50468. private _blurTexture2;
  50469. private _postProcesses1;
  50470. private _postProcesses2;
  50471. private _includedOnlyMeshes;
  50472. private _excludedMeshes;
  50473. /**
  50474. * Callback used to let the user override the color selection on a per mesh basis
  50475. */
  50476. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  50477. /**
  50478. * Callback used to let the user override the texture selection on a per mesh basis
  50479. */
  50480. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  50481. /**
  50482. * Instantiates a new glow Layer and references it to the scene.
  50483. * @param name The name of the layer
  50484. * @param scene The scene to use the layer in
  50485. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  50486. */
  50487. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  50488. /**
  50489. * Get the effect name of the layer.
  50490. * @return The effect name
  50491. */
  50492. getEffectName(): string;
  50493. /**
  50494. * Create the merge effect. This is the shader use to blit the information back
  50495. * to the main canvas at the end of the scene rendering.
  50496. */
  50497. protected _createMergeEffect(): Effect;
  50498. /**
  50499. * Creates the render target textures and post processes used in the glow layer.
  50500. */
  50501. protected _createTextureAndPostProcesses(): void;
  50502. /**
  50503. * Checks for the readiness of the element composing the layer.
  50504. * @param subMesh the mesh to check for
  50505. * @param useInstances specify wether or not to use instances to render the mesh
  50506. * @param emissiveTexture the associated emissive texture used to generate the glow
  50507. * @return true if ready otherwise, false
  50508. */
  50509. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50510. /**
  50511. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50512. */
  50513. needStencil(): boolean;
  50514. /**
  50515. * Returns true if the mesh can be rendered, otherwise false.
  50516. * @param mesh The mesh to render
  50517. * @param material The material used on the mesh
  50518. * @returns true if it can be rendered otherwise false
  50519. */
  50520. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50521. /**
  50522. * Implementation specific of rendering the generating effect on the main canvas.
  50523. * @param effect The effect used to render through
  50524. */
  50525. protected _internalRender(effect: Effect): void;
  50526. /**
  50527. * Sets the required values for both the emissive texture and and the main color.
  50528. */
  50529. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50530. /**
  50531. * Returns true if the mesh should render, otherwise false.
  50532. * @param mesh The mesh to render
  50533. * @returns true if it should render otherwise false
  50534. */
  50535. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50536. /**
  50537. * Adds specific effects defines.
  50538. * @param defines The defines to add specifics to.
  50539. */
  50540. protected _addCustomEffectDefines(defines: string[]): void;
  50541. /**
  50542. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  50543. * @param mesh The mesh to exclude from the glow layer
  50544. */
  50545. addExcludedMesh(mesh: Mesh): void;
  50546. /**
  50547. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  50548. * @param mesh The mesh to remove
  50549. */
  50550. removeExcludedMesh(mesh: Mesh): void;
  50551. /**
  50552. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  50553. * @param mesh The mesh to include in the glow layer
  50554. */
  50555. addIncludedOnlyMesh(mesh: Mesh): void;
  50556. /**
  50557. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  50558. * @param mesh The mesh to remove
  50559. */
  50560. removeIncludedOnlyMesh(mesh: Mesh): void;
  50561. /**
  50562. * Determine if a given mesh will be used in the glow layer
  50563. * @param mesh The mesh to test
  50564. * @returns true if the mesh will be highlighted by the current glow layer
  50565. */
  50566. hasMesh(mesh: AbstractMesh): boolean;
  50567. /**
  50568. * Free any resources and references associated to a mesh.
  50569. * Internal use
  50570. * @param mesh The mesh to free.
  50571. * @hidden
  50572. */
  50573. _disposeMesh(mesh: Mesh): void;
  50574. /**
  50575. * Gets the class name of the effect layer
  50576. * @returns the string with the class name of the effect layer
  50577. */
  50578. getClassName(): string;
  50579. /**
  50580. * Serializes this glow layer
  50581. * @returns a serialized glow layer object
  50582. */
  50583. serialize(): any;
  50584. /**
  50585. * Creates a Glow Layer from parsed glow layer data
  50586. * @param parsedGlowLayer defines glow layer data
  50587. * @param scene defines the current scene
  50588. * @param rootUrl defines the root URL containing the glow layer information
  50589. * @returns a parsed Glow Layer
  50590. */
  50591. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  50592. }
  50593. }
  50594. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  50595. /** @hidden */
  50596. export var glowBlurPostProcessPixelShader: {
  50597. name: string;
  50598. shader: string;
  50599. };
  50600. }
  50601. declare module "babylonjs/Layers/highlightLayer" {
  50602. import { Observable } from "babylonjs/Misc/observable";
  50603. import { Nullable } from "babylonjs/types";
  50604. import { Camera } from "babylonjs/Cameras/camera";
  50605. import { Scene } from "babylonjs/scene";
  50606. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50608. import { Mesh } from "babylonjs/Meshes/mesh";
  50609. import { Effect } from "babylonjs/Materials/effect";
  50610. import { Material } from "babylonjs/Materials/material";
  50611. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50612. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  50613. import "babylonjs/Shaders/glowMapMerge.fragment";
  50614. import "babylonjs/Shaders/glowMapMerge.vertex";
  50615. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  50616. module "babylonjs/abstractScene" {
  50617. interface AbstractScene {
  50618. /**
  50619. * Return a the first highlight layer of the scene with a given name.
  50620. * @param name The name of the highlight layer to look for.
  50621. * @return The highlight layer if found otherwise null.
  50622. */
  50623. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  50624. }
  50625. }
  50626. /**
  50627. * Highlight layer options. This helps customizing the behaviour
  50628. * of the highlight layer.
  50629. */
  50630. export interface IHighlightLayerOptions {
  50631. /**
  50632. * Multiplication factor apply to the canvas size to compute the render target size
  50633. * used to generated the glowing objects (the smaller the faster).
  50634. */
  50635. mainTextureRatio: number;
  50636. /**
  50637. * Enforces a fixed size texture to ensure resize independant blur.
  50638. */
  50639. mainTextureFixedSize?: number;
  50640. /**
  50641. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  50642. * of the picture to blur (the smaller the faster).
  50643. */
  50644. blurTextureSizeRatio: number;
  50645. /**
  50646. * How big in texel of the blur texture is the vertical blur.
  50647. */
  50648. blurVerticalSize: number;
  50649. /**
  50650. * How big in texel of the blur texture is the horizontal blur.
  50651. */
  50652. blurHorizontalSize: number;
  50653. /**
  50654. * Alpha blending mode used to apply the blur. Default is combine.
  50655. */
  50656. alphaBlendingMode: number;
  50657. /**
  50658. * The camera attached to the layer.
  50659. */
  50660. camera: Nullable<Camera>;
  50661. /**
  50662. * Should we display highlight as a solid stroke?
  50663. */
  50664. isStroke?: boolean;
  50665. /**
  50666. * The rendering group to draw the layer in.
  50667. */
  50668. renderingGroupId: number;
  50669. }
  50670. /**
  50671. * The highlight layer Helps adding a glow effect around a mesh.
  50672. *
  50673. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50674. * glowy meshes to your scene.
  50675. *
  50676. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  50677. */
  50678. export class HighlightLayer extends EffectLayer {
  50679. name: string;
  50680. /**
  50681. * Effect Name of the highlight layer.
  50682. */
  50683. static readonly EffectName: string;
  50684. /**
  50685. * The neutral color used during the preparation of the glow effect.
  50686. * This is black by default as the blend operation is a blend operation.
  50687. */
  50688. static NeutralColor: Color4;
  50689. /**
  50690. * Stencil value used for glowing meshes.
  50691. */
  50692. static GlowingMeshStencilReference: number;
  50693. /**
  50694. * Stencil value used for the other meshes in the scene.
  50695. */
  50696. static NormalMeshStencilReference: number;
  50697. /**
  50698. * Specifies whether or not the inner glow is ACTIVE in the layer.
  50699. */
  50700. innerGlow: boolean;
  50701. /**
  50702. * Specifies whether or not the outer glow is ACTIVE in the layer.
  50703. */
  50704. outerGlow: boolean;
  50705. /**
  50706. * Specifies the horizontal size of the blur.
  50707. */
  50708. /**
  50709. * Gets the horizontal size of the blur.
  50710. */
  50711. blurHorizontalSize: number;
  50712. /**
  50713. * Specifies the vertical size of the blur.
  50714. */
  50715. /**
  50716. * Gets the vertical size of the blur.
  50717. */
  50718. blurVerticalSize: number;
  50719. /**
  50720. * An event triggered when the highlight layer is being blurred.
  50721. */
  50722. onBeforeBlurObservable: Observable<HighlightLayer>;
  50723. /**
  50724. * An event triggered when the highlight layer has been blurred.
  50725. */
  50726. onAfterBlurObservable: Observable<HighlightLayer>;
  50727. private _instanceGlowingMeshStencilReference;
  50728. private _options;
  50729. private _downSamplePostprocess;
  50730. private _horizontalBlurPostprocess;
  50731. private _verticalBlurPostprocess;
  50732. private _blurTexture;
  50733. private _meshes;
  50734. private _excludedMeshes;
  50735. /**
  50736. * Instantiates a new highlight Layer and references it to the scene..
  50737. * @param name The name of the layer
  50738. * @param scene The scene to use the layer in
  50739. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  50740. */
  50741. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  50742. /**
  50743. * Get the effect name of the layer.
  50744. * @return The effect name
  50745. */
  50746. getEffectName(): string;
  50747. /**
  50748. * Create the merge effect. This is the shader use to blit the information back
  50749. * to the main canvas at the end of the scene rendering.
  50750. */
  50751. protected _createMergeEffect(): Effect;
  50752. /**
  50753. * Creates the render target textures and post processes used in the highlight layer.
  50754. */
  50755. protected _createTextureAndPostProcesses(): void;
  50756. /**
  50757. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50758. */
  50759. needStencil(): boolean;
  50760. /**
  50761. * Checks for the readiness of the element composing the layer.
  50762. * @param subMesh the mesh to check for
  50763. * @param useInstances specify wether or not to use instances to render the mesh
  50764. * @param emissiveTexture the associated emissive texture used to generate the glow
  50765. * @return true if ready otherwise, false
  50766. */
  50767. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50768. /**
  50769. * Implementation specific of rendering the generating effect on the main canvas.
  50770. * @param effect The effect used to render through
  50771. */
  50772. protected _internalRender(effect: Effect): void;
  50773. /**
  50774. * Returns true if the layer contains information to display, otherwise false.
  50775. */
  50776. shouldRender(): boolean;
  50777. /**
  50778. * Returns true if the mesh should render, otherwise false.
  50779. * @param mesh The mesh to render
  50780. * @returns true if it should render otherwise false
  50781. */
  50782. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50783. /**
  50784. * Sets the required values for both the emissive texture and and the main color.
  50785. */
  50786. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50787. /**
  50788. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50789. * @param mesh The mesh to exclude from the highlight layer
  50790. */
  50791. addExcludedMesh(mesh: Mesh): void;
  50792. /**
  50793. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50794. * @param mesh The mesh to highlight
  50795. */
  50796. removeExcludedMesh(mesh: Mesh): void;
  50797. /**
  50798. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50799. * @param mesh mesh to test
  50800. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50801. */
  50802. hasMesh(mesh: AbstractMesh): boolean;
  50803. /**
  50804. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50805. * @param mesh The mesh to highlight
  50806. * @param color The color of the highlight
  50807. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50808. */
  50809. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50810. /**
  50811. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50812. * @param mesh The mesh to highlight
  50813. */
  50814. removeMesh(mesh: Mesh): void;
  50815. /**
  50816. * Force the stencil to the normal expected value for none glowing parts
  50817. */
  50818. private _defaultStencilReference;
  50819. /**
  50820. * Free any resources and references associated to a mesh.
  50821. * Internal use
  50822. * @param mesh The mesh to free.
  50823. * @hidden
  50824. */
  50825. _disposeMesh(mesh: Mesh): void;
  50826. /**
  50827. * Dispose the highlight layer and free resources.
  50828. */
  50829. dispose(): void;
  50830. /**
  50831. * Gets the class name of the effect layer
  50832. * @returns the string with the class name of the effect layer
  50833. */
  50834. getClassName(): string;
  50835. /**
  50836. * Serializes this Highlight layer
  50837. * @returns a serialized Highlight layer object
  50838. */
  50839. serialize(): any;
  50840. /**
  50841. * Creates a Highlight layer from parsed Highlight layer data
  50842. * @param parsedHightlightLayer defines the Highlight layer data
  50843. * @param scene defines the current scene
  50844. * @param rootUrl defines the root URL containing the Highlight layer information
  50845. * @returns a parsed Highlight layer
  50846. */
  50847. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50848. }
  50849. }
  50850. declare module "babylonjs/Layers/layerSceneComponent" {
  50851. import { Scene } from "babylonjs/scene";
  50852. import { ISceneComponent } from "babylonjs/sceneComponent";
  50853. import { Layer } from "babylonjs/Layers/layer";
  50854. import { AbstractScene } from "babylonjs/abstractScene";
  50855. module "babylonjs/abstractScene" {
  50856. interface AbstractScene {
  50857. /**
  50858. * The list of layers (background and foreground) of the scene
  50859. */
  50860. layers: Array<Layer>;
  50861. }
  50862. }
  50863. /**
  50864. * Defines the layer scene component responsible to manage any layers
  50865. * in a given scene.
  50866. */
  50867. export class LayerSceneComponent implements ISceneComponent {
  50868. /**
  50869. * The component name helpfull to identify the component in the list of scene components.
  50870. */
  50871. readonly name: string;
  50872. /**
  50873. * The scene the component belongs to.
  50874. */
  50875. scene: Scene;
  50876. private _engine;
  50877. /**
  50878. * Creates a new instance of the component for the given scene
  50879. * @param scene Defines the scene to register the component in
  50880. */
  50881. constructor(scene: Scene);
  50882. /**
  50883. * Registers the component in a given scene
  50884. */
  50885. register(): void;
  50886. /**
  50887. * Rebuilds the elements related to this component in case of
  50888. * context lost for instance.
  50889. */
  50890. rebuild(): void;
  50891. /**
  50892. * Disposes the component and the associated ressources.
  50893. */
  50894. dispose(): void;
  50895. private _draw;
  50896. private _drawCameraPredicate;
  50897. private _drawCameraBackground;
  50898. private _drawCameraForeground;
  50899. private _drawRenderTargetPredicate;
  50900. private _drawRenderTargetBackground;
  50901. private _drawRenderTargetForeground;
  50902. /**
  50903. * Adds all the elements from the container to the scene
  50904. * @param container the container holding the elements
  50905. */
  50906. addFromContainer(container: AbstractScene): void;
  50907. /**
  50908. * Removes all the elements in the container from the scene
  50909. * @param container contains the elements to remove
  50910. * @param dispose if the removed element should be disposed (default: false)
  50911. */
  50912. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50913. }
  50914. }
  50915. declare module "babylonjs/Shaders/layer.fragment" {
  50916. /** @hidden */
  50917. export var layerPixelShader: {
  50918. name: string;
  50919. shader: string;
  50920. };
  50921. }
  50922. declare module "babylonjs/Shaders/layer.vertex" {
  50923. /** @hidden */
  50924. export var layerVertexShader: {
  50925. name: string;
  50926. shader: string;
  50927. };
  50928. }
  50929. declare module "babylonjs/Layers/layer" {
  50930. import { Observable } from "babylonjs/Misc/observable";
  50931. import { Nullable } from "babylonjs/types";
  50932. import { Scene } from "babylonjs/scene";
  50933. import { Vector2 } from "babylonjs/Maths/math.vector";
  50934. import { Color4 } from "babylonjs/Maths/math.color";
  50935. import { Texture } from "babylonjs/Materials/Textures/texture";
  50936. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50937. import "babylonjs/Shaders/layer.fragment";
  50938. import "babylonjs/Shaders/layer.vertex";
  50939. /**
  50940. * This represents a full screen 2d layer.
  50941. * This can be useful to display a picture in the background of your scene for instance.
  50942. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50943. */
  50944. export class Layer {
  50945. /**
  50946. * Define the name of the layer.
  50947. */
  50948. name: string;
  50949. /**
  50950. * Define the texture the layer should display.
  50951. */
  50952. texture: Nullable<Texture>;
  50953. /**
  50954. * Is the layer in background or foreground.
  50955. */
  50956. isBackground: boolean;
  50957. /**
  50958. * Define the color of the layer (instead of texture).
  50959. */
  50960. color: Color4;
  50961. /**
  50962. * Define the scale of the layer in order to zoom in out of the texture.
  50963. */
  50964. scale: Vector2;
  50965. /**
  50966. * Define an offset for the layer in order to shift the texture.
  50967. */
  50968. offset: Vector2;
  50969. /**
  50970. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50971. */
  50972. alphaBlendingMode: number;
  50973. /**
  50974. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50975. * Alpha test will not mix with the background color in case of transparency.
  50976. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50977. */
  50978. alphaTest: boolean;
  50979. /**
  50980. * Define a mask to restrict the layer to only some of the scene cameras.
  50981. */
  50982. layerMask: number;
  50983. /**
  50984. * Define the list of render target the layer is visible into.
  50985. */
  50986. renderTargetTextures: RenderTargetTexture[];
  50987. /**
  50988. * Define if the layer is only used in renderTarget or if it also
  50989. * renders in the main frame buffer of the canvas.
  50990. */
  50991. renderOnlyInRenderTargetTextures: boolean;
  50992. private _scene;
  50993. private _vertexBuffers;
  50994. private _indexBuffer;
  50995. private _effect;
  50996. private _alphaTestEffect;
  50997. /**
  50998. * An event triggered when the layer is disposed.
  50999. */
  51000. onDisposeObservable: Observable<Layer>;
  51001. private _onDisposeObserver;
  51002. /**
  51003. * Back compatibility with callback before the onDisposeObservable existed.
  51004. * The set callback will be triggered when the layer has been disposed.
  51005. */
  51006. onDispose: () => void;
  51007. /**
  51008. * An event triggered before rendering the scene
  51009. */
  51010. onBeforeRenderObservable: Observable<Layer>;
  51011. private _onBeforeRenderObserver;
  51012. /**
  51013. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51014. * The set callback will be triggered just before rendering the layer.
  51015. */
  51016. onBeforeRender: () => void;
  51017. /**
  51018. * An event triggered after rendering the scene
  51019. */
  51020. onAfterRenderObservable: Observable<Layer>;
  51021. private _onAfterRenderObserver;
  51022. /**
  51023. * Back compatibility with callback before the onAfterRenderObservable existed.
  51024. * The set callback will be triggered just after rendering the layer.
  51025. */
  51026. onAfterRender: () => void;
  51027. /**
  51028. * Instantiates a new layer.
  51029. * This represents a full screen 2d layer.
  51030. * This can be useful to display a picture in the background of your scene for instance.
  51031. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51032. * @param name Define the name of the layer in the scene
  51033. * @param imgUrl Define the url of the texture to display in the layer
  51034. * @param scene Define the scene the layer belongs to
  51035. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51036. * @param color Defines a color for the layer
  51037. */
  51038. constructor(
  51039. /**
  51040. * Define the name of the layer.
  51041. */
  51042. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51043. private _createIndexBuffer;
  51044. /** @hidden */
  51045. _rebuild(): void;
  51046. /**
  51047. * Renders the layer in the scene.
  51048. */
  51049. render(): void;
  51050. /**
  51051. * Disposes and releases the associated ressources.
  51052. */
  51053. dispose(): void;
  51054. }
  51055. }
  51056. declare module "babylonjs/Layers/index" {
  51057. export * from "babylonjs/Layers/effectLayer";
  51058. export * from "babylonjs/Layers/effectLayerSceneComponent";
  51059. export * from "babylonjs/Layers/glowLayer";
  51060. export * from "babylonjs/Layers/highlightLayer";
  51061. export * from "babylonjs/Layers/layer";
  51062. export * from "babylonjs/Layers/layerSceneComponent";
  51063. }
  51064. declare module "babylonjs/Shaders/lensFlare.fragment" {
  51065. /** @hidden */
  51066. export var lensFlarePixelShader: {
  51067. name: string;
  51068. shader: string;
  51069. };
  51070. }
  51071. declare module "babylonjs/Shaders/lensFlare.vertex" {
  51072. /** @hidden */
  51073. export var lensFlareVertexShader: {
  51074. name: string;
  51075. shader: string;
  51076. };
  51077. }
  51078. declare module "babylonjs/LensFlares/lensFlareSystem" {
  51079. import { Scene } from "babylonjs/scene";
  51080. import { Vector3 } from "babylonjs/Maths/math.vector";
  51081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51082. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  51083. import "babylonjs/Shaders/lensFlare.fragment";
  51084. import "babylonjs/Shaders/lensFlare.vertex";
  51085. import { Viewport } from "babylonjs/Maths/math.viewport";
  51086. /**
  51087. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51088. * It is usually composed of several `lensFlare`.
  51089. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51090. */
  51091. export class LensFlareSystem {
  51092. /**
  51093. * Define the name of the lens flare system
  51094. */
  51095. name: string;
  51096. /**
  51097. * List of lens flares used in this system.
  51098. */
  51099. lensFlares: LensFlare[];
  51100. /**
  51101. * Define a limit from the border the lens flare can be visible.
  51102. */
  51103. borderLimit: number;
  51104. /**
  51105. * Define a viewport border we do not want to see the lens flare in.
  51106. */
  51107. viewportBorder: number;
  51108. /**
  51109. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51110. */
  51111. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51112. /**
  51113. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51114. */
  51115. layerMask: number;
  51116. /**
  51117. * Define the id of the lens flare system in the scene.
  51118. * (equal to name by default)
  51119. */
  51120. id: string;
  51121. private _scene;
  51122. private _emitter;
  51123. private _vertexBuffers;
  51124. private _indexBuffer;
  51125. private _effect;
  51126. private _positionX;
  51127. private _positionY;
  51128. private _isEnabled;
  51129. /** @hidden */
  51130. static _SceneComponentInitialization: (scene: Scene) => void;
  51131. /**
  51132. * Instantiates a lens flare system.
  51133. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51134. * It is usually composed of several `lensFlare`.
  51135. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51136. * @param name Define the name of the lens flare system in the scene
  51137. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  51138. * @param scene Define the scene the lens flare system belongs to
  51139. */
  51140. constructor(
  51141. /**
  51142. * Define the name of the lens flare system
  51143. */
  51144. name: string, emitter: any, scene: Scene);
  51145. /**
  51146. * Define if the lens flare system is enabled.
  51147. */
  51148. isEnabled: boolean;
  51149. /**
  51150. * Get the scene the effects belongs to.
  51151. * @returns the scene holding the lens flare system
  51152. */
  51153. getScene(): Scene;
  51154. /**
  51155. * Get the emitter of the lens flare system.
  51156. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51157. * @returns the emitter of the lens flare system
  51158. */
  51159. getEmitter(): any;
  51160. /**
  51161. * Set the emitter of the lens flare system.
  51162. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51163. * @param newEmitter Define the new emitter of the system
  51164. */
  51165. setEmitter(newEmitter: any): void;
  51166. /**
  51167. * Get the lens flare system emitter position.
  51168. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  51169. * @returns the position
  51170. */
  51171. getEmitterPosition(): Vector3;
  51172. /**
  51173. * @hidden
  51174. */
  51175. computeEffectivePosition(globalViewport: Viewport): boolean;
  51176. /** @hidden */
  51177. _isVisible(): boolean;
  51178. /**
  51179. * @hidden
  51180. */
  51181. render(): boolean;
  51182. /**
  51183. * Dispose and release the lens flare with its associated resources.
  51184. */
  51185. dispose(): void;
  51186. /**
  51187. * Parse a lens flare system from a JSON repressentation
  51188. * @param parsedLensFlareSystem Define the JSON to parse
  51189. * @param scene Define the scene the parsed system should be instantiated in
  51190. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  51191. * @returns the parsed system
  51192. */
  51193. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  51194. /**
  51195. * Serialize the current Lens Flare System into a JSON representation.
  51196. * @returns the serialized JSON
  51197. */
  51198. serialize(): any;
  51199. }
  51200. }
  51201. declare module "babylonjs/LensFlares/lensFlare" {
  51202. import { Nullable } from "babylonjs/types";
  51203. import { Color3 } from "babylonjs/Maths/math.color";
  51204. import { Texture } from "babylonjs/Materials/Textures/texture";
  51205. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51206. /**
  51207. * This represents one of the lens effect in a `lensFlareSystem`.
  51208. * It controls one of the indiviual texture used in the effect.
  51209. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51210. */
  51211. export class LensFlare {
  51212. /**
  51213. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51214. */
  51215. size: number;
  51216. /**
  51217. * 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.
  51218. */
  51219. position: number;
  51220. /**
  51221. * Define the lens color.
  51222. */
  51223. color: Color3;
  51224. /**
  51225. * Define the lens texture.
  51226. */
  51227. texture: Nullable<Texture>;
  51228. /**
  51229. * Define the alpha mode to render this particular lens.
  51230. */
  51231. alphaMode: number;
  51232. private _system;
  51233. /**
  51234. * Creates a new Lens Flare.
  51235. * This represents one of the lens effect in a `lensFlareSystem`.
  51236. * It controls one of the indiviual texture used in the effect.
  51237. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51238. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  51239. * @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.
  51240. * @param color Define the lens color
  51241. * @param imgUrl Define the lens texture url
  51242. * @param system Define the `lensFlareSystem` this flare is part of
  51243. * @returns The newly created Lens Flare
  51244. */
  51245. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  51246. /**
  51247. * Instantiates a new Lens Flare.
  51248. * This represents one of the lens effect in a `lensFlareSystem`.
  51249. * It controls one of the indiviual texture used in the effect.
  51250. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51251. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  51252. * @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.
  51253. * @param color Define the lens color
  51254. * @param imgUrl Define the lens texture url
  51255. * @param system Define the `lensFlareSystem` this flare is part of
  51256. */
  51257. constructor(
  51258. /**
  51259. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51260. */
  51261. size: number,
  51262. /**
  51263. * 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.
  51264. */
  51265. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  51266. /**
  51267. * Dispose and release the lens flare with its associated resources.
  51268. */
  51269. dispose(): void;
  51270. }
  51271. }
  51272. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  51273. import { Nullable } from "babylonjs/types";
  51274. import { Scene } from "babylonjs/scene";
  51275. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51276. import { AbstractScene } from "babylonjs/abstractScene";
  51277. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51278. module "babylonjs/abstractScene" {
  51279. interface AbstractScene {
  51280. /**
  51281. * The list of lens flare system added to the scene
  51282. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51283. */
  51284. lensFlareSystems: Array<LensFlareSystem>;
  51285. /**
  51286. * Removes the given lens flare system from this scene.
  51287. * @param toRemove The lens flare system to remove
  51288. * @returns The index of the removed lens flare system
  51289. */
  51290. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  51291. /**
  51292. * Adds the given lens flare system to this scene
  51293. * @param newLensFlareSystem The lens flare system to add
  51294. */
  51295. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  51296. /**
  51297. * Gets a lens flare system using its name
  51298. * @param name defines the name to look for
  51299. * @returns the lens flare system or null if not found
  51300. */
  51301. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  51302. /**
  51303. * Gets a lens flare system using its id
  51304. * @param id defines the id to look for
  51305. * @returns the lens flare system or null if not found
  51306. */
  51307. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  51308. }
  51309. }
  51310. /**
  51311. * Defines the lens flare scene component responsible to manage any lens flares
  51312. * in a given scene.
  51313. */
  51314. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  51315. /**
  51316. * The component name helpfull to identify the component in the list of scene components.
  51317. */
  51318. readonly name: string;
  51319. /**
  51320. * The scene the component belongs to.
  51321. */
  51322. scene: Scene;
  51323. /**
  51324. * Creates a new instance of the component for the given scene
  51325. * @param scene Defines the scene to register the component in
  51326. */
  51327. constructor(scene: Scene);
  51328. /**
  51329. * Registers the component in a given scene
  51330. */
  51331. register(): void;
  51332. /**
  51333. * Rebuilds the elements related to this component in case of
  51334. * context lost for instance.
  51335. */
  51336. rebuild(): void;
  51337. /**
  51338. * Adds all the elements from the container to the scene
  51339. * @param container the container holding the elements
  51340. */
  51341. addFromContainer(container: AbstractScene): void;
  51342. /**
  51343. * Removes all the elements in the container from the scene
  51344. * @param container contains the elements to remove
  51345. * @param dispose if the removed element should be disposed (default: false)
  51346. */
  51347. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51348. /**
  51349. * Serializes the component data to the specified json object
  51350. * @param serializationObject The object to serialize to
  51351. */
  51352. serialize(serializationObject: any): void;
  51353. /**
  51354. * Disposes the component and the associated ressources.
  51355. */
  51356. dispose(): void;
  51357. private _draw;
  51358. }
  51359. }
  51360. declare module "babylonjs/LensFlares/index" {
  51361. export * from "babylonjs/LensFlares/lensFlare";
  51362. export * from "babylonjs/LensFlares/lensFlareSystem";
  51363. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  51364. }
  51365. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  51366. import { Scene } from "babylonjs/scene";
  51367. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51368. import { AbstractScene } from "babylonjs/abstractScene";
  51369. /**
  51370. * Defines the shadow generator component responsible to manage any shadow generators
  51371. * in a given scene.
  51372. */
  51373. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  51374. /**
  51375. * The component name helpfull to identify the component in the list of scene components.
  51376. */
  51377. readonly name: string;
  51378. /**
  51379. * The scene the component belongs to.
  51380. */
  51381. scene: Scene;
  51382. /**
  51383. * Creates a new instance of the component for the given scene
  51384. * @param scene Defines the scene to register the component in
  51385. */
  51386. constructor(scene: Scene);
  51387. /**
  51388. * Registers the component in a given scene
  51389. */
  51390. register(): void;
  51391. /**
  51392. * Rebuilds the elements related to this component in case of
  51393. * context lost for instance.
  51394. */
  51395. rebuild(): void;
  51396. /**
  51397. * Serializes the component data to the specified json object
  51398. * @param serializationObject The object to serialize to
  51399. */
  51400. serialize(serializationObject: any): void;
  51401. /**
  51402. * Adds all the elements from the container to the scene
  51403. * @param container the container holding the elements
  51404. */
  51405. addFromContainer(container: AbstractScene): void;
  51406. /**
  51407. * Removes all the elements in the container from the scene
  51408. * @param container contains the elements to remove
  51409. * @param dispose if the removed element should be disposed (default: false)
  51410. */
  51411. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51412. /**
  51413. * Rebuilds the elements related to this component in case of
  51414. * context lost for instance.
  51415. */
  51416. dispose(): void;
  51417. private _gatherRenderTargets;
  51418. }
  51419. }
  51420. declare module "babylonjs/Lights/Shadows/index" {
  51421. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  51422. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  51423. }
  51424. declare module "babylonjs/Lights/pointLight" {
  51425. import { Scene } from "babylonjs/scene";
  51426. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51428. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51429. import { Effect } from "babylonjs/Materials/effect";
  51430. /**
  51431. * A point light is a light defined by an unique point in world space.
  51432. * The light is emitted in every direction from this point.
  51433. * A good example of a point light is a standard light bulb.
  51434. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51435. */
  51436. export class PointLight extends ShadowLight {
  51437. private _shadowAngle;
  51438. /**
  51439. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51440. * This specifies what angle the shadow will use to be created.
  51441. *
  51442. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51443. */
  51444. /**
  51445. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51446. * This specifies what angle the shadow will use to be created.
  51447. *
  51448. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51449. */
  51450. shadowAngle: number;
  51451. /**
  51452. * Gets the direction if it has been set.
  51453. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51454. */
  51455. /**
  51456. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51457. */
  51458. direction: Vector3;
  51459. /**
  51460. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  51461. * A PointLight emits the light in every direction.
  51462. * It can cast shadows.
  51463. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  51464. * ```javascript
  51465. * var pointLight = new PointLight("pl", camera.position, scene);
  51466. * ```
  51467. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51468. * @param name The light friendly name
  51469. * @param position The position of the point light in the scene
  51470. * @param scene The scene the lights belongs to
  51471. */
  51472. constructor(name: string, position: Vector3, scene: Scene);
  51473. /**
  51474. * Returns the string "PointLight"
  51475. * @returns the class name
  51476. */
  51477. getClassName(): string;
  51478. /**
  51479. * Returns the integer 0.
  51480. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51481. */
  51482. getTypeID(): number;
  51483. /**
  51484. * Specifies wether or not the shadowmap should be a cube texture.
  51485. * @returns true if the shadowmap needs to be a cube texture.
  51486. */
  51487. needCube(): boolean;
  51488. /**
  51489. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  51490. * @param faceIndex The index of the face we are computed the direction to generate shadow
  51491. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  51492. */
  51493. getShadowDirection(faceIndex?: number): Vector3;
  51494. /**
  51495. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  51496. * - fov = PI / 2
  51497. * - aspect ratio : 1.0
  51498. * - z-near and far equal to the active camera minZ and maxZ.
  51499. * Returns the PointLight.
  51500. */
  51501. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51502. protected _buildUniformLayout(): void;
  51503. /**
  51504. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  51505. * @param effect The effect to update
  51506. * @param lightIndex The index of the light in the effect to update
  51507. * @returns The point light
  51508. */
  51509. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  51510. /**
  51511. * Prepares the list of defines specific to the light type.
  51512. * @param defines the list of defines
  51513. * @param lightIndex defines the index of the light for the effect
  51514. */
  51515. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51516. }
  51517. }
  51518. declare module "babylonjs/Lights/index" {
  51519. export * from "babylonjs/Lights/light";
  51520. export * from "babylonjs/Lights/shadowLight";
  51521. export * from "babylonjs/Lights/Shadows/index";
  51522. export * from "babylonjs/Lights/directionalLight";
  51523. export * from "babylonjs/Lights/hemisphericLight";
  51524. export * from "babylonjs/Lights/pointLight";
  51525. export * from "babylonjs/Lights/spotLight";
  51526. }
  51527. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  51528. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  51529. /**
  51530. * Header information of HDR texture files.
  51531. */
  51532. export interface HDRInfo {
  51533. /**
  51534. * The height of the texture in pixels.
  51535. */
  51536. height: number;
  51537. /**
  51538. * The width of the texture in pixels.
  51539. */
  51540. width: number;
  51541. /**
  51542. * The index of the beginning of the data in the binary file.
  51543. */
  51544. dataPosition: number;
  51545. }
  51546. /**
  51547. * This groups tools to convert HDR texture to native colors array.
  51548. */
  51549. export class HDRTools {
  51550. private static Ldexp;
  51551. private static Rgbe2float;
  51552. private static readStringLine;
  51553. /**
  51554. * Reads header information from an RGBE texture stored in a native array.
  51555. * More information on this format are available here:
  51556. * https://en.wikipedia.org/wiki/RGBE_image_format
  51557. *
  51558. * @param uint8array The binary file stored in native array.
  51559. * @return The header information.
  51560. */
  51561. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  51562. /**
  51563. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  51564. * This RGBE texture needs to store the information as a panorama.
  51565. *
  51566. * More information on this format are available here:
  51567. * https://en.wikipedia.org/wiki/RGBE_image_format
  51568. *
  51569. * @param buffer The binary file stored in an array buffer.
  51570. * @param size The expected size of the extracted cubemap.
  51571. * @return The Cube Map information.
  51572. */
  51573. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  51574. /**
  51575. * Returns the pixels data extracted from an RGBE texture.
  51576. * This pixels will be stored left to right up to down in the R G B order in one array.
  51577. *
  51578. * More information on this format are available here:
  51579. * https://en.wikipedia.org/wiki/RGBE_image_format
  51580. *
  51581. * @param uint8array The binary file stored in an array buffer.
  51582. * @param hdrInfo The header information of the file.
  51583. * @return The pixels data in RGB right to left up to down order.
  51584. */
  51585. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  51586. private static RGBE_ReadPixels_RLE;
  51587. }
  51588. }
  51589. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  51590. import { Nullable } from "babylonjs/types";
  51591. import { Scene } from "babylonjs/scene";
  51592. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51593. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51594. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51595. /**
  51596. * This represents a texture coming from an HDR input.
  51597. *
  51598. * The only supported format is currently panorama picture stored in RGBE format.
  51599. * Example of such files can be found on HDRLib: http://hdrlib.com/
  51600. */
  51601. export class HDRCubeTexture extends BaseTexture {
  51602. private static _facesMapping;
  51603. private _generateHarmonics;
  51604. private _noMipmap;
  51605. private _textureMatrix;
  51606. private _size;
  51607. private _onLoad;
  51608. private _onError;
  51609. /**
  51610. * The texture URL.
  51611. */
  51612. url: string;
  51613. /**
  51614. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  51615. */
  51616. coordinatesMode: number;
  51617. protected _isBlocking: boolean;
  51618. /**
  51619. * Sets wether or not the texture is blocking during loading.
  51620. */
  51621. /**
  51622. * Gets wether or not the texture is blocking during loading.
  51623. */
  51624. isBlocking: boolean;
  51625. protected _rotationY: number;
  51626. /**
  51627. * Sets texture matrix rotation angle around Y axis in radians.
  51628. */
  51629. /**
  51630. * Gets texture matrix rotation angle around Y axis radians.
  51631. */
  51632. rotationY: number;
  51633. /**
  51634. * Gets or sets the center of the bounding box associated with the cube texture
  51635. * It must define where the camera used to render the texture was set
  51636. */
  51637. boundingBoxPosition: Vector3;
  51638. private _boundingBoxSize;
  51639. /**
  51640. * Gets or sets the size of the bounding box associated with the cube texture
  51641. * When defined, the cubemap will switch to local mode
  51642. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  51643. * @example https://www.babylonjs-playground.com/#RNASML
  51644. */
  51645. boundingBoxSize: Vector3;
  51646. /**
  51647. * Instantiates an HDRTexture from the following parameters.
  51648. *
  51649. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  51650. * @param scene The scene the texture will be used in
  51651. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51652. * @param noMipmap Forces to not generate the mipmap if true
  51653. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  51654. * @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)
  51655. * @param reserved Reserved flag for internal use.
  51656. */
  51657. 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>);
  51658. /**
  51659. * Get the current class name of the texture useful for serialization or dynamic coding.
  51660. * @returns "HDRCubeTexture"
  51661. */
  51662. getClassName(): string;
  51663. /**
  51664. * Occurs when the file is raw .hdr file.
  51665. */
  51666. private loadTexture;
  51667. clone(): HDRCubeTexture;
  51668. delayLoad(): void;
  51669. /**
  51670. * Get the texture reflection matrix used to rotate/transform the reflection.
  51671. * @returns the reflection matrix
  51672. */
  51673. getReflectionTextureMatrix(): Matrix;
  51674. /**
  51675. * Set the texture reflection matrix used to rotate/transform the reflection.
  51676. * @param value Define the reflection matrix to set
  51677. */
  51678. setReflectionTextureMatrix(value: Matrix): void;
  51679. /**
  51680. * Parses a JSON representation of an HDR Texture in order to create the texture
  51681. * @param parsedTexture Define the JSON representation
  51682. * @param scene Define the scene the texture should be created in
  51683. * @param rootUrl Define the root url in case we need to load relative dependencies
  51684. * @returns the newly created texture after parsing
  51685. */
  51686. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  51687. serialize(): any;
  51688. }
  51689. }
  51690. declare module "babylonjs/Physics/physicsEngine" {
  51691. import { Nullable } from "babylonjs/types";
  51692. import { Vector3 } from "babylonjs/Maths/math.vector";
  51693. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51694. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  51695. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  51696. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51697. /**
  51698. * Class used to control physics engine
  51699. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51700. */
  51701. export class PhysicsEngine implements IPhysicsEngine {
  51702. private _physicsPlugin;
  51703. /**
  51704. * Global value used to control the smallest number supported by the simulation
  51705. */
  51706. static Epsilon: number;
  51707. private _impostors;
  51708. private _joints;
  51709. /**
  51710. * Gets the gravity vector used by the simulation
  51711. */
  51712. gravity: Vector3;
  51713. /**
  51714. * Factory used to create the default physics plugin.
  51715. * @returns The default physics plugin
  51716. */
  51717. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  51718. /**
  51719. * Creates a new Physics Engine
  51720. * @param gravity defines the gravity vector used by the simulation
  51721. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  51722. */
  51723. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  51724. /**
  51725. * Sets the gravity vector used by the simulation
  51726. * @param gravity defines the gravity vector to use
  51727. */
  51728. setGravity(gravity: Vector3): void;
  51729. /**
  51730. * Set the time step of the physics engine.
  51731. * Default is 1/60.
  51732. * To slow it down, enter 1/600 for example.
  51733. * To speed it up, 1/30
  51734. * @param newTimeStep defines the new timestep to apply to this world.
  51735. */
  51736. setTimeStep(newTimeStep?: number): void;
  51737. /**
  51738. * Get the time step of the physics engine.
  51739. * @returns the current time step
  51740. */
  51741. getTimeStep(): number;
  51742. /**
  51743. * Release all resources
  51744. */
  51745. dispose(): void;
  51746. /**
  51747. * Gets the name of the current physics plugin
  51748. * @returns the name of the plugin
  51749. */
  51750. getPhysicsPluginName(): string;
  51751. /**
  51752. * Adding a new impostor for the impostor tracking.
  51753. * This will be done by the impostor itself.
  51754. * @param impostor the impostor to add
  51755. */
  51756. addImpostor(impostor: PhysicsImpostor): void;
  51757. /**
  51758. * Remove an impostor from the engine.
  51759. * This impostor and its mesh will not longer be updated by the physics engine.
  51760. * @param impostor the impostor to remove
  51761. */
  51762. removeImpostor(impostor: PhysicsImpostor): void;
  51763. /**
  51764. * Add a joint to the physics engine
  51765. * @param mainImpostor defines the main impostor to which the joint is added.
  51766. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  51767. * @param joint defines the joint that will connect both impostors.
  51768. */
  51769. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51770. /**
  51771. * Removes a joint from the simulation
  51772. * @param mainImpostor defines the impostor used with the joint
  51773. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  51774. * @param joint defines the joint to remove
  51775. */
  51776. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51777. /**
  51778. * Called by the scene. No need to call it.
  51779. * @param delta defines the timespam between frames
  51780. */
  51781. _step(delta: number): void;
  51782. /**
  51783. * Gets the current plugin used to run the simulation
  51784. * @returns current plugin
  51785. */
  51786. getPhysicsPlugin(): IPhysicsEnginePlugin;
  51787. /**
  51788. * Gets the list of physic impostors
  51789. * @returns an array of PhysicsImpostor
  51790. */
  51791. getImpostors(): Array<PhysicsImpostor>;
  51792. /**
  51793. * Gets the impostor for a physics enabled object
  51794. * @param object defines the object impersonated by the impostor
  51795. * @returns the PhysicsImpostor or null if not found
  51796. */
  51797. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  51798. /**
  51799. * Gets the impostor for a physics body object
  51800. * @param body defines physics body used by the impostor
  51801. * @returns the PhysicsImpostor or null if not found
  51802. */
  51803. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  51804. /**
  51805. * Does a raycast in the physics world
  51806. * @param from when should the ray start?
  51807. * @param to when should the ray end?
  51808. * @returns PhysicsRaycastResult
  51809. */
  51810. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51811. }
  51812. }
  51813. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  51814. import { Nullable } from "babylonjs/types";
  51815. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  51816. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51817. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51818. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51819. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51820. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51821. /** @hidden */
  51822. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  51823. private _useDeltaForWorldStep;
  51824. world: any;
  51825. name: string;
  51826. private _physicsMaterials;
  51827. private _fixedTimeStep;
  51828. private _cannonRaycastResult;
  51829. private _raycastResult;
  51830. private _physicsBodysToRemoveAfterStep;
  51831. BJSCANNON: any;
  51832. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51833. setGravity(gravity: Vector3): void;
  51834. setTimeStep(timeStep: number): void;
  51835. getTimeStep(): number;
  51836. executeStep(delta: number): void;
  51837. private _removeMarkedPhysicsBodiesFromWorld;
  51838. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51839. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51840. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51841. private _processChildMeshes;
  51842. removePhysicsBody(impostor: PhysicsImpostor): void;
  51843. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51844. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51845. private _addMaterial;
  51846. private _checkWithEpsilon;
  51847. private _createShape;
  51848. private _createHeightmap;
  51849. private _minus90X;
  51850. private _plus90X;
  51851. private _tmpPosition;
  51852. private _tmpDeltaPosition;
  51853. private _tmpUnityRotation;
  51854. private _updatePhysicsBodyTransformation;
  51855. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51856. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51857. isSupported(): boolean;
  51858. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51859. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51860. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51861. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51862. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51863. getBodyMass(impostor: PhysicsImpostor): number;
  51864. getBodyFriction(impostor: PhysicsImpostor): number;
  51865. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51866. getBodyRestitution(impostor: PhysicsImpostor): number;
  51867. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51868. sleepBody(impostor: PhysicsImpostor): void;
  51869. wakeUpBody(impostor: PhysicsImpostor): void;
  51870. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51871. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51872. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51873. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51874. getRadius(impostor: PhysicsImpostor): number;
  51875. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51876. dispose(): void;
  51877. private _extendNamespace;
  51878. /**
  51879. * Does a raycast in the physics world
  51880. * @param from when should the ray start?
  51881. * @param to when should the ray end?
  51882. * @returns PhysicsRaycastResult
  51883. */
  51884. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51885. }
  51886. }
  51887. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  51888. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51889. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51890. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51892. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  51893. import { Nullable } from "babylonjs/types";
  51894. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51895. /** @hidden */
  51896. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51897. world: any;
  51898. name: string;
  51899. BJSOIMO: any;
  51900. private _raycastResult;
  51901. constructor(iterations?: number, oimoInjection?: any);
  51902. setGravity(gravity: Vector3): void;
  51903. setTimeStep(timeStep: number): void;
  51904. getTimeStep(): number;
  51905. private _tmpImpostorsArray;
  51906. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51907. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51908. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51909. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51910. private _tmpPositionVector;
  51911. removePhysicsBody(impostor: PhysicsImpostor): void;
  51912. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51913. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51914. isSupported(): boolean;
  51915. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51916. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51917. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51918. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51919. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51920. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51921. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51922. getBodyMass(impostor: PhysicsImpostor): number;
  51923. getBodyFriction(impostor: PhysicsImpostor): number;
  51924. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51925. getBodyRestitution(impostor: PhysicsImpostor): number;
  51926. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51927. sleepBody(impostor: PhysicsImpostor): void;
  51928. wakeUpBody(impostor: PhysicsImpostor): void;
  51929. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51930. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51931. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51932. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51933. getRadius(impostor: PhysicsImpostor): number;
  51934. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51935. dispose(): void;
  51936. /**
  51937. * Does a raycast in the physics world
  51938. * @param from when should the ray start?
  51939. * @param to when should the ray end?
  51940. * @returns PhysicsRaycastResult
  51941. */
  51942. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51943. }
  51944. }
  51945. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  51946. import { Nullable } from "babylonjs/types";
  51947. import { Scene } from "babylonjs/scene";
  51948. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  51949. import { Color4 } from "babylonjs/Maths/math.color";
  51950. import { Mesh } from "babylonjs/Meshes/mesh";
  51951. /**
  51952. * Class containing static functions to help procedurally build meshes
  51953. */
  51954. export class RibbonBuilder {
  51955. /**
  51956. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51957. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51958. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51959. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51960. * * 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
  51961. * * 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
  51962. * * 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
  51963. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51964. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51965. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51966. * * 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
  51967. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51968. * * 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
  51969. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51971. * @param name defines the name of the mesh
  51972. * @param options defines the options used to create the mesh
  51973. * @param scene defines the hosting scene
  51974. * @returns the ribbon mesh
  51975. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51976. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51977. */
  51978. static CreateRibbon(name: string, options: {
  51979. pathArray: Vector3[][];
  51980. closeArray?: boolean;
  51981. closePath?: boolean;
  51982. offset?: number;
  51983. updatable?: boolean;
  51984. sideOrientation?: number;
  51985. frontUVs?: Vector4;
  51986. backUVs?: Vector4;
  51987. instance?: Mesh;
  51988. invertUV?: boolean;
  51989. uvs?: Vector2[];
  51990. colors?: Color4[];
  51991. }, scene?: Nullable<Scene>): Mesh;
  51992. }
  51993. }
  51994. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  51995. import { Nullable } from "babylonjs/types";
  51996. import { Scene } from "babylonjs/scene";
  51997. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  51998. import { Mesh } from "babylonjs/Meshes/mesh";
  51999. /**
  52000. * Class containing static functions to help procedurally build meshes
  52001. */
  52002. export class ShapeBuilder {
  52003. /**
  52004. * 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.
  52005. * * 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.
  52006. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52007. * * 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.
  52008. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52009. * * 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
  52010. * * 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
  52011. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52012. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52013. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52014. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52016. * @param name defines the name of the mesh
  52017. * @param options defines the options used to create the mesh
  52018. * @param scene defines the hosting scene
  52019. * @returns the extruded shape mesh
  52020. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52021. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52022. */
  52023. static ExtrudeShape(name: string, options: {
  52024. shape: Vector3[];
  52025. path: Vector3[];
  52026. scale?: number;
  52027. rotation?: number;
  52028. cap?: number;
  52029. updatable?: boolean;
  52030. sideOrientation?: number;
  52031. frontUVs?: Vector4;
  52032. backUVs?: Vector4;
  52033. instance?: Mesh;
  52034. invertUV?: boolean;
  52035. }, scene?: Nullable<Scene>): Mesh;
  52036. /**
  52037. * Creates an custom extruded shape mesh.
  52038. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52039. * * 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.
  52040. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52041. * * 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
  52042. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52043. * * 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
  52044. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52045. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52046. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52047. * * 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
  52048. * * 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
  52049. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52050. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52051. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52052. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52054. * @param name defines the name of the mesh
  52055. * @param options defines the options used to create the mesh
  52056. * @param scene defines the hosting scene
  52057. * @returns the custom extruded shape mesh
  52058. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52059. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52060. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52061. */
  52062. static ExtrudeShapeCustom(name: string, options: {
  52063. shape: Vector3[];
  52064. path: Vector3[];
  52065. scaleFunction?: any;
  52066. rotationFunction?: any;
  52067. ribbonCloseArray?: boolean;
  52068. ribbonClosePath?: boolean;
  52069. cap?: number;
  52070. updatable?: boolean;
  52071. sideOrientation?: number;
  52072. frontUVs?: Vector4;
  52073. backUVs?: Vector4;
  52074. instance?: Mesh;
  52075. invertUV?: boolean;
  52076. }, scene?: Nullable<Scene>): Mesh;
  52077. private static _ExtrudeShapeGeneric;
  52078. }
  52079. }
  52080. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52081. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  52082. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52083. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52084. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52085. import { Nullable } from "babylonjs/types";
  52086. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52087. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52088. /**
  52089. * AmmoJS Physics plugin
  52090. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52091. * @see https://github.com/kripken/ammo.js/
  52092. */
  52093. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52094. private _useDeltaForWorldStep;
  52095. /**
  52096. * Reference to the Ammo library
  52097. */
  52098. bjsAMMO: any;
  52099. /**
  52100. * Created ammoJS world which physics bodies are added to
  52101. */
  52102. world: any;
  52103. /**
  52104. * Name of the plugin
  52105. */
  52106. name: string;
  52107. private _timeStep;
  52108. private _fixedTimeStep;
  52109. private _maxSteps;
  52110. private _tmpQuaternion;
  52111. private _tmpAmmoTransform;
  52112. private _tmpAmmoQuaternion;
  52113. private _tmpAmmoConcreteContactResultCallback;
  52114. private _collisionConfiguration;
  52115. private _dispatcher;
  52116. private _overlappingPairCache;
  52117. private _solver;
  52118. private _softBodySolver;
  52119. private _tmpAmmoVectorA;
  52120. private _tmpAmmoVectorB;
  52121. private _tmpAmmoVectorC;
  52122. private _tmpAmmoVectorD;
  52123. private _tmpContactCallbackResult;
  52124. private _tmpAmmoVectorRCA;
  52125. private _tmpAmmoVectorRCB;
  52126. private _raycastResult;
  52127. private static readonly DISABLE_COLLISION_FLAG;
  52128. private static readonly KINEMATIC_FLAG;
  52129. private static readonly DISABLE_DEACTIVATION_FLAG;
  52130. /**
  52131. * Initializes the ammoJS plugin
  52132. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52133. * @param ammoInjection can be used to inject your own ammo reference
  52134. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  52135. */
  52136. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  52137. /**
  52138. * Sets the gravity of the physics world (m/(s^2))
  52139. * @param gravity Gravity to set
  52140. */
  52141. setGravity(gravity: Vector3): void;
  52142. /**
  52143. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52144. * @param timeStep timestep to use in seconds
  52145. */
  52146. setTimeStep(timeStep: number): void;
  52147. /**
  52148. * 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)
  52149. * @param fixedTimeStep fixedTimeStep to use in seconds
  52150. */
  52151. setFixedTimeStep(fixedTimeStep: number): void;
  52152. /**
  52153. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52154. * @param maxSteps the maximum number of steps by the physics engine per frame
  52155. */
  52156. setMaxSteps(maxSteps: number): void;
  52157. /**
  52158. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52159. * @returns the current timestep in seconds
  52160. */
  52161. getTimeStep(): number;
  52162. private _isImpostorInContact;
  52163. private _isImpostorPairInContact;
  52164. private _stepSimulation;
  52165. /**
  52166. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52167. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52168. * After the step the babylon meshes are set to the position of the physics imposters
  52169. * @param delta amount of time to step forward
  52170. * @param impostors array of imposters to update before/after the step
  52171. */
  52172. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52173. /**
  52174. * Update babylon mesh to match physics world object
  52175. * @param impostor imposter to match
  52176. */
  52177. private _afterSoftStep;
  52178. /**
  52179. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52180. * @param impostor imposter to match
  52181. */
  52182. private _ropeStep;
  52183. /**
  52184. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52185. * @param impostor imposter to match
  52186. */
  52187. private _softbodyOrClothStep;
  52188. private _tmpVector;
  52189. private _tmpMatrix;
  52190. /**
  52191. * Applies an impulse on the imposter
  52192. * @param impostor imposter to apply impulse to
  52193. * @param force amount of force to be applied to the imposter
  52194. * @param contactPoint the location to apply the impulse on the imposter
  52195. */
  52196. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52197. /**
  52198. * Applies a force on the imposter
  52199. * @param impostor imposter to apply force
  52200. * @param force amount of force to be applied to the imposter
  52201. * @param contactPoint the location to apply the force on the imposter
  52202. */
  52203. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52204. /**
  52205. * Creates a physics body using the plugin
  52206. * @param impostor the imposter to create the physics body on
  52207. */
  52208. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52209. /**
  52210. * Removes the physics body from the imposter and disposes of the body's memory
  52211. * @param impostor imposter to remove the physics body from
  52212. */
  52213. removePhysicsBody(impostor: PhysicsImpostor): void;
  52214. /**
  52215. * Generates a joint
  52216. * @param impostorJoint the imposter joint to create the joint with
  52217. */
  52218. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52219. /**
  52220. * Removes a joint
  52221. * @param impostorJoint the imposter joint to remove the joint from
  52222. */
  52223. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52224. private _addMeshVerts;
  52225. /**
  52226. * Initialise the soft body vertices to match its object's (mesh) vertices
  52227. * Softbody vertices (nodes) are in world space and to match this
  52228. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  52229. * @param impostor to create the softbody for
  52230. */
  52231. private _softVertexData;
  52232. /**
  52233. * Create an impostor's soft body
  52234. * @param impostor to create the softbody for
  52235. */
  52236. private _createSoftbody;
  52237. /**
  52238. * Create cloth for an impostor
  52239. * @param impostor to create the softbody for
  52240. */
  52241. private _createCloth;
  52242. /**
  52243. * Create rope for an impostor
  52244. * @param impostor to create the softbody for
  52245. */
  52246. private _createRope;
  52247. private _addHullVerts;
  52248. private _createShape;
  52249. /**
  52250. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52251. * @param impostor imposter containing the physics body and babylon object
  52252. */
  52253. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52254. /**
  52255. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52256. * @param impostor imposter containing the physics body and babylon object
  52257. * @param newPosition new position
  52258. * @param newRotation new rotation
  52259. */
  52260. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52261. /**
  52262. * If this plugin is supported
  52263. * @returns true if its supported
  52264. */
  52265. isSupported(): boolean;
  52266. /**
  52267. * Sets the linear velocity of the physics body
  52268. * @param impostor imposter to set the velocity on
  52269. * @param velocity velocity to set
  52270. */
  52271. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52272. /**
  52273. * Sets the angular velocity of the physics body
  52274. * @param impostor imposter to set the velocity on
  52275. * @param velocity velocity to set
  52276. */
  52277. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52278. /**
  52279. * gets the linear velocity
  52280. * @param impostor imposter to get linear velocity from
  52281. * @returns linear velocity
  52282. */
  52283. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52284. /**
  52285. * gets the angular velocity
  52286. * @param impostor imposter to get angular velocity from
  52287. * @returns angular velocity
  52288. */
  52289. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52290. /**
  52291. * Sets the mass of physics body
  52292. * @param impostor imposter to set the mass on
  52293. * @param mass mass to set
  52294. */
  52295. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52296. /**
  52297. * Gets the mass of the physics body
  52298. * @param impostor imposter to get the mass from
  52299. * @returns mass
  52300. */
  52301. getBodyMass(impostor: PhysicsImpostor): number;
  52302. /**
  52303. * Gets friction of the impostor
  52304. * @param impostor impostor to get friction from
  52305. * @returns friction value
  52306. */
  52307. getBodyFriction(impostor: PhysicsImpostor): number;
  52308. /**
  52309. * Sets friction of the impostor
  52310. * @param impostor impostor to set friction on
  52311. * @param friction friction value
  52312. */
  52313. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52314. /**
  52315. * Gets restitution of the impostor
  52316. * @param impostor impostor to get restitution from
  52317. * @returns restitution value
  52318. */
  52319. getBodyRestitution(impostor: PhysicsImpostor): number;
  52320. /**
  52321. * Sets resitution of the impostor
  52322. * @param impostor impostor to set resitution on
  52323. * @param restitution resitution value
  52324. */
  52325. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52326. /**
  52327. * Gets pressure inside the impostor
  52328. * @param impostor impostor to get pressure from
  52329. * @returns pressure value
  52330. */
  52331. getBodyPressure(impostor: PhysicsImpostor): number;
  52332. /**
  52333. * Sets pressure inside a soft body impostor
  52334. * Cloth and rope must remain 0 pressure
  52335. * @param impostor impostor to set pressure on
  52336. * @param pressure pressure value
  52337. */
  52338. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  52339. /**
  52340. * Gets stiffness of the impostor
  52341. * @param impostor impostor to get stiffness from
  52342. * @returns pressure value
  52343. */
  52344. getBodyStiffness(impostor: PhysicsImpostor): number;
  52345. /**
  52346. * Sets stiffness of the impostor
  52347. * @param impostor impostor to set stiffness on
  52348. * @param stiffness stiffness value from 0 to 1
  52349. */
  52350. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  52351. /**
  52352. * Gets velocityIterations of the impostor
  52353. * @param impostor impostor to get velocity iterations from
  52354. * @returns velocityIterations value
  52355. */
  52356. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  52357. /**
  52358. * Sets velocityIterations of the impostor
  52359. * @param impostor impostor to set velocity iterations on
  52360. * @param velocityIterations velocityIterations value
  52361. */
  52362. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  52363. /**
  52364. * Gets positionIterations of the impostor
  52365. * @param impostor impostor to get position iterations from
  52366. * @returns positionIterations value
  52367. */
  52368. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  52369. /**
  52370. * Sets positionIterations of the impostor
  52371. * @param impostor impostor to set position on
  52372. * @param positionIterations positionIterations value
  52373. */
  52374. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  52375. /**
  52376. * Append an anchor to a cloth object
  52377. * @param impostor is the cloth impostor to add anchor to
  52378. * @param otherImpostor is the rigid impostor to anchor to
  52379. * @param width ratio across width from 0 to 1
  52380. * @param height ratio up height from 0 to 1
  52381. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  52382. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52383. */
  52384. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52385. /**
  52386. * Append an hook to a rope object
  52387. * @param impostor is the rope impostor to add hook to
  52388. * @param otherImpostor is the rigid impostor to hook to
  52389. * @param length ratio along the rope from 0 to 1
  52390. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  52391. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52392. */
  52393. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52394. /**
  52395. * Sleeps the physics body and stops it from being active
  52396. * @param impostor impostor to sleep
  52397. */
  52398. sleepBody(impostor: PhysicsImpostor): void;
  52399. /**
  52400. * Activates the physics body
  52401. * @param impostor impostor to activate
  52402. */
  52403. wakeUpBody(impostor: PhysicsImpostor): void;
  52404. /**
  52405. * Updates the distance parameters of the joint
  52406. * @param joint joint to update
  52407. * @param maxDistance maximum distance of the joint
  52408. * @param minDistance minimum distance of the joint
  52409. */
  52410. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52411. /**
  52412. * Sets a motor on the joint
  52413. * @param joint joint to set motor on
  52414. * @param speed speed of the motor
  52415. * @param maxForce maximum force of the motor
  52416. * @param motorIndex index of the motor
  52417. */
  52418. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52419. /**
  52420. * Sets the motors limit
  52421. * @param joint joint to set limit on
  52422. * @param upperLimit upper limit
  52423. * @param lowerLimit lower limit
  52424. */
  52425. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52426. /**
  52427. * Syncs the position and rotation of a mesh with the impostor
  52428. * @param mesh mesh to sync
  52429. * @param impostor impostor to update the mesh with
  52430. */
  52431. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52432. /**
  52433. * Gets the radius of the impostor
  52434. * @param impostor impostor to get radius from
  52435. * @returns the radius
  52436. */
  52437. getRadius(impostor: PhysicsImpostor): number;
  52438. /**
  52439. * Gets the box size of the impostor
  52440. * @param impostor impostor to get box size from
  52441. * @param result the resulting box size
  52442. */
  52443. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52444. /**
  52445. * Disposes of the impostor
  52446. */
  52447. dispose(): void;
  52448. /**
  52449. * Does a raycast in the physics world
  52450. * @param from when should the ray start?
  52451. * @param to when should the ray end?
  52452. * @returns PhysicsRaycastResult
  52453. */
  52454. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52455. }
  52456. }
  52457. declare module "babylonjs/Probes/reflectionProbe" {
  52458. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52459. import { Vector3 } from "babylonjs/Maths/math.vector";
  52460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52461. import { Nullable } from "babylonjs/types";
  52462. import { Scene } from "babylonjs/scene";
  52463. module "babylonjs/abstractScene" {
  52464. interface AbstractScene {
  52465. /**
  52466. * The list of reflection probes added to the scene
  52467. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52468. */
  52469. reflectionProbes: Array<ReflectionProbe>;
  52470. /**
  52471. * Removes the given reflection probe from this scene.
  52472. * @param toRemove The reflection probe to remove
  52473. * @returns The index of the removed reflection probe
  52474. */
  52475. removeReflectionProbe(toRemove: ReflectionProbe): number;
  52476. /**
  52477. * Adds the given reflection probe to this scene.
  52478. * @param newReflectionProbe The reflection probe to add
  52479. */
  52480. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  52481. }
  52482. }
  52483. /**
  52484. * Class used to generate realtime reflection / refraction cube textures
  52485. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52486. */
  52487. export class ReflectionProbe {
  52488. /** defines the name of the probe */
  52489. name: string;
  52490. private _scene;
  52491. private _renderTargetTexture;
  52492. private _projectionMatrix;
  52493. private _viewMatrix;
  52494. private _target;
  52495. private _add;
  52496. private _attachedMesh;
  52497. private _invertYAxis;
  52498. /** Gets or sets probe position (center of the cube map) */
  52499. position: Vector3;
  52500. /**
  52501. * Creates a new reflection probe
  52502. * @param name defines the name of the probe
  52503. * @param size defines the texture resolution (for each face)
  52504. * @param scene defines the hosting scene
  52505. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  52506. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  52507. */
  52508. constructor(
  52509. /** defines the name of the probe */
  52510. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  52511. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  52512. samples: number;
  52513. /** Gets or sets the refresh rate to use (on every frame by default) */
  52514. refreshRate: number;
  52515. /**
  52516. * Gets the hosting scene
  52517. * @returns a Scene
  52518. */
  52519. getScene(): Scene;
  52520. /** Gets the internal CubeTexture used to render to */
  52521. readonly cubeTexture: RenderTargetTexture;
  52522. /** Gets the list of meshes to render */
  52523. readonly renderList: Nullable<AbstractMesh[]>;
  52524. /**
  52525. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  52526. * @param mesh defines the mesh to attach to
  52527. */
  52528. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52529. /**
  52530. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  52531. * @param renderingGroupId The rendering group id corresponding to its index
  52532. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  52533. */
  52534. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  52535. /**
  52536. * Clean all associated resources
  52537. */
  52538. dispose(): void;
  52539. /**
  52540. * Converts the reflection probe information to a readable string for debug purpose.
  52541. * @param fullDetails Supports for multiple levels of logging within scene loading
  52542. * @returns the human readable reflection probe info
  52543. */
  52544. toString(fullDetails?: boolean): string;
  52545. /**
  52546. * Get the class name of the relfection probe.
  52547. * @returns "ReflectionProbe"
  52548. */
  52549. getClassName(): string;
  52550. /**
  52551. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  52552. * @returns The JSON representation of the texture
  52553. */
  52554. serialize(): any;
  52555. /**
  52556. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  52557. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  52558. * @param scene Define the scene the parsed reflection probe should be instantiated in
  52559. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  52560. * @returns The parsed reflection probe if successful
  52561. */
  52562. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  52563. }
  52564. }
  52565. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  52566. /** @hidden */
  52567. export var _BabylonLoaderRegistered: boolean;
  52568. }
  52569. declare module "babylonjs/Loading/Plugins/index" {
  52570. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  52571. }
  52572. declare module "babylonjs/Loading/index" {
  52573. export * from "babylonjs/Loading/loadingScreen";
  52574. export * from "babylonjs/Loading/Plugins/index";
  52575. export * from "babylonjs/Loading/sceneLoader";
  52576. export * from "babylonjs/Loading/sceneLoaderFlags";
  52577. }
  52578. declare module "babylonjs/Materials/Background/index" {
  52579. export * from "babylonjs/Materials/Background/backgroundMaterial";
  52580. }
  52581. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  52582. import { Scene } from "babylonjs/scene";
  52583. import { Color3 } from "babylonjs/Maths/math.color";
  52584. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52585. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52586. /**
  52587. * The Physically based simple base material of BJS.
  52588. *
  52589. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52590. * It is used as the base class for both the specGloss and metalRough conventions.
  52591. */
  52592. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  52593. /**
  52594. * Number of Simultaneous lights allowed on the material.
  52595. */
  52596. maxSimultaneousLights: number;
  52597. /**
  52598. * If sets to true, disables all the lights affecting the material.
  52599. */
  52600. disableLighting: boolean;
  52601. /**
  52602. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  52603. */
  52604. environmentTexture: BaseTexture;
  52605. /**
  52606. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52607. */
  52608. invertNormalMapX: boolean;
  52609. /**
  52610. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52611. */
  52612. invertNormalMapY: boolean;
  52613. /**
  52614. * Normal map used in the model.
  52615. */
  52616. normalTexture: BaseTexture;
  52617. /**
  52618. * Emissivie color used to self-illuminate the model.
  52619. */
  52620. emissiveColor: Color3;
  52621. /**
  52622. * Emissivie texture used to self-illuminate the model.
  52623. */
  52624. emissiveTexture: BaseTexture;
  52625. /**
  52626. * Occlusion Channel Strenght.
  52627. */
  52628. occlusionStrength: number;
  52629. /**
  52630. * Occlusion Texture of the material (adding extra occlusion effects).
  52631. */
  52632. occlusionTexture: BaseTexture;
  52633. /**
  52634. * Defines the alpha limits in alpha test mode.
  52635. */
  52636. alphaCutOff: number;
  52637. /**
  52638. * Gets the current double sided mode.
  52639. */
  52640. /**
  52641. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52642. */
  52643. doubleSided: boolean;
  52644. /**
  52645. * Stores the pre-calculated light information of a mesh in a texture.
  52646. */
  52647. lightmapTexture: BaseTexture;
  52648. /**
  52649. * If true, the light map contains occlusion information instead of lighting info.
  52650. */
  52651. useLightmapAsShadowmap: boolean;
  52652. /**
  52653. * Instantiates a new PBRMaterial instance.
  52654. *
  52655. * @param name The material name
  52656. * @param scene The scene the material will be use in.
  52657. */
  52658. constructor(name: string, scene: Scene);
  52659. getClassName(): string;
  52660. }
  52661. }
  52662. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  52663. import { Scene } from "babylonjs/scene";
  52664. import { Color3 } from "babylonjs/Maths/math.color";
  52665. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52666. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52667. /**
  52668. * The PBR material of BJS following the metal roughness convention.
  52669. *
  52670. * This fits to the PBR convention in the GLTF definition:
  52671. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52672. */
  52673. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  52674. /**
  52675. * The base color has two different interpretations depending on the value of metalness.
  52676. * When the material is a metal, the base color is the specific measured reflectance value
  52677. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  52678. * of the material.
  52679. */
  52680. baseColor: Color3;
  52681. /**
  52682. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  52683. * well as opacity information in the alpha channel.
  52684. */
  52685. baseTexture: BaseTexture;
  52686. /**
  52687. * Specifies the metallic scalar value of the material.
  52688. * Can also be used to scale the metalness values of the metallic texture.
  52689. */
  52690. metallic: number;
  52691. /**
  52692. * Specifies the roughness scalar value of the material.
  52693. * Can also be used to scale the roughness values of the metallic texture.
  52694. */
  52695. roughness: number;
  52696. /**
  52697. * Texture containing both the metallic value in the B channel and the
  52698. * roughness value in the G channel to keep better precision.
  52699. */
  52700. metallicRoughnessTexture: BaseTexture;
  52701. /**
  52702. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52703. *
  52704. * @param name The material name
  52705. * @param scene The scene the material will be use in.
  52706. */
  52707. constructor(name: string, scene: Scene);
  52708. /**
  52709. * Return the currrent class name of the material.
  52710. */
  52711. getClassName(): string;
  52712. /**
  52713. * Makes a duplicate of the current material.
  52714. * @param name - name to use for the new material.
  52715. */
  52716. clone(name: string): PBRMetallicRoughnessMaterial;
  52717. /**
  52718. * Serialize the material to a parsable JSON object.
  52719. */
  52720. serialize(): any;
  52721. /**
  52722. * Parses a JSON object correponding to the serialize function.
  52723. */
  52724. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  52725. }
  52726. }
  52727. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  52728. import { Scene } from "babylonjs/scene";
  52729. import { Color3 } from "babylonjs/Maths/math.color";
  52730. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52731. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52732. /**
  52733. * The PBR material of BJS following the specular glossiness convention.
  52734. *
  52735. * This fits to the PBR convention in the GLTF definition:
  52736. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  52737. */
  52738. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  52739. /**
  52740. * Specifies the diffuse color of the material.
  52741. */
  52742. diffuseColor: Color3;
  52743. /**
  52744. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  52745. * channel.
  52746. */
  52747. diffuseTexture: BaseTexture;
  52748. /**
  52749. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  52750. */
  52751. specularColor: Color3;
  52752. /**
  52753. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  52754. */
  52755. glossiness: number;
  52756. /**
  52757. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  52758. */
  52759. specularGlossinessTexture: BaseTexture;
  52760. /**
  52761. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  52762. *
  52763. * @param name The material name
  52764. * @param scene The scene the material will be use in.
  52765. */
  52766. constructor(name: string, scene: Scene);
  52767. /**
  52768. * Return the currrent class name of the material.
  52769. */
  52770. getClassName(): string;
  52771. /**
  52772. * Makes a duplicate of the current material.
  52773. * @param name - name to use for the new material.
  52774. */
  52775. clone(name: string): PBRSpecularGlossinessMaterial;
  52776. /**
  52777. * Serialize the material to a parsable JSON object.
  52778. */
  52779. serialize(): any;
  52780. /**
  52781. * Parses a JSON object correponding to the serialize function.
  52782. */
  52783. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  52784. }
  52785. }
  52786. declare module "babylonjs/Materials/PBR/index" {
  52787. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52788. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52789. export * from "babylonjs/Materials/PBR/pbrMaterial";
  52790. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  52791. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  52792. }
  52793. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  52794. import { Nullable } from "babylonjs/types";
  52795. import { Scene } from "babylonjs/scene";
  52796. import { Matrix } from "babylonjs/Maths/math.vector";
  52797. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52798. /**
  52799. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  52800. * It can help converting any input color in a desired output one. This can then be used to create effects
  52801. * from sepia, black and white to sixties or futuristic rendering...
  52802. *
  52803. * The only supported format is currently 3dl.
  52804. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  52805. */
  52806. export class ColorGradingTexture extends BaseTexture {
  52807. /**
  52808. * The current texture matrix. (will always be identity in color grading texture)
  52809. */
  52810. private _textureMatrix;
  52811. /**
  52812. * The texture URL.
  52813. */
  52814. url: string;
  52815. /**
  52816. * Empty line regex stored for GC.
  52817. */
  52818. private static _noneEmptyLineRegex;
  52819. private _engine;
  52820. /**
  52821. * Instantiates a ColorGradingTexture from the following parameters.
  52822. *
  52823. * @param url The location of the color gradind data (currently only supporting 3dl)
  52824. * @param scene The scene the texture will be used in
  52825. */
  52826. constructor(url: string, scene: Scene);
  52827. /**
  52828. * Returns the texture matrix used in most of the material.
  52829. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  52830. */
  52831. getTextureMatrix(): Matrix;
  52832. /**
  52833. * Occurs when the file being loaded is a .3dl LUT file.
  52834. */
  52835. private load3dlTexture;
  52836. /**
  52837. * Starts the loading process of the texture.
  52838. */
  52839. private loadTexture;
  52840. /**
  52841. * Clones the color gradind texture.
  52842. */
  52843. clone(): ColorGradingTexture;
  52844. /**
  52845. * Called during delayed load for textures.
  52846. */
  52847. delayLoad(): void;
  52848. /**
  52849. * Parses a color grading texture serialized by Babylon.
  52850. * @param parsedTexture The texture information being parsedTexture
  52851. * @param scene The scene to load the texture in
  52852. * @param rootUrl The root url of the data assets to load
  52853. * @return A color gradind texture
  52854. */
  52855. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52856. /**
  52857. * Serializes the LUT texture to json format.
  52858. */
  52859. serialize(): any;
  52860. }
  52861. }
  52862. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  52863. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52864. import { Scene } from "babylonjs/scene";
  52865. import { Nullable } from "babylonjs/types";
  52866. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52867. /**
  52868. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52869. */
  52870. export class EquiRectangularCubeTexture extends BaseTexture {
  52871. /** The six faces of the cube. */
  52872. private static _FacesMapping;
  52873. private _noMipmap;
  52874. private _onLoad;
  52875. private _onError;
  52876. /** The size of the cubemap. */
  52877. private _size;
  52878. /** The buffer of the image. */
  52879. private _buffer;
  52880. /** The width of the input image. */
  52881. private _width;
  52882. /** The height of the input image. */
  52883. private _height;
  52884. /** The URL to the image. */
  52885. url: string;
  52886. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52887. coordinatesMode: number;
  52888. /**
  52889. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52890. * @param url The location of the image
  52891. * @param scene The scene the texture will be used in
  52892. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52893. * @param noMipmap Forces to not generate the mipmap if true
  52894. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52895. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52896. * @param onLoad — defines a callback called when texture is loaded
  52897. * @param onError — defines a callback called if there is an error
  52898. */
  52899. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52900. /**
  52901. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52902. */
  52903. private loadImage;
  52904. /**
  52905. * Convert the image buffer into a cubemap and create a CubeTexture.
  52906. */
  52907. private loadTexture;
  52908. /**
  52909. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52910. * @param buffer The ArrayBuffer that should be converted.
  52911. * @returns The buffer as Float32Array.
  52912. */
  52913. private getFloat32ArrayFromArrayBuffer;
  52914. /**
  52915. * Get the current class name of the texture useful for serialization or dynamic coding.
  52916. * @returns "EquiRectangularCubeTexture"
  52917. */
  52918. getClassName(): string;
  52919. /**
  52920. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52921. * @returns A clone of the current EquiRectangularCubeTexture.
  52922. */
  52923. clone(): EquiRectangularCubeTexture;
  52924. }
  52925. }
  52926. declare module "babylonjs/Misc/tga" {
  52927. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52928. /**
  52929. * Based on jsTGALoader - Javascript loader for TGA file
  52930. * By Vincent Thibault
  52931. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52932. */
  52933. export class TGATools {
  52934. private static _TYPE_INDEXED;
  52935. private static _TYPE_RGB;
  52936. private static _TYPE_GREY;
  52937. private static _TYPE_RLE_INDEXED;
  52938. private static _TYPE_RLE_RGB;
  52939. private static _TYPE_RLE_GREY;
  52940. private static _ORIGIN_MASK;
  52941. private static _ORIGIN_SHIFT;
  52942. private static _ORIGIN_BL;
  52943. private static _ORIGIN_BR;
  52944. private static _ORIGIN_UL;
  52945. private static _ORIGIN_UR;
  52946. /**
  52947. * Gets the header of a TGA file
  52948. * @param data defines the TGA data
  52949. * @returns the header
  52950. */
  52951. static GetTGAHeader(data: Uint8Array): any;
  52952. /**
  52953. * Uploads TGA content to a Babylon Texture
  52954. * @hidden
  52955. */
  52956. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52957. /** @hidden */
  52958. 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;
  52959. /** @hidden */
  52960. 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;
  52961. /** @hidden */
  52962. 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;
  52963. /** @hidden */
  52964. 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;
  52965. /** @hidden */
  52966. 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;
  52967. /** @hidden */
  52968. 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;
  52969. }
  52970. }
  52971. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  52972. import { Nullable } from "babylonjs/types";
  52973. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52974. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52975. /**
  52976. * Implementation of the TGA Texture Loader.
  52977. * @hidden
  52978. */
  52979. export class _TGATextureLoader implements IInternalTextureLoader {
  52980. /**
  52981. * Defines wether the loader supports cascade loading the different faces.
  52982. */
  52983. readonly supportCascades: boolean;
  52984. /**
  52985. * This returns if the loader support the current file information.
  52986. * @param extension defines the file extension of the file being loaded
  52987. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52988. * @param fallback defines the fallback internal texture if any
  52989. * @param isBase64 defines whether the texture is encoded as a base64
  52990. * @param isBuffer defines whether the texture data are stored as a buffer
  52991. * @returns true if the loader can load the specified file
  52992. */
  52993. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52994. /**
  52995. * Transform the url before loading if required.
  52996. * @param rootUrl the url of the texture
  52997. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52998. * @returns the transformed texture
  52999. */
  53000. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53001. /**
  53002. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53003. * @param rootUrl the url of the texture
  53004. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53005. * @returns the fallback texture
  53006. */
  53007. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53008. /**
  53009. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53010. * @param data contains the texture data
  53011. * @param texture defines the BabylonJS internal texture
  53012. * @param createPolynomials will be true if polynomials have been requested
  53013. * @param onLoad defines the callback to trigger once the texture is ready
  53014. * @param onError defines the callback to trigger in case of error
  53015. */
  53016. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53017. /**
  53018. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53019. * @param data contains the texture data
  53020. * @param texture defines the BabylonJS internal texture
  53021. * @param callback defines the method to call once ready to upload
  53022. */
  53023. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53024. }
  53025. }
  53026. declare module "babylonjs/Misc/basis" {
  53027. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53028. /**
  53029. * Info about the .basis files
  53030. */
  53031. class BasisFileInfo {
  53032. /**
  53033. * If the file has alpha
  53034. */
  53035. hasAlpha: boolean;
  53036. /**
  53037. * Info about each image of the basis file
  53038. */
  53039. images: Array<{
  53040. levels: Array<{
  53041. width: number;
  53042. height: number;
  53043. transcodedPixels: ArrayBufferView;
  53044. }>;
  53045. }>;
  53046. }
  53047. /**
  53048. * Result of transcoding a basis file
  53049. */
  53050. class TranscodeResult {
  53051. /**
  53052. * Info about the .basis file
  53053. */
  53054. fileInfo: BasisFileInfo;
  53055. /**
  53056. * Format to use when loading the file
  53057. */
  53058. format: number;
  53059. }
  53060. /**
  53061. * Configuration options for the Basis transcoder
  53062. */
  53063. export class BasisTranscodeConfiguration {
  53064. /**
  53065. * Supported compression formats used to determine the supported output format of the transcoder
  53066. */
  53067. supportedCompressionFormats?: {
  53068. /**
  53069. * etc1 compression format
  53070. */
  53071. etc1?: boolean;
  53072. /**
  53073. * s3tc compression format
  53074. */
  53075. s3tc?: boolean;
  53076. /**
  53077. * pvrtc compression format
  53078. */
  53079. pvrtc?: boolean;
  53080. /**
  53081. * etc2 compression format
  53082. */
  53083. etc2?: boolean;
  53084. };
  53085. /**
  53086. * If mipmap levels should be loaded for transcoded images (Default: true)
  53087. */
  53088. loadMipmapLevels?: boolean;
  53089. /**
  53090. * Index of a single image to load (Default: all images)
  53091. */
  53092. loadSingleImage?: number;
  53093. }
  53094. /**
  53095. * Used to load .Basis files
  53096. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  53097. */
  53098. export class BasisTools {
  53099. private static _IgnoreSupportedFormats;
  53100. /**
  53101. * URL to use when loading the basis transcoder
  53102. */
  53103. static JSModuleURL: string;
  53104. /**
  53105. * URL to use when loading the wasm module for the transcoder
  53106. */
  53107. static WasmModuleURL: string;
  53108. /**
  53109. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  53110. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  53111. * @returns internal format corresponding to the Basis format
  53112. */
  53113. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  53114. private static _WorkerPromise;
  53115. private static _Worker;
  53116. private static _actionId;
  53117. private static _CreateWorkerAsync;
  53118. /**
  53119. * Transcodes a loaded image file to compressed pixel data
  53120. * @param imageData image data to transcode
  53121. * @param config configuration options for the transcoding
  53122. * @returns a promise resulting in the transcoded image
  53123. */
  53124. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  53125. /**
  53126. * Loads a texture from the transcode result
  53127. * @param texture texture load to
  53128. * @param transcodeResult the result of transcoding the basis file to load from
  53129. */
  53130. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  53131. }
  53132. }
  53133. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  53134. import { Nullable } from "babylonjs/types";
  53135. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53136. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53137. /**
  53138. * Loader for .basis file format
  53139. */
  53140. export class _BasisTextureLoader implements IInternalTextureLoader {
  53141. /**
  53142. * Defines whether the loader supports cascade loading the different faces.
  53143. */
  53144. readonly supportCascades: boolean;
  53145. /**
  53146. * This returns if the loader support the current file information.
  53147. * @param extension defines the file extension of the file being loaded
  53148. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53149. * @param fallback defines the fallback internal texture if any
  53150. * @param isBase64 defines whether the texture is encoded as a base64
  53151. * @param isBuffer defines whether the texture data are stored as a buffer
  53152. * @returns true if the loader can load the specified file
  53153. */
  53154. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53155. /**
  53156. * Transform the url before loading if required.
  53157. * @param rootUrl the url of the texture
  53158. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53159. * @returns the transformed texture
  53160. */
  53161. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53162. /**
  53163. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53164. * @param rootUrl the url of the texture
  53165. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53166. * @returns the fallback texture
  53167. */
  53168. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53169. /**
  53170. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  53171. * @param data contains the texture data
  53172. * @param texture defines the BabylonJS internal texture
  53173. * @param createPolynomials will be true if polynomials have been requested
  53174. * @param onLoad defines the callback to trigger once the texture is ready
  53175. * @param onError defines the callback to trigger in case of error
  53176. */
  53177. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53178. /**
  53179. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53180. * @param data contains the texture data
  53181. * @param texture defines the BabylonJS internal texture
  53182. * @param callback defines the method to call once ready to upload
  53183. */
  53184. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53185. }
  53186. }
  53187. declare module "babylonjs/Materials/Textures/Loaders/index" {
  53188. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  53189. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  53190. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  53191. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  53192. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  53193. }
  53194. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  53195. import { Scene } from "babylonjs/scene";
  53196. import { Texture } from "babylonjs/Materials/Textures/texture";
  53197. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53198. /**
  53199. * 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.
  53200. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53201. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53202. */
  53203. export class CustomProceduralTexture extends ProceduralTexture {
  53204. private _animate;
  53205. private _time;
  53206. private _config;
  53207. private _texturePath;
  53208. /**
  53209. * Instantiates a new Custom Procedural Texture.
  53210. * 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.
  53211. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53212. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53213. * @param name Define the name of the texture
  53214. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  53215. * @param size Define the size of the texture to create
  53216. * @param scene Define the scene the texture belongs to
  53217. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53218. * @param generateMipMaps Define if the texture should creates mip maps or not
  53219. */
  53220. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53221. private _loadJson;
  53222. /**
  53223. * Is the texture ready to be used ? (rendered at least once)
  53224. * @returns true if ready, otherwise, false.
  53225. */
  53226. isReady(): boolean;
  53227. /**
  53228. * Render the texture to its associated render target.
  53229. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  53230. */
  53231. render(useCameraPostProcess?: boolean): void;
  53232. /**
  53233. * Update the list of dependant textures samplers in the shader.
  53234. */
  53235. updateTextures(): void;
  53236. /**
  53237. * Update the uniform values of the procedural texture in the shader.
  53238. */
  53239. updateShaderUniforms(): void;
  53240. /**
  53241. * Define if the texture animates or not.
  53242. */
  53243. animate: boolean;
  53244. }
  53245. }
  53246. declare module "babylonjs/Shaders/noise.fragment" {
  53247. /** @hidden */
  53248. export var noisePixelShader: {
  53249. name: string;
  53250. shader: string;
  53251. };
  53252. }
  53253. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  53254. import { Nullable } from "babylonjs/types";
  53255. import { Scene } from "babylonjs/scene";
  53256. import { Texture } from "babylonjs/Materials/Textures/texture";
  53257. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53258. import "babylonjs/Shaders/noise.fragment";
  53259. /**
  53260. * Class used to generate noise procedural textures
  53261. */
  53262. export class NoiseProceduralTexture extends ProceduralTexture {
  53263. private _time;
  53264. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  53265. brightness: number;
  53266. /** Defines the number of octaves to process */
  53267. octaves: number;
  53268. /** Defines the level of persistence (0.8 by default) */
  53269. persistence: number;
  53270. /** Gets or sets animation speed factor (default is 1) */
  53271. animationSpeedFactor: number;
  53272. /**
  53273. * Creates a new NoiseProceduralTexture
  53274. * @param name defines the name fo the texture
  53275. * @param size defines the size of the texture (default is 256)
  53276. * @param scene defines the hosting scene
  53277. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  53278. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  53279. */
  53280. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53281. private _updateShaderUniforms;
  53282. protected _getDefines(): string;
  53283. /** Generate the current state of the procedural texture */
  53284. render(useCameraPostProcess?: boolean): void;
  53285. /**
  53286. * Serializes this noise procedural texture
  53287. * @returns a serialized noise procedural texture object
  53288. */
  53289. serialize(): any;
  53290. /**
  53291. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  53292. * @param parsedTexture defines parsed texture data
  53293. * @param scene defines the current scene
  53294. * @param rootUrl defines the root URL containing noise procedural texture information
  53295. * @returns a parsed NoiseProceduralTexture
  53296. */
  53297. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  53298. }
  53299. }
  53300. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  53301. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  53302. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  53303. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53304. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  53305. }
  53306. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  53307. import { Nullable } from "babylonjs/types";
  53308. import { Scene } from "babylonjs/scene";
  53309. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53310. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53311. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  53312. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53313. /**
  53314. * Raw cube texture where the raw buffers are passed in
  53315. */
  53316. export class RawCubeTexture extends CubeTexture {
  53317. /**
  53318. * Creates a cube texture where the raw buffers are passed in.
  53319. * @param scene defines the scene the texture is attached to
  53320. * @param data defines the array of data to use to create each face
  53321. * @param size defines the size of the textures
  53322. * @param format defines the format of the data
  53323. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  53324. * @param generateMipMaps defines if the engine should generate the mip levels
  53325. * @param invertY defines if data must be stored with Y axis inverted
  53326. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  53327. * @param compression defines the compression used (null by default)
  53328. */
  53329. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  53330. /**
  53331. * Updates the raw cube texture.
  53332. * @param data defines the data to store
  53333. * @param format defines the data format
  53334. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53335. * @param invertY defines if data must be stored with Y axis inverted
  53336. * @param compression defines the compression used (null by default)
  53337. * @param level defines which level of the texture to update
  53338. */
  53339. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  53340. /**
  53341. * Updates a raw cube texture with RGBD encoded data.
  53342. * @param data defines the array of data [mipmap][face] to use to create each face
  53343. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  53344. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53345. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53346. * @returns a promsie that resolves when the operation is complete
  53347. */
  53348. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  53349. /**
  53350. * Clones the raw cube texture.
  53351. * @return a new cube texture
  53352. */
  53353. clone(): CubeTexture;
  53354. /** @hidden */
  53355. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53356. }
  53357. }
  53358. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  53359. import { Scene } from "babylonjs/scene";
  53360. import { Texture } from "babylonjs/Materials/Textures/texture";
  53361. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53362. /**
  53363. * Class used to store 3D textures containing user data
  53364. */
  53365. export class RawTexture3D extends Texture {
  53366. /** Gets or sets the texture format to use */
  53367. format: number;
  53368. private _engine;
  53369. /**
  53370. * Create a new RawTexture3D
  53371. * @param data defines the data of the texture
  53372. * @param width defines the width of the texture
  53373. * @param height defines the height of the texture
  53374. * @param depth defines the depth of the texture
  53375. * @param format defines the texture format to use
  53376. * @param scene defines the hosting scene
  53377. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53378. * @param invertY defines if texture must be stored with Y axis inverted
  53379. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53380. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53381. */
  53382. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53383. /** Gets or sets the texture format to use */
  53384. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53385. /**
  53386. * Update the texture with new data
  53387. * @param data defines the data to store in the texture
  53388. */
  53389. update(data: ArrayBufferView): void;
  53390. }
  53391. }
  53392. declare module "babylonjs/Materials/Textures/refractionTexture" {
  53393. import { Scene } from "babylonjs/scene";
  53394. import { Plane } from "babylonjs/Maths/math.plane";
  53395. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53396. /**
  53397. * Creates a refraction texture used by refraction channel of the standard material.
  53398. * It is like a mirror but to see through a material.
  53399. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53400. */
  53401. export class RefractionTexture extends RenderTargetTexture {
  53402. /**
  53403. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  53404. * 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.
  53405. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53406. */
  53407. refractionPlane: Plane;
  53408. /**
  53409. * Define how deep under the surface we should see.
  53410. */
  53411. depth: number;
  53412. /**
  53413. * Creates a refraction texture used by refraction channel of the standard material.
  53414. * It is like a mirror but to see through a material.
  53415. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53416. * @param name Define the texture name
  53417. * @param size Define the size of the underlying texture
  53418. * @param scene Define the scene the refraction belongs to
  53419. * @param generateMipMaps Define if we need to generate mips level for the refraction
  53420. */
  53421. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  53422. /**
  53423. * Clone the refraction texture.
  53424. * @returns the cloned texture
  53425. */
  53426. clone(): RefractionTexture;
  53427. /**
  53428. * Serialize the texture to a JSON representation you could use in Parse later on
  53429. * @returns the serialized JSON representation
  53430. */
  53431. serialize(): any;
  53432. }
  53433. }
  53434. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  53435. import { Nullable } from "babylonjs/types";
  53436. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53437. import { Matrix } from "babylonjs/Maths/math.vector";
  53438. import { Engine } from "babylonjs/Engines/engine";
  53439. import { Scene } from "babylonjs/scene";
  53440. /**
  53441. * Defines the options related to the creation of an HtmlElementTexture
  53442. */
  53443. export interface IHtmlElementTextureOptions {
  53444. /**
  53445. * Defines wether mip maps should be created or not.
  53446. */
  53447. generateMipMaps?: boolean;
  53448. /**
  53449. * Defines the sampling mode of the texture.
  53450. */
  53451. samplingMode?: number;
  53452. /**
  53453. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  53454. */
  53455. engine: Nullable<Engine>;
  53456. /**
  53457. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  53458. */
  53459. scene: Nullable<Scene>;
  53460. }
  53461. /**
  53462. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  53463. * To be as efficient as possible depending on your constraints nothing aside the first upload
  53464. * is automatically managed.
  53465. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  53466. * in your application.
  53467. *
  53468. * As the update is not automatic, you need to call them manually.
  53469. */
  53470. export class HtmlElementTexture extends BaseTexture {
  53471. /**
  53472. * The texture URL.
  53473. */
  53474. element: HTMLVideoElement | HTMLCanvasElement;
  53475. private static readonly DefaultOptions;
  53476. private _textureMatrix;
  53477. private _engine;
  53478. private _isVideo;
  53479. private _generateMipMaps;
  53480. private _samplingMode;
  53481. /**
  53482. * Instantiates a HtmlElementTexture from the following parameters.
  53483. *
  53484. * @param name Defines the name of the texture
  53485. * @param element Defines the video or canvas the texture is filled with
  53486. * @param options Defines the other none mandatory texture creation options
  53487. */
  53488. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  53489. private _createInternalTexture;
  53490. /**
  53491. * Returns the texture matrix used in most of the material.
  53492. */
  53493. getTextureMatrix(): Matrix;
  53494. /**
  53495. * Updates the content of the texture.
  53496. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  53497. */
  53498. update(invertY?: Nullable<boolean>): void;
  53499. }
  53500. }
  53501. declare module "babylonjs/Materials/Textures/index" {
  53502. export * from "babylonjs/Materials/Textures/baseTexture";
  53503. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  53504. export * from "babylonjs/Materials/Textures/cubeTexture";
  53505. export * from "babylonjs/Materials/Textures/dynamicTexture";
  53506. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  53507. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  53508. export * from "babylonjs/Materials/Textures/internalTexture";
  53509. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  53510. export * from "babylonjs/Materials/Textures/Loaders/index";
  53511. export * from "babylonjs/Materials/Textures/mirrorTexture";
  53512. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  53513. export * from "babylonjs/Materials/Textures/Procedurals/index";
  53514. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  53515. export * from "babylonjs/Materials/Textures/rawTexture";
  53516. export * from "babylonjs/Materials/Textures/rawTexture3D";
  53517. export * from "babylonjs/Materials/Textures/refractionTexture";
  53518. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  53519. export * from "babylonjs/Materials/Textures/texture";
  53520. export * from "babylonjs/Materials/Textures/videoTexture";
  53521. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  53522. }
  53523. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  53524. /**
  53525. * Enum used to define the target of a block
  53526. */
  53527. export enum NodeMaterialBlockTargets {
  53528. /** Vertex shader */
  53529. Vertex = 1,
  53530. /** Fragment shader */
  53531. Fragment = 2,
  53532. /** Neutral */
  53533. Neutral = 4,
  53534. /** Vertex and Fragment */
  53535. VertexAndFragment = 3
  53536. }
  53537. }
  53538. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  53539. /**
  53540. * Defines the kind of connection point for node based material
  53541. */
  53542. export enum NodeMaterialBlockConnectionPointTypes {
  53543. /** Float */
  53544. Float = 1,
  53545. /** Int */
  53546. Int = 2,
  53547. /** Vector2 */
  53548. Vector2 = 4,
  53549. /** Vector3 */
  53550. Vector3 = 8,
  53551. /** Vector4 */
  53552. Vector4 = 16,
  53553. /** Color3 */
  53554. Color3 = 32,
  53555. /** Color4 */
  53556. Color4 = 64,
  53557. /** Matrix */
  53558. Matrix = 128,
  53559. /** Vector3 or Color3 */
  53560. Vector3OrColor3 = 40,
  53561. /** Vector3 or Vector4 */
  53562. Vector3OrVector4 = 24,
  53563. /** Vector4 or Color4 */
  53564. Vector4OrColor4 = 80,
  53565. /** Color3 or Color4 */
  53566. Color3OrColor4 = 96,
  53567. /** Vector2 or Color3 or Color4 */
  53568. Vector2OrColor3OrColor4 = 100,
  53569. /** Vector3 or Color3 or Color4 or Vector4 */
  53570. Vector3OrColor3OrVector4OrColor4 = 120,
  53571. /** Vector2 or Vector3 or Color3 or Color4 or Vector4 */
  53572. Vector2OrVector3OrColor3OrVector4OrColor4 = 124,
  53573. /** Detect type based on connection */
  53574. AutoDetect = 1024,
  53575. /** Output type that will be defined by input type */
  53576. BasedOnInput = 2048
  53577. }
  53578. }
  53579. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  53580. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53581. /**
  53582. * Root class for all node material optimizers
  53583. */
  53584. export class NodeMaterialOptimizer {
  53585. /**
  53586. * Function used to optimize a NodeMaterial graph
  53587. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53588. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53589. */
  53590. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53591. }
  53592. }
  53593. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  53594. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53595. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53596. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53597. import { Scene } from "babylonjs/scene";
  53598. /**
  53599. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  53600. */
  53601. export class TransformBlock extends NodeMaterialBlock {
  53602. /**
  53603. * Defines the value to use to complement W value to transform it to a Vector4
  53604. */
  53605. complementW: number;
  53606. /**
  53607. * Defines the value to use to complement z value to transform it to a Vector4
  53608. */
  53609. complementZ: number;
  53610. /**
  53611. * Creates a new TransformBlock
  53612. * @param name defines the block name
  53613. */
  53614. constructor(name: string);
  53615. /**
  53616. * Gets the current class name
  53617. * @returns the class name
  53618. */
  53619. getClassName(): string;
  53620. /**
  53621. * Gets the vector input
  53622. */
  53623. readonly vector: NodeMaterialConnectionPoint;
  53624. /**
  53625. * Gets the output component
  53626. */
  53627. readonly output: NodeMaterialConnectionPoint;
  53628. /**
  53629. * Gets the matrix transform input
  53630. */
  53631. readonly transform: NodeMaterialConnectionPoint;
  53632. protected _buildBlock(state: NodeMaterialBuildState): this;
  53633. serialize(): any;
  53634. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53635. }
  53636. }
  53637. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  53638. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53639. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53640. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53641. /**
  53642. * Block used to output the vertex position
  53643. */
  53644. export class VertexOutputBlock extends NodeMaterialBlock {
  53645. /**
  53646. * Creates a new VertexOutputBlock
  53647. * @param name defines the block name
  53648. */
  53649. constructor(name: string);
  53650. /**
  53651. * Gets the current class name
  53652. * @returns the class name
  53653. */
  53654. getClassName(): string;
  53655. /**
  53656. * Gets the vector input component
  53657. */
  53658. readonly vector: NodeMaterialConnectionPoint;
  53659. protected _buildBlock(state: NodeMaterialBuildState): this;
  53660. }
  53661. }
  53662. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  53663. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53664. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53665. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53666. /**
  53667. * Block used to output the final color
  53668. */
  53669. export class FragmentOutputBlock extends NodeMaterialBlock {
  53670. /**
  53671. * Create a new FragmentOutputBlock
  53672. * @param name defines the block name
  53673. */
  53674. constructor(name: string);
  53675. /**
  53676. * Gets the current class name
  53677. * @returns the class name
  53678. */
  53679. getClassName(): string;
  53680. /**
  53681. * Gets the rgba input component
  53682. */
  53683. readonly rgba: NodeMaterialConnectionPoint;
  53684. /**
  53685. * Gets the rgb input component
  53686. */
  53687. readonly rgb: NodeMaterialConnectionPoint;
  53688. /**
  53689. * Gets the a input component
  53690. */
  53691. readonly a: NodeMaterialConnectionPoint;
  53692. protected _buildBlock(state: NodeMaterialBuildState): this;
  53693. }
  53694. }
  53695. declare module "babylonjs/Materials/Node/nodeMaterial" {
  53696. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53697. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53698. import { Scene } from "babylonjs/scene";
  53699. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53700. import { Matrix } from "babylonjs/Maths/math.vector";
  53701. import { Mesh } from "babylonjs/Meshes/mesh";
  53702. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53703. import { Observable } from "babylonjs/Misc/observable";
  53704. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53705. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53706. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  53707. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53708. import { Nullable } from "babylonjs/types";
  53709. /**
  53710. * Interface used to configure the node material editor
  53711. */
  53712. export interface INodeMaterialEditorOptions {
  53713. /** Define the URl to load node editor script */
  53714. editorURL?: string;
  53715. }
  53716. /** @hidden */
  53717. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53718. /** BONES */
  53719. NUM_BONE_INFLUENCERS: number;
  53720. BonesPerMesh: number;
  53721. BONETEXTURE: boolean;
  53722. /** MORPH TARGETS */
  53723. MORPHTARGETS: boolean;
  53724. MORPHTARGETS_NORMAL: boolean;
  53725. MORPHTARGETS_TANGENT: boolean;
  53726. MORPHTARGETS_UV: boolean;
  53727. NUM_MORPH_INFLUENCERS: number;
  53728. /** IMAGE PROCESSING */
  53729. IMAGEPROCESSING: boolean;
  53730. VIGNETTE: boolean;
  53731. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53732. VIGNETTEBLENDMODEOPAQUE: boolean;
  53733. TONEMAPPING: boolean;
  53734. TONEMAPPING_ACES: boolean;
  53735. CONTRAST: boolean;
  53736. EXPOSURE: boolean;
  53737. COLORCURVES: boolean;
  53738. COLORGRADING: boolean;
  53739. COLORGRADING3D: boolean;
  53740. SAMPLER3DGREENDEPTH: boolean;
  53741. SAMPLER3DBGRMAP: boolean;
  53742. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53743. constructor();
  53744. setValue(name: string, value: boolean): void;
  53745. }
  53746. /**
  53747. * Class used to configure NodeMaterial
  53748. */
  53749. export interface INodeMaterialOptions {
  53750. /**
  53751. * Defines if blocks should emit comments
  53752. */
  53753. emitComments: boolean;
  53754. }
  53755. /**
  53756. * Class used to create a node based material built by assembling shader blocks
  53757. */
  53758. export class NodeMaterial extends PushMaterial {
  53759. private _options;
  53760. private _vertexCompilationState;
  53761. private _fragmentCompilationState;
  53762. private _sharedData;
  53763. private _buildId;
  53764. private _buildWasSuccessful;
  53765. private _cachedWorldViewMatrix;
  53766. private _cachedWorldViewProjectionMatrix;
  53767. private _optimizers;
  53768. /** Define the URl to load node editor script */
  53769. static EditorURL: string;
  53770. private BJSNODEMATERIALEDITOR;
  53771. /** Get the inspector from bundle or global */
  53772. private _getGlobalNodeMaterialEditor;
  53773. /**
  53774. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  53775. */
  53776. ignoreAlpha: boolean;
  53777. /**
  53778. * Defines the maximum number of lights that can be used in the material
  53779. */
  53780. maxSimultaneousLights: number;
  53781. /**
  53782. * Observable raised when the material is built
  53783. */
  53784. onBuildObservable: Observable<NodeMaterial>;
  53785. /**
  53786. * Gets or sets the root nodes of the material vertex shader
  53787. */
  53788. _vertexOutputNodes: NodeMaterialBlock[];
  53789. /**
  53790. * Gets or sets the root nodes of the material fragment (pixel) shader
  53791. */
  53792. _fragmentOutputNodes: NodeMaterialBlock[];
  53793. /** Gets or sets options to control the node material overall behavior */
  53794. options: INodeMaterialOptions;
  53795. /**
  53796. * Default configuration related to image processing available in the standard Material.
  53797. */
  53798. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53799. /**
  53800. * Gets the image processing configuration used either in this material.
  53801. */
  53802. /**
  53803. * Sets the Default image processing configuration used either in the this material.
  53804. *
  53805. * If sets to null, the scene one is in use.
  53806. */
  53807. imageProcessingConfiguration: ImageProcessingConfiguration;
  53808. /**
  53809. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  53810. */
  53811. attachedBlocks: NodeMaterialBlock[];
  53812. /**
  53813. * Create a new node based material
  53814. * @param name defines the material name
  53815. * @param scene defines the hosting scene
  53816. * @param options defines creation option
  53817. */
  53818. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  53819. /**
  53820. * Gets the current class name of the material e.g. "NodeMaterial"
  53821. * @returns the class name
  53822. */
  53823. getClassName(): string;
  53824. /**
  53825. * Keep track of the image processing observer to allow dispose and replace.
  53826. */
  53827. private _imageProcessingObserver;
  53828. /**
  53829. * Attaches a new image processing configuration to the Standard Material.
  53830. * @param configuration
  53831. */
  53832. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53833. /**
  53834. * Adds a new optimizer to the list of optimizers
  53835. * @param optimizer defines the optimizers to add
  53836. * @returns the current material
  53837. */
  53838. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53839. /**
  53840. * Remove an optimizer from the list of optimizers
  53841. * @param optimizer defines the optimizers to remove
  53842. * @returns the current material
  53843. */
  53844. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53845. /**
  53846. * Add a new block to the list of output nodes
  53847. * @param node defines the node to add
  53848. * @returns the current material
  53849. */
  53850. addOutputNode(node: NodeMaterialBlock): this;
  53851. /**
  53852. * Remove a block from the list of root nodes
  53853. * @param node defines the node to remove
  53854. * @returns the current material
  53855. */
  53856. removeOutputNode(node: NodeMaterialBlock): this;
  53857. private _addVertexOutputNode;
  53858. private _removeVertexOutputNode;
  53859. private _addFragmentOutputNode;
  53860. private _removeFragmentOutputNode;
  53861. /**
  53862. * Specifies if the material will require alpha blending
  53863. * @returns a boolean specifying if alpha blending is needed
  53864. */
  53865. needAlphaBlending(): boolean;
  53866. /**
  53867. * Specifies if this material should be rendered in alpha test mode
  53868. * @returns a boolean specifying if an alpha test is needed.
  53869. */
  53870. needAlphaTesting(): boolean;
  53871. private _initializeBlock;
  53872. private _resetDualBlocks;
  53873. /**
  53874. * Build the material and generates the inner effect
  53875. * @param verbose defines if the build should log activity
  53876. */
  53877. build(verbose?: boolean): void;
  53878. /**
  53879. * Runs an otpimization phase to try to improve the shader code
  53880. */
  53881. optimize(): void;
  53882. private _prepareDefinesForAttributes;
  53883. /**
  53884. * Get if the submesh is ready to be used and all its information available.
  53885. * Child classes can use it to update shaders
  53886. * @param mesh defines the mesh to check
  53887. * @param subMesh defines which submesh to check
  53888. * @param useInstances specifies that instances should be used
  53889. * @returns a boolean indicating that the submesh is ready or not
  53890. */
  53891. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53892. /**
  53893. * Get a string representing the shaders built by the current node graph
  53894. */
  53895. readonly compiledShaders: string;
  53896. /**
  53897. * Binds the world matrix to the material
  53898. * @param world defines the world transformation matrix
  53899. */
  53900. bindOnlyWorldMatrix(world: Matrix): void;
  53901. /**
  53902. * Binds the submesh to this material by preparing the effect and shader to draw
  53903. * @param world defines the world transformation matrix
  53904. * @param mesh defines the mesh containing the submesh
  53905. * @param subMesh defines the submesh to bind the material to
  53906. */
  53907. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53908. /**
  53909. * Gets the active textures from the material
  53910. * @returns an array of textures
  53911. */
  53912. getActiveTextures(): BaseTexture[];
  53913. /**
  53914. * Specifies if the material uses a texture
  53915. * @param texture defines the texture to check against the material
  53916. * @returns a boolean specifying if the material uses the texture
  53917. */
  53918. hasTexture(texture: BaseTexture): boolean;
  53919. /**
  53920. * Disposes the material
  53921. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53922. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53923. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53924. */
  53925. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53926. /** Creates the node editor window. */
  53927. private _createNodeEditor;
  53928. /**
  53929. * Launch the node material editor
  53930. * @param config Define the configuration of the editor
  53931. * @return a promise fulfilled when the node editor is visible
  53932. */
  53933. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53934. /**
  53935. * Clear the current material
  53936. */
  53937. clear(): void;
  53938. /**
  53939. * Clear the current material and set it to a default state
  53940. */
  53941. setToDefault(): void;
  53942. private _gatherBlocks;
  53943. /**
  53944. * Serializes this material in a JSON representation
  53945. * @returns the serialized material object
  53946. */
  53947. serialize(): any;
  53948. /**
  53949. * Clear the current graph and load a new one from a serialization object
  53950. * @param source defines the JSON representation of the material
  53951. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53952. */
  53953. loadFromSerialization(source: any, rootUrl?: string): void;
  53954. /**
  53955. * Creates a node material from parsed material data
  53956. * @param source defines the JSON representation of the material
  53957. * @param scene defines the hosting scene
  53958. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53959. * @returns a new node material
  53960. */
  53961. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  53962. }
  53963. }
  53964. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  53965. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53966. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53967. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53968. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  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. import { Nullable } from "babylonjs/types";
  53974. import { Scene } from "babylonjs/scene";
  53975. /**
  53976. * Block used to read a texture from a sampler
  53977. */
  53978. export class TextureBlock extends NodeMaterialBlock {
  53979. private _defineName;
  53980. private _samplerName;
  53981. private _transformedUVName;
  53982. private _textureTransformName;
  53983. private _textureInfoName;
  53984. private _mainUVName;
  53985. private _mainUVDefineName;
  53986. /**
  53987. * Gets or sets the texture associated with the node
  53988. */
  53989. texture: Nullable<BaseTexture>;
  53990. /**
  53991. * Create a new TextureBlock
  53992. * @param name defines the block name
  53993. */
  53994. constructor(name: string);
  53995. /**
  53996. * Gets the current class name
  53997. * @returns the class name
  53998. */
  53999. getClassName(): string;
  54000. /**
  54001. * Gets the uv input component
  54002. */
  54003. readonly uv: NodeMaterialConnectionPoint;
  54004. /**
  54005. * Gets the output component
  54006. */
  54007. readonly output: NodeMaterialConnectionPoint;
  54008. autoConfigure(): void;
  54009. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54010. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54011. isReady(): boolean;
  54012. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54013. private _injectVertexCode;
  54014. private _writeOutput;
  54015. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54016. serialize(): any;
  54017. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54018. }
  54019. }
  54020. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  54021. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54022. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54023. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54024. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54025. /**
  54026. * Class used to store shared data between 2 NodeMaterialBuildState
  54027. */
  54028. export class NodeMaterialBuildStateSharedData {
  54029. /**
  54030. * Gets the list of emitted varyings
  54031. */
  54032. varyings: string[];
  54033. /**
  54034. * Gets the varying declaration string
  54035. */
  54036. varyingDeclaration: string;
  54037. /**
  54038. * Input blocks
  54039. */
  54040. inputBlocks: InputBlock[];
  54041. /**
  54042. * Input blocks
  54043. */
  54044. textureBlocks: TextureBlock[];
  54045. /**
  54046. * Bindable blocks (Blocks that need to set data to the effect)
  54047. */
  54048. bindableBlocks: NodeMaterialBlock[];
  54049. /**
  54050. * List of blocks that can provide a compilation fallback
  54051. */
  54052. blocksWithFallbacks: NodeMaterialBlock[];
  54053. /**
  54054. * List of blocks that can provide a define update
  54055. */
  54056. blocksWithDefines: NodeMaterialBlock[];
  54057. /**
  54058. * List of blocks that can provide a repeatable content
  54059. */
  54060. repeatableContentBlocks: NodeMaterialBlock[];
  54061. /**
  54062. * List of blocks that can provide a dynamic list of uniforms
  54063. */
  54064. dynamicUniformBlocks: NodeMaterialBlock[];
  54065. /**
  54066. * List of blocks that can block the isReady function for the material
  54067. */
  54068. blockingBlocks: NodeMaterialBlock[];
  54069. /**
  54070. * Build Id used to avoid multiple recompilations
  54071. */
  54072. buildId: number;
  54073. /** List of emitted variables */
  54074. variableNames: {
  54075. [key: string]: number;
  54076. };
  54077. /** List of emitted defines */
  54078. defineNames: {
  54079. [key: string]: number;
  54080. };
  54081. /** Should emit comments? */
  54082. emitComments: boolean;
  54083. /** Emit build activity */
  54084. verbose: boolean;
  54085. /**
  54086. * Gets the compilation hints emitted at compilation time
  54087. */
  54088. hints: {
  54089. needWorldViewMatrix: boolean;
  54090. needWorldViewProjectionMatrix: boolean;
  54091. needAlphaBlending: boolean;
  54092. needAlphaTesting: boolean;
  54093. };
  54094. /**
  54095. * List of compilation checks
  54096. */
  54097. checks: {
  54098. emitVertex: boolean;
  54099. emitFragment: boolean;
  54100. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  54101. };
  54102. /** Creates a new shared data */
  54103. constructor();
  54104. /**
  54105. * Emits console errors and exceptions if there is a failing check
  54106. */
  54107. emitErrors(): void;
  54108. }
  54109. }
  54110. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  54111. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54112. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54113. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  54114. /**
  54115. * Class used to store node based material build state
  54116. */
  54117. export class NodeMaterialBuildState {
  54118. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  54119. supportUniformBuffers: boolean;
  54120. /**
  54121. * Gets the list of emitted attributes
  54122. */
  54123. attributes: string[];
  54124. /**
  54125. * Gets the list of emitted uniforms
  54126. */
  54127. uniforms: string[];
  54128. /**
  54129. * Gets the list of emitted uniform buffers
  54130. */
  54131. uniformBuffers: string[];
  54132. /**
  54133. * Gets the list of emitted samplers
  54134. */
  54135. samplers: string[];
  54136. /**
  54137. * Gets the list of emitted functions
  54138. */
  54139. functions: {
  54140. [key: string]: string;
  54141. };
  54142. /**
  54143. * Gets the target of the compilation state
  54144. */
  54145. target: NodeMaterialBlockTargets;
  54146. /**
  54147. * Gets the list of emitted counters
  54148. */
  54149. counters: {
  54150. [key: string]: number;
  54151. };
  54152. /**
  54153. * Shared data between multiple NodeMaterialBuildState instances
  54154. */
  54155. sharedData: NodeMaterialBuildStateSharedData;
  54156. /** @hidden */
  54157. _vertexState: NodeMaterialBuildState;
  54158. /** @hidden */
  54159. _attributeDeclaration: string;
  54160. /** @hidden */
  54161. _uniformDeclaration: string;
  54162. /** @hidden */
  54163. _samplerDeclaration: string;
  54164. /** @hidden */
  54165. _varyingTransfer: string;
  54166. private _repeatableContentAnchorIndex;
  54167. /** @hidden */
  54168. _builtCompilationString: string;
  54169. /**
  54170. * Gets the emitted compilation strings
  54171. */
  54172. compilationString: string;
  54173. /**
  54174. * Finalize the compilation strings
  54175. * @param state defines the current compilation state
  54176. */
  54177. finalize(state: NodeMaterialBuildState): void;
  54178. /** @hidden */
  54179. readonly _repeatableContentAnchor: string;
  54180. /** @hidden */
  54181. _getFreeVariableName(prefix: string): string;
  54182. /** @hidden */
  54183. _getFreeDefineName(prefix: string): string;
  54184. /** @hidden */
  54185. _excludeVariableName(name: string): void;
  54186. /** @hidden */
  54187. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  54188. /** @hidden */
  54189. _emitFunction(name: string, code: string, comments: string): void;
  54190. /** @hidden */
  54191. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  54192. replaceStrings?: {
  54193. search: RegExp;
  54194. replace: string;
  54195. }[];
  54196. repeatKey?: string;
  54197. }): string;
  54198. /** @hidden */
  54199. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  54200. repeatKey?: string;
  54201. removeAttributes?: boolean;
  54202. removeUniforms?: boolean;
  54203. removeVaryings?: boolean;
  54204. removeIfDef?: boolean;
  54205. replaceStrings?: {
  54206. search: RegExp;
  54207. replace: string;
  54208. }[];
  54209. }, storeKey?: string): void;
  54210. /** @hidden */
  54211. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54212. /** @hidden */
  54213. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54214. }
  54215. }
  54216. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  54217. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54218. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54219. import { Nullable } from "babylonjs/types";
  54220. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54221. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54222. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54223. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54224. import { Mesh } from "babylonjs/Meshes/mesh";
  54225. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54226. import { Scene } from "babylonjs/scene";
  54227. /**
  54228. * Defines a block that can be used inside a node based material
  54229. */
  54230. export class NodeMaterialBlock {
  54231. private _buildId;
  54232. private _buildTarget;
  54233. private _target;
  54234. private _isFinalMerger;
  54235. private _isInput;
  54236. /** @hidden */
  54237. _inputs: NodeMaterialConnectionPoint[];
  54238. /** @hidden */
  54239. _outputs: NodeMaterialConnectionPoint[];
  54240. /**
  54241. * Gets or sets the name of the block
  54242. */
  54243. name: string;
  54244. /**
  54245. * Gets or sets the unique id of the node
  54246. */
  54247. uniqueId: number;
  54248. /**
  54249. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  54250. */
  54251. readonly isFinalMerger: boolean;
  54252. /**
  54253. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  54254. */
  54255. readonly isInput: boolean;
  54256. /**
  54257. * Gets or sets the build Id
  54258. */
  54259. buildId: number;
  54260. /**
  54261. * Gets or sets the target of the block
  54262. */
  54263. target: NodeMaterialBlockTargets;
  54264. /**
  54265. * Gets the list of input points
  54266. */
  54267. readonly inputs: NodeMaterialConnectionPoint[];
  54268. /** Gets the list of output points */
  54269. readonly outputs: NodeMaterialConnectionPoint[];
  54270. /**
  54271. * Find an input by its name
  54272. * @param name defines the name of the input to look for
  54273. * @returns the input or null if not found
  54274. */
  54275. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54276. /**
  54277. * Find an output by its name
  54278. * @param name defines the name of the outputto look for
  54279. * @returns the output or null if not found
  54280. */
  54281. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54282. /**
  54283. * Creates a new NodeMaterialBlock
  54284. * @param name defines the block name
  54285. * @param target defines the target of that block (Vertex by default)
  54286. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  54287. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  54288. */
  54289. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  54290. /**
  54291. * Initialize the block and prepare the context for build
  54292. * @param state defines the state that will be used for the build
  54293. */
  54294. initialize(state: NodeMaterialBuildState): void;
  54295. /**
  54296. * Bind data to effect. Will only be called for blocks with isBindable === true
  54297. * @param effect defines the effect to bind data to
  54298. * @param nodeMaterial defines the hosting NodeMaterial
  54299. * @param mesh defines the mesh that will be rendered
  54300. */
  54301. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54302. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  54303. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  54304. protected _writeFloat(value: number): string;
  54305. /**
  54306. * Gets the current class name e.g. "NodeMaterialBlock"
  54307. * @returns the class name
  54308. */
  54309. getClassName(): string;
  54310. /**
  54311. * Register a new input. Must be called inside a block constructor
  54312. * @param name defines the connection point name
  54313. * @param type defines the connection point type
  54314. * @param isOptional defines a boolean indicating that this input can be omitted
  54315. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  54316. * @returns the current block
  54317. */
  54318. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  54319. /**
  54320. * Register a new output. Must be called inside a block constructor
  54321. * @param name defines the connection point name
  54322. * @param type defines the connection point type
  54323. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  54324. * @returns the current block
  54325. */
  54326. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  54327. /**
  54328. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  54329. * @param forOutput defines an optional connection point to check compatibility with
  54330. * @returns the first available input or null
  54331. */
  54332. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  54333. /**
  54334. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  54335. * @param forBlock defines an optional block to check compatibility with
  54336. * @returns the first available input or null
  54337. */
  54338. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  54339. /**
  54340. * Connect current block with another block
  54341. * @param other defines the block to connect with
  54342. * @param options define the various options to help pick the right connections
  54343. * @returns the current block
  54344. */
  54345. connectTo(other: NodeMaterialBlock, options?: {
  54346. input?: string;
  54347. output?: string;
  54348. outputSwizzle?: string;
  54349. }): this | undefined;
  54350. protected _buildBlock(state: NodeMaterialBuildState): void;
  54351. /**
  54352. * Add uniforms, samplers and uniform buffers at compilation time
  54353. * @param state defines the state to update
  54354. * @param nodeMaterial defines the node material requesting the update
  54355. * @param defines defines the material defines to update
  54356. */
  54357. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54358. /**
  54359. * Add potential fallbacks if shader compilation fails
  54360. * @param mesh defines the mesh to be rendered
  54361. * @param fallbacks defines the current prioritized list of fallbacks
  54362. */
  54363. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54364. /**
  54365. * Update defines for shader compilation
  54366. * @param mesh defines the mesh to be rendered
  54367. * @param nodeMaterial defines the node material requesting the update
  54368. * @param defines defines the material defines to update
  54369. * @param useInstances specifies that instances should be used
  54370. */
  54371. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54372. /**
  54373. * Initialize defines for shader compilation
  54374. * @param mesh defines the mesh to be rendered
  54375. * @param nodeMaterial defines the node material requesting the update
  54376. * @param defines defines the material defines to be prepared
  54377. * @param useInstances specifies that instances should be used
  54378. */
  54379. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54380. /**
  54381. * Lets the block try to connect some inputs automatically
  54382. */
  54383. autoConfigure(): void;
  54384. /**
  54385. * Function called when a block is declared as repeatable content generator
  54386. * @param vertexShaderState defines the current compilation state for the vertex shader
  54387. * @param fragmentShaderState defines the current compilation state for the fragment shader
  54388. * @param mesh defines the mesh to be rendered
  54389. * @param defines defines the material defines to update
  54390. */
  54391. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54392. /**
  54393. * Checks if the block is ready
  54394. * @param mesh defines the mesh to be rendered
  54395. * @param nodeMaterial defines the node material requesting the update
  54396. * @param defines defines the material defines to update
  54397. * @param useInstances specifies that instances should be used
  54398. * @returns true if the block is ready
  54399. */
  54400. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  54401. private _processBuild;
  54402. /**
  54403. * Compile the current node and generate the shader code
  54404. * @param state defines the current compilation state (uniforms, samplers, current string)
  54405. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  54406. * @returns true if already built
  54407. */
  54408. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  54409. /**
  54410. * Serializes this block in a JSON representation
  54411. * @returns the serialized block object
  54412. */
  54413. serialize(): any;
  54414. /** @hidden */
  54415. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54416. }
  54417. }
  54418. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  54419. /**
  54420. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54421. */
  54422. export enum NodeMaterialBlockConnectionPointMode {
  54423. /** Value is an uniform */
  54424. Uniform = 0,
  54425. /** Value is a mesh attribute */
  54426. Attribute = 1,
  54427. /** Value is a varying between vertex and fragment shaders */
  54428. Varying = 2,
  54429. /** Mode is undefined */
  54430. Undefined = 3
  54431. }
  54432. }
  54433. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  54434. /**
  54435. * Enum used to define well known values e.g. values automatically provided by the system
  54436. */
  54437. export enum NodeMaterialWellKnownValues {
  54438. /** World */
  54439. World = 1,
  54440. /** View */
  54441. View = 2,
  54442. /** Projection */
  54443. Projection = 3,
  54444. /** ViewProjection */
  54445. ViewProjection = 4,
  54446. /** WorldView */
  54447. WorldView = 5,
  54448. /** WorldViewProjection */
  54449. WorldViewProjection = 6,
  54450. /** CameraPosition */
  54451. CameraPosition = 7,
  54452. /** Fog Color */
  54453. FogColor = 8
  54454. }
  54455. }
  54456. declare module "babylonjs/Maths/math.vertexFormat" {
  54457. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  54458. /**
  54459. * Contains position and normal vectors for a vertex
  54460. */
  54461. export class PositionNormalVertex {
  54462. /** the position of the vertex (defaut: 0,0,0) */
  54463. position: Vector3;
  54464. /** the normal of the vertex (defaut: 0,1,0) */
  54465. normal: Vector3;
  54466. /**
  54467. * Creates a PositionNormalVertex
  54468. * @param position the position of the vertex (defaut: 0,0,0)
  54469. * @param normal the normal of the vertex (defaut: 0,1,0)
  54470. */
  54471. constructor(
  54472. /** the position of the vertex (defaut: 0,0,0) */
  54473. position?: Vector3,
  54474. /** the normal of the vertex (defaut: 0,1,0) */
  54475. normal?: Vector3);
  54476. /**
  54477. * Clones the PositionNormalVertex
  54478. * @returns the cloned PositionNormalVertex
  54479. */
  54480. clone(): PositionNormalVertex;
  54481. }
  54482. /**
  54483. * Contains position, normal and uv vectors for a vertex
  54484. */
  54485. export class PositionNormalTextureVertex {
  54486. /** the position of the vertex (defaut: 0,0,0) */
  54487. position: Vector3;
  54488. /** the normal of the vertex (defaut: 0,1,0) */
  54489. normal: Vector3;
  54490. /** the uv of the vertex (default: 0,0) */
  54491. uv: Vector2;
  54492. /**
  54493. * Creates a PositionNormalTextureVertex
  54494. * @param position the position of the vertex (defaut: 0,0,0)
  54495. * @param normal the normal of the vertex (defaut: 0,1,0)
  54496. * @param uv the uv of the vertex (default: 0,0)
  54497. */
  54498. constructor(
  54499. /** the position of the vertex (defaut: 0,0,0) */
  54500. position?: Vector3,
  54501. /** the normal of the vertex (defaut: 0,1,0) */
  54502. normal?: Vector3,
  54503. /** the uv of the vertex (default: 0,0) */
  54504. uv?: Vector2);
  54505. /**
  54506. * Clones the PositionNormalTextureVertex
  54507. * @returns the cloned PositionNormalTextureVertex
  54508. */
  54509. clone(): PositionNormalTextureVertex;
  54510. }
  54511. }
  54512. declare module "babylonjs/Maths/math" {
  54513. export * from "babylonjs/Maths/math.axis";
  54514. export * from "babylonjs/Maths/math.color";
  54515. export * from "babylonjs/Maths/math.constants";
  54516. export * from "babylonjs/Maths/math.frustum";
  54517. export * from "babylonjs/Maths/math.path";
  54518. export * from "babylonjs/Maths/math.plane";
  54519. export * from "babylonjs/Maths/math.size";
  54520. export * from "babylonjs/Maths/math.vector";
  54521. export * from "babylonjs/Maths/math.vertexFormat";
  54522. export * from "babylonjs/Maths/math.viewport";
  54523. }
  54524. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  54525. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54526. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54527. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  54528. import { Nullable } from "babylonjs/types";
  54529. import { Effect } from "babylonjs/Materials/effect";
  54530. import { Matrix } from "babylonjs/Maths/math.vector";
  54531. import { Scene } from "babylonjs/scene";
  54532. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54533. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54534. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54535. /**
  54536. * Block used to expose an input value
  54537. */
  54538. export class InputBlock extends NodeMaterialBlock {
  54539. private _mode;
  54540. private _associatedVariableName;
  54541. private _storedValue;
  54542. private _valueCallback;
  54543. private _type;
  54544. /** @hidden */
  54545. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  54546. /**
  54547. * Gets or sets the connection point type (default is float)
  54548. */
  54549. readonly type: NodeMaterialBlockConnectionPointTypes;
  54550. /**
  54551. * Creates a new InputBlock
  54552. * @param name defines the block name
  54553. * @param target defines the target of that block (Vertex by default)
  54554. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  54555. */
  54556. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  54557. /**
  54558. * Gets the output component
  54559. */
  54560. readonly output: NodeMaterialConnectionPoint;
  54561. /**
  54562. * Set the source of this connection point to a vertex attribute
  54563. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  54564. * @returns the current connection point
  54565. */
  54566. setAsAttribute(attributeName?: string): InputBlock;
  54567. /**
  54568. * Set the source of this connection point to a well known value
  54569. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  54570. * @returns the current connection point
  54571. */
  54572. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  54573. /**
  54574. * Gets or sets the value of that point.
  54575. * Please note that this value will be ignored if valueCallback is defined
  54576. */
  54577. value: any;
  54578. /**
  54579. * Gets or sets a callback used to get the value of that point.
  54580. * Please note that setting this value will force the connection point to ignore the value property
  54581. */
  54582. valueCallback: () => any;
  54583. /**
  54584. * Gets or sets the associated variable name in the shader
  54585. */
  54586. associatedVariableName: string;
  54587. /**
  54588. * Gets a boolean indicating that this connection point not defined yet
  54589. */
  54590. readonly isUndefined: boolean;
  54591. /**
  54592. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  54593. * In this case the connection point name must be the name of the uniform to use.
  54594. * Can only be set on inputs
  54595. */
  54596. isUniform: boolean;
  54597. /**
  54598. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  54599. * In this case the connection point name must be the name of the attribute to use
  54600. * Can only be set on inputs
  54601. */
  54602. isAttribute: boolean;
  54603. /**
  54604. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  54605. * Can only be set on exit points
  54606. */
  54607. isVarying: boolean;
  54608. /**
  54609. * Gets a boolean indicating that the current connection point is a well known value
  54610. */
  54611. readonly isWellKnownValue: boolean;
  54612. /**
  54613. * Gets or sets the current well known value or null if not defined as well know value
  54614. */
  54615. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  54616. /**
  54617. * Gets the current class name
  54618. * @returns the class name
  54619. */
  54620. getClassName(): string;
  54621. private _emitDefine;
  54622. /**
  54623. * Set the input block to its default value (based on its type)
  54624. */
  54625. setDefaultValue(): void;
  54626. private _emit;
  54627. /** @hidden */
  54628. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  54629. /** @hidden */
  54630. _transmit(effect: Effect, scene: Scene): void;
  54631. protected _buildBlock(state: NodeMaterialBuildState): void;
  54632. serialize(): any;
  54633. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54634. }
  54635. }
  54636. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  54637. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54638. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54639. import { Nullable } from "babylonjs/types";
  54640. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54641. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54642. /**
  54643. * Defines a connection point for a block
  54644. */
  54645. export class NodeMaterialConnectionPoint {
  54646. /** @hidden */
  54647. _ownerBlock: NodeMaterialBlock;
  54648. /** @hidden */
  54649. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54650. private _endpoints;
  54651. private _associatedVariableName;
  54652. /** @hidden */
  54653. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  54654. private _type;
  54655. /** @hidden */
  54656. _enforceAssociatedVariableName: boolean;
  54657. /**
  54658. * Gets or sets the associated variable name in the shader
  54659. */
  54660. associatedVariableName: string;
  54661. /**
  54662. * Gets or sets the connection point type (default is float)
  54663. */
  54664. type: NodeMaterialBlockConnectionPointTypes;
  54665. /**
  54666. * Gets or sets the connection point name
  54667. */
  54668. name: string;
  54669. /**
  54670. * Gets or sets the swizzle to apply to this connection point when reading or writing
  54671. */
  54672. swizzle: string;
  54673. /**
  54674. * Gets or sets a boolean indicating that this connection point can be omitted
  54675. */
  54676. isOptional: boolean;
  54677. /**
  54678. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  54679. */
  54680. define: string;
  54681. /** Gets or sets the target of that connection point */
  54682. target: NodeMaterialBlockTargets;
  54683. /**
  54684. * Gets a boolean indicating that the current point is connected
  54685. */
  54686. readonly isConnected: boolean;
  54687. /**
  54688. * Gets a boolean indicating that the current point is connected to an input block
  54689. */
  54690. readonly isConnectedToInput: boolean;
  54691. /**
  54692. * Gets a the connected input block (if any)
  54693. */
  54694. readonly connectInputBlock: Nullable<InputBlock>;
  54695. /** Get the other side of the connection (if any) */
  54696. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54697. /** Get the block that owns this connection point */
  54698. readonly ownerBlock: NodeMaterialBlock;
  54699. /** Get the block connected on the other side of this connection (if any) */
  54700. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  54701. /** Get the block connected on the endpoints of this connection (if any) */
  54702. readonly connectedBlocks: Array<NodeMaterialBlock>;
  54703. /** Gets the list of connected endpoints */
  54704. readonly endpoints: NodeMaterialConnectionPoint[];
  54705. /**
  54706. * Creates a new connection point
  54707. * @param name defines the connection point name
  54708. * @param ownerBlock defines the block hosting this connection point
  54709. */
  54710. constructor(name: string, ownerBlock: NodeMaterialBlock);
  54711. /**
  54712. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  54713. * @returns the class name
  54714. */
  54715. getClassName(): string;
  54716. /**
  54717. * Gets an boolean indicating if the current point can be connected to another point
  54718. * @param connectionPoint defines the other connection point
  54719. * @returns true if the connection is possible
  54720. */
  54721. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  54722. /**
  54723. * Connect this point to another connection point
  54724. * @param connectionPoint defines the other connection point
  54725. * @returns the current connection point
  54726. */
  54727. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  54728. /**
  54729. * Disconnect this point from one of his endpoint
  54730. * @param endpoint defines the other connection point
  54731. * @returns the current connection point
  54732. */
  54733. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  54734. /**
  54735. * Serializes this point in a JSON representation
  54736. * @returns the serialized point object
  54737. */
  54738. serialize(): any;
  54739. private static _GetTypeLength;
  54740. }
  54741. }
  54742. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  54743. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54744. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54745. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54746. import { Mesh } from "babylonjs/Meshes/mesh";
  54747. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54748. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54749. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54750. /**
  54751. * Block used to add support for vertex skinning (bones)
  54752. */
  54753. export class BonesBlock extends NodeMaterialBlock {
  54754. /**
  54755. * Creates a new BonesBlock
  54756. * @param name defines the block name
  54757. */
  54758. constructor(name: string);
  54759. /**
  54760. * Initialize the block and prepare the context for build
  54761. * @param state defines the state that will be used for the build
  54762. */
  54763. initialize(state: NodeMaterialBuildState): void;
  54764. /**
  54765. * Gets the current class name
  54766. * @returns the class name
  54767. */
  54768. getClassName(): string;
  54769. /**
  54770. * Gets the matrix indices input component
  54771. */
  54772. readonly matricesIndices: NodeMaterialConnectionPoint;
  54773. /**
  54774. * Gets the matrix weights input component
  54775. */
  54776. readonly matricesWeights: NodeMaterialConnectionPoint;
  54777. /**
  54778. * Gets the extra matrix indices input component
  54779. */
  54780. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  54781. /**
  54782. * Gets the extra matrix weights input component
  54783. */
  54784. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  54785. /**
  54786. * Gets the world input component
  54787. */
  54788. readonly world: NodeMaterialConnectionPoint;
  54789. /**
  54790. * Gets the output component
  54791. */
  54792. readonly output: NodeMaterialConnectionPoint;
  54793. autoConfigure(): void;
  54794. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54795. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54796. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54797. protected _buildBlock(state: NodeMaterialBuildState): this;
  54798. }
  54799. }
  54800. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  54801. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54802. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54803. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54805. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54806. /**
  54807. * Block used to add support for instances
  54808. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  54809. */
  54810. export class InstancesBlock extends NodeMaterialBlock {
  54811. /**
  54812. * Creates a new InstancesBlock
  54813. * @param name defines the block name
  54814. */
  54815. constructor(name: string);
  54816. /**
  54817. * Gets the current class name
  54818. * @returns the class name
  54819. */
  54820. getClassName(): string;
  54821. /**
  54822. * Gets the first world row input component
  54823. */
  54824. readonly world0: NodeMaterialConnectionPoint;
  54825. /**
  54826. * Gets the second world row input component
  54827. */
  54828. readonly world1: NodeMaterialConnectionPoint;
  54829. /**
  54830. * Gets the third world row input component
  54831. */
  54832. readonly world2: NodeMaterialConnectionPoint;
  54833. /**
  54834. * Gets the forth world row input component
  54835. */
  54836. readonly world3: NodeMaterialConnectionPoint;
  54837. /**
  54838. * Gets the world input component
  54839. */
  54840. readonly world: NodeMaterialConnectionPoint;
  54841. /**
  54842. * Gets the output component
  54843. */
  54844. readonly output: NodeMaterialConnectionPoint;
  54845. autoConfigure(): void;
  54846. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54847. protected _buildBlock(state: NodeMaterialBuildState): this;
  54848. }
  54849. }
  54850. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  54851. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54852. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54853. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54854. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54855. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54856. import { Effect } from "babylonjs/Materials/effect";
  54857. import { Mesh } from "babylonjs/Meshes/mesh";
  54858. /**
  54859. * Block used to add morph targets support to vertex shader
  54860. */
  54861. export class MorphTargetsBlock extends NodeMaterialBlock {
  54862. private _repeatableContentAnchor;
  54863. private _repeatebleContentGenerated;
  54864. /**
  54865. * Create a new MorphTargetsBlock
  54866. * @param name defines the block name
  54867. */
  54868. constructor(name: string);
  54869. /**
  54870. * Gets the current class name
  54871. * @returns the class name
  54872. */
  54873. getClassName(): string;
  54874. /**
  54875. * Gets the position input component
  54876. */
  54877. readonly position: NodeMaterialConnectionPoint;
  54878. /**
  54879. * Gets the normal input component
  54880. */
  54881. readonly normal: NodeMaterialConnectionPoint;
  54882. /**
  54883. * Gets the tangent input component
  54884. */
  54885. readonly tangent: NodeMaterialConnectionPoint;
  54886. /**
  54887. * Gets the tangent input component
  54888. */
  54889. readonly uv: NodeMaterialConnectionPoint;
  54890. /**
  54891. * Gets the position output component
  54892. */
  54893. readonly positionOutput: NodeMaterialConnectionPoint;
  54894. /**
  54895. * Gets the normal output component
  54896. */
  54897. readonly normalOutput: NodeMaterialConnectionPoint;
  54898. /**
  54899. * Gets the tangent output component
  54900. */
  54901. readonly tangentOutput: NodeMaterialConnectionPoint;
  54902. /**
  54903. * Gets the tangent output component
  54904. */
  54905. readonly uvOutput: NodeMaterialConnectionPoint;
  54906. initialize(state: NodeMaterialBuildState): void;
  54907. autoConfigure(): void;
  54908. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54909. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54910. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54911. protected _buildBlock(state: NodeMaterialBuildState): this;
  54912. }
  54913. }
  54914. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  54915. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  54916. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  54917. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  54918. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  54919. }
  54920. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  54921. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54922. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54923. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54924. /**
  54925. * Block used to add an alpha test in the fragment shader
  54926. */
  54927. export class AlphaTestBlock extends NodeMaterialBlock {
  54928. /**
  54929. * Gets or sets the alpha value where alpha testing happens
  54930. */
  54931. alphaCutOff: number;
  54932. /**
  54933. * Create a new AlphaTestBlock
  54934. * @param name defines the block name
  54935. */
  54936. constructor(name: string);
  54937. /**
  54938. * Gets the current class name
  54939. * @returns the class name
  54940. */
  54941. getClassName(): string;
  54942. /**
  54943. * Gets the color input component
  54944. */
  54945. readonly color: NodeMaterialConnectionPoint;
  54946. protected _buildBlock(state: NodeMaterialBuildState): this;
  54947. }
  54948. }
  54949. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  54950. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54951. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54952. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54953. /**
  54954. * Block used to create a Color3/4 out of individual inputs (one for each component)
  54955. */
  54956. export class ColorMergerBlock extends NodeMaterialBlock {
  54957. /**
  54958. * Create a new ColorMergerBlock
  54959. * @param name defines the block name
  54960. */
  54961. constructor(name: string);
  54962. /**
  54963. * Gets the current class name
  54964. * @returns the class name
  54965. */
  54966. getClassName(): string;
  54967. /**
  54968. * Gets the r component (input)
  54969. */
  54970. readonly r: NodeMaterialConnectionPoint;
  54971. /**
  54972. * Gets the g component (input)
  54973. */
  54974. readonly g: NodeMaterialConnectionPoint;
  54975. /**
  54976. * Gets the b component (input)
  54977. */
  54978. readonly b: NodeMaterialConnectionPoint;
  54979. /**
  54980. * Gets the a component (input)
  54981. */
  54982. readonly a: NodeMaterialConnectionPoint;
  54983. /**
  54984. * Gets the rgba component (output)
  54985. */
  54986. readonly rgba: NodeMaterialConnectionPoint;
  54987. /**
  54988. * Gets the rgb component (output)
  54989. */
  54990. readonly rgb: NodeMaterialConnectionPoint;
  54991. protected _buildBlock(state: NodeMaterialBuildState): this;
  54992. }
  54993. }
  54994. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  54995. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54996. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54997. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54998. /**
  54999. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  55000. */
  55001. export class VectorMergerBlock extends NodeMaterialBlock {
  55002. /**
  55003. * Create a new VectorMergerBlock
  55004. * @param name defines the block name
  55005. */
  55006. constructor(name: string);
  55007. /**
  55008. * Gets the current class name
  55009. * @returns the class name
  55010. */
  55011. getClassName(): string;
  55012. /**
  55013. * Gets the x component (input)
  55014. */
  55015. readonly x: NodeMaterialConnectionPoint;
  55016. /**
  55017. * Gets the y component (input)
  55018. */
  55019. readonly y: NodeMaterialConnectionPoint;
  55020. /**
  55021. * Gets the z component (input)
  55022. */
  55023. readonly z: NodeMaterialConnectionPoint;
  55024. /**
  55025. * Gets the w component (input)
  55026. */
  55027. readonly w: NodeMaterialConnectionPoint;
  55028. /**
  55029. * Gets the xyzw component (output)
  55030. */
  55031. readonly xyzw: NodeMaterialConnectionPoint;
  55032. /**
  55033. * Gets the xyz component (output)
  55034. */
  55035. readonly xyz: NodeMaterialConnectionPoint;
  55036. /**
  55037. * Gets the xy component (output)
  55038. */
  55039. readonly xy: NodeMaterialConnectionPoint;
  55040. protected _buildBlock(state: NodeMaterialBuildState): this;
  55041. }
  55042. }
  55043. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  55044. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55045. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55046. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55047. /**
  55048. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  55049. */
  55050. export class ColorSplitterBlock extends NodeMaterialBlock {
  55051. /**
  55052. * Create a new ColorSplitterBlock
  55053. * @param name defines the block name
  55054. */
  55055. constructor(name: string);
  55056. /**
  55057. * Gets the current class name
  55058. * @returns the class name
  55059. */
  55060. getClassName(): string;
  55061. /**
  55062. * Gets the rgba component (input)
  55063. */
  55064. readonly rgba: NodeMaterialConnectionPoint;
  55065. /**
  55066. * Gets the rgb component (input)
  55067. */
  55068. readonly rgbIn: NodeMaterialConnectionPoint;
  55069. /**
  55070. * Gets the rgb component (output)
  55071. */
  55072. readonly rgbOut: NodeMaterialConnectionPoint;
  55073. /**
  55074. * Gets the r component (output)
  55075. */
  55076. readonly r: NodeMaterialConnectionPoint;
  55077. /**
  55078. * Gets the g component (output)
  55079. */
  55080. readonly g: NodeMaterialConnectionPoint;
  55081. /**
  55082. * Gets the b component (output)
  55083. */
  55084. readonly b: NodeMaterialConnectionPoint;
  55085. /**
  55086. * Gets the a component (output)
  55087. */
  55088. readonly a: NodeMaterialConnectionPoint;
  55089. protected _buildBlock(state: NodeMaterialBuildState): this;
  55090. }
  55091. }
  55092. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  55093. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55094. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55095. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55096. /**
  55097. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  55098. */
  55099. export class VectorSplitterBlock extends NodeMaterialBlock {
  55100. /**
  55101. * Create a new VectorSplitterBlock
  55102. * @param name defines the block name
  55103. */
  55104. constructor(name: string);
  55105. /**
  55106. * Gets the current class name
  55107. * @returns the class name
  55108. */
  55109. getClassName(): string;
  55110. /**
  55111. * Gets the xyzw component (input)
  55112. */
  55113. readonly xyzw: NodeMaterialConnectionPoint;
  55114. /**
  55115. * Gets the xyz component (input)
  55116. */
  55117. readonly xyzIn: NodeMaterialConnectionPoint;
  55118. /**
  55119. * Gets the xyz component (output)
  55120. */
  55121. readonly xyzOut: NodeMaterialConnectionPoint;
  55122. /**
  55123. * Gets the xy component (output)
  55124. */
  55125. readonly xy: NodeMaterialConnectionPoint;
  55126. /**
  55127. * Gets the x component (output)
  55128. */
  55129. readonly x: NodeMaterialConnectionPoint;
  55130. /**
  55131. * Gets the y component (output)
  55132. */
  55133. readonly y: NodeMaterialConnectionPoint;
  55134. /**
  55135. * Gets the z component (output)
  55136. */
  55137. readonly z: NodeMaterialConnectionPoint;
  55138. /**
  55139. * Gets the w component (output)
  55140. */
  55141. readonly w: NodeMaterialConnectionPoint;
  55142. protected _buildBlock(state: NodeMaterialBuildState): this;
  55143. }
  55144. }
  55145. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  55146. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55147. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55148. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55149. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55150. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55151. import { Effect } from "babylonjs/Materials/effect";
  55152. import { Mesh } from "babylonjs/Meshes/mesh";
  55153. /**
  55154. * Block used to add image processing support to fragment shader
  55155. */
  55156. export class ImageProcessingBlock extends NodeMaterialBlock {
  55157. /**
  55158. * Create a new ImageProcessingBlock
  55159. * @param name defines the block name
  55160. */
  55161. constructor(name: string);
  55162. /**
  55163. * Gets the current class name
  55164. * @returns the class name
  55165. */
  55166. getClassName(): string;
  55167. /**
  55168. * Gets the color input component
  55169. */
  55170. readonly color: NodeMaterialConnectionPoint;
  55171. /**
  55172. * Gets the output component
  55173. */
  55174. readonly output: NodeMaterialConnectionPoint;
  55175. /**
  55176. * Initialize the block and prepare the context for build
  55177. * @param state defines the state that will be used for the build
  55178. */
  55179. initialize(state: NodeMaterialBuildState): void;
  55180. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  55181. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55182. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55183. protected _buildBlock(state: NodeMaterialBuildState): this;
  55184. }
  55185. }
  55186. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  55187. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  55188. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  55189. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  55190. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  55191. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  55192. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  55193. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  55194. }
  55195. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  55196. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55197. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55198. import { Mesh } from "babylonjs/Meshes/mesh";
  55199. import { Effect } from "babylonjs/Materials/effect";
  55200. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55202. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55203. /**
  55204. * Block used to add support for scene fog
  55205. */
  55206. export class FogBlock extends NodeMaterialBlock {
  55207. private _fogDistanceName;
  55208. private _fogParameters;
  55209. /**
  55210. * Create a new FogBlock
  55211. * @param name defines the block name
  55212. */
  55213. constructor(name: string);
  55214. /**
  55215. * Gets the current class name
  55216. * @returns the class name
  55217. */
  55218. getClassName(): string;
  55219. /**
  55220. * Gets the world position input component
  55221. */
  55222. readonly worldPosition: NodeMaterialConnectionPoint;
  55223. /**
  55224. * Gets the view input component
  55225. */
  55226. readonly view: NodeMaterialConnectionPoint;
  55227. /**
  55228. * Gets the color input component
  55229. */
  55230. readonly color: NodeMaterialConnectionPoint;
  55231. /**
  55232. * Gets the fog color input component
  55233. */
  55234. readonly fogColor: NodeMaterialConnectionPoint;
  55235. /**
  55236. * Gets the output component
  55237. */
  55238. readonly output: NodeMaterialConnectionPoint;
  55239. autoConfigure(): void;
  55240. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55241. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55242. protected _buildBlock(state: NodeMaterialBuildState): this;
  55243. }
  55244. }
  55245. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  55246. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55247. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55248. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55249. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55250. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55251. import { Effect } from "babylonjs/Materials/effect";
  55252. import { Mesh } from "babylonjs/Meshes/mesh";
  55253. import { Light } from "babylonjs/Lights/light";
  55254. import { Nullable } from "babylonjs/types";
  55255. import { Scene } from "babylonjs/scene";
  55256. /**
  55257. * Block used to add light in the fragment shader
  55258. */
  55259. export class LightBlock extends NodeMaterialBlock {
  55260. private _lightId;
  55261. /**
  55262. * Gets or sets the light associated with this block
  55263. */
  55264. light: Nullable<Light>;
  55265. /**
  55266. * Create a new LightBlock
  55267. * @param name defines the block name
  55268. */
  55269. constructor(name: string);
  55270. /**
  55271. * Gets the current class name
  55272. * @returns the class name
  55273. */
  55274. getClassName(): string;
  55275. /**
  55276. * Gets the world position input component
  55277. */
  55278. readonly worldPosition: NodeMaterialConnectionPoint;
  55279. /**
  55280. * Gets the world normal input component
  55281. */
  55282. readonly worldNormal: NodeMaterialConnectionPoint;
  55283. /**
  55284. * Gets the camera (or eye) position component
  55285. */
  55286. readonly cameraPosition: NodeMaterialConnectionPoint;
  55287. /**
  55288. * Gets the diffuse output component
  55289. */
  55290. readonly diffuseOutput: NodeMaterialConnectionPoint;
  55291. /**
  55292. * Gets the specular output component
  55293. */
  55294. readonly specularOutput: NodeMaterialConnectionPoint;
  55295. autoConfigure(): void;
  55296. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55297. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55298. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55299. private _injectVertexCode;
  55300. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55301. serialize(): any;
  55302. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55303. }
  55304. }
  55305. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  55306. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  55307. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  55308. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55309. }
  55310. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  55311. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55312. }
  55313. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  55314. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55315. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55316. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55317. /**
  55318. * Block used to multiply 2 values
  55319. */
  55320. export class MultiplyBlock extends NodeMaterialBlock {
  55321. /**
  55322. * Creates a new MultiplyBlock
  55323. * @param name defines the block name
  55324. */
  55325. constructor(name: string);
  55326. /**
  55327. * Gets the current class name
  55328. * @returns the class name
  55329. */
  55330. getClassName(): string;
  55331. /**
  55332. * Gets the left operand input component
  55333. */
  55334. readonly left: NodeMaterialConnectionPoint;
  55335. /**
  55336. * Gets the right operand input component
  55337. */
  55338. readonly right: NodeMaterialConnectionPoint;
  55339. /**
  55340. * Gets the output component
  55341. */
  55342. readonly output: NodeMaterialConnectionPoint;
  55343. protected _buildBlock(state: NodeMaterialBuildState): this;
  55344. }
  55345. }
  55346. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  55347. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55348. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55349. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55350. /**
  55351. * Block used to add 2 vectors
  55352. */
  55353. export class AddBlock extends NodeMaterialBlock {
  55354. /**
  55355. * Creates a new AddBlock
  55356. * @param name defines the block name
  55357. */
  55358. constructor(name: string);
  55359. /**
  55360. * Gets the current class name
  55361. * @returns the class name
  55362. */
  55363. getClassName(): string;
  55364. /**
  55365. * Gets the left operand input component
  55366. */
  55367. readonly left: NodeMaterialConnectionPoint;
  55368. /**
  55369. * Gets the right operand input component
  55370. */
  55371. readonly right: NodeMaterialConnectionPoint;
  55372. /**
  55373. * Gets the output component
  55374. */
  55375. readonly output: NodeMaterialConnectionPoint;
  55376. protected _buildBlock(state: NodeMaterialBuildState): this;
  55377. }
  55378. }
  55379. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  55380. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55381. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55382. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55383. /**
  55384. * Block used to clamp a float
  55385. */
  55386. export class ClampBlock extends NodeMaterialBlock {
  55387. /** Gets or sets the minimum range */
  55388. minimum: number;
  55389. /** Gets or sets the maximum range */
  55390. maximum: number;
  55391. /**
  55392. * Creates a new ClampBlock
  55393. * @param name defines the block name
  55394. */
  55395. constructor(name: string);
  55396. /**
  55397. * Gets the current class name
  55398. * @returns the class name
  55399. */
  55400. getClassName(): string;
  55401. /**
  55402. * Gets the value input component
  55403. */
  55404. readonly value: NodeMaterialConnectionPoint;
  55405. /**
  55406. * Gets the output component
  55407. */
  55408. readonly output: NodeMaterialConnectionPoint;
  55409. protected _buildBlock(state: NodeMaterialBuildState): this;
  55410. }
  55411. }
  55412. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  55413. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55414. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55415. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55416. /**
  55417. * Block used to apply a cross product between 2 vectors
  55418. */
  55419. export class CrossBlock extends NodeMaterialBlock {
  55420. /**
  55421. * Creates a new CrossBlock
  55422. * @param name defines the block name
  55423. */
  55424. constructor(name: string);
  55425. /**
  55426. * Gets the current class name
  55427. * @returns the class name
  55428. */
  55429. getClassName(): string;
  55430. /**
  55431. * Gets the left operand input component
  55432. */
  55433. readonly left: NodeMaterialConnectionPoint;
  55434. /**
  55435. * Gets the right operand input component
  55436. */
  55437. readonly right: NodeMaterialConnectionPoint;
  55438. /**
  55439. * Gets the output component
  55440. */
  55441. readonly output: NodeMaterialConnectionPoint;
  55442. protected _buildBlock(state: NodeMaterialBuildState): this;
  55443. }
  55444. }
  55445. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  55446. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55447. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55448. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55449. /**
  55450. * Block used to apply a dot product between 2 vectors
  55451. */
  55452. export class DotBlock extends NodeMaterialBlock {
  55453. /**
  55454. * Creates a new DotBlock
  55455. * @param name defines the block name
  55456. */
  55457. constructor(name: string);
  55458. /**
  55459. * Gets the current class name
  55460. * @returns the class name
  55461. */
  55462. getClassName(): string;
  55463. /**
  55464. * Gets the left operand input component
  55465. */
  55466. readonly left: NodeMaterialConnectionPoint;
  55467. /**
  55468. * Gets the right operand input component
  55469. */
  55470. readonly right: NodeMaterialConnectionPoint;
  55471. /**
  55472. * Gets the output component
  55473. */
  55474. readonly output: NodeMaterialConnectionPoint;
  55475. protected _buildBlock(state: NodeMaterialBuildState): this;
  55476. }
  55477. }
  55478. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  55479. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55480. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55481. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55482. import { Vector2 } from "babylonjs/Maths/math.vector";
  55483. /**
  55484. * Block used to remap a float from a range to a new one
  55485. */
  55486. export class RemapBlock extends NodeMaterialBlock {
  55487. /**
  55488. * Gets or sets the source range
  55489. */
  55490. sourceRange: Vector2;
  55491. /**
  55492. * Gets or sets the target range
  55493. */
  55494. targetRange: Vector2;
  55495. /**
  55496. * Creates a new RemapBlock
  55497. * @param name defines the block name
  55498. */
  55499. constructor(name: string);
  55500. /**
  55501. * Gets the current class name
  55502. * @returns the class name
  55503. */
  55504. getClassName(): string;
  55505. /**
  55506. * Gets the input component
  55507. */
  55508. readonly input: NodeMaterialConnectionPoint;
  55509. /**
  55510. * Gets the output component
  55511. */
  55512. readonly output: NodeMaterialConnectionPoint;
  55513. protected _buildBlock(state: NodeMaterialBuildState): this;
  55514. }
  55515. }
  55516. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  55517. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55518. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55519. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55520. /**
  55521. * Block used to normalize a vector
  55522. */
  55523. export class NormalizeBlock extends NodeMaterialBlock {
  55524. /**
  55525. * Creates a new NormalizeBlock
  55526. * @param name defines the block name
  55527. */
  55528. constructor(name: string);
  55529. /**
  55530. * Gets the current class name
  55531. * @returns the class name
  55532. */
  55533. getClassName(): string;
  55534. /**
  55535. * Gets the input component
  55536. */
  55537. readonly input: NodeMaterialConnectionPoint;
  55538. /**
  55539. * Gets the output component
  55540. */
  55541. readonly output: NodeMaterialConnectionPoint;
  55542. protected _buildBlock(state: NodeMaterialBuildState): this;
  55543. }
  55544. }
  55545. declare module "babylonjs/Materials/Node/Blocks/index" {
  55546. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  55547. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  55548. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  55549. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  55550. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  55551. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  55552. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  55553. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  55554. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  55555. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  55556. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  55557. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  55558. }
  55559. declare module "babylonjs/Materials/Node/Optimizers/index" {
  55560. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55561. }
  55562. declare module "babylonjs/Materials/Node/index" {
  55563. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55564. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55565. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55566. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  55567. export * from "babylonjs/Materials/Node/nodeMaterial";
  55568. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  55569. export * from "babylonjs/Materials/Node/Blocks/index";
  55570. export * from "babylonjs/Materials/Node/Optimizers/index";
  55571. }
  55572. declare module "babylonjs/Materials/effectRenderer" {
  55573. import { Nullable } from "babylonjs/types";
  55574. import { Texture } from "babylonjs/Materials/Textures/texture";
  55575. import { Engine } from "babylonjs/Engines/engine";
  55576. import { Viewport } from "babylonjs/Maths/math.viewport";
  55577. import { Observable } from "babylonjs/Misc/observable";
  55578. import { Effect } from "babylonjs/Materials/effect";
  55579. import "babylonjs/Shaders/postprocess.vertex";
  55580. /**
  55581. * Effect Render Options
  55582. */
  55583. export interface IEffectRendererOptions {
  55584. /**
  55585. * Defines the vertices positions.
  55586. */
  55587. positions?: number[];
  55588. /**
  55589. * Defines the indices.
  55590. */
  55591. indices?: number[];
  55592. }
  55593. /**
  55594. * Helper class to render one or more effects
  55595. */
  55596. export class EffectRenderer {
  55597. private engine;
  55598. private static _DefaultOptions;
  55599. private _vertexBuffers;
  55600. private _indexBuffer;
  55601. private _ringBufferIndex;
  55602. private _ringScreenBuffer;
  55603. private _fullscreenViewport;
  55604. private _getNextFrameBuffer;
  55605. /**
  55606. * Creates an effect renderer
  55607. * @param engine the engine to use for rendering
  55608. * @param options defines the options of the effect renderer
  55609. */
  55610. constructor(engine: Engine, options?: IEffectRendererOptions);
  55611. /**
  55612. * Sets the current viewport in normalized coordinates 0-1
  55613. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  55614. */
  55615. setViewport(viewport?: Viewport): void;
  55616. /**
  55617. * Sets the current effect wrapper to use during draw.
  55618. * The effect needs to be ready before calling this api.
  55619. * This also sets the default full screen position attribute.
  55620. * @param effectWrapper Defines the effect to draw with
  55621. */
  55622. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  55623. /**
  55624. * Draws a full screen quad.
  55625. */
  55626. draw(): void;
  55627. /**
  55628. * renders one or more effects to a specified texture
  55629. * @param effectWrappers list of effects to renderer
  55630. * @param outputTexture texture to draw to, if null it will render to the screen
  55631. */
  55632. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  55633. /**
  55634. * Disposes of the effect renderer
  55635. */
  55636. dispose(): void;
  55637. }
  55638. /**
  55639. * Options to create an EffectWrapper
  55640. */
  55641. interface EffectWrapperCreationOptions {
  55642. /**
  55643. * Engine to use to create the effect
  55644. */
  55645. engine: Engine;
  55646. /**
  55647. * Fragment shader for the effect
  55648. */
  55649. fragmentShader: string;
  55650. /**
  55651. * Vertex shader for the effect
  55652. */
  55653. vertexShader: string;
  55654. /**
  55655. * Attributes to use in the shader
  55656. */
  55657. attributeNames?: Array<string>;
  55658. /**
  55659. * Uniforms to use in the shader
  55660. */
  55661. uniformNames?: Array<string>;
  55662. /**
  55663. * Texture sampler names to use in the shader
  55664. */
  55665. samplerNames?: Array<string>;
  55666. /**
  55667. * The friendly name of the effect displayed in Spector.
  55668. */
  55669. name?: string;
  55670. }
  55671. /**
  55672. * Wraps an effect to be used for rendering
  55673. */
  55674. export class EffectWrapper {
  55675. /**
  55676. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  55677. */
  55678. onApplyObservable: Observable<{}>;
  55679. /**
  55680. * The underlying effect
  55681. */
  55682. effect: Effect;
  55683. /**
  55684. * Creates an effect to be renderer
  55685. * @param creationOptions options to create the effect
  55686. */
  55687. constructor(creationOptions: EffectWrapperCreationOptions);
  55688. /**
  55689. * Disposes of the effect wrapper
  55690. */
  55691. dispose(): void;
  55692. }
  55693. }
  55694. declare module "babylonjs/Materials/index" {
  55695. export * from "babylonjs/Materials/Background/index";
  55696. export * from "babylonjs/Materials/colorCurves";
  55697. export * from "babylonjs/Materials/effect";
  55698. export * from "babylonjs/Materials/fresnelParameters";
  55699. export * from "babylonjs/Materials/imageProcessingConfiguration";
  55700. export * from "babylonjs/Materials/material";
  55701. export * from "babylonjs/Materials/materialDefines";
  55702. export * from "babylonjs/Materials/materialHelper";
  55703. export * from "babylonjs/Materials/multiMaterial";
  55704. export * from "babylonjs/Materials/PBR/index";
  55705. export * from "babylonjs/Materials/pushMaterial";
  55706. export * from "babylonjs/Materials/shaderMaterial";
  55707. export * from "babylonjs/Materials/standardMaterial";
  55708. export * from "babylonjs/Materials/Textures/index";
  55709. export * from "babylonjs/Materials/uniformBuffer";
  55710. export * from "babylonjs/Materials/materialFlags";
  55711. export * from "babylonjs/Materials/Node/index";
  55712. export * from "babylonjs/Materials/effectRenderer";
  55713. }
  55714. declare module "babylonjs/Maths/index" {
  55715. export * from "babylonjs/Maths/math.scalar";
  55716. export * from "babylonjs/Maths/math";
  55717. export * from "babylonjs/Maths/sphericalPolynomial";
  55718. }
  55719. declare module "babylonjs/Misc/workerPool" {
  55720. import { IDisposable } from "babylonjs/scene";
  55721. /**
  55722. * Helper class to push actions to a pool of workers.
  55723. */
  55724. export class WorkerPool implements IDisposable {
  55725. private _workerInfos;
  55726. private _pendingActions;
  55727. /**
  55728. * Constructor
  55729. * @param workers Array of workers to use for actions
  55730. */
  55731. constructor(workers: Array<Worker>);
  55732. /**
  55733. * Terminates all workers and clears any pending actions.
  55734. */
  55735. dispose(): void;
  55736. /**
  55737. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55738. * pended until a worker has completed its action.
  55739. * @param action The action to perform. Call onComplete when the action is complete.
  55740. */
  55741. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55742. private _execute;
  55743. }
  55744. }
  55745. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  55746. import { IDisposable } from "babylonjs/scene";
  55747. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  55748. /**
  55749. * Configuration for Draco compression
  55750. */
  55751. export interface IDracoCompressionConfiguration {
  55752. /**
  55753. * Configuration for the decoder.
  55754. */
  55755. decoder: {
  55756. /**
  55757. * The url to the WebAssembly module.
  55758. */
  55759. wasmUrl?: string;
  55760. /**
  55761. * The url to the WebAssembly binary.
  55762. */
  55763. wasmBinaryUrl?: string;
  55764. /**
  55765. * The url to the fallback JavaScript module.
  55766. */
  55767. fallbackUrl?: string;
  55768. };
  55769. }
  55770. /**
  55771. * Draco compression (https://google.github.io/draco/)
  55772. *
  55773. * This class wraps the Draco module.
  55774. *
  55775. * **Encoder**
  55776. *
  55777. * The encoder is not currently implemented.
  55778. *
  55779. * **Decoder**
  55780. *
  55781. * 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.
  55782. *
  55783. * To update the configuration, use the following code:
  55784. * ```javascript
  55785. * DracoCompression.Configuration = {
  55786. * decoder: {
  55787. * wasmUrl: "<url to the WebAssembly library>",
  55788. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  55789. * fallbackUrl: "<url to the fallback JavaScript library>",
  55790. * }
  55791. * };
  55792. * ```
  55793. *
  55794. * 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.
  55795. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  55796. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  55797. *
  55798. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  55799. * ```javascript
  55800. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  55801. * ```
  55802. *
  55803. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  55804. */
  55805. export class DracoCompression implements IDisposable {
  55806. private _workerPoolPromise?;
  55807. private _decoderModulePromise?;
  55808. /**
  55809. * The configuration. Defaults to the following urls:
  55810. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  55811. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  55812. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  55813. */
  55814. static Configuration: IDracoCompressionConfiguration;
  55815. /**
  55816. * Returns true if the decoder configuration is available.
  55817. */
  55818. static readonly DecoderAvailable: boolean;
  55819. /**
  55820. * Default number of workers to create when creating the draco compression object.
  55821. */
  55822. static DefaultNumWorkers: number;
  55823. private static GetDefaultNumWorkers;
  55824. private static _Default;
  55825. /**
  55826. * Default instance for the draco compression object.
  55827. */
  55828. static readonly Default: DracoCompression;
  55829. /**
  55830. * Constructor
  55831. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  55832. */
  55833. constructor(numWorkers?: number);
  55834. /**
  55835. * Stop all async operations and release resources.
  55836. */
  55837. dispose(): void;
  55838. /**
  55839. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  55840. * @returns a promise that resolves when ready
  55841. */
  55842. whenReadyAsync(): Promise<void>;
  55843. /**
  55844. * Decode Draco compressed mesh data to vertex data.
  55845. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  55846. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  55847. * @returns A promise that resolves with the decoded vertex data
  55848. */
  55849. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  55850. [kind: string]: number;
  55851. }): Promise<VertexData>;
  55852. }
  55853. }
  55854. declare module "babylonjs/Meshes/Compression/index" {
  55855. export * from "babylonjs/Meshes/Compression/dracoCompression";
  55856. }
  55857. declare module "babylonjs/Meshes/csg" {
  55858. import { Nullable } from "babylonjs/types";
  55859. import { Scene } from "babylonjs/scene";
  55860. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55861. import { Mesh } from "babylonjs/Meshes/mesh";
  55862. import { Material } from "babylonjs/Materials/material";
  55863. /**
  55864. * Class for building Constructive Solid Geometry
  55865. */
  55866. export class CSG {
  55867. private polygons;
  55868. /**
  55869. * The world matrix
  55870. */
  55871. matrix: Matrix;
  55872. /**
  55873. * Stores the position
  55874. */
  55875. position: Vector3;
  55876. /**
  55877. * Stores the rotation
  55878. */
  55879. rotation: Vector3;
  55880. /**
  55881. * Stores the rotation quaternion
  55882. */
  55883. rotationQuaternion: Nullable<Quaternion>;
  55884. /**
  55885. * Stores the scaling vector
  55886. */
  55887. scaling: Vector3;
  55888. /**
  55889. * Convert the Mesh to CSG
  55890. * @param mesh The Mesh to convert to CSG
  55891. * @returns A new CSG from the Mesh
  55892. */
  55893. static FromMesh(mesh: Mesh): CSG;
  55894. /**
  55895. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  55896. * @param polygons Polygons used to construct a CSG solid
  55897. */
  55898. private static FromPolygons;
  55899. /**
  55900. * Clones, or makes a deep copy, of the CSG
  55901. * @returns A new CSG
  55902. */
  55903. clone(): CSG;
  55904. /**
  55905. * Unions this CSG with another CSG
  55906. * @param csg The CSG to union against this CSG
  55907. * @returns The unioned CSG
  55908. */
  55909. union(csg: CSG): CSG;
  55910. /**
  55911. * Unions this CSG with another CSG in place
  55912. * @param csg The CSG to union against this CSG
  55913. */
  55914. unionInPlace(csg: CSG): void;
  55915. /**
  55916. * Subtracts this CSG with another CSG
  55917. * @param csg The CSG to subtract against this CSG
  55918. * @returns A new CSG
  55919. */
  55920. subtract(csg: CSG): CSG;
  55921. /**
  55922. * Subtracts this CSG with another CSG in place
  55923. * @param csg The CSG to subtact against this CSG
  55924. */
  55925. subtractInPlace(csg: CSG): void;
  55926. /**
  55927. * Intersect this CSG with another CSG
  55928. * @param csg The CSG to intersect against this CSG
  55929. * @returns A new CSG
  55930. */
  55931. intersect(csg: CSG): CSG;
  55932. /**
  55933. * Intersects this CSG with another CSG in place
  55934. * @param csg The CSG to intersect against this CSG
  55935. */
  55936. intersectInPlace(csg: CSG): void;
  55937. /**
  55938. * Return a new CSG solid with solid and empty space switched. This solid is
  55939. * not modified.
  55940. * @returns A new CSG solid with solid and empty space switched
  55941. */
  55942. inverse(): CSG;
  55943. /**
  55944. * Inverses the CSG in place
  55945. */
  55946. inverseInPlace(): void;
  55947. /**
  55948. * This is used to keep meshes transformations so they can be restored
  55949. * when we build back a Babylon Mesh
  55950. * NB : All CSG operations are performed in world coordinates
  55951. * @param csg The CSG to copy the transform attributes from
  55952. * @returns This CSG
  55953. */
  55954. copyTransformAttributes(csg: CSG): CSG;
  55955. /**
  55956. * Build Raw mesh from CSG
  55957. * Coordinates here are in world space
  55958. * @param name The name of the mesh geometry
  55959. * @param scene The Scene
  55960. * @param keepSubMeshes Specifies if the submeshes should be kept
  55961. * @returns A new Mesh
  55962. */
  55963. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  55964. /**
  55965. * Build Mesh from CSG taking material and transforms into account
  55966. * @param name The name of the Mesh
  55967. * @param material The material of the Mesh
  55968. * @param scene The Scene
  55969. * @param keepSubMeshes Specifies if submeshes should be kept
  55970. * @returns The new Mesh
  55971. */
  55972. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  55973. }
  55974. }
  55975. declare module "babylonjs/Meshes/trailMesh" {
  55976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55977. import { Mesh } from "babylonjs/Meshes/mesh";
  55978. import { Scene } from "babylonjs/scene";
  55979. /**
  55980. * Class used to create a trail following a mesh
  55981. */
  55982. export class TrailMesh extends Mesh {
  55983. private _generator;
  55984. private _autoStart;
  55985. private _running;
  55986. private _diameter;
  55987. private _length;
  55988. private _sectionPolygonPointsCount;
  55989. private _sectionVectors;
  55990. private _sectionNormalVectors;
  55991. private _beforeRenderObserver;
  55992. /**
  55993. * @constructor
  55994. * @param name The value used by scene.getMeshByName() to do a lookup.
  55995. * @param generator The mesh to generate a trail.
  55996. * @param scene The scene to add this mesh to.
  55997. * @param diameter Diameter of trailing mesh. Default is 1.
  55998. * @param length Length of trailing mesh. Default is 60.
  55999. * @param autoStart Automatically start trailing mesh. Default true.
  56000. */
  56001. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  56002. /**
  56003. * "TrailMesh"
  56004. * @returns "TrailMesh"
  56005. */
  56006. getClassName(): string;
  56007. private _createMesh;
  56008. /**
  56009. * Start trailing mesh.
  56010. */
  56011. start(): void;
  56012. /**
  56013. * Stop trailing mesh.
  56014. */
  56015. stop(): void;
  56016. /**
  56017. * Update trailing mesh geometry.
  56018. */
  56019. update(): void;
  56020. /**
  56021. * Returns a new TrailMesh object.
  56022. * @param name is a string, the name given to the new mesh
  56023. * @param newGenerator use new generator object for cloned trail mesh
  56024. * @returns a new mesh
  56025. */
  56026. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  56027. /**
  56028. * Serializes this trail mesh
  56029. * @param serializationObject object to write serialization to
  56030. */
  56031. serialize(serializationObject: any): void;
  56032. /**
  56033. * Parses a serialized trail mesh
  56034. * @param parsedMesh the serialized mesh
  56035. * @param scene the scene to create the trail mesh in
  56036. * @returns the created trail mesh
  56037. */
  56038. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  56039. }
  56040. }
  56041. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  56042. import { Nullable } from "babylonjs/types";
  56043. import { Scene } from "babylonjs/scene";
  56044. import { Vector4 } from "babylonjs/Maths/math.vector";
  56045. import { Color4 } from "babylonjs/Maths/math.color";
  56046. import { Mesh } from "babylonjs/Meshes/mesh";
  56047. /**
  56048. * Class containing static functions to help procedurally build meshes
  56049. */
  56050. export class TiledBoxBuilder {
  56051. /**
  56052. * Creates a box mesh
  56053. * 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)
  56054. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56055. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56056. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56058. * @param name defines the name of the mesh
  56059. * @param options defines the options used to create the mesh
  56060. * @param scene defines the hosting scene
  56061. * @returns the box mesh
  56062. */
  56063. static CreateTiledBox(name: string, options: {
  56064. pattern?: number;
  56065. width?: number;
  56066. height?: number;
  56067. depth?: number;
  56068. tileSize?: number;
  56069. tileWidth?: number;
  56070. tileHeight?: number;
  56071. alignHorizontal?: number;
  56072. alignVertical?: number;
  56073. faceUV?: Vector4[];
  56074. faceColors?: Color4[];
  56075. sideOrientation?: number;
  56076. updatable?: boolean;
  56077. }, scene?: Nullable<Scene>): Mesh;
  56078. }
  56079. }
  56080. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  56081. import { Vector4 } from "babylonjs/Maths/math.vector";
  56082. import { Mesh } from "babylonjs/Meshes/mesh";
  56083. /**
  56084. * Class containing static functions to help procedurally build meshes
  56085. */
  56086. export class TorusKnotBuilder {
  56087. /**
  56088. * Creates a torus knot mesh
  56089. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56090. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56091. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56092. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56094. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56096. * @param name defines the name of the mesh
  56097. * @param options defines the options used to create the mesh
  56098. * @param scene defines the hosting scene
  56099. * @returns the torus knot mesh
  56100. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56101. */
  56102. static CreateTorusKnot(name: string, options: {
  56103. radius?: number;
  56104. tube?: number;
  56105. radialSegments?: number;
  56106. tubularSegments?: number;
  56107. p?: number;
  56108. q?: number;
  56109. updatable?: boolean;
  56110. sideOrientation?: number;
  56111. frontUVs?: Vector4;
  56112. backUVs?: Vector4;
  56113. }, scene: any): Mesh;
  56114. }
  56115. }
  56116. declare module "babylonjs/Meshes/polygonMesh" {
  56117. import { Scene } from "babylonjs/scene";
  56118. import { Vector2 } from "babylonjs/Maths/math.vector";
  56119. import { Mesh } from "babylonjs/Meshes/mesh";
  56120. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  56121. import { Path2 } from "babylonjs/Maths/math.path";
  56122. /**
  56123. * Polygon
  56124. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  56125. */
  56126. export class Polygon {
  56127. /**
  56128. * Creates a rectangle
  56129. * @param xmin bottom X coord
  56130. * @param ymin bottom Y coord
  56131. * @param xmax top X coord
  56132. * @param ymax top Y coord
  56133. * @returns points that make the resulting rectation
  56134. */
  56135. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  56136. /**
  56137. * Creates a circle
  56138. * @param radius radius of circle
  56139. * @param cx scale in x
  56140. * @param cy scale in y
  56141. * @param numberOfSides number of sides that make up the circle
  56142. * @returns points that make the resulting circle
  56143. */
  56144. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  56145. /**
  56146. * Creates a polygon from input string
  56147. * @param input Input polygon data
  56148. * @returns the parsed points
  56149. */
  56150. static Parse(input: string): Vector2[];
  56151. /**
  56152. * Starts building a polygon from x and y coordinates
  56153. * @param x x coordinate
  56154. * @param y y coordinate
  56155. * @returns the started path2
  56156. */
  56157. static StartingAt(x: number, y: number): Path2;
  56158. }
  56159. /**
  56160. * Builds a polygon
  56161. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  56162. */
  56163. export class PolygonMeshBuilder {
  56164. private _points;
  56165. private _outlinepoints;
  56166. private _holes;
  56167. private _name;
  56168. private _scene;
  56169. private _epoints;
  56170. private _eholes;
  56171. private _addToepoint;
  56172. /**
  56173. * Babylon reference to the earcut plugin.
  56174. */
  56175. bjsEarcut: any;
  56176. /**
  56177. * Creates a PolygonMeshBuilder
  56178. * @param name name of the builder
  56179. * @param contours Path of the polygon
  56180. * @param scene scene to add to when creating the mesh
  56181. * @param earcutInjection can be used to inject your own earcut reference
  56182. */
  56183. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  56184. /**
  56185. * Adds a whole within the polygon
  56186. * @param hole Array of points defining the hole
  56187. * @returns this
  56188. */
  56189. addHole(hole: Vector2[]): PolygonMeshBuilder;
  56190. /**
  56191. * Creates the polygon
  56192. * @param updatable If the mesh should be updatable
  56193. * @param depth The depth of the mesh created
  56194. * @returns the created mesh
  56195. */
  56196. build(updatable?: boolean, depth?: number): Mesh;
  56197. /**
  56198. * Creates the polygon
  56199. * @param depth The depth of the mesh created
  56200. * @returns the created VertexData
  56201. */
  56202. buildVertexData(depth?: number): VertexData;
  56203. /**
  56204. * Adds a side to the polygon
  56205. * @param positions points that make the polygon
  56206. * @param normals normals of the polygon
  56207. * @param uvs uvs of the polygon
  56208. * @param indices indices of the polygon
  56209. * @param bounds bounds of the polygon
  56210. * @param points points of the polygon
  56211. * @param depth depth of the polygon
  56212. * @param flip flip of the polygon
  56213. */
  56214. private addSide;
  56215. }
  56216. }
  56217. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  56218. import { Scene } from "babylonjs/scene";
  56219. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56220. import { Color4 } from "babylonjs/Maths/math.color";
  56221. import { Mesh } from "babylonjs/Meshes/mesh";
  56222. import { Nullable } from "babylonjs/types";
  56223. /**
  56224. * Class containing static functions to help procedurally build meshes
  56225. */
  56226. export class PolygonBuilder {
  56227. /**
  56228. * Creates a polygon mesh
  56229. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56230. * * 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
  56231. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56233. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  56234. * * Remember you can only change the shape positions, not their number when updating a polygon
  56235. * @param name defines the name of the mesh
  56236. * @param options defines the options used to create the mesh
  56237. * @param scene defines the hosting scene
  56238. * @param earcutInjection can be used to inject your own earcut reference
  56239. * @returns the polygon mesh
  56240. */
  56241. static CreatePolygon(name: string, options: {
  56242. shape: Vector3[];
  56243. holes?: Vector3[][];
  56244. depth?: number;
  56245. faceUV?: Vector4[];
  56246. faceColors?: Color4[];
  56247. updatable?: boolean;
  56248. sideOrientation?: number;
  56249. frontUVs?: Vector4;
  56250. backUVs?: Vector4;
  56251. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56252. /**
  56253. * Creates an extruded polygon mesh, with depth in the Y direction.
  56254. * * 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)
  56255. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56256. * @param name defines the name of the mesh
  56257. * @param options defines the options used to create the mesh
  56258. * @param scene defines the hosting scene
  56259. * @param earcutInjection can be used to inject your own earcut reference
  56260. * @returns the polygon mesh
  56261. */
  56262. static ExtrudePolygon(name: string, options: {
  56263. shape: Vector3[];
  56264. holes?: Vector3[][];
  56265. depth?: number;
  56266. faceUV?: Vector4[];
  56267. faceColors?: Color4[];
  56268. updatable?: boolean;
  56269. sideOrientation?: number;
  56270. frontUVs?: Vector4;
  56271. backUVs?: Vector4;
  56272. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56273. }
  56274. }
  56275. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  56276. import { Scene } from "babylonjs/scene";
  56277. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56278. import { Mesh } from "babylonjs/Meshes/mesh";
  56279. import { Nullable } from "babylonjs/types";
  56280. /**
  56281. * Class containing static functions to help procedurally build meshes
  56282. */
  56283. export class LatheBuilder {
  56284. /**
  56285. * Creates lathe mesh.
  56286. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56287. * * 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
  56288. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56289. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56290. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56291. * * 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
  56292. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56293. * * 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
  56294. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56295. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56296. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56298. * @param name defines the name of the mesh
  56299. * @param options defines the options used to create the mesh
  56300. * @param scene defines the hosting scene
  56301. * @returns the lathe mesh
  56302. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56303. */
  56304. static CreateLathe(name: string, options: {
  56305. shape: Vector3[];
  56306. radius?: number;
  56307. tessellation?: number;
  56308. clip?: number;
  56309. arc?: number;
  56310. closed?: boolean;
  56311. updatable?: boolean;
  56312. sideOrientation?: number;
  56313. frontUVs?: Vector4;
  56314. backUVs?: Vector4;
  56315. cap?: number;
  56316. invertUV?: boolean;
  56317. }, scene?: Nullable<Scene>): Mesh;
  56318. }
  56319. }
  56320. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  56321. import { Nullable } from "babylonjs/types";
  56322. import { Scene } from "babylonjs/scene";
  56323. import { Vector4 } from "babylonjs/Maths/math.vector";
  56324. import { Mesh } from "babylonjs/Meshes/mesh";
  56325. /**
  56326. * Class containing static functions to help procedurally build meshes
  56327. */
  56328. export class TiledPlaneBuilder {
  56329. /**
  56330. * Creates a tiled plane mesh
  56331. * * The parameter `pattern` will, depending on value, do nothing or
  56332. * * * flip (reflect about central vertical) alternate tiles across and up
  56333. * * * flip every tile on alternate rows
  56334. * * * rotate (180 degs) alternate tiles across and up
  56335. * * * rotate every tile on alternate rows
  56336. * * * flip and rotate alternate tiles across and up
  56337. * * * flip and rotate every tile on alternate rows
  56338. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  56339. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  56340. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56341. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56342. * * 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)
  56343. * * 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)
  56344. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56345. * @param name defines the name of the mesh
  56346. * @param options defines the options used to create the mesh
  56347. * @param scene defines the hosting scene
  56348. * @returns the box mesh
  56349. */
  56350. static CreateTiledPlane(name: string, options: {
  56351. pattern?: number;
  56352. tileSize?: number;
  56353. tileWidth?: number;
  56354. tileHeight?: number;
  56355. size?: number;
  56356. width?: number;
  56357. height?: number;
  56358. alignHorizontal?: number;
  56359. alignVertical?: number;
  56360. sideOrientation?: number;
  56361. frontUVs?: Vector4;
  56362. backUVs?: Vector4;
  56363. updatable?: boolean;
  56364. }, scene?: Nullable<Scene>): Mesh;
  56365. }
  56366. }
  56367. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  56368. import { Nullable } from "babylonjs/types";
  56369. import { Scene } from "babylonjs/scene";
  56370. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56371. import { Mesh } from "babylonjs/Meshes/mesh";
  56372. /**
  56373. * Class containing static functions to help procedurally build meshes
  56374. */
  56375. export class TubeBuilder {
  56376. /**
  56377. * Creates a tube mesh.
  56378. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56379. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56380. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56381. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56382. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56383. * * 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)
  56384. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56385. * * 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
  56386. * * 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
  56387. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56388. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56389. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56391. * @param name defines the name of the mesh
  56392. * @param options defines the options used to create the mesh
  56393. * @param scene defines the hosting scene
  56394. * @returns the tube mesh
  56395. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56396. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56397. */
  56398. static CreateTube(name: string, options: {
  56399. path: Vector3[];
  56400. radius?: number;
  56401. tessellation?: number;
  56402. radiusFunction?: {
  56403. (i: number, distance: number): number;
  56404. };
  56405. cap?: number;
  56406. arc?: number;
  56407. updatable?: boolean;
  56408. sideOrientation?: number;
  56409. frontUVs?: Vector4;
  56410. backUVs?: Vector4;
  56411. instance?: Mesh;
  56412. invertUV?: boolean;
  56413. }, scene?: Nullable<Scene>): Mesh;
  56414. }
  56415. }
  56416. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  56417. import { Scene } from "babylonjs/scene";
  56418. import { Vector4 } from "babylonjs/Maths/math.vector";
  56419. import { Mesh } from "babylonjs/Meshes/mesh";
  56420. import { Nullable } from "babylonjs/types";
  56421. /**
  56422. * Class containing static functions to help procedurally build meshes
  56423. */
  56424. export class IcoSphereBuilder {
  56425. /**
  56426. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56427. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56428. * * 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`)
  56429. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56430. * * 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
  56431. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56432. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56434. * @param name defines the name of the mesh
  56435. * @param options defines the options used to create the mesh
  56436. * @param scene defines the hosting scene
  56437. * @returns the icosahedron mesh
  56438. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56439. */
  56440. static CreateIcoSphere(name: string, options: {
  56441. radius?: number;
  56442. radiusX?: number;
  56443. radiusY?: number;
  56444. radiusZ?: number;
  56445. flat?: boolean;
  56446. subdivisions?: number;
  56447. sideOrientation?: number;
  56448. frontUVs?: Vector4;
  56449. backUVs?: Vector4;
  56450. updatable?: boolean;
  56451. }, scene?: Nullable<Scene>): Mesh;
  56452. }
  56453. }
  56454. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  56455. import { Vector3 } from "babylonjs/Maths/math.vector";
  56456. import { Mesh } from "babylonjs/Meshes/mesh";
  56457. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56458. /**
  56459. * Class containing static functions to help procedurally build meshes
  56460. */
  56461. export class DecalBuilder {
  56462. /**
  56463. * Creates a decal mesh.
  56464. * 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
  56465. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56466. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56467. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56468. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56469. * @param name defines the name of the mesh
  56470. * @param sourceMesh defines the mesh where the decal must be applied
  56471. * @param options defines the options used to create the mesh
  56472. * @param scene defines the hosting scene
  56473. * @returns the decal mesh
  56474. * @see https://doc.babylonjs.com/how_to/decals
  56475. */
  56476. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56477. position?: Vector3;
  56478. normal?: Vector3;
  56479. size?: Vector3;
  56480. angle?: number;
  56481. }): Mesh;
  56482. }
  56483. }
  56484. declare module "babylonjs/Meshes/meshBuilder" {
  56485. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  56486. import { Nullable } from "babylonjs/types";
  56487. import { Scene } from "babylonjs/scene";
  56488. import { Mesh } from "babylonjs/Meshes/mesh";
  56489. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  56490. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  56491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56492. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  56493. import { Plane } from "babylonjs/Maths/math.plane";
  56494. /**
  56495. * Class containing static functions to help procedurally build meshes
  56496. */
  56497. export class MeshBuilder {
  56498. /**
  56499. * Creates a box mesh
  56500. * * The parameter `size` sets the size (float) of each box side (default 1)
  56501. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56502. * * 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)
  56503. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56504. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56505. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56507. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56508. * @param name defines the name of the mesh
  56509. * @param options defines the options used to create the mesh
  56510. * @param scene defines the hosting scene
  56511. * @returns the box mesh
  56512. */
  56513. static CreateBox(name: string, options: {
  56514. size?: number;
  56515. width?: number;
  56516. height?: number;
  56517. depth?: number;
  56518. faceUV?: Vector4[];
  56519. faceColors?: Color4[];
  56520. sideOrientation?: number;
  56521. frontUVs?: Vector4;
  56522. backUVs?: Vector4;
  56523. updatable?: boolean;
  56524. }, scene?: Nullable<Scene>): Mesh;
  56525. /**
  56526. * Creates a tiled box mesh
  56527. * * faceTiles sets the pattern, tile size and number of tiles for a face
  56528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56529. * @param name defines the name of the mesh
  56530. * @param options defines the options used to create the mesh
  56531. * @param scene defines the hosting scene
  56532. * @returns the tiled box mesh
  56533. */
  56534. static CreateTiledBox(name: string, options: {
  56535. pattern?: number;
  56536. size?: number;
  56537. width?: number;
  56538. height?: number;
  56539. depth: number;
  56540. tileSize?: number;
  56541. tileWidth?: number;
  56542. tileHeight?: number;
  56543. faceUV?: Vector4[];
  56544. faceColors?: Color4[];
  56545. alignHorizontal?: number;
  56546. alignVertical?: number;
  56547. sideOrientation?: number;
  56548. updatable?: boolean;
  56549. }, scene?: Nullable<Scene>): Mesh;
  56550. /**
  56551. * Creates a sphere mesh
  56552. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  56553. * * 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`)
  56554. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  56555. * * 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
  56556. * * 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)
  56557. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56558. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56560. * @param name defines the name of the mesh
  56561. * @param options defines the options used to create the mesh
  56562. * @param scene defines the hosting scene
  56563. * @returns the sphere mesh
  56564. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  56565. */
  56566. static CreateSphere(name: string, options: {
  56567. segments?: number;
  56568. diameter?: number;
  56569. diameterX?: number;
  56570. diameterY?: number;
  56571. diameterZ?: number;
  56572. arc?: number;
  56573. slice?: number;
  56574. sideOrientation?: number;
  56575. frontUVs?: Vector4;
  56576. backUVs?: Vector4;
  56577. updatable?: boolean;
  56578. }, scene?: Nullable<Scene>): Mesh;
  56579. /**
  56580. * Creates a plane polygonal mesh. By default, this is a disc
  56581. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  56582. * * 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
  56583. * * 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
  56584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56585. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56587. * @param name defines the name of the mesh
  56588. * @param options defines the options used to create the mesh
  56589. * @param scene defines the hosting scene
  56590. * @returns the plane polygonal mesh
  56591. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  56592. */
  56593. static CreateDisc(name: string, options: {
  56594. radius?: number;
  56595. tessellation?: number;
  56596. arc?: number;
  56597. updatable?: boolean;
  56598. sideOrientation?: number;
  56599. frontUVs?: Vector4;
  56600. backUVs?: Vector4;
  56601. }, scene?: Nullable<Scene>): Mesh;
  56602. /**
  56603. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56604. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56605. * * 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`)
  56606. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56607. * * 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
  56608. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56609. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56611. * @param name defines the name of the mesh
  56612. * @param options defines the options used to create the mesh
  56613. * @param scene defines the hosting scene
  56614. * @returns the icosahedron mesh
  56615. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56616. */
  56617. static CreateIcoSphere(name: string, options: {
  56618. radius?: number;
  56619. radiusX?: number;
  56620. radiusY?: number;
  56621. radiusZ?: number;
  56622. flat?: boolean;
  56623. subdivisions?: number;
  56624. sideOrientation?: number;
  56625. frontUVs?: Vector4;
  56626. backUVs?: Vector4;
  56627. updatable?: boolean;
  56628. }, scene?: Nullable<Scene>): Mesh;
  56629. /**
  56630. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56631. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56632. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56633. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56634. * * 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
  56635. * * 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
  56636. * * 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
  56637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56638. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56639. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56640. * * 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
  56641. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56642. * * 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
  56643. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56645. * @param name defines the name of the mesh
  56646. * @param options defines the options used to create the mesh
  56647. * @param scene defines the hosting scene
  56648. * @returns the ribbon mesh
  56649. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56650. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56651. */
  56652. static CreateRibbon(name: string, options: {
  56653. pathArray: Vector3[][];
  56654. closeArray?: boolean;
  56655. closePath?: boolean;
  56656. offset?: number;
  56657. updatable?: boolean;
  56658. sideOrientation?: number;
  56659. frontUVs?: Vector4;
  56660. backUVs?: Vector4;
  56661. instance?: Mesh;
  56662. invertUV?: boolean;
  56663. uvs?: Vector2[];
  56664. colors?: Color4[];
  56665. }, scene?: Nullable<Scene>): Mesh;
  56666. /**
  56667. * Creates a cylinder or a cone mesh
  56668. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  56669. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  56670. * * 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.
  56671. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  56672. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  56673. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  56674. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  56675. * * 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).
  56676. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  56677. * * 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).
  56678. * * 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
  56679. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  56680. * * 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
  56681. * * 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.
  56682. * * If `enclose` is false, a ring surface is one element.
  56683. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  56684. * * 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
  56685. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56686. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56688. * @param name defines the name of the mesh
  56689. * @param options defines the options used to create the mesh
  56690. * @param scene defines the hosting scene
  56691. * @returns the cylinder mesh
  56692. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  56693. */
  56694. static CreateCylinder(name: string, options: {
  56695. height?: number;
  56696. diameterTop?: number;
  56697. diameterBottom?: number;
  56698. diameter?: number;
  56699. tessellation?: number;
  56700. subdivisions?: number;
  56701. arc?: number;
  56702. faceColors?: Color4[];
  56703. faceUV?: Vector4[];
  56704. updatable?: boolean;
  56705. hasRings?: boolean;
  56706. enclose?: boolean;
  56707. cap?: number;
  56708. sideOrientation?: number;
  56709. frontUVs?: Vector4;
  56710. backUVs?: Vector4;
  56711. }, scene?: Nullable<Scene>): Mesh;
  56712. /**
  56713. * Creates a torus mesh
  56714. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  56715. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  56716. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  56717. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56718. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56720. * @param name defines the name of the mesh
  56721. * @param options defines the options used to create the mesh
  56722. * @param scene defines the hosting scene
  56723. * @returns the torus mesh
  56724. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  56725. */
  56726. static CreateTorus(name: string, options: {
  56727. diameter?: number;
  56728. thickness?: number;
  56729. tessellation?: number;
  56730. updatable?: boolean;
  56731. sideOrientation?: number;
  56732. frontUVs?: Vector4;
  56733. backUVs?: Vector4;
  56734. }, scene?: Nullable<Scene>): Mesh;
  56735. /**
  56736. * Creates a torus knot mesh
  56737. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56738. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56739. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56740. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56741. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56742. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56744. * @param name defines the name of the mesh
  56745. * @param options defines the options used to create the mesh
  56746. * @param scene defines the hosting scene
  56747. * @returns the torus knot mesh
  56748. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56749. */
  56750. static CreateTorusKnot(name: string, options: {
  56751. radius?: number;
  56752. tube?: number;
  56753. radialSegments?: number;
  56754. tubularSegments?: number;
  56755. p?: number;
  56756. q?: number;
  56757. updatable?: boolean;
  56758. sideOrientation?: number;
  56759. frontUVs?: Vector4;
  56760. backUVs?: Vector4;
  56761. }, scene?: Nullable<Scene>): Mesh;
  56762. /**
  56763. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  56764. * * 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
  56765. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  56766. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  56767. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  56768. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  56769. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56770. * * 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
  56771. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  56772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56773. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  56774. * @param name defines the name of the new line system
  56775. * @param options defines the options used to create the line system
  56776. * @param scene defines the hosting scene
  56777. * @returns a new line system mesh
  56778. */
  56779. static CreateLineSystem(name: string, options: {
  56780. lines: Vector3[][];
  56781. updatable?: boolean;
  56782. instance?: Nullable<LinesMesh>;
  56783. colors?: Nullable<Color4[][]>;
  56784. useVertexAlpha?: boolean;
  56785. }, scene: Nullable<Scene>): LinesMesh;
  56786. /**
  56787. * Creates a line mesh
  56788. * 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
  56789. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56790. * * The parameter `points` is an array successive Vector3
  56791. * * 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
  56792. * * The optional parameter `colors` is an array of successive Color4, one per line point
  56793. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  56794. * * When updating an instance, remember that only point positions can change, not the number of points
  56795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56796. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  56797. * @param name defines the name of the new line system
  56798. * @param options defines the options used to create the line system
  56799. * @param scene defines the hosting scene
  56800. * @returns a new line mesh
  56801. */
  56802. static CreateLines(name: string, options: {
  56803. points: Vector3[];
  56804. updatable?: boolean;
  56805. instance?: Nullable<LinesMesh>;
  56806. colors?: Color4[];
  56807. useVertexAlpha?: boolean;
  56808. }, scene?: Nullable<Scene>): LinesMesh;
  56809. /**
  56810. * Creates a dashed line mesh
  56811. * * 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
  56812. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56813. * * The parameter `points` is an array successive Vector3
  56814. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56815. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56816. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56817. * * 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
  56818. * * When updating an instance, remember that only point positions can change, not the number of points
  56819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56820. * @param name defines the name of the mesh
  56821. * @param options defines the options used to create the mesh
  56822. * @param scene defines the hosting scene
  56823. * @returns the dashed line mesh
  56824. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56825. */
  56826. static CreateDashedLines(name: string, options: {
  56827. points: Vector3[];
  56828. dashSize?: number;
  56829. gapSize?: number;
  56830. dashNb?: number;
  56831. updatable?: boolean;
  56832. instance?: LinesMesh;
  56833. }, scene?: Nullable<Scene>): LinesMesh;
  56834. /**
  56835. * 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.
  56836. * * 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.
  56837. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56838. * * 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.
  56839. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56840. * * 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
  56841. * * 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
  56842. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56843. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56844. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56845. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56847. * @param name defines the name of the mesh
  56848. * @param options defines the options used to create the mesh
  56849. * @param scene defines the hosting scene
  56850. * @returns the extruded shape mesh
  56851. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56852. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56853. */
  56854. static ExtrudeShape(name: string, options: {
  56855. shape: Vector3[];
  56856. path: Vector3[];
  56857. scale?: number;
  56858. rotation?: number;
  56859. cap?: number;
  56860. updatable?: boolean;
  56861. sideOrientation?: number;
  56862. frontUVs?: Vector4;
  56863. backUVs?: Vector4;
  56864. instance?: Mesh;
  56865. invertUV?: boolean;
  56866. }, scene?: Nullable<Scene>): Mesh;
  56867. /**
  56868. * Creates an custom extruded shape mesh.
  56869. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56870. * * 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.
  56871. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56872. * * 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
  56873. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56874. * * 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
  56875. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56876. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56877. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56878. * * 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
  56879. * * 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
  56880. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56882. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56883. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56885. * @param name defines the name of the mesh
  56886. * @param options defines the options used to create the mesh
  56887. * @param scene defines the hosting scene
  56888. * @returns the custom extruded shape mesh
  56889. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56890. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56891. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56892. */
  56893. static ExtrudeShapeCustom(name: string, options: {
  56894. shape: Vector3[];
  56895. path: Vector3[];
  56896. scaleFunction?: any;
  56897. rotationFunction?: any;
  56898. ribbonCloseArray?: boolean;
  56899. ribbonClosePath?: boolean;
  56900. cap?: number;
  56901. updatable?: boolean;
  56902. sideOrientation?: number;
  56903. frontUVs?: Vector4;
  56904. backUVs?: Vector4;
  56905. instance?: Mesh;
  56906. invertUV?: boolean;
  56907. }, scene?: Nullable<Scene>): Mesh;
  56908. /**
  56909. * Creates lathe mesh.
  56910. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56911. * * 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
  56912. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56913. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56914. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56915. * * 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
  56916. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56917. * * 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
  56918. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56919. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56920. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56922. * @param name defines the name of the mesh
  56923. * @param options defines the options used to create the mesh
  56924. * @param scene defines the hosting scene
  56925. * @returns the lathe mesh
  56926. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56927. */
  56928. static CreateLathe(name: string, options: {
  56929. shape: Vector3[];
  56930. radius?: number;
  56931. tessellation?: number;
  56932. clip?: number;
  56933. arc?: number;
  56934. closed?: boolean;
  56935. updatable?: boolean;
  56936. sideOrientation?: number;
  56937. frontUVs?: Vector4;
  56938. backUVs?: Vector4;
  56939. cap?: number;
  56940. invertUV?: boolean;
  56941. }, scene?: Nullable<Scene>): Mesh;
  56942. /**
  56943. * Creates a tiled plane mesh
  56944. * * You can set a limited pattern arrangement with the tiles
  56945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56946. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56948. * @param name defines the name of the mesh
  56949. * @param options defines the options used to create the mesh
  56950. * @param scene defines the hosting scene
  56951. * @returns the plane mesh
  56952. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56953. */
  56954. static CreateTiledPlane(name: string, options: {
  56955. pattern?: number;
  56956. tileSize?: number;
  56957. tileWidth?: number;
  56958. tileHeight?: number;
  56959. size?: number;
  56960. width?: number;
  56961. height?: number;
  56962. alignHorizontal?: number;
  56963. alignVertical?: number;
  56964. sideOrientation?: number;
  56965. frontUVs?: Vector4;
  56966. backUVs?: Vector4;
  56967. updatable?: boolean;
  56968. }, scene?: Nullable<Scene>): Mesh;
  56969. /**
  56970. * Creates a plane mesh
  56971. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  56972. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  56973. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  56974. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56975. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56977. * @param name defines the name of the mesh
  56978. * @param options defines the options used to create the mesh
  56979. * @param scene defines the hosting scene
  56980. * @returns the plane mesh
  56981. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56982. */
  56983. static CreatePlane(name: string, options: {
  56984. size?: number;
  56985. width?: number;
  56986. height?: number;
  56987. sideOrientation?: number;
  56988. frontUVs?: Vector4;
  56989. backUVs?: Vector4;
  56990. updatable?: boolean;
  56991. sourcePlane?: Plane;
  56992. }, scene?: Nullable<Scene>): Mesh;
  56993. /**
  56994. * Creates a ground mesh
  56995. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  56996. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  56997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56998. * @param name defines the name of the mesh
  56999. * @param options defines the options used to create the mesh
  57000. * @param scene defines the hosting scene
  57001. * @returns the ground mesh
  57002. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  57003. */
  57004. static CreateGround(name: string, options: {
  57005. width?: number;
  57006. height?: number;
  57007. subdivisions?: number;
  57008. subdivisionsX?: number;
  57009. subdivisionsY?: number;
  57010. updatable?: boolean;
  57011. }, scene?: Nullable<Scene>): Mesh;
  57012. /**
  57013. * Creates a tiled ground mesh
  57014. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  57015. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  57016. * * 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
  57017. * * 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
  57018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57019. * @param name defines the name of the mesh
  57020. * @param options defines the options used to create the mesh
  57021. * @param scene defines the hosting scene
  57022. * @returns the tiled ground mesh
  57023. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  57024. */
  57025. static CreateTiledGround(name: string, options: {
  57026. xmin: number;
  57027. zmin: number;
  57028. xmax: number;
  57029. zmax: number;
  57030. subdivisions?: {
  57031. w: number;
  57032. h: number;
  57033. };
  57034. precision?: {
  57035. w: number;
  57036. h: number;
  57037. };
  57038. updatable?: boolean;
  57039. }, scene?: Nullable<Scene>): Mesh;
  57040. /**
  57041. * Creates a ground mesh from a height map
  57042. * * The parameter `url` sets the URL of the height map image resource.
  57043. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  57044. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  57045. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  57046. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  57047. * * 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.
  57048. * * 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).
  57049. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  57050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57051. * @param name defines the name of the mesh
  57052. * @param url defines the url to the height map
  57053. * @param options defines the options used to create the mesh
  57054. * @param scene defines the hosting scene
  57055. * @returns the ground mesh
  57056. * @see https://doc.babylonjs.com/babylon101/height_map
  57057. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  57058. */
  57059. static CreateGroundFromHeightMap(name: string, url: string, options: {
  57060. width?: number;
  57061. height?: number;
  57062. subdivisions?: number;
  57063. minHeight?: number;
  57064. maxHeight?: number;
  57065. colorFilter?: Color3;
  57066. alphaFilter?: number;
  57067. updatable?: boolean;
  57068. onReady?: (mesh: GroundMesh) => void;
  57069. }, scene?: Nullable<Scene>): GroundMesh;
  57070. /**
  57071. * Creates a polygon mesh
  57072. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57073. * * 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
  57074. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57076. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  57077. * * Remember you can only change the shape positions, not their number when updating a polygon
  57078. * @param name defines the name of the mesh
  57079. * @param options defines the options used to create the mesh
  57080. * @param scene defines the hosting scene
  57081. * @param earcutInjection can be used to inject your own earcut reference
  57082. * @returns the polygon mesh
  57083. */
  57084. static CreatePolygon(name: string, options: {
  57085. shape: Vector3[];
  57086. holes?: Vector3[][];
  57087. depth?: number;
  57088. faceUV?: Vector4[];
  57089. faceColors?: Color4[];
  57090. updatable?: boolean;
  57091. sideOrientation?: number;
  57092. frontUVs?: Vector4;
  57093. backUVs?: Vector4;
  57094. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57095. /**
  57096. * Creates an extruded polygon mesh, with depth in the Y direction.
  57097. * * 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)
  57098. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57099. * @param name defines the name of the mesh
  57100. * @param options defines the options used to create the mesh
  57101. * @param scene defines the hosting scene
  57102. * @param earcutInjection can be used to inject your own earcut reference
  57103. * @returns the polygon mesh
  57104. */
  57105. static ExtrudePolygon(name: string, options: {
  57106. shape: Vector3[];
  57107. holes?: Vector3[][];
  57108. depth?: number;
  57109. faceUV?: Vector4[];
  57110. faceColors?: Color4[];
  57111. updatable?: boolean;
  57112. sideOrientation?: number;
  57113. frontUVs?: Vector4;
  57114. backUVs?: Vector4;
  57115. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  57116. /**
  57117. * Creates a tube mesh.
  57118. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57119. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  57120. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  57121. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  57122. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  57123. * * 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)
  57124. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  57125. * * 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
  57126. * * 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
  57127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57128. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57129. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57131. * @param name defines the name of the mesh
  57132. * @param options defines the options used to create the mesh
  57133. * @param scene defines the hosting scene
  57134. * @returns the tube mesh
  57135. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57136. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57137. */
  57138. static CreateTube(name: string, options: {
  57139. path: Vector3[];
  57140. radius?: number;
  57141. tessellation?: number;
  57142. radiusFunction?: {
  57143. (i: number, distance: number): number;
  57144. };
  57145. cap?: number;
  57146. arc?: number;
  57147. updatable?: boolean;
  57148. sideOrientation?: number;
  57149. frontUVs?: Vector4;
  57150. backUVs?: Vector4;
  57151. instance?: Mesh;
  57152. invertUV?: boolean;
  57153. }, scene?: Nullable<Scene>): Mesh;
  57154. /**
  57155. * Creates a polyhedron mesh
  57156. * * 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
  57157. * * The parameter `size` (positive float, default 1) sets the polygon size
  57158. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57159. * * 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`
  57160. * * 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
  57161. * * 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)`)
  57162. * * 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
  57163. * * 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
  57164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57165. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57167. * @param name defines the name of the mesh
  57168. * @param options defines the options used to create the mesh
  57169. * @param scene defines the hosting scene
  57170. * @returns the polyhedron mesh
  57171. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57172. */
  57173. static CreatePolyhedron(name: string, options: {
  57174. type?: number;
  57175. size?: number;
  57176. sizeX?: number;
  57177. sizeY?: number;
  57178. sizeZ?: number;
  57179. custom?: any;
  57180. faceUV?: Vector4[];
  57181. faceColors?: Color4[];
  57182. flat?: boolean;
  57183. updatable?: boolean;
  57184. sideOrientation?: number;
  57185. frontUVs?: Vector4;
  57186. backUVs?: Vector4;
  57187. }, scene?: Nullable<Scene>): Mesh;
  57188. /**
  57189. * Creates a decal mesh.
  57190. * 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
  57191. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57192. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57193. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57194. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57195. * @param name defines the name of the mesh
  57196. * @param sourceMesh defines the mesh where the decal must be applied
  57197. * @param options defines the options used to create the mesh
  57198. * @param scene defines the hosting scene
  57199. * @returns the decal mesh
  57200. * @see https://doc.babylonjs.com/how_to/decals
  57201. */
  57202. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57203. position?: Vector3;
  57204. normal?: Vector3;
  57205. size?: Vector3;
  57206. angle?: number;
  57207. }): Mesh;
  57208. }
  57209. }
  57210. declare module "babylonjs/Meshes/meshSimplification" {
  57211. import { Mesh } from "babylonjs/Meshes/mesh";
  57212. /**
  57213. * A simplifier interface for future simplification implementations
  57214. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57215. */
  57216. export interface ISimplifier {
  57217. /**
  57218. * Simplification of a given mesh according to the given settings.
  57219. * Since this requires computation, it is assumed that the function runs async.
  57220. * @param settings The settings of the simplification, including quality and distance
  57221. * @param successCallback A callback that will be called after the mesh was simplified.
  57222. * @param errorCallback in case of an error, this callback will be called. optional.
  57223. */
  57224. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  57225. }
  57226. /**
  57227. * Expected simplification settings.
  57228. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  57229. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57230. */
  57231. export interface ISimplificationSettings {
  57232. /**
  57233. * Gets or sets the expected quality
  57234. */
  57235. quality: number;
  57236. /**
  57237. * Gets or sets the distance when this optimized version should be used
  57238. */
  57239. distance: number;
  57240. /**
  57241. * Gets an already optimized mesh
  57242. */
  57243. optimizeMesh?: boolean;
  57244. }
  57245. /**
  57246. * Class used to specify simplification options
  57247. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57248. */
  57249. export class SimplificationSettings implements ISimplificationSettings {
  57250. /** expected quality */
  57251. quality: number;
  57252. /** distance when this optimized version should be used */
  57253. distance: number;
  57254. /** already optimized mesh */
  57255. optimizeMesh?: boolean | undefined;
  57256. /**
  57257. * Creates a SimplificationSettings
  57258. * @param quality expected quality
  57259. * @param distance distance when this optimized version should be used
  57260. * @param optimizeMesh already optimized mesh
  57261. */
  57262. constructor(
  57263. /** expected quality */
  57264. quality: number,
  57265. /** distance when this optimized version should be used */
  57266. distance: number,
  57267. /** already optimized mesh */
  57268. optimizeMesh?: boolean | undefined);
  57269. }
  57270. /**
  57271. * Interface used to define a simplification task
  57272. */
  57273. export interface ISimplificationTask {
  57274. /**
  57275. * Array of settings
  57276. */
  57277. settings: Array<ISimplificationSettings>;
  57278. /**
  57279. * Simplification type
  57280. */
  57281. simplificationType: SimplificationType;
  57282. /**
  57283. * Mesh to simplify
  57284. */
  57285. mesh: Mesh;
  57286. /**
  57287. * Callback called on success
  57288. */
  57289. successCallback?: () => void;
  57290. /**
  57291. * Defines if parallel processing can be used
  57292. */
  57293. parallelProcessing: boolean;
  57294. }
  57295. /**
  57296. * Queue used to order the simplification tasks
  57297. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57298. */
  57299. export class SimplificationQueue {
  57300. private _simplificationArray;
  57301. /**
  57302. * Gets a boolean indicating that the process is still running
  57303. */
  57304. running: boolean;
  57305. /**
  57306. * Creates a new queue
  57307. */
  57308. constructor();
  57309. /**
  57310. * Adds a new simplification task
  57311. * @param task defines a task to add
  57312. */
  57313. addTask(task: ISimplificationTask): void;
  57314. /**
  57315. * Execute next task
  57316. */
  57317. executeNext(): void;
  57318. /**
  57319. * Execute a simplification task
  57320. * @param task defines the task to run
  57321. */
  57322. runSimplification(task: ISimplificationTask): void;
  57323. private getSimplifier;
  57324. }
  57325. /**
  57326. * The implemented types of simplification
  57327. * At the moment only Quadratic Error Decimation is implemented
  57328. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57329. */
  57330. export enum SimplificationType {
  57331. /** Quadratic error decimation */
  57332. QUADRATIC = 0
  57333. }
  57334. }
  57335. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  57336. import { Scene } from "babylonjs/scene";
  57337. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  57338. import { ISceneComponent } from "babylonjs/sceneComponent";
  57339. module "babylonjs/scene" {
  57340. interface Scene {
  57341. /** @hidden (Backing field) */
  57342. _simplificationQueue: SimplificationQueue;
  57343. /**
  57344. * Gets or sets the simplification queue attached to the scene
  57345. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57346. */
  57347. simplificationQueue: SimplificationQueue;
  57348. }
  57349. }
  57350. module "babylonjs/Meshes/mesh" {
  57351. interface Mesh {
  57352. /**
  57353. * Simplify the mesh according to the given array of settings.
  57354. * Function will return immediately and will simplify async
  57355. * @param settings a collection of simplification settings
  57356. * @param parallelProcessing should all levels calculate parallel or one after the other
  57357. * @param simplificationType the type of simplification to run
  57358. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  57359. * @returns the current mesh
  57360. */
  57361. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  57362. }
  57363. }
  57364. /**
  57365. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  57366. * created in a scene
  57367. */
  57368. export class SimplicationQueueSceneComponent implements ISceneComponent {
  57369. /**
  57370. * The component name helpfull to identify the component in the list of scene components.
  57371. */
  57372. readonly name: string;
  57373. /**
  57374. * The scene the component belongs to.
  57375. */
  57376. scene: Scene;
  57377. /**
  57378. * Creates a new instance of the component for the given scene
  57379. * @param scene Defines the scene to register the component in
  57380. */
  57381. constructor(scene: Scene);
  57382. /**
  57383. * Registers the component in a given scene
  57384. */
  57385. register(): void;
  57386. /**
  57387. * Rebuilds the elements related to this component in case of
  57388. * context lost for instance.
  57389. */
  57390. rebuild(): void;
  57391. /**
  57392. * Disposes the component and the associated ressources
  57393. */
  57394. dispose(): void;
  57395. private _beforeCameraUpdate;
  57396. }
  57397. }
  57398. declare module "babylonjs/Meshes/Builders/index" {
  57399. export * from "babylonjs/Meshes/Builders/boxBuilder";
  57400. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  57401. export * from "babylonjs/Meshes/Builders/discBuilder";
  57402. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  57403. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  57404. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  57405. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  57406. export * from "babylonjs/Meshes/Builders/torusBuilder";
  57407. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  57408. export * from "babylonjs/Meshes/Builders/linesBuilder";
  57409. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  57410. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  57411. export * from "babylonjs/Meshes/Builders/latheBuilder";
  57412. export * from "babylonjs/Meshes/Builders/planeBuilder";
  57413. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  57414. export * from "babylonjs/Meshes/Builders/groundBuilder";
  57415. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  57416. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  57417. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  57418. export * from "babylonjs/Meshes/Builders/decalBuilder";
  57419. }
  57420. declare module "babylonjs/Meshes/index" {
  57421. export * from "babylonjs/Meshes/abstractMesh";
  57422. export * from "babylonjs/Meshes/buffer";
  57423. export * from "babylonjs/Meshes/Compression/index";
  57424. export * from "babylonjs/Meshes/csg";
  57425. export * from "babylonjs/Meshes/geometry";
  57426. export * from "babylonjs/Meshes/groundMesh";
  57427. export * from "babylonjs/Meshes/trailMesh";
  57428. export * from "babylonjs/Meshes/instancedMesh";
  57429. export * from "babylonjs/Meshes/linesMesh";
  57430. export * from "babylonjs/Meshes/mesh";
  57431. export * from "babylonjs/Meshes/mesh.vertexData";
  57432. export * from "babylonjs/Meshes/meshBuilder";
  57433. export * from "babylonjs/Meshes/meshSimplification";
  57434. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  57435. export * from "babylonjs/Meshes/polygonMesh";
  57436. export * from "babylonjs/Meshes/subMesh";
  57437. export * from "babylonjs/Meshes/meshLODLevel";
  57438. export * from "babylonjs/Meshes/transformNode";
  57439. export * from "babylonjs/Meshes/Builders/index";
  57440. export * from "babylonjs/Meshes/dataBuffer";
  57441. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  57442. }
  57443. declare module "babylonjs/Morph/index" {
  57444. export * from "babylonjs/Morph/morphTarget";
  57445. export * from "babylonjs/Morph/morphTargetManager";
  57446. }
  57447. declare module "babylonjs/Navigation/INavigationEngine" {
  57448. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57449. import { Vector3 } from "babylonjs/Maths/math";
  57450. import { Mesh } from "babylonjs/Meshes/mesh";
  57451. import { Scene } from "babylonjs/scene";
  57452. /**
  57453. * Navigation plugin interface to add navigation constrained by a navigation mesh
  57454. */
  57455. export interface INavigationEnginePlugin {
  57456. /**
  57457. * plugin name
  57458. */
  57459. name: string;
  57460. /**
  57461. * Creates a navigation mesh
  57462. * @param meshes array of all the geometry used to compute the navigatio mesh
  57463. * @param parameters bunch of parameters used to filter geometry
  57464. */
  57465. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57466. /**
  57467. * Create a navigation mesh debug mesh
  57468. * @param scene is where the mesh will be added
  57469. * @returns debug display mesh
  57470. */
  57471. createDebugNavMesh(scene: Scene): Mesh;
  57472. /**
  57473. * Get a navigation mesh constrained position, closest to the parameter position
  57474. * @param position world position
  57475. * @returns the closest point to position constrained by the navigation mesh
  57476. */
  57477. getClosestPoint(position: Vector3): Vector3;
  57478. /**
  57479. * Get a navigation mesh constrained position, within a particular radius
  57480. * @param position world position
  57481. * @param maxRadius the maximum distance to the constrained world position
  57482. * @returns the closest point to position constrained by the navigation mesh
  57483. */
  57484. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57485. /**
  57486. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57487. * @param start world position
  57488. * @param end world position
  57489. * @returns array containing world position composing the path
  57490. */
  57491. computePath(start: Vector3, end: Vector3): Vector3[];
  57492. /**
  57493. * If this plugin is supported
  57494. * @returns true if plugin is supported
  57495. */
  57496. isSupported(): boolean;
  57497. /**
  57498. * Create a new Crowd so you can add agents
  57499. * @param maxAgents the maximum agent count in the crowd
  57500. * @param maxAgentRadius the maximum radius an agent can have
  57501. * @param scene to attach the crowd to
  57502. * @returns the crowd you can add agents to
  57503. */
  57504. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57505. /**
  57506. * Release all resources
  57507. */
  57508. dispose(): void;
  57509. }
  57510. /**
  57511. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  57512. */
  57513. export interface ICrowd {
  57514. /**
  57515. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57516. * You can attach anything to that node. The node position is updated in the scene update tick.
  57517. * @param pos world position that will be constrained by the navigation mesh
  57518. * @param parameters agent parameters
  57519. * @param transform hooked to the agent that will be update by the scene
  57520. * @returns agent index
  57521. */
  57522. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57523. /**
  57524. * Returns the agent position in world space
  57525. * @param index agent index returned by addAgent
  57526. * @returns world space position
  57527. */
  57528. getAgentPosition(index: number): Vector3;
  57529. /**
  57530. * Gets the agent velocity in world space
  57531. * @param index agent index returned by addAgent
  57532. * @returns world space velocity
  57533. */
  57534. getAgentVelocity(index: number): Vector3;
  57535. /**
  57536. * remove a particular agent previously created
  57537. * @param index agent index returned by addAgent
  57538. */
  57539. removeAgent(index: number): void;
  57540. /**
  57541. * get the list of all agents attached to this crowd
  57542. * @returns list of agent indices
  57543. */
  57544. getAgents(): number[];
  57545. /**
  57546. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57547. * @param deltaTime in seconds
  57548. */
  57549. update(deltaTime: number): void;
  57550. /**
  57551. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57552. * @param index agent index returned by addAgent
  57553. * @param destination targeted world position
  57554. */
  57555. agentGoto(index: number, destination: Vector3): void;
  57556. /**
  57557. * Release all resources
  57558. */
  57559. dispose(): void;
  57560. }
  57561. /**
  57562. * Configures an agent
  57563. */
  57564. export interface IAgentParameters {
  57565. /**
  57566. * Agent radius. [Limit: >= 0]
  57567. */
  57568. radius: number;
  57569. /**
  57570. * Agent height. [Limit: > 0]
  57571. */
  57572. height: number;
  57573. /**
  57574. * Maximum allowed acceleration. [Limit: >= 0]
  57575. */
  57576. maxAcceleration: number;
  57577. /**
  57578. * Maximum allowed speed. [Limit: >= 0]
  57579. */
  57580. maxSpeed: number;
  57581. /**
  57582. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  57583. */
  57584. collisionQueryRange: number;
  57585. /**
  57586. * The path visibility optimization range. [Limit: > 0]
  57587. */
  57588. pathOptimizationRange: number;
  57589. /**
  57590. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  57591. */
  57592. separationWeight: number;
  57593. }
  57594. /**
  57595. * Configures the navigation mesh creation
  57596. */
  57597. export interface INavMeshParameters {
  57598. /**
  57599. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  57600. */
  57601. cs: number;
  57602. /**
  57603. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  57604. */
  57605. ch: number;
  57606. /**
  57607. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  57608. */
  57609. walkableSlopeAngle: number;
  57610. /**
  57611. * Minimum floor to 'ceiling' height that will still allow the floor area to
  57612. * be considered walkable. [Limit: >= 3] [Units: vx]
  57613. */
  57614. walkableHeight: number;
  57615. /**
  57616. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  57617. */
  57618. walkableClimb: number;
  57619. /**
  57620. * The distance to erode/shrink the walkable area of the heightfield away from
  57621. * obstructions. [Limit: >=0] [Units: vx]
  57622. */
  57623. walkableRadius: number;
  57624. /**
  57625. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  57626. */
  57627. maxEdgeLen: number;
  57628. /**
  57629. * The maximum distance a simplfied contour's border edges should deviate
  57630. * the original raw contour. [Limit: >=0] [Units: vx]
  57631. */
  57632. maxSimplificationError: number;
  57633. /**
  57634. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  57635. */
  57636. minRegionArea: number;
  57637. /**
  57638. * Any regions with a span count smaller than this value will, if possible,
  57639. * be merged with larger regions. [Limit: >=0] [Units: vx]
  57640. */
  57641. mergeRegionArea: number;
  57642. /**
  57643. * The maximum number of vertices allowed for polygons generated during the
  57644. * contour to polygon conversion process. [Limit: >= 3]
  57645. */
  57646. maxVertsPerPoly: number;
  57647. /**
  57648. * Sets the sampling distance to use when generating the detail mesh.
  57649. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  57650. */
  57651. detailSampleDist: number;
  57652. /**
  57653. * The maximum distance the detail mesh surface should deviate from heightfield
  57654. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  57655. */
  57656. detailSampleMaxError: number;
  57657. }
  57658. }
  57659. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  57660. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  57661. import { Mesh } from "babylonjs/Meshes/mesh";
  57662. import { Scene } from "babylonjs/scene";
  57663. import { Vector3 } from "babylonjs/Maths/math";
  57664. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57665. /**
  57666. * RecastJS navigation plugin
  57667. */
  57668. export class RecastJSPlugin implements INavigationEnginePlugin {
  57669. /**
  57670. * Reference to the Recast library
  57671. */
  57672. bjsRECAST: any;
  57673. /**
  57674. * plugin name
  57675. */
  57676. name: string;
  57677. /**
  57678. * the first navmesh created. We might extend this to support multiple navmeshes
  57679. */
  57680. navMesh: any;
  57681. /**
  57682. * Initializes the recastJS plugin
  57683. * @param recastInjection can be used to inject your own recast reference
  57684. */
  57685. constructor(recastInjection?: any);
  57686. /**
  57687. * Creates a navigation mesh
  57688. * @param meshes array of all the geometry used to compute the navigatio mesh
  57689. * @param parameters bunch of parameters used to filter geometry
  57690. */
  57691. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57692. /**
  57693. * Create a navigation mesh debug mesh
  57694. * @param scene is where the mesh will be added
  57695. * @returns debug display mesh
  57696. */
  57697. createDebugNavMesh(scene: Scene): Mesh;
  57698. /**
  57699. * Get a navigation mesh constrained position, closest to the parameter position
  57700. * @param position world position
  57701. * @returns the closest point to position constrained by the navigation mesh
  57702. */
  57703. getClosestPoint(position: Vector3): Vector3;
  57704. /**
  57705. * Get a navigation mesh constrained position, within a particular radius
  57706. * @param position world position
  57707. * @param maxRadius the maximum distance to the constrained world position
  57708. * @returns the closest point to position constrained by the navigation mesh
  57709. */
  57710. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57711. /**
  57712. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57713. * @param start world position
  57714. * @param end world position
  57715. * @returns array containing world position composing the path
  57716. */
  57717. computePath(start: Vector3, end: Vector3): Vector3[];
  57718. /**
  57719. * Create a new Crowd so you can add agents
  57720. * @param maxAgents the maximum agent count in the crowd
  57721. * @param maxAgentRadius the maximum radius an agent can have
  57722. * @param scene to attach the crowd to
  57723. * @returns the crowd you can add agents to
  57724. */
  57725. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57726. /**
  57727. * Disposes
  57728. */
  57729. dispose(): void;
  57730. /**
  57731. * If this plugin is supported
  57732. * @returns true if plugin is supported
  57733. */
  57734. isSupported(): boolean;
  57735. }
  57736. /**
  57737. * Recast detour crowd implementation
  57738. */
  57739. export class RecastJSCrowd implements ICrowd {
  57740. /**
  57741. * Recast/detour plugin
  57742. */
  57743. bjsRECASTPlugin: RecastJSPlugin;
  57744. /**
  57745. * Link to the detour crowd
  57746. */
  57747. recastCrowd: any;
  57748. /**
  57749. * One transform per agent
  57750. */
  57751. transforms: TransformNode[];
  57752. /**
  57753. * All agents created
  57754. */
  57755. agents: number[];
  57756. /**
  57757. * Link to the scene is kept to unregister the crowd from the scene
  57758. */
  57759. private _scene;
  57760. /**
  57761. * Observer for crowd updates
  57762. */
  57763. private _onBeforeAnimationsObserver;
  57764. /**
  57765. * Constructor
  57766. * @param plugin recastJS plugin
  57767. * @param maxAgents the maximum agent count in the crowd
  57768. * @param maxAgentRadius the maximum radius an agent can have
  57769. * @param scene to attach the crowd to
  57770. * @returns the crowd you can add agents to
  57771. */
  57772. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  57773. /**
  57774. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57775. * You can attach anything to that node. The node position is updated in the scene update tick.
  57776. * @param pos world position that will be constrained by the navigation mesh
  57777. * @param parameters agent parameters
  57778. * @param transform hooked to the agent that will be update by the scene
  57779. * @returns agent index
  57780. */
  57781. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57782. /**
  57783. * Returns the agent position in world space
  57784. * @param index agent index returned by addAgent
  57785. * @returns world space position
  57786. */
  57787. getAgentPosition(index: number): Vector3;
  57788. /**
  57789. * Returns the agent velocity in world space
  57790. * @param index agent index returned by addAgent
  57791. * @returns world space velocity
  57792. */
  57793. getAgentVelocity(index: number): Vector3;
  57794. /**
  57795. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57796. * @param index agent index returned by addAgent
  57797. * @param destination targeted world position
  57798. */
  57799. agentGoto(index: number, destination: Vector3): void;
  57800. /**
  57801. * remove a particular agent previously created
  57802. * @param index agent index returned by addAgent
  57803. */
  57804. removeAgent(index: number): void;
  57805. /**
  57806. * get the list of all agents attached to this crowd
  57807. * @returns list of agent indices
  57808. */
  57809. getAgents(): number[];
  57810. /**
  57811. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57812. * @param deltaTime in seconds
  57813. */
  57814. update(deltaTime: number): void;
  57815. /**
  57816. * Release all resources
  57817. */
  57818. dispose(): void;
  57819. }
  57820. }
  57821. declare module "babylonjs/Navigation/Plugins/index" {
  57822. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  57823. }
  57824. declare module "babylonjs/Navigation/index" {
  57825. export * from "babylonjs/Navigation/INavigationEngine";
  57826. export * from "babylonjs/Navigation/Plugins/index";
  57827. }
  57828. declare module "babylonjs/Offline/database" {
  57829. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  57830. /**
  57831. * Class used to enable access to IndexedDB
  57832. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  57833. */
  57834. export class Database implements IOfflineProvider {
  57835. private _callbackManifestChecked;
  57836. private _currentSceneUrl;
  57837. private _db;
  57838. private _enableSceneOffline;
  57839. private _enableTexturesOffline;
  57840. private _manifestVersionFound;
  57841. private _mustUpdateRessources;
  57842. private _hasReachedQuota;
  57843. private _isSupported;
  57844. private _idbFactory;
  57845. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  57846. private static IsUASupportingBlobStorage;
  57847. /**
  57848. * Gets a boolean indicating if Database storate is enabled (off by default)
  57849. */
  57850. static IDBStorageEnabled: boolean;
  57851. /**
  57852. * Gets a boolean indicating if scene must be saved in the database
  57853. */
  57854. readonly enableSceneOffline: boolean;
  57855. /**
  57856. * Gets a boolean indicating if textures must be saved in the database
  57857. */
  57858. readonly enableTexturesOffline: boolean;
  57859. /**
  57860. * Creates a new Database
  57861. * @param urlToScene defines the url to load the scene
  57862. * @param callbackManifestChecked defines the callback to use when manifest is checked
  57863. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  57864. */
  57865. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  57866. private static _ParseURL;
  57867. private static _ReturnFullUrlLocation;
  57868. private _checkManifestFile;
  57869. /**
  57870. * Open the database and make it available
  57871. * @param successCallback defines the callback to call on success
  57872. * @param errorCallback defines the callback to call on error
  57873. */
  57874. open(successCallback: () => void, errorCallback: () => void): void;
  57875. /**
  57876. * Loads an image from the database
  57877. * @param url defines the url to load from
  57878. * @param image defines the target DOM image
  57879. */
  57880. loadImage(url: string, image: HTMLImageElement): void;
  57881. private _loadImageFromDBAsync;
  57882. private _saveImageIntoDBAsync;
  57883. private _checkVersionFromDB;
  57884. private _loadVersionFromDBAsync;
  57885. private _saveVersionIntoDBAsync;
  57886. /**
  57887. * Loads a file from database
  57888. * @param url defines the URL to load from
  57889. * @param sceneLoaded defines a callback to call on success
  57890. * @param progressCallBack defines a callback to call when progress changed
  57891. * @param errorCallback defines a callback to call on error
  57892. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  57893. */
  57894. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  57895. private _loadFileAsync;
  57896. private _saveFileAsync;
  57897. /**
  57898. * Validates if xhr data is correct
  57899. * @param xhr defines the request to validate
  57900. * @param dataType defines the expected data type
  57901. * @returns true if data is correct
  57902. */
  57903. private static _ValidateXHRData;
  57904. }
  57905. }
  57906. declare module "babylonjs/Offline/index" {
  57907. export * from "babylonjs/Offline/database";
  57908. export * from "babylonjs/Offline/IOfflineProvider";
  57909. }
  57910. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  57911. /** @hidden */
  57912. export var gpuUpdateParticlesPixelShader: {
  57913. name: string;
  57914. shader: string;
  57915. };
  57916. }
  57917. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  57918. /** @hidden */
  57919. export var gpuUpdateParticlesVertexShader: {
  57920. name: string;
  57921. shader: string;
  57922. };
  57923. }
  57924. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  57925. /** @hidden */
  57926. export var clipPlaneFragmentDeclaration2: {
  57927. name: string;
  57928. shader: string;
  57929. };
  57930. }
  57931. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  57932. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  57933. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57934. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57935. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57936. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  57937. /** @hidden */
  57938. export var gpuRenderParticlesPixelShader: {
  57939. name: string;
  57940. shader: string;
  57941. };
  57942. }
  57943. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  57944. /** @hidden */
  57945. export var clipPlaneVertexDeclaration2: {
  57946. name: string;
  57947. shader: string;
  57948. };
  57949. }
  57950. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  57951. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  57952. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  57953. /** @hidden */
  57954. export var gpuRenderParticlesVertexShader: {
  57955. name: string;
  57956. shader: string;
  57957. };
  57958. }
  57959. declare module "babylonjs/Particles/gpuParticleSystem" {
  57960. import { Nullable } from "babylonjs/types";
  57961. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  57962. import { Observable } from "babylonjs/Misc/observable";
  57963. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  57964. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57965. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  57966. import { Scene, IDisposable } from "babylonjs/scene";
  57967. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  57968. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57969. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  57970. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  57971. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  57972. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  57973. /**
  57974. * This represents a GPU particle system in Babylon
  57975. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  57976. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  57977. */
  57978. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  57979. /**
  57980. * The layer mask we are rendering the particles through.
  57981. */
  57982. layerMask: number;
  57983. private _capacity;
  57984. private _activeCount;
  57985. private _currentActiveCount;
  57986. private _accumulatedCount;
  57987. private _renderEffect;
  57988. private _updateEffect;
  57989. private _buffer0;
  57990. private _buffer1;
  57991. private _spriteBuffer;
  57992. private _updateVAO;
  57993. private _renderVAO;
  57994. private _targetIndex;
  57995. private _sourceBuffer;
  57996. private _targetBuffer;
  57997. private _engine;
  57998. private _currentRenderId;
  57999. private _started;
  58000. private _stopped;
  58001. private _timeDelta;
  58002. private _randomTexture;
  58003. private _randomTexture2;
  58004. private _attributesStrideSize;
  58005. private _updateEffectOptions;
  58006. private _randomTextureSize;
  58007. private _actualFrame;
  58008. private readonly _rawTextureWidth;
  58009. /**
  58010. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  58011. */
  58012. static readonly IsSupported: boolean;
  58013. /**
  58014. * An event triggered when the system is disposed.
  58015. */
  58016. onDisposeObservable: Observable<GPUParticleSystem>;
  58017. /**
  58018. * Gets the maximum number of particles active at the same time.
  58019. * @returns The max number of active particles.
  58020. */
  58021. getCapacity(): number;
  58022. /**
  58023. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  58024. * to override the particles.
  58025. */
  58026. forceDepthWrite: boolean;
  58027. /**
  58028. * Gets or set the number of active particles
  58029. */
  58030. activeParticleCount: number;
  58031. private _preWarmDone;
  58032. /**
  58033. * Is this system ready to be used/rendered
  58034. * @return true if the system is ready
  58035. */
  58036. isReady(): boolean;
  58037. /**
  58038. * Gets if the system has been started. (Note: this will still be true after stop is called)
  58039. * @returns True if it has been started, otherwise false.
  58040. */
  58041. isStarted(): boolean;
  58042. /**
  58043. * Starts the particle system and begins to emit
  58044. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  58045. */
  58046. start(delay?: number): void;
  58047. /**
  58048. * Stops the particle system.
  58049. */
  58050. stop(): void;
  58051. /**
  58052. * Remove all active particles
  58053. */
  58054. reset(): void;
  58055. /**
  58056. * Returns the string "GPUParticleSystem"
  58057. * @returns a string containing the class name
  58058. */
  58059. getClassName(): string;
  58060. private _colorGradientsTexture;
  58061. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  58062. /**
  58063. * Adds a new color gradient
  58064. * @param gradient defines the gradient to use (between 0 and 1)
  58065. * @param color1 defines the color to affect to the specified gradient
  58066. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  58067. * @returns the current particle system
  58068. */
  58069. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  58070. /**
  58071. * Remove a specific color gradient
  58072. * @param gradient defines the gradient to remove
  58073. * @returns the current particle system
  58074. */
  58075. removeColorGradient(gradient: number): GPUParticleSystem;
  58076. private _angularSpeedGradientsTexture;
  58077. private _sizeGradientsTexture;
  58078. private _velocityGradientsTexture;
  58079. private _limitVelocityGradientsTexture;
  58080. private _dragGradientsTexture;
  58081. private _addFactorGradient;
  58082. /**
  58083. * Adds a new size gradient
  58084. * @param gradient defines the gradient to use (between 0 and 1)
  58085. * @param factor defines the size factor to affect to the specified gradient
  58086. * @returns the current particle system
  58087. */
  58088. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  58089. /**
  58090. * Remove a specific size gradient
  58091. * @param gradient defines the gradient to remove
  58092. * @returns the current particle system
  58093. */
  58094. removeSizeGradient(gradient: number): GPUParticleSystem;
  58095. /**
  58096. * Adds a new angular speed gradient
  58097. * @param gradient defines the gradient to use (between 0 and 1)
  58098. * @param factor defines the angular speed to affect to the specified gradient
  58099. * @returns the current particle system
  58100. */
  58101. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  58102. /**
  58103. * Remove a specific angular speed gradient
  58104. * @param gradient defines the gradient to remove
  58105. * @returns the current particle system
  58106. */
  58107. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  58108. /**
  58109. * Adds a new velocity gradient
  58110. * @param gradient defines the gradient to use (between 0 and 1)
  58111. * @param factor defines the velocity to affect to the specified gradient
  58112. * @returns the current particle system
  58113. */
  58114. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58115. /**
  58116. * Remove a specific velocity gradient
  58117. * @param gradient defines the gradient to remove
  58118. * @returns the current particle system
  58119. */
  58120. removeVelocityGradient(gradient: number): GPUParticleSystem;
  58121. /**
  58122. * Adds a new limit velocity gradient
  58123. * @param gradient defines the gradient to use (between 0 and 1)
  58124. * @param factor defines the limit velocity value to affect to the specified gradient
  58125. * @returns the current particle system
  58126. */
  58127. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  58128. /**
  58129. * Remove a specific limit velocity gradient
  58130. * @param gradient defines the gradient to remove
  58131. * @returns the current particle system
  58132. */
  58133. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  58134. /**
  58135. * Adds a new drag gradient
  58136. * @param gradient defines the gradient to use (between 0 and 1)
  58137. * @param factor defines the drag value to affect to the specified gradient
  58138. * @returns the current particle system
  58139. */
  58140. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  58141. /**
  58142. * Remove a specific drag gradient
  58143. * @param gradient defines the gradient to remove
  58144. * @returns the current particle system
  58145. */
  58146. removeDragGradient(gradient: number): GPUParticleSystem;
  58147. /**
  58148. * Not supported by GPUParticleSystem
  58149. * @param gradient defines the gradient to use (between 0 and 1)
  58150. * @param factor defines the emit rate value to affect to the specified gradient
  58151. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58152. * @returns the current particle system
  58153. */
  58154. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58155. /**
  58156. * Not supported by GPUParticleSystem
  58157. * @param gradient defines the gradient to remove
  58158. * @returns the current particle system
  58159. */
  58160. removeEmitRateGradient(gradient: number): IParticleSystem;
  58161. /**
  58162. * Not supported by GPUParticleSystem
  58163. * @param gradient defines the gradient to use (between 0 and 1)
  58164. * @param factor defines the start size value to affect to the specified gradient
  58165. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58166. * @returns the current particle system
  58167. */
  58168. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58169. /**
  58170. * Not supported by GPUParticleSystem
  58171. * @param gradient defines the gradient to remove
  58172. * @returns the current particle system
  58173. */
  58174. removeStartSizeGradient(gradient: number): IParticleSystem;
  58175. /**
  58176. * Not supported by GPUParticleSystem
  58177. * @param gradient defines the gradient to use (between 0 and 1)
  58178. * @param min defines the color remap minimal range
  58179. * @param max defines the color remap maximal range
  58180. * @returns the current particle system
  58181. */
  58182. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58183. /**
  58184. * Not supported by GPUParticleSystem
  58185. * @param gradient defines the gradient to remove
  58186. * @returns the current particle system
  58187. */
  58188. removeColorRemapGradient(): IParticleSystem;
  58189. /**
  58190. * Not supported by GPUParticleSystem
  58191. * @param gradient defines the gradient to use (between 0 and 1)
  58192. * @param min defines the alpha remap minimal range
  58193. * @param max defines the alpha remap maximal range
  58194. * @returns the current particle system
  58195. */
  58196. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58197. /**
  58198. * Not supported by GPUParticleSystem
  58199. * @param gradient defines the gradient to remove
  58200. * @returns the current particle system
  58201. */
  58202. removeAlphaRemapGradient(): IParticleSystem;
  58203. /**
  58204. * Not supported by GPUParticleSystem
  58205. * @param gradient defines the gradient to use (between 0 and 1)
  58206. * @param color defines the color to affect to the specified gradient
  58207. * @returns the current particle system
  58208. */
  58209. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  58210. /**
  58211. * Not supported by GPUParticleSystem
  58212. * @param gradient defines the gradient to remove
  58213. * @returns the current particle system
  58214. */
  58215. removeRampGradient(): IParticleSystem;
  58216. /**
  58217. * Not supported by GPUParticleSystem
  58218. * @returns the list of ramp gradients
  58219. */
  58220. getRampGradients(): Nullable<Array<Color3Gradient>>;
  58221. /**
  58222. * Not supported by GPUParticleSystem
  58223. * Gets or sets a boolean indicating that ramp gradients must be used
  58224. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  58225. */
  58226. useRampGradients: boolean;
  58227. /**
  58228. * Not supported by GPUParticleSystem
  58229. * @param gradient defines the gradient to use (between 0 and 1)
  58230. * @param factor defines the life time factor to affect to the specified gradient
  58231. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58232. * @returns the current particle system
  58233. */
  58234. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58235. /**
  58236. * Not supported by GPUParticleSystem
  58237. * @param gradient defines the gradient to remove
  58238. * @returns the current particle system
  58239. */
  58240. removeLifeTimeGradient(gradient: number): IParticleSystem;
  58241. /**
  58242. * Instantiates a GPU particle system.
  58243. * 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.
  58244. * @param name The name of the particle system
  58245. * @param options The options used to create the system
  58246. * @param scene The scene the particle system belongs to
  58247. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  58248. */
  58249. constructor(name: string, options: Partial<{
  58250. capacity: number;
  58251. randomTextureSize: number;
  58252. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  58253. protected _reset(): void;
  58254. private _createUpdateVAO;
  58255. private _createRenderVAO;
  58256. private _initialize;
  58257. /** @hidden */
  58258. _recreateUpdateEffect(): void;
  58259. /** @hidden */
  58260. _recreateRenderEffect(): void;
  58261. /**
  58262. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  58263. * @param preWarm defines if we are in the pre-warmimg phase
  58264. */
  58265. animate(preWarm?: boolean): void;
  58266. private _createFactorGradientTexture;
  58267. private _createSizeGradientTexture;
  58268. private _createAngularSpeedGradientTexture;
  58269. private _createVelocityGradientTexture;
  58270. private _createLimitVelocityGradientTexture;
  58271. private _createDragGradientTexture;
  58272. private _createColorGradientTexture;
  58273. /**
  58274. * Renders the particle system in its current state
  58275. * @param preWarm defines if the system should only update the particles but not render them
  58276. * @returns the current number of particles
  58277. */
  58278. render(preWarm?: boolean): number;
  58279. /**
  58280. * Rebuilds the particle system
  58281. */
  58282. rebuild(): void;
  58283. private _releaseBuffers;
  58284. private _releaseVAOs;
  58285. /**
  58286. * Disposes the particle system and free the associated resources
  58287. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  58288. */
  58289. dispose(disposeTexture?: boolean): void;
  58290. /**
  58291. * Clones the particle system.
  58292. * @param name The name of the cloned object
  58293. * @param newEmitter The new emitter to use
  58294. * @returns the cloned particle system
  58295. */
  58296. clone(name: string, newEmitter: any): GPUParticleSystem;
  58297. /**
  58298. * Serializes the particle system to a JSON object.
  58299. * @returns the JSON object
  58300. */
  58301. serialize(): any;
  58302. /**
  58303. * Parses a JSON object to create a GPU particle system.
  58304. * @param parsedParticleSystem The JSON object to parse
  58305. * @param scene The scene to create the particle system in
  58306. * @param rootUrl The root url to use to load external dependencies like texture
  58307. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  58308. * @returns the parsed GPU particle system
  58309. */
  58310. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  58311. }
  58312. }
  58313. declare module "babylonjs/Particles/particleSystemSet" {
  58314. import { Nullable } from "babylonjs/types";
  58315. import { Color3 } from "babylonjs/Maths/math.color";
  58316. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58317. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58318. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58319. import { Scene, IDisposable } from "babylonjs/scene";
  58320. /**
  58321. * Represents a set of particle systems working together to create a specific effect
  58322. */
  58323. export class ParticleSystemSet implements IDisposable {
  58324. private _emitterCreationOptions;
  58325. private _emitterNode;
  58326. /**
  58327. * Gets the particle system list
  58328. */
  58329. systems: IParticleSystem[];
  58330. /**
  58331. * Gets the emitter node used with this set
  58332. */
  58333. readonly emitterNode: Nullable<TransformNode>;
  58334. /**
  58335. * Creates a new emitter mesh as a sphere
  58336. * @param options defines the options used to create the sphere
  58337. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  58338. * @param scene defines the hosting scene
  58339. */
  58340. setEmitterAsSphere(options: {
  58341. diameter: number;
  58342. segments: number;
  58343. color: Color3;
  58344. }, renderingGroupId: number, scene: Scene): void;
  58345. /**
  58346. * Starts all particle systems of the set
  58347. * @param emitter defines an optional mesh to use as emitter for the particle systems
  58348. */
  58349. start(emitter?: AbstractMesh): void;
  58350. /**
  58351. * Release all associated resources
  58352. */
  58353. dispose(): void;
  58354. /**
  58355. * Serialize the set into a JSON compatible object
  58356. * @returns a JSON compatible representation of the set
  58357. */
  58358. serialize(): any;
  58359. /**
  58360. * Parse a new ParticleSystemSet from a serialized source
  58361. * @param data defines a JSON compatible representation of the set
  58362. * @param scene defines the hosting scene
  58363. * @param gpu defines if we want GPU particles or CPU particles
  58364. * @returns a new ParticleSystemSet
  58365. */
  58366. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  58367. }
  58368. }
  58369. declare module "babylonjs/Particles/particleHelper" {
  58370. import { Nullable } from "babylonjs/types";
  58371. import { Scene } from "babylonjs/scene";
  58372. import { Vector3 } from "babylonjs/Maths/math.vector";
  58373. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58374. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58375. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  58376. /**
  58377. * This class is made for on one-liner static method to help creating particle system set.
  58378. */
  58379. export class ParticleHelper {
  58380. /**
  58381. * Gets or sets base Assets URL
  58382. */
  58383. static BaseAssetsUrl: string;
  58384. /**
  58385. * Create a default particle system that you can tweak
  58386. * @param emitter defines the emitter to use
  58387. * @param capacity defines the system capacity (default is 500 particles)
  58388. * @param scene defines the hosting scene
  58389. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  58390. * @returns the new Particle system
  58391. */
  58392. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  58393. /**
  58394. * This is the main static method (one-liner) of this helper to create different particle systems
  58395. * @param type This string represents the type to the particle system to create
  58396. * @param scene The scene where the particle system should live
  58397. * @param gpu If the system will use gpu
  58398. * @returns the ParticleSystemSet created
  58399. */
  58400. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  58401. /**
  58402. * Static function used to export a particle system to a ParticleSystemSet variable.
  58403. * Please note that the emitter shape is not exported
  58404. * @param systems defines the particle systems to export
  58405. * @returns the created particle system set
  58406. */
  58407. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  58408. }
  58409. }
  58410. declare module "babylonjs/Particles/particleSystemComponent" {
  58411. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58412. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  58413. import "babylonjs/Shaders/particles.vertex";
  58414. module "babylonjs/Engines/engine" {
  58415. interface Engine {
  58416. /**
  58417. * Create an effect to use with particle systems.
  58418. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  58419. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  58420. * @param uniformsNames defines a list of attribute names
  58421. * @param samplers defines an array of string used to represent textures
  58422. * @param defines defines the string containing the defines to use to compile the shaders
  58423. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  58424. * @param onCompiled defines a function to call when the effect creation is successful
  58425. * @param onError defines a function to call when the effect creation has failed
  58426. * @returns the new Effect
  58427. */
  58428. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  58429. }
  58430. }
  58431. module "babylonjs/Meshes/mesh" {
  58432. interface Mesh {
  58433. /**
  58434. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  58435. * @returns an array of IParticleSystem
  58436. */
  58437. getEmittedParticleSystems(): IParticleSystem[];
  58438. /**
  58439. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  58440. * @returns an array of IParticleSystem
  58441. */
  58442. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  58443. }
  58444. }
  58445. /**
  58446. * @hidden
  58447. */
  58448. export var _IDoNeedToBeInTheBuild: number;
  58449. }
  58450. declare module "babylonjs/Particles/index" {
  58451. export * from "babylonjs/Particles/baseParticleSystem";
  58452. export * from "babylonjs/Particles/EmitterTypes/index";
  58453. export * from "babylonjs/Particles/gpuParticleSystem";
  58454. export * from "babylonjs/Particles/IParticleSystem";
  58455. export * from "babylonjs/Particles/particle";
  58456. export * from "babylonjs/Particles/particleHelper";
  58457. export * from "babylonjs/Particles/particleSystem";
  58458. export * from "babylonjs/Particles/particleSystemComponent";
  58459. export * from "babylonjs/Particles/particleSystemSet";
  58460. export * from "babylonjs/Particles/solidParticle";
  58461. export * from "babylonjs/Particles/solidParticleSystem";
  58462. export * from "babylonjs/Particles/subEmitter";
  58463. }
  58464. declare module "babylonjs/Physics/physicsEngineComponent" {
  58465. import { Nullable } from "babylonjs/types";
  58466. import { Observable, Observer } from "babylonjs/Misc/observable";
  58467. import { Vector3 } from "babylonjs/Maths/math.vector";
  58468. import { Mesh } from "babylonjs/Meshes/mesh";
  58469. import { ISceneComponent } from "babylonjs/sceneComponent";
  58470. import { Scene } from "babylonjs/scene";
  58471. import { Node } from "babylonjs/node";
  58472. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  58473. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58474. module "babylonjs/scene" {
  58475. interface Scene {
  58476. /** @hidden (Backing field) */
  58477. _physicsEngine: Nullable<IPhysicsEngine>;
  58478. /**
  58479. * Gets the current physics engine
  58480. * @returns a IPhysicsEngine or null if none attached
  58481. */
  58482. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  58483. /**
  58484. * Enables physics to the current scene
  58485. * @param gravity defines the scene's gravity for the physics engine
  58486. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  58487. * @return a boolean indicating if the physics engine was initialized
  58488. */
  58489. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  58490. /**
  58491. * Disables and disposes the physics engine associated with the scene
  58492. */
  58493. disablePhysicsEngine(): void;
  58494. /**
  58495. * Gets a boolean indicating if there is an active physics engine
  58496. * @returns a boolean indicating if there is an active physics engine
  58497. */
  58498. isPhysicsEnabled(): boolean;
  58499. /**
  58500. * Deletes a physics compound impostor
  58501. * @param compound defines the compound to delete
  58502. */
  58503. deleteCompoundImpostor(compound: any): void;
  58504. /**
  58505. * An event triggered when physic simulation is about to be run
  58506. */
  58507. onBeforePhysicsObservable: Observable<Scene>;
  58508. /**
  58509. * An event triggered when physic simulation has been done
  58510. */
  58511. onAfterPhysicsObservable: Observable<Scene>;
  58512. }
  58513. }
  58514. module "babylonjs/Meshes/abstractMesh" {
  58515. interface AbstractMesh {
  58516. /** @hidden */
  58517. _physicsImpostor: Nullable<PhysicsImpostor>;
  58518. /**
  58519. * Gets or sets impostor used for physic simulation
  58520. * @see http://doc.babylonjs.com/features/physics_engine
  58521. */
  58522. physicsImpostor: Nullable<PhysicsImpostor>;
  58523. /**
  58524. * Gets the current physics impostor
  58525. * @see http://doc.babylonjs.com/features/physics_engine
  58526. * @returns a physics impostor or null
  58527. */
  58528. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  58529. /** Apply a physic impulse to the mesh
  58530. * @param force defines the force to apply
  58531. * @param contactPoint defines where to apply the force
  58532. * @returns the current mesh
  58533. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58534. */
  58535. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  58536. /**
  58537. * Creates a physic joint between two meshes
  58538. * @param otherMesh defines the other mesh to use
  58539. * @param pivot1 defines the pivot to use on this mesh
  58540. * @param pivot2 defines the pivot to use on the other mesh
  58541. * @param options defines additional options (can be plugin dependent)
  58542. * @returns the current mesh
  58543. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  58544. */
  58545. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  58546. /** @hidden */
  58547. _disposePhysicsObserver: Nullable<Observer<Node>>;
  58548. }
  58549. }
  58550. /**
  58551. * Defines the physics engine scene component responsible to manage a physics engine
  58552. */
  58553. export class PhysicsEngineSceneComponent implements ISceneComponent {
  58554. /**
  58555. * The component name helpful to identify the component in the list of scene components.
  58556. */
  58557. readonly name: string;
  58558. /**
  58559. * The scene the component belongs to.
  58560. */
  58561. scene: Scene;
  58562. /**
  58563. * Creates a new instance of the component for the given scene
  58564. * @param scene Defines the scene to register the component in
  58565. */
  58566. constructor(scene: Scene);
  58567. /**
  58568. * Registers the component in a given scene
  58569. */
  58570. register(): void;
  58571. /**
  58572. * Rebuilds the elements related to this component in case of
  58573. * context lost for instance.
  58574. */
  58575. rebuild(): void;
  58576. /**
  58577. * Disposes the component and the associated ressources
  58578. */
  58579. dispose(): void;
  58580. }
  58581. }
  58582. declare module "babylonjs/Physics/physicsHelper" {
  58583. import { Nullable } from "babylonjs/types";
  58584. import { Vector3 } from "babylonjs/Maths/math.vector";
  58585. import { Mesh } from "babylonjs/Meshes/mesh";
  58586. import { Scene } from "babylonjs/scene";
  58587. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58588. /**
  58589. * A helper for physics simulations
  58590. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58591. */
  58592. export class PhysicsHelper {
  58593. private _scene;
  58594. private _physicsEngine;
  58595. /**
  58596. * Initializes the Physics helper
  58597. * @param scene Babylon.js scene
  58598. */
  58599. constructor(scene: Scene);
  58600. /**
  58601. * Applies a radial explosion impulse
  58602. * @param origin the origin of the explosion
  58603. * @param radiusOrEventOptions the radius or the options of radial explosion
  58604. * @param strength the explosion strength
  58605. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58606. * @returns A physics radial explosion event, or null
  58607. */
  58608. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58609. /**
  58610. * Applies a radial explosion force
  58611. * @param origin the origin of the explosion
  58612. * @param radiusOrEventOptions the radius or the options of radial explosion
  58613. * @param strength the explosion strength
  58614. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58615. * @returns A physics radial explosion event, or null
  58616. */
  58617. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58618. /**
  58619. * Creates a gravitational field
  58620. * @param origin the origin of the explosion
  58621. * @param radiusOrEventOptions the radius or the options of radial explosion
  58622. * @param strength the explosion strength
  58623. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58624. * @returns A physics gravitational field event, or null
  58625. */
  58626. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  58627. /**
  58628. * Creates a physics updraft event
  58629. * @param origin the origin of the updraft
  58630. * @param radiusOrEventOptions the radius or the options of the updraft
  58631. * @param strength the strength of the updraft
  58632. * @param height the height of the updraft
  58633. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  58634. * @returns A physics updraft event, or null
  58635. */
  58636. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  58637. /**
  58638. * Creates a physics vortex event
  58639. * @param origin the of the vortex
  58640. * @param radiusOrEventOptions the radius or the options of the vortex
  58641. * @param strength the strength of the vortex
  58642. * @param height the height of the vortex
  58643. * @returns a Physics vortex event, or null
  58644. * A physics vortex event or null
  58645. */
  58646. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  58647. }
  58648. /**
  58649. * Represents a physics radial explosion event
  58650. */
  58651. class PhysicsRadialExplosionEvent {
  58652. private _scene;
  58653. private _options;
  58654. private _sphere;
  58655. private _dataFetched;
  58656. /**
  58657. * Initializes a radial explosioin event
  58658. * @param _scene BabylonJS scene
  58659. * @param _options The options for the vortex event
  58660. */
  58661. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  58662. /**
  58663. * Returns the data related to the radial explosion event (sphere).
  58664. * @returns The radial explosion event data
  58665. */
  58666. getData(): PhysicsRadialExplosionEventData;
  58667. /**
  58668. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  58669. * @param impostor A physics imposter
  58670. * @param origin the origin of the explosion
  58671. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  58672. */
  58673. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  58674. /**
  58675. * Triggers affecterd impostors callbacks
  58676. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  58677. */
  58678. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  58679. /**
  58680. * Disposes the sphere.
  58681. * @param force Specifies if the sphere should be disposed by force
  58682. */
  58683. dispose(force?: boolean): void;
  58684. /*** Helpers ***/
  58685. private _prepareSphere;
  58686. private _intersectsWithSphere;
  58687. }
  58688. /**
  58689. * Represents a gravitational field event
  58690. */
  58691. class PhysicsGravitationalFieldEvent {
  58692. private _physicsHelper;
  58693. private _scene;
  58694. private _origin;
  58695. private _options;
  58696. private _tickCallback;
  58697. private _sphere;
  58698. private _dataFetched;
  58699. /**
  58700. * Initializes the physics gravitational field event
  58701. * @param _physicsHelper A physics helper
  58702. * @param _scene BabylonJS scene
  58703. * @param _origin The origin position of the gravitational field event
  58704. * @param _options The options for the vortex event
  58705. */
  58706. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  58707. /**
  58708. * Returns the data related to the gravitational field event (sphere).
  58709. * @returns A gravitational field event
  58710. */
  58711. getData(): PhysicsGravitationalFieldEventData;
  58712. /**
  58713. * Enables the gravitational field.
  58714. */
  58715. enable(): void;
  58716. /**
  58717. * Disables the gravitational field.
  58718. */
  58719. disable(): void;
  58720. /**
  58721. * Disposes the sphere.
  58722. * @param force The force to dispose from the gravitational field event
  58723. */
  58724. dispose(force?: boolean): void;
  58725. private _tick;
  58726. }
  58727. /**
  58728. * Represents a physics updraft event
  58729. */
  58730. class PhysicsUpdraftEvent {
  58731. private _scene;
  58732. private _origin;
  58733. private _options;
  58734. private _physicsEngine;
  58735. private _originTop;
  58736. private _originDirection;
  58737. private _tickCallback;
  58738. private _cylinder;
  58739. private _cylinderPosition;
  58740. private _dataFetched;
  58741. /**
  58742. * Initializes the physics updraft event
  58743. * @param _scene BabylonJS scene
  58744. * @param _origin The origin position of the updraft
  58745. * @param _options The options for the updraft event
  58746. */
  58747. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  58748. /**
  58749. * Returns the data related to the updraft event (cylinder).
  58750. * @returns A physics updraft event
  58751. */
  58752. getData(): PhysicsUpdraftEventData;
  58753. /**
  58754. * Enables the updraft.
  58755. */
  58756. enable(): void;
  58757. /**
  58758. * Disables the updraft.
  58759. */
  58760. disable(): void;
  58761. /**
  58762. * Disposes the cylinder.
  58763. * @param force Specifies if the updraft should be disposed by force
  58764. */
  58765. dispose(force?: boolean): void;
  58766. private getImpostorHitData;
  58767. private _tick;
  58768. /*** Helpers ***/
  58769. private _prepareCylinder;
  58770. private _intersectsWithCylinder;
  58771. }
  58772. /**
  58773. * Represents a physics vortex event
  58774. */
  58775. class PhysicsVortexEvent {
  58776. private _scene;
  58777. private _origin;
  58778. private _options;
  58779. private _physicsEngine;
  58780. private _originTop;
  58781. private _tickCallback;
  58782. private _cylinder;
  58783. private _cylinderPosition;
  58784. private _dataFetched;
  58785. /**
  58786. * Initializes the physics vortex event
  58787. * @param _scene The BabylonJS scene
  58788. * @param _origin The origin position of the vortex
  58789. * @param _options The options for the vortex event
  58790. */
  58791. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  58792. /**
  58793. * Returns the data related to the vortex event (cylinder).
  58794. * @returns The physics vortex event data
  58795. */
  58796. getData(): PhysicsVortexEventData;
  58797. /**
  58798. * Enables the vortex.
  58799. */
  58800. enable(): void;
  58801. /**
  58802. * Disables the cortex.
  58803. */
  58804. disable(): void;
  58805. /**
  58806. * Disposes the sphere.
  58807. * @param force
  58808. */
  58809. dispose(force?: boolean): void;
  58810. private getImpostorHitData;
  58811. private _tick;
  58812. /*** Helpers ***/
  58813. private _prepareCylinder;
  58814. private _intersectsWithCylinder;
  58815. }
  58816. /**
  58817. * Options fot the radial explosion event
  58818. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58819. */
  58820. export class PhysicsRadialExplosionEventOptions {
  58821. /**
  58822. * The radius of the sphere for the radial explosion.
  58823. */
  58824. radius: number;
  58825. /**
  58826. * The strenth of the explosion.
  58827. */
  58828. strength: number;
  58829. /**
  58830. * The strenght of the force in correspondence to the distance of the affected object
  58831. */
  58832. falloff: PhysicsRadialImpulseFalloff;
  58833. /**
  58834. * Sphere options for the radial explosion.
  58835. */
  58836. sphere: {
  58837. segments: number;
  58838. diameter: number;
  58839. };
  58840. /**
  58841. * Sphere options for the radial explosion.
  58842. */
  58843. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  58844. }
  58845. /**
  58846. * Options fot the updraft event
  58847. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58848. */
  58849. export class PhysicsUpdraftEventOptions {
  58850. /**
  58851. * The radius of the cylinder for the vortex
  58852. */
  58853. radius: number;
  58854. /**
  58855. * The strenth of the updraft.
  58856. */
  58857. strength: number;
  58858. /**
  58859. * The height of the cylinder for the updraft.
  58860. */
  58861. height: number;
  58862. /**
  58863. * The mode for the the updraft.
  58864. */
  58865. updraftMode: PhysicsUpdraftMode;
  58866. }
  58867. /**
  58868. * Options fot the vortex event
  58869. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58870. */
  58871. export class PhysicsVortexEventOptions {
  58872. /**
  58873. * The radius of the cylinder for the vortex
  58874. */
  58875. radius: number;
  58876. /**
  58877. * The strenth of the vortex.
  58878. */
  58879. strength: number;
  58880. /**
  58881. * The height of the cylinder for the vortex.
  58882. */
  58883. height: number;
  58884. /**
  58885. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  58886. */
  58887. centripetalForceThreshold: number;
  58888. /**
  58889. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  58890. */
  58891. centripetalForceMultiplier: number;
  58892. /**
  58893. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  58894. */
  58895. centrifugalForceMultiplier: number;
  58896. /**
  58897. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  58898. */
  58899. updraftForceMultiplier: number;
  58900. }
  58901. /**
  58902. * The strenght of the force in correspondence to the distance of the affected object
  58903. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58904. */
  58905. export enum PhysicsRadialImpulseFalloff {
  58906. /** Defines that impulse is constant in strength across it's whole radius */
  58907. Constant = 0,
  58908. /** Defines that impulse gets weaker if it's further from the origin */
  58909. Linear = 1
  58910. }
  58911. /**
  58912. * The strength of the force in correspondence to the distance of the affected object
  58913. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58914. */
  58915. export enum PhysicsUpdraftMode {
  58916. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  58917. Center = 0,
  58918. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  58919. Perpendicular = 1
  58920. }
  58921. /**
  58922. * Interface for a physics hit data
  58923. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58924. */
  58925. export interface PhysicsHitData {
  58926. /**
  58927. * The force applied at the contact point
  58928. */
  58929. force: Vector3;
  58930. /**
  58931. * The contact point
  58932. */
  58933. contactPoint: Vector3;
  58934. /**
  58935. * The distance from the origin to the contact point
  58936. */
  58937. distanceFromOrigin: number;
  58938. }
  58939. /**
  58940. * Interface for radial explosion event data
  58941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58942. */
  58943. export interface PhysicsRadialExplosionEventData {
  58944. /**
  58945. * A sphere used for the radial explosion event
  58946. */
  58947. sphere: Mesh;
  58948. }
  58949. /**
  58950. * Interface for gravitational field event data
  58951. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58952. */
  58953. export interface PhysicsGravitationalFieldEventData {
  58954. /**
  58955. * A sphere mesh used for the gravitational field event
  58956. */
  58957. sphere: Mesh;
  58958. }
  58959. /**
  58960. * Interface for updraft event data
  58961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58962. */
  58963. export interface PhysicsUpdraftEventData {
  58964. /**
  58965. * A cylinder used for the updraft event
  58966. */
  58967. cylinder: Mesh;
  58968. }
  58969. /**
  58970. * Interface for vortex event data
  58971. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58972. */
  58973. export interface PhysicsVortexEventData {
  58974. /**
  58975. * A cylinder used for the vortex event
  58976. */
  58977. cylinder: Mesh;
  58978. }
  58979. /**
  58980. * Interface for an affected physics impostor
  58981. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58982. */
  58983. export interface PhysicsAffectedImpostorWithData {
  58984. /**
  58985. * The impostor affected by the effect
  58986. */
  58987. impostor: PhysicsImpostor;
  58988. /**
  58989. * The data about the hit/horce from the explosion
  58990. */
  58991. hitData: PhysicsHitData;
  58992. }
  58993. }
  58994. declare module "babylonjs/Physics/Plugins/index" {
  58995. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  58996. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  58997. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  58998. }
  58999. declare module "babylonjs/Physics/index" {
  59000. export * from "babylonjs/Physics/IPhysicsEngine";
  59001. export * from "babylonjs/Physics/physicsEngine";
  59002. export * from "babylonjs/Physics/physicsEngineComponent";
  59003. export * from "babylonjs/Physics/physicsHelper";
  59004. export * from "babylonjs/Physics/physicsImpostor";
  59005. export * from "babylonjs/Physics/physicsJoint";
  59006. export * from "babylonjs/Physics/Plugins/index";
  59007. }
  59008. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  59009. /** @hidden */
  59010. export var blackAndWhitePixelShader: {
  59011. name: string;
  59012. shader: string;
  59013. };
  59014. }
  59015. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  59016. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59017. import { Camera } from "babylonjs/Cameras/camera";
  59018. import { Engine } from "babylonjs/Engines/engine";
  59019. import "babylonjs/Shaders/blackAndWhite.fragment";
  59020. /**
  59021. * Post process used to render in black and white
  59022. */
  59023. export class BlackAndWhitePostProcess extends PostProcess {
  59024. /**
  59025. * Linear about to convert he result to black and white (default: 1)
  59026. */
  59027. degree: number;
  59028. /**
  59029. * Creates a black and white post process
  59030. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  59031. * @param name The name of the effect.
  59032. * @param options The required width/height ratio to downsize to before computing the render pass.
  59033. * @param camera The camera to apply the render pass to.
  59034. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59035. * @param engine The engine which the post process will be applied. (default: current engine)
  59036. * @param reusable If the post process can be reused on the same frame. (default: false)
  59037. */
  59038. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59039. }
  59040. }
  59041. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  59042. import { Nullable } from "babylonjs/types";
  59043. import { Camera } from "babylonjs/Cameras/camera";
  59044. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59045. import { Engine } from "babylonjs/Engines/engine";
  59046. /**
  59047. * This represents a set of one or more post processes in Babylon.
  59048. * A post process can be used to apply a shader to a texture after it is rendered.
  59049. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59050. */
  59051. export class PostProcessRenderEffect {
  59052. private _postProcesses;
  59053. private _getPostProcesses;
  59054. private _singleInstance;
  59055. private _cameras;
  59056. private _indicesForCamera;
  59057. /**
  59058. * Name of the effect
  59059. * @hidden
  59060. */
  59061. _name: string;
  59062. /**
  59063. * Instantiates a post process render effect.
  59064. * A post process can be used to apply a shader to a texture after it is rendered.
  59065. * @param engine The engine the effect is tied to
  59066. * @param name The name of the effect
  59067. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  59068. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  59069. */
  59070. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  59071. /**
  59072. * Checks if all the post processes in the effect are supported.
  59073. */
  59074. readonly isSupported: boolean;
  59075. /**
  59076. * Updates the current state of the effect
  59077. * @hidden
  59078. */
  59079. _update(): void;
  59080. /**
  59081. * Attaches the effect on cameras
  59082. * @param cameras The camera to attach to.
  59083. * @hidden
  59084. */
  59085. _attachCameras(cameras: Camera): void;
  59086. /**
  59087. * Attaches the effect on cameras
  59088. * @param cameras The camera to attach to.
  59089. * @hidden
  59090. */
  59091. _attachCameras(cameras: Camera[]): void;
  59092. /**
  59093. * Detaches the effect on cameras
  59094. * @param cameras The camera to detatch from.
  59095. * @hidden
  59096. */
  59097. _detachCameras(cameras: Camera): void;
  59098. /**
  59099. * Detatches the effect on cameras
  59100. * @param cameras The camera to detatch from.
  59101. * @hidden
  59102. */
  59103. _detachCameras(cameras: Camera[]): void;
  59104. /**
  59105. * Enables the effect on given cameras
  59106. * @param cameras The camera to enable.
  59107. * @hidden
  59108. */
  59109. _enable(cameras: Camera): void;
  59110. /**
  59111. * Enables the effect on given cameras
  59112. * @param cameras The camera to enable.
  59113. * @hidden
  59114. */
  59115. _enable(cameras: Nullable<Camera[]>): void;
  59116. /**
  59117. * Disables the effect on the given cameras
  59118. * @param cameras The camera to disable.
  59119. * @hidden
  59120. */
  59121. _disable(cameras: Camera): void;
  59122. /**
  59123. * Disables the effect on the given cameras
  59124. * @param cameras The camera to disable.
  59125. * @hidden
  59126. */
  59127. _disable(cameras: Nullable<Camera[]>): void;
  59128. /**
  59129. * Gets a list of the post processes contained in the effect.
  59130. * @param camera The camera to get the post processes on.
  59131. * @returns The list of the post processes in the effect.
  59132. */
  59133. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  59134. }
  59135. }
  59136. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  59137. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59138. /** @hidden */
  59139. export var extractHighlightsPixelShader: {
  59140. name: string;
  59141. shader: string;
  59142. };
  59143. }
  59144. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  59145. import { Nullable } from "babylonjs/types";
  59146. import { Camera } from "babylonjs/Cameras/camera";
  59147. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59148. import { Engine } from "babylonjs/Engines/engine";
  59149. import "babylonjs/Shaders/extractHighlights.fragment";
  59150. /**
  59151. * 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.
  59152. */
  59153. export class ExtractHighlightsPostProcess extends PostProcess {
  59154. /**
  59155. * The luminance threshold, pixels below this value will be set to black.
  59156. */
  59157. threshold: number;
  59158. /** @hidden */
  59159. _exposure: number;
  59160. /**
  59161. * Post process which has the input texture to be used when performing highlight extraction
  59162. * @hidden
  59163. */
  59164. _inputPostProcess: Nullable<PostProcess>;
  59165. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59166. }
  59167. }
  59168. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  59169. /** @hidden */
  59170. export var bloomMergePixelShader: {
  59171. name: string;
  59172. shader: string;
  59173. };
  59174. }
  59175. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  59176. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59177. import { Nullable } from "babylonjs/types";
  59178. import { Engine } from "babylonjs/Engines/engine";
  59179. import { Camera } from "babylonjs/Cameras/camera";
  59180. import "babylonjs/Shaders/bloomMerge.fragment";
  59181. /**
  59182. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59183. */
  59184. export class BloomMergePostProcess extends PostProcess {
  59185. /** Weight of the bloom to be added to the original input. */
  59186. weight: number;
  59187. /**
  59188. * Creates a new instance of @see BloomMergePostProcess
  59189. * @param name The name of the effect.
  59190. * @param originalFromInput Post process which's input will be used for the merge.
  59191. * @param blurred Blurred highlights post process which's output will be used.
  59192. * @param weight Weight of the bloom to be added to the original input.
  59193. * @param options The required width/height ratio to downsize to before computing the render pass.
  59194. * @param camera The camera to apply the render pass to.
  59195. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59196. * @param engine The engine which the post process will be applied. (default: current engine)
  59197. * @param reusable If the post process can be reused on the same frame. (default: false)
  59198. * @param textureType Type of textures used when performing the post process. (default: 0)
  59199. * @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)
  59200. */
  59201. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  59202. /** Weight of the bloom to be added to the original input. */
  59203. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59204. }
  59205. }
  59206. declare module "babylonjs/PostProcesses/bloomEffect" {
  59207. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  59208. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59209. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  59210. import { Camera } from "babylonjs/Cameras/camera";
  59211. import { Scene } from "babylonjs/scene";
  59212. /**
  59213. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  59214. */
  59215. export class BloomEffect extends PostProcessRenderEffect {
  59216. private bloomScale;
  59217. /**
  59218. * @hidden Internal
  59219. */
  59220. _effects: Array<PostProcess>;
  59221. /**
  59222. * @hidden Internal
  59223. */
  59224. _downscale: ExtractHighlightsPostProcess;
  59225. private _blurX;
  59226. private _blurY;
  59227. private _merge;
  59228. /**
  59229. * The luminance threshold to find bright areas of the image to bloom.
  59230. */
  59231. threshold: number;
  59232. /**
  59233. * The strength of the bloom.
  59234. */
  59235. weight: number;
  59236. /**
  59237. * Specifies the size of the bloom blur kernel, relative to the final output size
  59238. */
  59239. kernel: number;
  59240. /**
  59241. * Creates a new instance of @see BloomEffect
  59242. * @param scene The scene the effect belongs to.
  59243. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  59244. * @param bloomKernel The size of the kernel to be used when applying the blur.
  59245. * @param bloomWeight The the strength of bloom.
  59246. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59247. * @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)
  59248. */
  59249. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  59250. /**
  59251. * Disposes each of the internal effects for a given camera.
  59252. * @param camera The camera to dispose the effect on.
  59253. */
  59254. disposeEffects(camera: Camera): void;
  59255. /**
  59256. * @hidden Internal
  59257. */
  59258. _updateEffects(): void;
  59259. /**
  59260. * Internal
  59261. * @returns if all the contained post processes are ready.
  59262. * @hidden
  59263. */
  59264. _isReady(): boolean;
  59265. }
  59266. }
  59267. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  59268. /** @hidden */
  59269. export var chromaticAberrationPixelShader: {
  59270. name: string;
  59271. shader: string;
  59272. };
  59273. }
  59274. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  59275. import { Vector2 } from "babylonjs/Maths/math.vector";
  59276. import { Nullable } from "babylonjs/types";
  59277. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59278. import { Camera } from "babylonjs/Cameras/camera";
  59279. import { Engine } from "babylonjs/Engines/engine";
  59280. import "babylonjs/Shaders/chromaticAberration.fragment";
  59281. /**
  59282. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  59283. */
  59284. export class ChromaticAberrationPostProcess extends PostProcess {
  59285. /**
  59286. * The amount of seperation of rgb channels (default: 30)
  59287. */
  59288. aberrationAmount: number;
  59289. /**
  59290. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  59291. */
  59292. radialIntensity: number;
  59293. /**
  59294. * 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))
  59295. */
  59296. direction: Vector2;
  59297. /**
  59298. * 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))
  59299. */
  59300. centerPosition: Vector2;
  59301. /**
  59302. * Creates a new instance ChromaticAberrationPostProcess
  59303. * @param name The name of the effect.
  59304. * @param screenWidth The width of the screen to apply the effect on.
  59305. * @param screenHeight The height of the screen to apply the effect on.
  59306. * @param options The required width/height ratio to downsize to before computing the render pass.
  59307. * @param camera The camera to apply the render pass to.
  59308. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59309. * @param engine The engine which the post process will be applied. (default: current engine)
  59310. * @param reusable If the post process can be reused on the same frame. (default: false)
  59311. * @param textureType Type of textures used when performing the post process. (default: 0)
  59312. * @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)
  59313. */
  59314. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59315. }
  59316. }
  59317. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  59318. /** @hidden */
  59319. export var circleOfConfusionPixelShader: {
  59320. name: string;
  59321. shader: string;
  59322. };
  59323. }
  59324. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  59325. import { Nullable } from "babylonjs/types";
  59326. import { Engine } from "babylonjs/Engines/engine";
  59327. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59328. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59329. import { Camera } from "babylonjs/Cameras/camera";
  59330. import "babylonjs/Shaders/circleOfConfusion.fragment";
  59331. /**
  59332. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  59333. */
  59334. export class CircleOfConfusionPostProcess extends PostProcess {
  59335. /**
  59336. * 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.
  59337. */
  59338. lensSize: number;
  59339. /**
  59340. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59341. */
  59342. fStop: number;
  59343. /**
  59344. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59345. */
  59346. focusDistance: number;
  59347. /**
  59348. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  59349. */
  59350. focalLength: number;
  59351. private _depthTexture;
  59352. /**
  59353. * Creates a new instance CircleOfConfusionPostProcess
  59354. * @param name The name of the effect.
  59355. * @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.
  59356. * @param options The required width/height ratio to downsize to before computing the render pass.
  59357. * @param camera The camera to apply the render pass to.
  59358. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59359. * @param engine The engine which the post process will be applied. (default: current engine)
  59360. * @param reusable If the post process can be reused on the same frame. (default: false)
  59361. * @param textureType Type of textures used when performing the post process. (default: 0)
  59362. * @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)
  59363. */
  59364. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59365. /**
  59366. * 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.
  59367. */
  59368. depthTexture: RenderTargetTexture;
  59369. }
  59370. }
  59371. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  59372. /** @hidden */
  59373. export var colorCorrectionPixelShader: {
  59374. name: string;
  59375. shader: string;
  59376. };
  59377. }
  59378. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  59379. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59380. import { Engine } from "babylonjs/Engines/engine";
  59381. import { Camera } from "babylonjs/Cameras/camera";
  59382. import "babylonjs/Shaders/colorCorrection.fragment";
  59383. /**
  59384. *
  59385. * This post-process allows the modification of rendered colors by using
  59386. * a 'look-up table' (LUT). This effect is also called Color Grading.
  59387. *
  59388. * The object needs to be provided an url to a texture containing the color
  59389. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  59390. * Use an image editing software to tweak the LUT to match your needs.
  59391. *
  59392. * For an example of a color LUT, see here:
  59393. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  59394. * For explanations on color grading, see here:
  59395. * @see http://udn.epicgames.com/Three/ColorGrading.html
  59396. *
  59397. */
  59398. export class ColorCorrectionPostProcess extends PostProcess {
  59399. private _colorTableTexture;
  59400. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59401. }
  59402. }
  59403. declare module "babylonjs/Shaders/convolution.fragment" {
  59404. /** @hidden */
  59405. export var convolutionPixelShader: {
  59406. name: string;
  59407. shader: string;
  59408. };
  59409. }
  59410. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  59411. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59412. import { Nullable } from "babylonjs/types";
  59413. import { Camera } from "babylonjs/Cameras/camera";
  59414. import { Engine } from "babylonjs/Engines/engine";
  59415. import "babylonjs/Shaders/convolution.fragment";
  59416. /**
  59417. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  59418. * input texture to perform effects such as edge detection or sharpening
  59419. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59420. */
  59421. export class ConvolutionPostProcess extends PostProcess {
  59422. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59423. kernel: number[];
  59424. /**
  59425. * Creates a new instance ConvolutionPostProcess
  59426. * @param name The name of the effect.
  59427. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  59428. * @param options The required width/height ratio to downsize to before computing the render pass.
  59429. * @param camera The camera to apply the render pass to.
  59430. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59431. * @param engine The engine which the post process will be applied. (default: current engine)
  59432. * @param reusable If the post process can be reused on the same frame. (default: false)
  59433. * @param textureType Type of textures used when performing the post process. (default: 0)
  59434. */
  59435. constructor(name: string,
  59436. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59437. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59438. /**
  59439. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59440. */
  59441. static EdgeDetect0Kernel: number[];
  59442. /**
  59443. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59444. */
  59445. static EdgeDetect1Kernel: number[];
  59446. /**
  59447. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59448. */
  59449. static EdgeDetect2Kernel: number[];
  59450. /**
  59451. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59452. */
  59453. static SharpenKernel: number[];
  59454. /**
  59455. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59456. */
  59457. static EmbossKernel: number[];
  59458. /**
  59459. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59460. */
  59461. static GaussianKernel: number[];
  59462. }
  59463. }
  59464. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  59465. import { Nullable } from "babylonjs/types";
  59466. import { Vector2 } from "babylonjs/Maths/math.vector";
  59467. import { Camera } from "babylonjs/Cameras/camera";
  59468. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59469. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  59470. import { Engine } from "babylonjs/Engines/engine";
  59471. import { Scene } from "babylonjs/scene";
  59472. /**
  59473. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  59474. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  59475. * based on samples that have a large difference in distance than the center pixel.
  59476. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  59477. */
  59478. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  59479. direction: Vector2;
  59480. /**
  59481. * Creates a new instance CircleOfConfusionPostProcess
  59482. * @param name The name of the effect.
  59483. * @param scene The scene the effect belongs to.
  59484. * @param direction The direction the blur should be applied.
  59485. * @param kernel The size of the kernel used to blur.
  59486. * @param options The required width/height ratio to downsize to before computing the render pass.
  59487. * @param camera The camera to apply the render pass to.
  59488. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  59489. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  59490. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59491. * @param engine The engine which the post process will be applied. (default: current engine)
  59492. * @param reusable If the post process can be reused on the same frame. (default: false)
  59493. * @param textureType Type of textures used when performing the post process. (default: 0)
  59494. * @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)
  59495. */
  59496. 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);
  59497. }
  59498. }
  59499. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  59500. /** @hidden */
  59501. export var depthOfFieldMergePixelShader: {
  59502. name: string;
  59503. shader: string;
  59504. };
  59505. }
  59506. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  59507. import { Nullable } from "babylonjs/types";
  59508. import { Camera } from "babylonjs/Cameras/camera";
  59509. import { Effect } from "babylonjs/Materials/effect";
  59510. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59511. import { Engine } from "babylonjs/Engines/engine";
  59512. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  59513. /**
  59514. * Options to be set when merging outputs from the default pipeline.
  59515. */
  59516. export class DepthOfFieldMergePostProcessOptions {
  59517. /**
  59518. * The original image to merge on top of
  59519. */
  59520. originalFromInput: PostProcess;
  59521. /**
  59522. * Parameters to perform the merge of the depth of field effect
  59523. */
  59524. depthOfField?: {
  59525. circleOfConfusion: PostProcess;
  59526. blurSteps: Array<PostProcess>;
  59527. };
  59528. /**
  59529. * Parameters to perform the merge of bloom effect
  59530. */
  59531. bloom?: {
  59532. blurred: PostProcess;
  59533. weight: number;
  59534. };
  59535. }
  59536. /**
  59537. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59538. */
  59539. export class DepthOfFieldMergePostProcess extends PostProcess {
  59540. private blurSteps;
  59541. /**
  59542. * Creates a new instance of DepthOfFieldMergePostProcess
  59543. * @param name The name of the effect.
  59544. * @param originalFromInput Post process which's input will be used for the merge.
  59545. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  59546. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  59547. * @param options The required width/height ratio to downsize to before computing the render pass.
  59548. * @param camera The camera to apply the render pass to.
  59549. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59550. * @param engine The engine which the post process will be applied. (default: current engine)
  59551. * @param reusable If the post process can be reused on the same frame. (default: false)
  59552. * @param textureType Type of textures used when performing the post process. (default: 0)
  59553. * @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)
  59554. */
  59555. 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);
  59556. /**
  59557. * Updates the effect with the current post process compile time values and recompiles the shader.
  59558. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  59559. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  59560. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  59561. * @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
  59562. * @param onCompiled Called when the shader has been compiled.
  59563. * @param onError Called if there is an error when compiling a shader.
  59564. */
  59565. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  59566. }
  59567. }
  59568. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  59569. import { Nullable } from "babylonjs/types";
  59570. import { Camera } from "babylonjs/Cameras/camera";
  59571. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59572. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59573. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  59574. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  59575. import { Scene } from "babylonjs/scene";
  59576. /**
  59577. * Specifies the level of max blur that should be applied when using the depth of field effect
  59578. */
  59579. export enum DepthOfFieldEffectBlurLevel {
  59580. /**
  59581. * Subtle blur
  59582. */
  59583. Low = 0,
  59584. /**
  59585. * Medium blur
  59586. */
  59587. Medium = 1,
  59588. /**
  59589. * Large blur
  59590. */
  59591. High = 2
  59592. }
  59593. /**
  59594. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  59595. */
  59596. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  59597. private _circleOfConfusion;
  59598. /**
  59599. * @hidden Internal, blurs from high to low
  59600. */
  59601. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  59602. private _depthOfFieldBlurY;
  59603. private _dofMerge;
  59604. /**
  59605. * @hidden Internal post processes in depth of field effect
  59606. */
  59607. _effects: Array<PostProcess>;
  59608. /**
  59609. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  59610. */
  59611. focalLength: number;
  59612. /**
  59613. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59614. */
  59615. fStop: number;
  59616. /**
  59617. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59618. */
  59619. focusDistance: number;
  59620. /**
  59621. * 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.
  59622. */
  59623. lensSize: number;
  59624. /**
  59625. * Creates a new instance DepthOfFieldEffect
  59626. * @param scene The scene the effect belongs to.
  59627. * @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.
  59628. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59629. * @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)
  59630. */
  59631. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  59632. /**
  59633. * Get the current class name of the current effet
  59634. * @returns "DepthOfFieldEffect"
  59635. */
  59636. getClassName(): string;
  59637. /**
  59638. * 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.
  59639. */
  59640. depthTexture: RenderTargetTexture;
  59641. /**
  59642. * Disposes each of the internal effects for a given camera.
  59643. * @param camera The camera to dispose the effect on.
  59644. */
  59645. disposeEffects(camera: Camera): void;
  59646. /**
  59647. * @hidden Internal
  59648. */
  59649. _updateEffects(): void;
  59650. /**
  59651. * Internal
  59652. * @returns if all the contained post processes are ready.
  59653. * @hidden
  59654. */
  59655. _isReady(): boolean;
  59656. }
  59657. }
  59658. declare module "babylonjs/Shaders/displayPass.fragment" {
  59659. /** @hidden */
  59660. export var displayPassPixelShader: {
  59661. name: string;
  59662. shader: string;
  59663. };
  59664. }
  59665. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  59666. import { Nullable } from "babylonjs/types";
  59667. import { Camera } from "babylonjs/Cameras/camera";
  59668. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59669. import { Engine } from "babylonjs/Engines/engine";
  59670. import "babylonjs/Shaders/displayPass.fragment";
  59671. /**
  59672. * DisplayPassPostProcess which produces an output the same as it's input
  59673. */
  59674. export class DisplayPassPostProcess extends PostProcess {
  59675. /**
  59676. * Creates the DisplayPassPostProcess
  59677. * @param name The name of the effect.
  59678. * @param options The required width/height ratio to downsize to before computing the render pass.
  59679. * @param camera The camera to apply the render pass to.
  59680. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59681. * @param engine The engine which the post process will be applied. (default: current engine)
  59682. * @param reusable If the post process can be reused on the same frame. (default: false)
  59683. */
  59684. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59685. }
  59686. }
  59687. declare module "babylonjs/Shaders/filter.fragment" {
  59688. /** @hidden */
  59689. export var filterPixelShader: {
  59690. name: string;
  59691. shader: string;
  59692. };
  59693. }
  59694. declare module "babylonjs/PostProcesses/filterPostProcess" {
  59695. import { Nullable } from "babylonjs/types";
  59696. import { Matrix } from "babylonjs/Maths/math.vector";
  59697. import { Camera } from "babylonjs/Cameras/camera";
  59698. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59699. import { Engine } from "babylonjs/Engines/engine";
  59700. import "babylonjs/Shaders/filter.fragment";
  59701. /**
  59702. * Applies a kernel filter to the image
  59703. */
  59704. export class FilterPostProcess extends PostProcess {
  59705. /** The matrix to be applied to the image */
  59706. kernelMatrix: Matrix;
  59707. /**
  59708. *
  59709. * @param name The name of the effect.
  59710. * @param kernelMatrix The matrix to be applied to the image
  59711. * @param options The required width/height ratio to downsize to before computing the render pass.
  59712. * @param camera The camera to apply the render pass to.
  59713. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59714. * @param engine The engine which the post process will be applied. (default: current engine)
  59715. * @param reusable If the post process can be reused on the same frame. (default: false)
  59716. */
  59717. constructor(name: string,
  59718. /** The matrix to be applied to the image */
  59719. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59720. }
  59721. }
  59722. declare module "babylonjs/Shaders/fxaa.fragment" {
  59723. /** @hidden */
  59724. export var fxaaPixelShader: {
  59725. name: string;
  59726. shader: string;
  59727. };
  59728. }
  59729. declare module "babylonjs/Shaders/fxaa.vertex" {
  59730. /** @hidden */
  59731. export var fxaaVertexShader: {
  59732. name: string;
  59733. shader: string;
  59734. };
  59735. }
  59736. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  59737. import { Nullable } from "babylonjs/types";
  59738. import { Camera } from "babylonjs/Cameras/camera";
  59739. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59740. import { Engine } from "babylonjs/Engines/engine";
  59741. import "babylonjs/Shaders/fxaa.fragment";
  59742. import "babylonjs/Shaders/fxaa.vertex";
  59743. /**
  59744. * Fxaa post process
  59745. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  59746. */
  59747. export class FxaaPostProcess extends PostProcess {
  59748. /** @hidden */
  59749. texelWidth: number;
  59750. /** @hidden */
  59751. texelHeight: number;
  59752. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59753. private _getDefines;
  59754. }
  59755. }
  59756. declare module "babylonjs/Shaders/grain.fragment" {
  59757. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59758. /** @hidden */
  59759. export var grainPixelShader: {
  59760. name: string;
  59761. shader: string;
  59762. };
  59763. }
  59764. declare module "babylonjs/PostProcesses/grainPostProcess" {
  59765. import { Nullable } from "babylonjs/types";
  59766. import { Camera } from "babylonjs/Cameras/camera";
  59767. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59768. import { Engine } from "babylonjs/Engines/engine";
  59769. import "babylonjs/Shaders/grain.fragment";
  59770. /**
  59771. * The GrainPostProcess adds noise to the image at mid luminance levels
  59772. */
  59773. export class GrainPostProcess extends PostProcess {
  59774. /**
  59775. * The intensity of the grain added (default: 30)
  59776. */
  59777. intensity: number;
  59778. /**
  59779. * If the grain should be randomized on every frame
  59780. */
  59781. animated: boolean;
  59782. /**
  59783. * Creates a new instance of @see GrainPostProcess
  59784. * @param name The name of the effect.
  59785. * @param options The required width/height ratio to downsize to before computing the render pass.
  59786. * @param camera The camera to apply the render pass to.
  59787. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59788. * @param engine The engine which the post process will be applied. (default: current engine)
  59789. * @param reusable If the post process can be reused on the same frame. (default: false)
  59790. * @param textureType Type of textures used when performing the post process. (default: 0)
  59791. * @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)
  59792. */
  59793. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59794. }
  59795. }
  59796. declare module "babylonjs/Shaders/highlights.fragment" {
  59797. /** @hidden */
  59798. export var highlightsPixelShader: {
  59799. name: string;
  59800. shader: string;
  59801. };
  59802. }
  59803. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  59804. import { Nullable } from "babylonjs/types";
  59805. import { Camera } from "babylonjs/Cameras/camera";
  59806. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59807. import { Engine } from "babylonjs/Engines/engine";
  59808. import "babylonjs/Shaders/highlights.fragment";
  59809. /**
  59810. * Extracts highlights from the image
  59811. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59812. */
  59813. export class HighlightsPostProcess extends PostProcess {
  59814. /**
  59815. * Extracts highlights from the image
  59816. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59817. * @param name The name of the effect.
  59818. * @param options The required width/height ratio to downsize to before computing the render pass.
  59819. * @param camera The camera to apply the render pass to.
  59820. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59821. * @param engine The engine which the post process will be applied. (default: current engine)
  59822. * @param reusable If the post process can be reused on the same frame. (default: false)
  59823. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  59824. */
  59825. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59826. }
  59827. }
  59828. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  59829. /** @hidden */
  59830. export var mrtFragmentDeclaration: {
  59831. name: string;
  59832. shader: string;
  59833. };
  59834. }
  59835. declare module "babylonjs/Shaders/geometry.fragment" {
  59836. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  59837. /** @hidden */
  59838. export var geometryPixelShader: {
  59839. name: string;
  59840. shader: string;
  59841. };
  59842. }
  59843. declare module "babylonjs/Shaders/geometry.vertex" {
  59844. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59845. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59846. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59847. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59848. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59849. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59850. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59851. /** @hidden */
  59852. export var geometryVertexShader: {
  59853. name: string;
  59854. shader: string;
  59855. };
  59856. }
  59857. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  59858. import { Matrix } from "babylonjs/Maths/math.vector";
  59859. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59860. import { Mesh } from "babylonjs/Meshes/mesh";
  59861. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  59862. import { Effect } from "babylonjs/Materials/effect";
  59863. import { Scene } from "babylonjs/scene";
  59864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59865. import "babylonjs/Shaders/geometry.fragment";
  59866. import "babylonjs/Shaders/geometry.vertex";
  59867. /** @hidden */
  59868. interface ISavedTransformationMatrix {
  59869. world: Matrix;
  59870. viewProjection: Matrix;
  59871. }
  59872. /**
  59873. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  59874. */
  59875. export class GeometryBufferRenderer {
  59876. /**
  59877. * Constant used to retrieve the position texture index in the G-Buffer textures array
  59878. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  59879. */
  59880. static readonly POSITION_TEXTURE_TYPE: number;
  59881. /**
  59882. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  59883. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  59884. */
  59885. static readonly VELOCITY_TEXTURE_TYPE: number;
  59886. /**
  59887. * Dictionary used to store the previous transformation matrices of each rendered mesh
  59888. * in order to compute objects velocities when enableVelocity is set to "true"
  59889. * @hidden
  59890. */
  59891. _previousTransformationMatrices: {
  59892. [index: number]: ISavedTransformationMatrix;
  59893. };
  59894. /**
  59895. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  59896. * in order to compute objects velocities when enableVelocity is set to "true"
  59897. * @hidden
  59898. */
  59899. _previousBonesTransformationMatrices: {
  59900. [index: number]: Float32Array;
  59901. };
  59902. /**
  59903. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  59904. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  59905. */
  59906. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  59907. private _scene;
  59908. private _multiRenderTarget;
  59909. private _ratio;
  59910. private _enablePosition;
  59911. private _enableVelocity;
  59912. private _positionIndex;
  59913. private _velocityIndex;
  59914. protected _effect: Effect;
  59915. protected _cachedDefines: string;
  59916. /**
  59917. * Set the render list (meshes to be rendered) used in the G buffer.
  59918. */
  59919. renderList: Mesh[];
  59920. /**
  59921. * Gets wether or not G buffer are supported by the running hardware.
  59922. * This requires draw buffer supports
  59923. */
  59924. readonly isSupported: boolean;
  59925. /**
  59926. * Returns the index of the given texture type in the G-Buffer textures array
  59927. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  59928. * @returns the index of the given texture type in the G-Buffer textures array
  59929. */
  59930. getTextureIndex(textureType: number): number;
  59931. /**
  59932. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  59933. */
  59934. /**
  59935. * Sets whether or not objects positions are enabled for the G buffer.
  59936. */
  59937. enablePosition: boolean;
  59938. /**
  59939. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  59940. */
  59941. /**
  59942. * Sets wether or not objects velocities are enabled for the G buffer.
  59943. */
  59944. enableVelocity: boolean;
  59945. /**
  59946. * Gets the scene associated with the buffer.
  59947. */
  59948. readonly scene: Scene;
  59949. /**
  59950. * Gets the ratio used by the buffer during its creation.
  59951. * How big is the buffer related to the main canvas.
  59952. */
  59953. readonly ratio: number;
  59954. /** @hidden */
  59955. static _SceneComponentInitialization: (scene: Scene) => void;
  59956. /**
  59957. * Creates a new G Buffer for the scene
  59958. * @param scene The scene the buffer belongs to
  59959. * @param ratio How big is the buffer related to the main canvas.
  59960. */
  59961. constructor(scene: Scene, ratio?: number);
  59962. /**
  59963. * Checks wether everything is ready to render a submesh to the G buffer.
  59964. * @param subMesh the submesh to check readiness for
  59965. * @param useInstances is the mesh drawn using instance or not
  59966. * @returns true if ready otherwise false
  59967. */
  59968. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59969. /**
  59970. * Gets the current underlying G Buffer.
  59971. * @returns the buffer
  59972. */
  59973. getGBuffer(): MultiRenderTarget;
  59974. /**
  59975. * Gets the number of samples used to render the buffer (anti aliasing).
  59976. */
  59977. /**
  59978. * Sets the number of samples used to render the buffer (anti aliasing).
  59979. */
  59980. samples: number;
  59981. /**
  59982. * Disposes the renderer and frees up associated resources.
  59983. */
  59984. dispose(): void;
  59985. protected _createRenderTargets(): void;
  59986. private _copyBonesTransformationMatrices;
  59987. }
  59988. }
  59989. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  59990. import { Nullable } from "babylonjs/types";
  59991. import { Scene } from "babylonjs/scene";
  59992. import { ISceneComponent } from "babylonjs/sceneComponent";
  59993. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  59994. module "babylonjs/scene" {
  59995. interface Scene {
  59996. /** @hidden (Backing field) */
  59997. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  59998. /**
  59999. * Gets or Sets the current geometry buffer associated to the scene.
  60000. */
  60001. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  60002. /**
  60003. * Enables a GeometryBufferRender and associates it with the scene
  60004. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  60005. * @returns the GeometryBufferRenderer
  60006. */
  60007. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  60008. /**
  60009. * Disables the GeometryBufferRender associated with the scene
  60010. */
  60011. disableGeometryBufferRenderer(): void;
  60012. }
  60013. }
  60014. /**
  60015. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  60016. * in several rendering techniques.
  60017. */
  60018. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  60019. /**
  60020. * The component name helpful to identify the component in the list of scene components.
  60021. */
  60022. readonly name: string;
  60023. /**
  60024. * The scene the component belongs to.
  60025. */
  60026. scene: Scene;
  60027. /**
  60028. * Creates a new instance of the component for the given scene
  60029. * @param scene Defines the scene to register the component in
  60030. */
  60031. constructor(scene: Scene);
  60032. /**
  60033. * Registers the component in a given scene
  60034. */
  60035. register(): void;
  60036. /**
  60037. * Rebuilds the elements related to this component in case of
  60038. * context lost for instance.
  60039. */
  60040. rebuild(): void;
  60041. /**
  60042. * Disposes the component and the associated ressources
  60043. */
  60044. dispose(): void;
  60045. private _gatherRenderTargets;
  60046. }
  60047. }
  60048. declare module "babylonjs/Shaders/motionBlur.fragment" {
  60049. /** @hidden */
  60050. export var motionBlurPixelShader: {
  60051. name: string;
  60052. shader: string;
  60053. };
  60054. }
  60055. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  60056. import { Nullable } from "babylonjs/types";
  60057. import { Camera } from "babylonjs/Cameras/camera";
  60058. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60059. import { Scene } from "babylonjs/scene";
  60060. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60061. import "babylonjs/Animations/animatable";
  60062. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  60063. import "babylonjs/Shaders/motionBlur.fragment";
  60064. import { Engine } from "babylonjs/Engines/engine";
  60065. /**
  60066. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  60067. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  60068. * As an example, all you have to do is to create the post-process:
  60069. * var mb = new BABYLON.MotionBlurPostProcess(
  60070. * 'mb', // The name of the effect.
  60071. * scene, // The scene containing the objects to blur according to their velocity.
  60072. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  60073. * camera // The camera to apply the render pass to.
  60074. * );
  60075. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  60076. */
  60077. export class MotionBlurPostProcess extends PostProcess {
  60078. /**
  60079. * Defines how much the image is blurred by the movement. Default value is equal to 1
  60080. */
  60081. motionStrength: number;
  60082. /**
  60083. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  60084. */
  60085. /**
  60086. * Sets the number of iterations to be used for motion blur quality
  60087. */
  60088. motionBlurSamples: number;
  60089. private _motionBlurSamples;
  60090. private _geometryBufferRenderer;
  60091. /**
  60092. * Creates a new instance MotionBlurPostProcess
  60093. * @param name The name of the effect.
  60094. * @param scene The scene containing the objects to blur according to their velocity.
  60095. * @param options The required width/height ratio to downsize to before computing the render pass.
  60096. * @param camera The camera to apply the render pass to.
  60097. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60098. * @param engine The engine which the post process will be applied. (default: current engine)
  60099. * @param reusable If the post process can be reused on the same frame. (default: false)
  60100. * @param textureType Type of textures used when performing the post process. (default: 0)
  60101. * @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)
  60102. */
  60103. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60104. /**
  60105. * Excludes the given skinned mesh from computing bones velocities.
  60106. * 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.
  60107. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  60108. */
  60109. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60110. /**
  60111. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  60112. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  60113. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  60114. */
  60115. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  60116. /**
  60117. * Disposes the post process.
  60118. * @param camera The camera to dispose the post process on.
  60119. */
  60120. dispose(camera?: Camera): void;
  60121. }
  60122. }
  60123. declare module "babylonjs/Shaders/refraction.fragment" {
  60124. /** @hidden */
  60125. export var refractionPixelShader: {
  60126. name: string;
  60127. shader: string;
  60128. };
  60129. }
  60130. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  60131. import { Color3 } from "babylonjs/Maths/math.color";
  60132. import { Camera } from "babylonjs/Cameras/camera";
  60133. import { Texture } from "babylonjs/Materials/Textures/texture";
  60134. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60135. import { Engine } from "babylonjs/Engines/engine";
  60136. import "babylonjs/Shaders/refraction.fragment";
  60137. /**
  60138. * Post process which applies a refractin texture
  60139. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60140. */
  60141. export class RefractionPostProcess extends PostProcess {
  60142. /** the base color of the refraction (used to taint the rendering) */
  60143. color: Color3;
  60144. /** simulated refraction depth */
  60145. depth: number;
  60146. /** the coefficient of the base color (0 to remove base color tainting) */
  60147. colorLevel: number;
  60148. private _refTexture;
  60149. private _ownRefractionTexture;
  60150. /**
  60151. * Gets or sets the refraction texture
  60152. * Please note that you are responsible for disposing the texture if you set it manually
  60153. */
  60154. refractionTexture: Texture;
  60155. /**
  60156. * Initializes the RefractionPostProcess
  60157. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60158. * @param name The name of the effect.
  60159. * @param refractionTextureUrl Url of the refraction texture to use
  60160. * @param color the base color of the refraction (used to taint the rendering)
  60161. * @param depth simulated refraction depth
  60162. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  60163. * @param camera The camera to apply the render pass to.
  60164. * @param options The required width/height ratio to downsize to before computing the render pass.
  60165. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60166. * @param engine The engine which the post process will be applied. (default: current engine)
  60167. * @param reusable If the post process can be reused on the same frame. (default: false)
  60168. */
  60169. constructor(name: string, refractionTextureUrl: string,
  60170. /** the base color of the refraction (used to taint the rendering) */
  60171. color: Color3,
  60172. /** simulated refraction depth */
  60173. depth: number,
  60174. /** the coefficient of the base color (0 to remove base color tainting) */
  60175. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60176. /**
  60177. * Disposes of the post process
  60178. * @param camera Camera to dispose post process on
  60179. */
  60180. dispose(camera: Camera): void;
  60181. }
  60182. }
  60183. declare module "babylonjs/Shaders/sharpen.fragment" {
  60184. /** @hidden */
  60185. export var sharpenPixelShader: {
  60186. name: string;
  60187. shader: string;
  60188. };
  60189. }
  60190. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  60191. import { Nullable } from "babylonjs/types";
  60192. import { Camera } from "babylonjs/Cameras/camera";
  60193. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60194. import "babylonjs/Shaders/sharpen.fragment";
  60195. import { Engine } from "babylonjs/Engines/engine";
  60196. /**
  60197. * The SharpenPostProcess applies a sharpen kernel to every pixel
  60198. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60199. */
  60200. export class SharpenPostProcess extends PostProcess {
  60201. /**
  60202. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  60203. */
  60204. colorAmount: number;
  60205. /**
  60206. * How much sharpness should be applied (default: 0.3)
  60207. */
  60208. edgeAmount: number;
  60209. /**
  60210. * Creates a new instance ConvolutionPostProcess
  60211. * @param name The name of the effect.
  60212. * @param options The required width/height ratio to downsize to before computing the render pass.
  60213. * @param camera The camera to apply the render pass to.
  60214. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60215. * @param engine The engine which the post process will be applied. (default: current engine)
  60216. * @param reusable If the post process can be reused on the same frame. (default: false)
  60217. * @param textureType Type of textures used when performing the post process. (default: 0)
  60218. * @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)
  60219. */
  60220. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60221. }
  60222. }
  60223. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  60224. import { Nullable } from "babylonjs/types";
  60225. import { Camera } from "babylonjs/Cameras/camera";
  60226. import { Engine } from "babylonjs/Engines/engine";
  60227. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60228. import { IInspectable } from "babylonjs/Misc/iInspectable";
  60229. /**
  60230. * PostProcessRenderPipeline
  60231. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60232. */
  60233. export class PostProcessRenderPipeline {
  60234. private engine;
  60235. private _renderEffects;
  60236. private _renderEffectsForIsolatedPass;
  60237. /**
  60238. * List of inspectable custom properties (used by the Inspector)
  60239. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  60240. */
  60241. inspectableCustomProperties: IInspectable[];
  60242. /**
  60243. * @hidden
  60244. */
  60245. protected _cameras: Camera[];
  60246. /** @hidden */
  60247. _name: string;
  60248. /**
  60249. * Gets pipeline name
  60250. */
  60251. readonly name: string;
  60252. /**
  60253. * Initializes a PostProcessRenderPipeline
  60254. * @param engine engine to add the pipeline to
  60255. * @param name name of the pipeline
  60256. */
  60257. constructor(engine: Engine, name: string);
  60258. /**
  60259. * Gets the class name
  60260. * @returns "PostProcessRenderPipeline"
  60261. */
  60262. getClassName(): string;
  60263. /**
  60264. * If all the render effects in the pipeline are supported
  60265. */
  60266. readonly isSupported: boolean;
  60267. /**
  60268. * Adds an effect to the pipeline
  60269. * @param renderEffect the effect to add
  60270. */
  60271. addEffect(renderEffect: PostProcessRenderEffect): void;
  60272. /** @hidden */
  60273. _rebuild(): void;
  60274. /** @hidden */
  60275. _enableEffect(renderEffectName: string, cameras: Camera): void;
  60276. /** @hidden */
  60277. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  60278. /** @hidden */
  60279. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60280. /** @hidden */
  60281. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60282. /** @hidden */
  60283. _attachCameras(cameras: Camera, unique: boolean): void;
  60284. /** @hidden */
  60285. _attachCameras(cameras: Camera[], unique: boolean): void;
  60286. /** @hidden */
  60287. _detachCameras(cameras: Camera): void;
  60288. /** @hidden */
  60289. _detachCameras(cameras: Nullable<Camera[]>): void;
  60290. /** @hidden */
  60291. _update(): void;
  60292. /** @hidden */
  60293. _reset(): void;
  60294. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  60295. /**
  60296. * Disposes of the pipeline
  60297. */
  60298. dispose(): void;
  60299. }
  60300. }
  60301. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  60302. import { Camera } from "babylonjs/Cameras/camera";
  60303. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60304. /**
  60305. * PostProcessRenderPipelineManager class
  60306. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60307. */
  60308. export class PostProcessRenderPipelineManager {
  60309. private _renderPipelines;
  60310. /**
  60311. * Initializes a PostProcessRenderPipelineManager
  60312. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60313. */
  60314. constructor();
  60315. /**
  60316. * Gets the list of supported render pipelines
  60317. */
  60318. readonly supportedPipelines: PostProcessRenderPipeline[];
  60319. /**
  60320. * Adds a pipeline to the manager
  60321. * @param renderPipeline The pipeline to add
  60322. */
  60323. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  60324. /**
  60325. * Attaches a camera to the pipeline
  60326. * @param renderPipelineName The name of the pipeline to attach to
  60327. * @param cameras the camera to attach
  60328. * @param unique if the camera can be attached multiple times to the pipeline
  60329. */
  60330. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  60331. /**
  60332. * Detaches a camera from the pipeline
  60333. * @param renderPipelineName The name of the pipeline to detach from
  60334. * @param cameras the camera to detach
  60335. */
  60336. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  60337. /**
  60338. * Enables an effect by name on a pipeline
  60339. * @param renderPipelineName the name of the pipeline to enable the effect in
  60340. * @param renderEffectName the name of the effect to enable
  60341. * @param cameras the cameras that the effect should be enabled on
  60342. */
  60343. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60344. /**
  60345. * Disables an effect by name on a pipeline
  60346. * @param renderPipelineName the name of the pipeline to disable the effect in
  60347. * @param renderEffectName the name of the effect to disable
  60348. * @param cameras the cameras that the effect should be disabled on
  60349. */
  60350. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60351. /**
  60352. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  60353. */
  60354. update(): void;
  60355. /** @hidden */
  60356. _rebuild(): void;
  60357. /**
  60358. * Disposes of the manager and pipelines
  60359. */
  60360. dispose(): void;
  60361. }
  60362. }
  60363. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  60364. import { ISceneComponent } from "babylonjs/sceneComponent";
  60365. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  60366. import { Scene } from "babylonjs/scene";
  60367. module "babylonjs/scene" {
  60368. interface Scene {
  60369. /** @hidden (Backing field) */
  60370. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60371. /**
  60372. * Gets the postprocess render pipeline manager
  60373. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60374. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60375. */
  60376. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60377. }
  60378. }
  60379. /**
  60380. * Defines the Render Pipeline scene component responsible to rendering pipelines
  60381. */
  60382. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  60383. /**
  60384. * The component name helpfull to identify the component in the list of scene components.
  60385. */
  60386. readonly name: string;
  60387. /**
  60388. * The scene the component belongs to.
  60389. */
  60390. scene: Scene;
  60391. /**
  60392. * Creates a new instance of the component for the given scene
  60393. * @param scene Defines the scene to register the component in
  60394. */
  60395. constructor(scene: Scene);
  60396. /**
  60397. * Registers the component in a given scene
  60398. */
  60399. register(): void;
  60400. /**
  60401. * Rebuilds the elements related to this component in case of
  60402. * context lost for instance.
  60403. */
  60404. rebuild(): void;
  60405. /**
  60406. * Disposes the component and the associated ressources
  60407. */
  60408. dispose(): void;
  60409. private _gatherRenderTargets;
  60410. }
  60411. }
  60412. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  60413. import { Nullable } from "babylonjs/types";
  60414. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60415. import { Camera } from "babylonjs/Cameras/camera";
  60416. import { IDisposable } from "babylonjs/scene";
  60417. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  60418. import { Scene } from "babylonjs/scene";
  60419. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  60420. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  60421. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  60422. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  60423. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  60424. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60425. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  60426. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  60427. import { Animation } from "babylonjs/Animations/animation";
  60428. /**
  60429. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  60430. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60431. */
  60432. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60433. private _scene;
  60434. private _camerasToBeAttached;
  60435. /**
  60436. * ID of the sharpen post process,
  60437. */
  60438. private readonly SharpenPostProcessId;
  60439. /**
  60440. * @ignore
  60441. * ID of the image processing post process;
  60442. */
  60443. readonly ImageProcessingPostProcessId: string;
  60444. /**
  60445. * @ignore
  60446. * ID of the Fast Approximate Anti-Aliasing post process;
  60447. */
  60448. readonly FxaaPostProcessId: string;
  60449. /**
  60450. * ID of the chromatic aberration post process,
  60451. */
  60452. private readonly ChromaticAberrationPostProcessId;
  60453. /**
  60454. * ID of the grain post process
  60455. */
  60456. private readonly GrainPostProcessId;
  60457. /**
  60458. * Sharpen post process which will apply a sharpen convolution to enhance edges
  60459. */
  60460. sharpen: SharpenPostProcess;
  60461. private _sharpenEffect;
  60462. private bloom;
  60463. /**
  60464. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  60465. */
  60466. depthOfField: DepthOfFieldEffect;
  60467. /**
  60468. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60469. */
  60470. fxaa: FxaaPostProcess;
  60471. /**
  60472. * Image post processing pass used to perform operations such as tone mapping or color grading.
  60473. */
  60474. imageProcessing: ImageProcessingPostProcess;
  60475. /**
  60476. * Chromatic aberration post process which will shift rgb colors in the image
  60477. */
  60478. chromaticAberration: ChromaticAberrationPostProcess;
  60479. private _chromaticAberrationEffect;
  60480. /**
  60481. * Grain post process which add noise to the image
  60482. */
  60483. grain: GrainPostProcess;
  60484. private _grainEffect;
  60485. /**
  60486. * Glow post process which adds a glow to emissive areas of the image
  60487. */
  60488. private _glowLayer;
  60489. /**
  60490. * Animations which can be used to tweak settings over a period of time
  60491. */
  60492. animations: Animation[];
  60493. private _imageProcessingConfigurationObserver;
  60494. private _sharpenEnabled;
  60495. private _bloomEnabled;
  60496. private _depthOfFieldEnabled;
  60497. private _depthOfFieldBlurLevel;
  60498. private _fxaaEnabled;
  60499. private _imageProcessingEnabled;
  60500. private _defaultPipelineTextureType;
  60501. private _bloomScale;
  60502. private _chromaticAberrationEnabled;
  60503. private _grainEnabled;
  60504. private _buildAllowed;
  60505. /**
  60506. * Gets active scene
  60507. */
  60508. readonly scene: Scene;
  60509. /**
  60510. * Enable or disable the sharpen process from the pipeline
  60511. */
  60512. sharpenEnabled: boolean;
  60513. private _resizeObserver;
  60514. private _hardwareScaleLevel;
  60515. private _bloomKernel;
  60516. /**
  60517. * Specifies the size of the bloom blur kernel, relative to the final output size
  60518. */
  60519. bloomKernel: number;
  60520. /**
  60521. * Specifies the weight of the bloom in the final rendering
  60522. */
  60523. private _bloomWeight;
  60524. /**
  60525. * Specifies the luma threshold for the area that will be blurred by the bloom
  60526. */
  60527. private _bloomThreshold;
  60528. private _hdr;
  60529. /**
  60530. * The strength of the bloom.
  60531. */
  60532. bloomWeight: number;
  60533. /**
  60534. * The strength of the bloom.
  60535. */
  60536. bloomThreshold: number;
  60537. /**
  60538. * The scale of the bloom, lower value will provide better performance.
  60539. */
  60540. bloomScale: number;
  60541. /**
  60542. * Enable or disable the bloom from the pipeline
  60543. */
  60544. bloomEnabled: boolean;
  60545. private _rebuildBloom;
  60546. /**
  60547. * If the depth of field is enabled.
  60548. */
  60549. depthOfFieldEnabled: boolean;
  60550. /**
  60551. * Blur level of the depth of field effect. (Higher blur will effect performance)
  60552. */
  60553. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  60554. /**
  60555. * If the anti aliasing is enabled.
  60556. */
  60557. fxaaEnabled: boolean;
  60558. private _samples;
  60559. /**
  60560. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60561. */
  60562. samples: number;
  60563. /**
  60564. * If image processing is enabled.
  60565. */
  60566. imageProcessingEnabled: boolean;
  60567. /**
  60568. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  60569. */
  60570. glowLayerEnabled: boolean;
  60571. /**
  60572. * Gets the glow layer (or null if not defined)
  60573. */
  60574. readonly glowLayer: Nullable<GlowLayer>;
  60575. /**
  60576. * Enable or disable the chromaticAberration process from the pipeline
  60577. */
  60578. chromaticAberrationEnabled: boolean;
  60579. /**
  60580. * Enable or disable the grain process from the pipeline
  60581. */
  60582. grainEnabled: boolean;
  60583. /**
  60584. * @constructor
  60585. * @param name - The rendering pipeline name (default: "")
  60586. * @param hdr - If high dynamic range textures should be used (default: true)
  60587. * @param scene - The scene linked to this pipeline (default: the last created scene)
  60588. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  60589. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  60590. */
  60591. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  60592. /**
  60593. * Get the class name
  60594. * @returns "DefaultRenderingPipeline"
  60595. */
  60596. getClassName(): string;
  60597. /**
  60598. * Force the compilation of the entire pipeline.
  60599. */
  60600. prepare(): void;
  60601. private _hasCleared;
  60602. private _prevPostProcess;
  60603. private _prevPrevPostProcess;
  60604. private _setAutoClearAndTextureSharing;
  60605. private _depthOfFieldSceneObserver;
  60606. private _buildPipeline;
  60607. private _disposePostProcesses;
  60608. /**
  60609. * Adds a camera to the pipeline
  60610. * @param camera the camera to be added
  60611. */
  60612. addCamera(camera: Camera): void;
  60613. /**
  60614. * Removes a camera from the pipeline
  60615. * @param camera the camera to remove
  60616. */
  60617. removeCamera(camera: Camera): void;
  60618. /**
  60619. * Dispose of the pipeline and stop all post processes
  60620. */
  60621. dispose(): void;
  60622. /**
  60623. * Serialize the rendering pipeline (Used when exporting)
  60624. * @returns the serialized object
  60625. */
  60626. serialize(): any;
  60627. /**
  60628. * Parse the serialized pipeline
  60629. * @param source Source pipeline.
  60630. * @param scene The scene to load the pipeline to.
  60631. * @param rootUrl The URL of the serialized pipeline.
  60632. * @returns An instantiated pipeline from the serialized object.
  60633. */
  60634. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  60635. }
  60636. }
  60637. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  60638. /** @hidden */
  60639. export var lensHighlightsPixelShader: {
  60640. name: string;
  60641. shader: string;
  60642. };
  60643. }
  60644. declare module "babylonjs/Shaders/depthOfField.fragment" {
  60645. /** @hidden */
  60646. export var depthOfFieldPixelShader: {
  60647. name: string;
  60648. shader: string;
  60649. };
  60650. }
  60651. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  60652. import { Camera } from "babylonjs/Cameras/camera";
  60653. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60654. import { Scene } from "babylonjs/scene";
  60655. import "babylonjs/Shaders/chromaticAberration.fragment";
  60656. import "babylonjs/Shaders/lensHighlights.fragment";
  60657. import "babylonjs/Shaders/depthOfField.fragment";
  60658. /**
  60659. * BABYLON.JS Chromatic Aberration GLSL Shader
  60660. * Author: Olivier Guyot
  60661. * Separates very slightly R, G and B colors on the edges of the screen
  60662. * Inspired by Francois Tarlier & Martins Upitis
  60663. */
  60664. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  60665. /**
  60666. * @ignore
  60667. * The chromatic aberration PostProcess id in the pipeline
  60668. */
  60669. LensChromaticAberrationEffect: string;
  60670. /**
  60671. * @ignore
  60672. * The highlights enhancing PostProcess id in the pipeline
  60673. */
  60674. HighlightsEnhancingEffect: string;
  60675. /**
  60676. * @ignore
  60677. * The depth-of-field PostProcess id in the pipeline
  60678. */
  60679. LensDepthOfFieldEffect: string;
  60680. private _scene;
  60681. private _depthTexture;
  60682. private _grainTexture;
  60683. private _chromaticAberrationPostProcess;
  60684. private _highlightsPostProcess;
  60685. private _depthOfFieldPostProcess;
  60686. private _edgeBlur;
  60687. private _grainAmount;
  60688. private _chromaticAberration;
  60689. private _distortion;
  60690. private _highlightsGain;
  60691. private _highlightsThreshold;
  60692. private _dofDistance;
  60693. private _dofAperture;
  60694. private _dofDarken;
  60695. private _dofPentagon;
  60696. private _blurNoise;
  60697. /**
  60698. * @constructor
  60699. *
  60700. * Effect parameters are as follow:
  60701. * {
  60702. * chromatic_aberration: number; // from 0 to x (1 for realism)
  60703. * edge_blur: number; // from 0 to x (1 for realism)
  60704. * distortion: number; // from 0 to x (1 for realism)
  60705. * grain_amount: number; // from 0 to 1
  60706. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  60707. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  60708. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  60709. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  60710. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  60711. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  60712. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  60713. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  60714. * }
  60715. * Note: if an effect parameter is unset, effect is disabled
  60716. *
  60717. * @param name The rendering pipeline name
  60718. * @param parameters - An object containing all parameters (see above)
  60719. * @param scene The scene linked to this pipeline
  60720. * @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)
  60721. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60722. */
  60723. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  60724. /**
  60725. * Get the class name
  60726. * @returns "LensRenderingPipeline"
  60727. */
  60728. getClassName(): string;
  60729. /**
  60730. * Gets associated scene
  60731. */
  60732. readonly scene: Scene;
  60733. /**
  60734. * Gets or sets the edge blur
  60735. */
  60736. edgeBlur: number;
  60737. /**
  60738. * Gets or sets the grain amount
  60739. */
  60740. grainAmount: number;
  60741. /**
  60742. * Gets or sets the chromatic aberration amount
  60743. */
  60744. chromaticAberration: number;
  60745. /**
  60746. * Gets or sets the depth of field aperture
  60747. */
  60748. dofAperture: number;
  60749. /**
  60750. * Gets or sets the edge distortion
  60751. */
  60752. edgeDistortion: number;
  60753. /**
  60754. * Gets or sets the depth of field distortion
  60755. */
  60756. dofDistortion: number;
  60757. /**
  60758. * Gets or sets the darken out of focus amount
  60759. */
  60760. darkenOutOfFocus: number;
  60761. /**
  60762. * Gets or sets a boolean indicating if blur noise is enabled
  60763. */
  60764. blurNoise: boolean;
  60765. /**
  60766. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  60767. */
  60768. pentagonBokeh: boolean;
  60769. /**
  60770. * Gets or sets the highlight grain amount
  60771. */
  60772. highlightsGain: number;
  60773. /**
  60774. * Gets or sets the highlight threshold
  60775. */
  60776. highlightsThreshold: number;
  60777. /**
  60778. * Sets the amount of blur at the edges
  60779. * @param amount blur amount
  60780. */
  60781. setEdgeBlur(amount: number): void;
  60782. /**
  60783. * Sets edge blur to 0
  60784. */
  60785. disableEdgeBlur(): void;
  60786. /**
  60787. * Sets the amout of grain
  60788. * @param amount Amount of grain
  60789. */
  60790. setGrainAmount(amount: number): void;
  60791. /**
  60792. * Set grain amount to 0
  60793. */
  60794. disableGrain(): void;
  60795. /**
  60796. * Sets the chromatic aberration amount
  60797. * @param amount amount of chromatic aberration
  60798. */
  60799. setChromaticAberration(amount: number): void;
  60800. /**
  60801. * Sets chromatic aberration amount to 0
  60802. */
  60803. disableChromaticAberration(): void;
  60804. /**
  60805. * Sets the EdgeDistortion amount
  60806. * @param amount amount of EdgeDistortion
  60807. */
  60808. setEdgeDistortion(amount: number): void;
  60809. /**
  60810. * Sets edge distortion to 0
  60811. */
  60812. disableEdgeDistortion(): void;
  60813. /**
  60814. * Sets the FocusDistance amount
  60815. * @param amount amount of FocusDistance
  60816. */
  60817. setFocusDistance(amount: number): void;
  60818. /**
  60819. * Disables depth of field
  60820. */
  60821. disableDepthOfField(): void;
  60822. /**
  60823. * Sets the Aperture amount
  60824. * @param amount amount of Aperture
  60825. */
  60826. setAperture(amount: number): void;
  60827. /**
  60828. * Sets the DarkenOutOfFocus amount
  60829. * @param amount amount of DarkenOutOfFocus
  60830. */
  60831. setDarkenOutOfFocus(amount: number): void;
  60832. private _pentagonBokehIsEnabled;
  60833. /**
  60834. * Creates a pentagon bokeh effect
  60835. */
  60836. enablePentagonBokeh(): void;
  60837. /**
  60838. * Disables the pentagon bokeh effect
  60839. */
  60840. disablePentagonBokeh(): void;
  60841. /**
  60842. * Enables noise blur
  60843. */
  60844. enableNoiseBlur(): void;
  60845. /**
  60846. * Disables noise blur
  60847. */
  60848. disableNoiseBlur(): void;
  60849. /**
  60850. * Sets the HighlightsGain amount
  60851. * @param amount amount of HighlightsGain
  60852. */
  60853. setHighlightsGain(amount: number): void;
  60854. /**
  60855. * Sets the HighlightsThreshold amount
  60856. * @param amount amount of HighlightsThreshold
  60857. */
  60858. setHighlightsThreshold(amount: number): void;
  60859. /**
  60860. * Disables highlights
  60861. */
  60862. disableHighlights(): void;
  60863. /**
  60864. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  60865. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  60866. */
  60867. dispose(disableDepthRender?: boolean): void;
  60868. private _createChromaticAberrationPostProcess;
  60869. private _createHighlightsPostProcess;
  60870. private _createDepthOfFieldPostProcess;
  60871. private _createGrainTexture;
  60872. }
  60873. }
  60874. declare module "babylonjs/Shaders/ssao2.fragment" {
  60875. /** @hidden */
  60876. export var ssao2PixelShader: {
  60877. name: string;
  60878. shader: string;
  60879. };
  60880. }
  60881. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  60882. /** @hidden */
  60883. export var ssaoCombinePixelShader: {
  60884. name: string;
  60885. shader: string;
  60886. };
  60887. }
  60888. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  60889. import { Camera } from "babylonjs/Cameras/camera";
  60890. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60891. import { Scene } from "babylonjs/scene";
  60892. import "babylonjs/Shaders/ssao2.fragment";
  60893. import "babylonjs/Shaders/ssaoCombine.fragment";
  60894. /**
  60895. * Render pipeline to produce ssao effect
  60896. */
  60897. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  60898. /**
  60899. * @ignore
  60900. * The PassPostProcess id in the pipeline that contains the original scene color
  60901. */
  60902. SSAOOriginalSceneColorEffect: string;
  60903. /**
  60904. * @ignore
  60905. * The SSAO PostProcess id in the pipeline
  60906. */
  60907. SSAORenderEffect: string;
  60908. /**
  60909. * @ignore
  60910. * The horizontal blur PostProcess id in the pipeline
  60911. */
  60912. SSAOBlurHRenderEffect: string;
  60913. /**
  60914. * @ignore
  60915. * The vertical blur PostProcess id in the pipeline
  60916. */
  60917. SSAOBlurVRenderEffect: string;
  60918. /**
  60919. * @ignore
  60920. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60921. */
  60922. SSAOCombineRenderEffect: string;
  60923. /**
  60924. * The output strength of the SSAO post-process. Default value is 1.0.
  60925. */
  60926. totalStrength: number;
  60927. /**
  60928. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  60929. */
  60930. maxZ: number;
  60931. /**
  60932. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  60933. */
  60934. minZAspect: number;
  60935. private _samples;
  60936. /**
  60937. * Number of samples used for the SSAO calculations. Default value is 8
  60938. */
  60939. samples: number;
  60940. private _textureSamples;
  60941. /**
  60942. * Number of samples to use for antialiasing
  60943. */
  60944. textureSamples: number;
  60945. /**
  60946. * Ratio object used for SSAO ratio and blur ratio
  60947. */
  60948. private _ratio;
  60949. /**
  60950. * Dynamically generated sphere sampler.
  60951. */
  60952. private _sampleSphere;
  60953. /**
  60954. * Blur filter offsets
  60955. */
  60956. private _samplerOffsets;
  60957. private _expensiveBlur;
  60958. /**
  60959. * If bilateral blur should be used
  60960. */
  60961. expensiveBlur: boolean;
  60962. /**
  60963. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  60964. */
  60965. radius: number;
  60966. /**
  60967. * The base color of the SSAO post-process
  60968. * The final result is "base + ssao" between [0, 1]
  60969. */
  60970. base: number;
  60971. /**
  60972. * Support test.
  60973. */
  60974. static readonly IsSupported: boolean;
  60975. private _scene;
  60976. private _depthTexture;
  60977. private _normalTexture;
  60978. private _randomTexture;
  60979. private _originalColorPostProcess;
  60980. private _ssaoPostProcess;
  60981. private _blurHPostProcess;
  60982. private _blurVPostProcess;
  60983. private _ssaoCombinePostProcess;
  60984. private _firstUpdate;
  60985. /**
  60986. * Gets active scene
  60987. */
  60988. readonly scene: Scene;
  60989. /**
  60990. * @constructor
  60991. * @param name The rendering pipeline name
  60992. * @param scene The scene linked to this pipeline
  60993. * @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 }
  60994. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60995. */
  60996. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  60997. /**
  60998. * Get the class name
  60999. * @returns "SSAO2RenderingPipeline"
  61000. */
  61001. getClassName(): string;
  61002. /**
  61003. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61004. */
  61005. dispose(disableGeometryBufferRenderer?: boolean): void;
  61006. private _createBlurPostProcess;
  61007. /** @hidden */
  61008. _rebuild(): void;
  61009. private _bits;
  61010. private _radicalInverse_VdC;
  61011. private _hammersley;
  61012. private _hemisphereSample_uniform;
  61013. private _generateHemisphere;
  61014. private _createSSAOPostProcess;
  61015. private _createSSAOCombinePostProcess;
  61016. private _createRandomTexture;
  61017. /**
  61018. * Serialize the rendering pipeline (Used when exporting)
  61019. * @returns the serialized object
  61020. */
  61021. serialize(): any;
  61022. /**
  61023. * Parse the serialized pipeline
  61024. * @param source Source pipeline.
  61025. * @param scene The scene to load the pipeline to.
  61026. * @param rootUrl The URL of the serialized pipeline.
  61027. * @returns An instantiated pipeline from the serialized object.
  61028. */
  61029. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  61030. }
  61031. }
  61032. declare module "babylonjs/Shaders/ssao.fragment" {
  61033. /** @hidden */
  61034. export var ssaoPixelShader: {
  61035. name: string;
  61036. shader: string;
  61037. };
  61038. }
  61039. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  61040. import { Camera } from "babylonjs/Cameras/camera";
  61041. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61042. import { Scene } from "babylonjs/scene";
  61043. import "babylonjs/Shaders/ssao.fragment";
  61044. import "babylonjs/Shaders/ssaoCombine.fragment";
  61045. /**
  61046. * Render pipeline to produce ssao effect
  61047. */
  61048. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  61049. /**
  61050. * @ignore
  61051. * The PassPostProcess id in the pipeline that contains the original scene color
  61052. */
  61053. SSAOOriginalSceneColorEffect: string;
  61054. /**
  61055. * @ignore
  61056. * The SSAO PostProcess id in the pipeline
  61057. */
  61058. SSAORenderEffect: string;
  61059. /**
  61060. * @ignore
  61061. * The horizontal blur PostProcess id in the pipeline
  61062. */
  61063. SSAOBlurHRenderEffect: string;
  61064. /**
  61065. * @ignore
  61066. * The vertical blur PostProcess id in the pipeline
  61067. */
  61068. SSAOBlurVRenderEffect: string;
  61069. /**
  61070. * @ignore
  61071. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  61072. */
  61073. SSAOCombineRenderEffect: string;
  61074. /**
  61075. * The output strength of the SSAO post-process. Default value is 1.0.
  61076. */
  61077. totalStrength: number;
  61078. /**
  61079. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  61080. */
  61081. radius: number;
  61082. /**
  61083. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  61084. * Must not be equal to fallOff and superior to fallOff.
  61085. * Default value is 0.0075
  61086. */
  61087. area: number;
  61088. /**
  61089. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  61090. * Must not be equal to area and inferior to area.
  61091. * Default value is 0.000001
  61092. */
  61093. fallOff: number;
  61094. /**
  61095. * The base color of the SSAO post-process
  61096. * The final result is "base + ssao" between [0, 1]
  61097. */
  61098. base: number;
  61099. private _scene;
  61100. private _depthTexture;
  61101. private _randomTexture;
  61102. private _originalColorPostProcess;
  61103. private _ssaoPostProcess;
  61104. private _blurHPostProcess;
  61105. private _blurVPostProcess;
  61106. private _ssaoCombinePostProcess;
  61107. private _firstUpdate;
  61108. /**
  61109. * Gets active scene
  61110. */
  61111. readonly scene: Scene;
  61112. /**
  61113. * @constructor
  61114. * @param name - The rendering pipeline name
  61115. * @param scene - The scene linked to this pipeline
  61116. * @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 }
  61117. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  61118. */
  61119. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  61120. /**
  61121. * Get the class name
  61122. * @returns "SSAORenderingPipeline"
  61123. */
  61124. getClassName(): string;
  61125. /**
  61126. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  61127. */
  61128. dispose(disableDepthRender?: boolean): void;
  61129. private _createBlurPostProcess;
  61130. /** @hidden */
  61131. _rebuild(): void;
  61132. private _createSSAOPostProcess;
  61133. private _createSSAOCombinePostProcess;
  61134. private _createRandomTexture;
  61135. }
  61136. }
  61137. declare module "babylonjs/Shaders/standard.fragment" {
  61138. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  61139. /** @hidden */
  61140. export var standardPixelShader: {
  61141. name: string;
  61142. shader: string;
  61143. };
  61144. }
  61145. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  61146. import { Nullable } from "babylonjs/types";
  61147. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61148. import { Camera } from "babylonjs/Cameras/camera";
  61149. import { Texture } from "babylonjs/Materials/Textures/texture";
  61150. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61151. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61152. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  61153. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  61154. import { IDisposable } from "babylonjs/scene";
  61155. import { SpotLight } from "babylonjs/Lights/spotLight";
  61156. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  61157. import { Scene } from "babylonjs/scene";
  61158. import { Animation } from "babylonjs/Animations/animation";
  61159. import "babylonjs/Shaders/standard.fragment";
  61160. /**
  61161. * Standard rendering pipeline
  61162. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61163. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  61164. */
  61165. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61166. /**
  61167. * Public members
  61168. */
  61169. /**
  61170. * Post-process which contains the original scene color before the pipeline applies all the effects
  61171. */
  61172. originalPostProcess: Nullable<PostProcess>;
  61173. /**
  61174. * Post-process used to down scale an image x4
  61175. */
  61176. downSampleX4PostProcess: Nullable<PostProcess>;
  61177. /**
  61178. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  61179. */
  61180. brightPassPostProcess: Nullable<PostProcess>;
  61181. /**
  61182. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  61183. */
  61184. blurHPostProcesses: PostProcess[];
  61185. /**
  61186. * Post-process array storing all the vertical blur post-processes used by the pipeline
  61187. */
  61188. blurVPostProcesses: PostProcess[];
  61189. /**
  61190. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  61191. */
  61192. textureAdderPostProcess: Nullable<PostProcess>;
  61193. /**
  61194. * Post-process used to create volumetric lighting effect
  61195. */
  61196. volumetricLightPostProcess: Nullable<PostProcess>;
  61197. /**
  61198. * Post-process used to smooth the previous volumetric light post-process on the X axis
  61199. */
  61200. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  61201. /**
  61202. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  61203. */
  61204. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  61205. /**
  61206. * Post-process used to merge the volumetric light effect and the real scene color
  61207. */
  61208. volumetricLightMergePostProces: Nullable<PostProcess>;
  61209. /**
  61210. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  61211. */
  61212. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  61213. /**
  61214. * Base post-process used to calculate the average luminance of the final image for HDR
  61215. */
  61216. luminancePostProcess: Nullable<PostProcess>;
  61217. /**
  61218. * Post-processes used to create down sample post-processes in order to get
  61219. * the average luminance of the final image for HDR
  61220. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  61221. */
  61222. luminanceDownSamplePostProcesses: PostProcess[];
  61223. /**
  61224. * Post-process used to create a HDR effect (light adaptation)
  61225. */
  61226. hdrPostProcess: Nullable<PostProcess>;
  61227. /**
  61228. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  61229. */
  61230. textureAdderFinalPostProcess: Nullable<PostProcess>;
  61231. /**
  61232. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  61233. */
  61234. lensFlareFinalPostProcess: Nullable<PostProcess>;
  61235. /**
  61236. * Post-process used to merge the final HDR post-process and the real scene color
  61237. */
  61238. hdrFinalPostProcess: Nullable<PostProcess>;
  61239. /**
  61240. * Post-process used to create a lens flare effect
  61241. */
  61242. lensFlarePostProcess: Nullable<PostProcess>;
  61243. /**
  61244. * Post-process that merges the result of the lens flare post-process and the real scene color
  61245. */
  61246. lensFlareComposePostProcess: Nullable<PostProcess>;
  61247. /**
  61248. * Post-process used to create a motion blur effect
  61249. */
  61250. motionBlurPostProcess: Nullable<PostProcess>;
  61251. /**
  61252. * Post-process used to create a depth of field effect
  61253. */
  61254. depthOfFieldPostProcess: Nullable<PostProcess>;
  61255. /**
  61256. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61257. */
  61258. fxaaPostProcess: Nullable<FxaaPostProcess>;
  61259. /**
  61260. * Represents the brightness threshold in order to configure the illuminated surfaces
  61261. */
  61262. brightThreshold: number;
  61263. /**
  61264. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  61265. */
  61266. blurWidth: number;
  61267. /**
  61268. * Sets if the blur for highlighted surfaces must be only horizontal
  61269. */
  61270. horizontalBlur: boolean;
  61271. /**
  61272. * Gets the overall exposure used by the pipeline
  61273. */
  61274. /**
  61275. * Sets the overall exposure used by the pipeline
  61276. */
  61277. exposure: number;
  61278. /**
  61279. * Texture used typically to simulate "dirty" on camera lens
  61280. */
  61281. lensTexture: Nullable<Texture>;
  61282. /**
  61283. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  61284. */
  61285. volumetricLightCoefficient: number;
  61286. /**
  61287. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  61288. */
  61289. volumetricLightPower: number;
  61290. /**
  61291. * Used the set the blur intensity to smooth the volumetric lights
  61292. */
  61293. volumetricLightBlurScale: number;
  61294. /**
  61295. * Light (spot or directional) used to generate the volumetric lights rays
  61296. * The source light must have a shadow generate so the pipeline can get its
  61297. * depth map
  61298. */
  61299. sourceLight: Nullable<SpotLight | DirectionalLight>;
  61300. /**
  61301. * For eye adaptation, represents the minimum luminance the eye can see
  61302. */
  61303. hdrMinimumLuminance: number;
  61304. /**
  61305. * For eye adaptation, represents the decrease luminance speed
  61306. */
  61307. hdrDecreaseRate: number;
  61308. /**
  61309. * For eye adaptation, represents the increase luminance speed
  61310. */
  61311. hdrIncreaseRate: number;
  61312. /**
  61313. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61314. */
  61315. /**
  61316. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61317. */
  61318. hdrAutoExposure: boolean;
  61319. /**
  61320. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  61321. */
  61322. lensColorTexture: Nullable<Texture>;
  61323. /**
  61324. * The overall strengh for the lens flare effect
  61325. */
  61326. lensFlareStrength: number;
  61327. /**
  61328. * Dispersion coefficient for lens flare ghosts
  61329. */
  61330. lensFlareGhostDispersal: number;
  61331. /**
  61332. * Main lens flare halo width
  61333. */
  61334. lensFlareHaloWidth: number;
  61335. /**
  61336. * Based on the lens distortion effect, defines how much the lens flare result
  61337. * is distorted
  61338. */
  61339. lensFlareDistortionStrength: number;
  61340. /**
  61341. * Lens star texture must be used to simulate rays on the flares and is available
  61342. * in the documentation
  61343. */
  61344. lensStarTexture: Nullable<Texture>;
  61345. /**
  61346. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  61347. * flare effect by taking account of the dirt texture
  61348. */
  61349. lensFlareDirtTexture: Nullable<Texture>;
  61350. /**
  61351. * Represents the focal length for the depth of field effect
  61352. */
  61353. depthOfFieldDistance: number;
  61354. /**
  61355. * Represents the blur intensity for the blurred part of the depth of field effect
  61356. */
  61357. depthOfFieldBlurWidth: number;
  61358. /**
  61359. * Gets how much the image is blurred by the movement while using the motion blur post-process
  61360. */
  61361. /**
  61362. * Sets how much the image is blurred by the movement while using the motion blur post-process
  61363. */
  61364. motionStrength: number;
  61365. /**
  61366. * Gets wether or not the motion blur post-process is object based or screen based.
  61367. */
  61368. /**
  61369. * Sets wether or not the motion blur post-process should be object based or screen based
  61370. */
  61371. objectBasedMotionBlur: boolean;
  61372. /**
  61373. * List of animations for the pipeline (IAnimatable implementation)
  61374. */
  61375. animations: Animation[];
  61376. /**
  61377. * Private members
  61378. */
  61379. private _scene;
  61380. private _currentDepthOfFieldSource;
  61381. private _basePostProcess;
  61382. private _fixedExposure;
  61383. private _currentExposure;
  61384. private _hdrAutoExposure;
  61385. private _hdrCurrentLuminance;
  61386. private _motionStrength;
  61387. private _isObjectBasedMotionBlur;
  61388. private _floatTextureType;
  61389. private _ratio;
  61390. private _bloomEnabled;
  61391. private _depthOfFieldEnabled;
  61392. private _vlsEnabled;
  61393. private _lensFlareEnabled;
  61394. private _hdrEnabled;
  61395. private _motionBlurEnabled;
  61396. private _fxaaEnabled;
  61397. private _motionBlurSamples;
  61398. private _volumetricLightStepsCount;
  61399. private _samples;
  61400. /**
  61401. * @ignore
  61402. * Specifies if the bloom pipeline is enabled
  61403. */
  61404. BloomEnabled: boolean;
  61405. /**
  61406. * @ignore
  61407. * Specifies if the depth of field pipeline is enabed
  61408. */
  61409. DepthOfFieldEnabled: boolean;
  61410. /**
  61411. * @ignore
  61412. * Specifies if the lens flare pipeline is enabed
  61413. */
  61414. LensFlareEnabled: boolean;
  61415. /**
  61416. * @ignore
  61417. * Specifies if the HDR pipeline is enabled
  61418. */
  61419. HDREnabled: boolean;
  61420. /**
  61421. * @ignore
  61422. * Specifies if the volumetric lights scattering effect is enabled
  61423. */
  61424. VLSEnabled: boolean;
  61425. /**
  61426. * @ignore
  61427. * Specifies if the motion blur effect is enabled
  61428. */
  61429. MotionBlurEnabled: boolean;
  61430. /**
  61431. * Specifies if anti-aliasing is enabled
  61432. */
  61433. fxaaEnabled: boolean;
  61434. /**
  61435. * Specifies the number of steps used to calculate the volumetric lights
  61436. * Typically in interval [50, 200]
  61437. */
  61438. volumetricLightStepsCount: number;
  61439. /**
  61440. * Specifies the number of samples used for the motion blur effect
  61441. * Typically in interval [16, 64]
  61442. */
  61443. motionBlurSamples: number;
  61444. /**
  61445. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61446. */
  61447. samples: number;
  61448. /**
  61449. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61450. * @constructor
  61451. * @param name The rendering pipeline name
  61452. * @param scene The scene linked to this pipeline
  61453. * @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)
  61454. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  61455. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61456. */
  61457. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  61458. private _buildPipeline;
  61459. private _createDownSampleX4PostProcess;
  61460. private _createBrightPassPostProcess;
  61461. private _createBlurPostProcesses;
  61462. private _createTextureAdderPostProcess;
  61463. private _createVolumetricLightPostProcess;
  61464. private _createLuminancePostProcesses;
  61465. private _createHdrPostProcess;
  61466. private _createLensFlarePostProcess;
  61467. private _createDepthOfFieldPostProcess;
  61468. private _createMotionBlurPostProcess;
  61469. private _getDepthTexture;
  61470. private _disposePostProcesses;
  61471. /**
  61472. * Dispose of the pipeline and stop all post processes
  61473. */
  61474. dispose(): void;
  61475. /**
  61476. * Serialize the rendering pipeline (Used when exporting)
  61477. * @returns the serialized object
  61478. */
  61479. serialize(): any;
  61480. /**
  61481. * Parse the serialized pipeline
  61482. * @param source Source pipeline.
  61483. * @param scene The scene to load the pipeline to.
  61484. * @param rootUrl The URL of the serialized pipeline.
  61485. * @returns An instantiated pipeline from the serialized object.
  61486. */
  61487. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  61488. /**
  61489. * Luminance steps
  61490. */
  61491. static LuminanceSteps: number;
  61492. }
  61493. }
  61494. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  61495. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  61496. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  61497. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  61498. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  61499. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  61500. }
  61501. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  61502. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  61503. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61504. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61505. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  61506. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61507. }
  61508. declare module "babylonjs/Shaders/tonemap.fragment" {
  61509. /** @hidden */
  61510. export var tonemapPixelShader: {
  61511. name: string;
  61512. shader: string;
  61513. };
  61514. }
  61515. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  61516. import { Camera } from "babylonjs/Cameras/camera";
  61517. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61518. import "babylonjs/Shaders/tonemap.fragment";
  61519. import { Engine } from "babylonjs/Engines/engine";
  61520. /** Defines operator used for tonemapping */
  61521. export enum TonemappingOperator {
  61522. /** Hable */
  61523. Hable = 0,
  61524. /** Reinhard */
  61525. Reinhard = 1,
  61526. /** HejiDawson */
  61527. HejiDawson = 2,
  61528. /** Photographic */
  61529. Photographic = 3
  61530. }
  61531. /**
  61532. * Defines a post process to apply tone mapping
  61533. */
  61534. export class TonemapPostProcess extends PostProcess {
  61535. private _operator;
  61536. /** Defines the required exposure adjustement */
  61537. exposureAdjustment: number;
  61538. /**
  61539. * Creates a new TonemapPostProcess
  61540. * @param name defines the name of the postprocess
  61541. * @param _operator defines the operator to use
  61542. * @param exposureAdjustment defines the required exposure adjustement
  61543. * @param camera defines the camera to use (can be null)
  61544. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  61545. * @param engine defines the hosting engine (can be ignore if camera is set)
  61546. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61547. */
  61548. constructor(name: string, _operator: TonemappingOperator,
  61549. /** Defines the required exposure adjustement */
  61550. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  61551. }
  61552. }
  61553. declare module "babylonjs/Shaders/depth.vertex" {
  61554. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61555. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61556. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61557. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61558. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61559. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61560. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61561. /** @hidden */
  61562. export var depthVertexShader: {
  61563. name: string;
  61564. shader: string;
  61565. };
  61566. }
  61567. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  61568. /** @hidden */
  61569. export var volumetricLightScatteringPixelShader: {
  61570. name: string;
  61571. shader: string;
  61572. };
  61573. }
  61574. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  61575. /** @hidden */
  61576. export var volumetricLightScatteringPassPixelShader: {
  61577. name: string;
  61578. shader: string;
  61579. };
  61580. }
  61581. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  61582. import { Vector3 } from "babylonjs/Maths/math.vector";
  61583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61584. import { Mesh } from "babylonjs/Meshes/mesh";
  61585. import { Camera } from "babylonjs/Cameras/camera";
  61586. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61587. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61588. import { Scene } from "babylonjs/scene";
  61589. import "babylonjs/Meshes/Builders/planeBuilder";
  61590. import "babylonjs/Shaders/depth.vertex";
  61591. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  61592. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  61593. import { Engine } from "babylonjs/Engines/engine";
  61594. /**
  61595. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  61596. */
  61597. export class VolumetricLightScatteringPostProcess extends PostProcess {
  61598. private _volumetricLightScatteringPass;
  61599. private _volumetricLightScatteringRTT;
  61600. private _viewPort;
  61601. private _screenCoordinates;
  61602. private _cachedDefines;
  61603. /**
  61604. * If not undefined, the mesh position is computed from the attached node position
  61605. */
  61606. attachedNode: {
  61607. position: Vector3;
  61608. };
  61609. /**
  61610. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  61611. */
  61612. customMeshPosition: Vector3;
  61613. /**
  61614. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  61615. */
  61616. useCustomMeshPosition: boolean;
  61617. /**
  61618. * If the post-process should inverse the light scattering direction
  61619. */
  61620. invert: boolean;
  61621. /**
  61622. * The internal mesh used by the post-process
  61623. */
  61624. mesh: Mesh;
  61625. /**
  61626. * @hidden
  61627. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  61628. */
  61629. useDiffuseColor: boolean;
  61630. /**
  61631. * Array containing the excluded meshes not rendered in the internal pass
  61632. */
  61633. excludedMeshes: AbstractMesh[];
  61634. /**
  61635. * Controls the overall intensity of the post-process
  61636. */
  61637. exposure: number;
  61638. /**
  61639. * Dissipates each sample's contribution in range [0, 1]
  61640. */
  61641. decay: number;
  61642. /**
  61643. * Controls the overall intensity of each sample
  61644. */
  61645. weight: number;
  61646. /**
  61647. * Controls the density of each sample
  61648. */
  61649. density: number;
  61650. /**
  61651. * @constructor
  61652. * @param name The post-process name
  61653. * @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)
  61654. * @param camera The camera that the post-process will be attached to
  61655. * @param mesh The mesh used to create the light scattering
  61656. * @param samples The post-process quality, default 100
  61657. * @param samplingModeThe post-process filtering mode
  61658. * @param engine The babylon engine
  61659. * @param reusable If the post-process is reusable
  61660. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  61661. */
  61662. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  61663. /**
  61664. * Returns the string "VolumetricLightScatteringPostProcess"
  61665. * @returns "VolumetricLightScatteringPostProcess"
  61666. */
  61667. getClassName(): string;
  61668. private _isReady;
  61669. /**
  61670. * Sets the new light position for light scattering effect
  61671. * @param position The new custom light position
  61672. */
  61673. setCustomMeshPosition(position: Vector3): void;
  61674. /**
  61675. * Returns the light position for light scattering effect
  61676. * @return Vector3 The custom light position
  61677. */
  61678. getCustomMeshPosition(): Vector3;
  61679. /**
  61680. * Disposes the internal assets and detaches the post-process from the camera
  61681. */
  61682. dispose(camera: Camera): void;
  61683. /**
  61684. * Returns the render target texture used by the post-process
  61685. * @return the render target texture used by the post-process
  61686. */
  61687. getPass(): RenderTargetTexture;
  61688. private _meshExcluded;
  61689. private _createPass;
  61690. private _updateMeshScreenCoordinates;
  61691. /**
  61692. * Creates a default mesh for the Volumeric Light Scattering post-process
  61693. * @param name The mesh name
  61694. * @param scene The scene where to create the mesh
  61695. * @return the default mesh
  61696. */
  61697. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  61698. }
  61699. }
  61700. declare module "babylonjs/PostProcesses/index" {
  61701. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  61702. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  61703. export * from "babylonjs/PostProcesses/bloomEffect";
  61704. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  61705. export * from "babylonjs/PostProcesses/blurPostProcess";
  61706. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  61707. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  61708. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  61709. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  61710. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  61711. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  61712. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  61713. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  61714. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  61715. export * from "babylonjs/PostProcesses/filterPostProcess";
  61716. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  61717. export * from "babylonjs/PostProcesses/grainPostProcess";
  61718. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  61719. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  61720. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  61721. export * from "babylonjs/PostProcesses/passPostProcess";
  61722. export * from "babylonjs/PostProcesses/postProcess";
  61723. export * from "babylonjs/PostProcesses/postProcessManager";
  61724. export * from "babylonjs/PostProcesses/refractionPostProcess";
  61725. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  61726. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  61727. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  61728. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  61729. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  61730. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  61731. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  61732. }
  61733. declare module "babylonjs/Probes/index" {
  61734. export * from "babylonjs/Probes/reflectionProbe";
  61735. }
  61736. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  61737. import { Scene } from "babylonjs/scene";
  61738. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61739. import { SmartArray } from "babylonjs/Misc/smartArray";
  61740. import { ISceneComponent } from "babylonjs/sceneComponent";
  61741. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  61742. import "babylonjs/Meshes/Builders/boxBuilder";
  61743. import "babylonjs/Shaders/color.fragment";
  61744. import "babylonjs/Shaders/color.vertex";
  61745. import { Color3 } from "babylonjs/Maths/math.color";
  61746. module "babylonjs/scene" {
  61747. interface Scene {
  61748. /** @hidden (Backing field) */
  61749. _boundingBoxRenderer: BoundingBoxRenderer;
  61750. /** @hidden (Backing field) */
  61751. _forceShowBoundingBoxes: boolean;
  61752. /**
  61753. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  61754. */
  61755. forceShowBoundingBoxes: boolean;
  61756. /**
  61757. * Gets the bounding box renderer associated with the scene
  61758. * @returns a BoundingBoxRenderer
  61759. */
  61760. getBoundingBoxRenderer(): BoundingBoxRenderer;
  61761. }
  61762. }
  61763. module "babylonjs/Meshes/abstractMesh" {
  61764. interface AbstractMesh {
  61765. /** @hidden (Backing field) */
  61766. _showBoundingBox: boolean;
  61767. /**
  61768. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  61769. */
  61770. showBoundingBox: boolean;
  61771. }
  61772. }
  61773. /**
  61774. * Component responsible of rendering the bounding box of the meshes in a scene.
  61775. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  61776. */
  61777. export class BoundingBoxRenderer implements ISceneComponent {
  61778. /**
  61779. * The component name helpfull to identify the component in the list of scene components.
  61780. */
  61781. readonly name: string;
  61782. /**
  61783. * The scene the component belongs to.
  61784. */
  61785. scene: Scene;
  61786. /**
  61787. * Color of the bounding box lines placed in front of an object
  61788. */
  61789. frontColor: Color3;
  61790. /**
  61791. * Color of the bounding box lines placed behind an object
  61792. */
  61793. backColor: Color3;
  61794. /**
  61795. * Defines if the renderer should show the back lines or not
  61796. */
  61797. showBackLines: boolean;
  61798. /**
  61799. * @hidden
  61800. */
  61801. renderList: SmartArray<BoundingBox>;
  61802. private _colorShader;
  61803. private _vertexBuffers;
  61804. private _indexBuffer;
  61805. private _fillIndexBuffer;
  61806. private _fillIndexData;
  61807. /**
  61808. * Instantiates a new bounding box renderer in a scene.
  61809. * @param scene the scene the renderer renders in
  61810. */
  61811. constructor(scene: Scene);
  61812. /**
  61813. * Registers the component in a given scene
  61814. */
  61815. register(): void;
  61816. private _evaluateSubMesh;
  61817. private _activeMesh;
  61818. private _prepareRessources;
  61819. private _createIndexBuffer;
  61820. /**
  61821. * Rebuilds the elements related to this component in case of
  61822. * context lost for instance.
  61823. */
  61824. rebuild(): void;
  61825. /**
  61826. * @hidden
  61827. */
  61828. reset(): void;
  61829. /**
  61830. * Render the bounding boxes of a specific rendering group
  61831. * @param renderingGroupId defines the rendering group to render
  61832. */
  61833. render(renderingGroupId: number): void;
  61834. /**
  61835. * In case of occlusion queries, we can render the occlusion bounding box through this method
  61836. * @param mesh Define the mesh to render the occlusion bounding box for
  61837. */
  61838. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  61839. /**
  61840. * Dispose and release the resources attached to this renderer.
  61841. */
  61842. dispose(): void;
  61843. }
  61844. }
  61845. declare module "babylonjs/Shaders/depth.fragment" {
  61846. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  61847. /** @hidden */
  61848. export var depthPixelShader: {
  61849. name: string;
  61850. shader: string;
  61851. };
  61852. }
  61853. declare module "babylonjs/Rendering/depthRenderer" {
  61854. import { Nullable } from "babylonjs/types";
  61855. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61856. import { Scene } from "babylonjs/scene";
  61857. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61858. import { Camera } from "babylonjs/Cameras/camera";
  61859. import "babylonjs/Shaders/depth.fragment";
  61860. import "babylonjs/Shaders/depth.vertex";
  61861. /**
  61862. * This represents a depth renderer in Babylon.
  61863. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61864. */
  61865. export class DepthRenderer {
  61866. private _scene;
  61867. private _depthMap;
  61868. private _effect;
  61869. private readonly _storeNonLinearDepth;
  61870. private readonly _clearColor;
  61871. /** Get if the depth renderer is using packed depth or not */
  61872. readonly isPacked: boolean;
  61873. private _cachedDefines;
  61874. private _camera;
  61875. /**
  61876. * Specifiess that the depth renderer will only be used within
  61877. * the camera it is created for.
  61878. * This can help forcing its rendering during the camera processing.
  61879. */
  61880. useOnlyInActiveCamera: boolean;
  61881. /** @hidden */
  61882. static _SceneComponentInitialization: (scene: Scene) => void;
  61883. /**
  61884. * Instantiates a depth renderer
  61885. * @param scene The scene the renderer belongs to
  61886. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61887. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61888. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61889. */
  61890. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61891. /**
  61892. * Creates the depth rendering effect and checks if the effect is ready.
  61893. * @param subMesh The submesh to be used to render the depth map of
  61894. * @param useInstances If multiple world instances should be used
  61895. * @returns if the depth renderer is ready to render the depth map
  61896. */
  61897. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61898. /**
  61899. * Gets the texture which the depth map will be written to.
  61900. * @returns The depth map texture
  61901. */
  61902. getDepthMap(): RenderTargetTexture;
  61903. /**
  61904. * Disposes of the depth renderer.
  61905. */
  61906. dispose(): void;
  61907. }
  61908. }
  61909. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  61910. import { Nullable } from "babylonjs/types";
  61911. import { Scene } from "babylonjs/scene";
  61912. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61913. import { Camera } from "babylonjs/Cameras/camera";
  61914. import { ISceneComponent } from "babylonjs/sceneComponent";
  61915. module "babylonjs/scene" {
  61916. interface Scene {
  61917. /** @hidden (Backing field) */
  61918. _depthRenderer: {
  61919. [id: string]: DepthRenderer;
  61920. };
  61921. /**
  61922. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  61923. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  61924. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61925. * @returns the created depth renderer
  61926. */
  61927. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  61928. /**
  61929. * Disables a depth renderer for a given camera
  61930. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  61931. */
  61932. disableDepthRenderer(camera?: Nullable<Camera>): void;
  61933. }
  61934. }
  61935. /**
  61936. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  61937. * in several rendering techniques.
  61938. */
  61939. export class DepthRendererSceneComponent implements ISceneComponent {
  61940. /**
  61941. * The component name helpfull to identify the component in the list of scene components.
  61942. */
  61943. readonly name: string;
  61944. /**
  61945. * The scene the component belongs to.
  61946. */
  61947. scene: Scene;
  61948. /**
  61949. * Creates a new instance of the component for the given scene
  61950. * @param scene Defines the scene to register the component in
  61951. */
  61952. constructor(scene: Scene);
  61953. /**
  61954. * Registers the component in a given scene
  61955. */
  61956. register(): void;
  61957. /**
  61958. * Rebuilds the elements related to this component in case of
  61959. * context lost for instance.
  61960. */
  61961. rebuild(): void;
  61962. /**
  61963. * Disposes the component and the associated ressources
  61964. */
  61965. dispose(): void;
  61966. private _gatherRenderTargets;
  61967. private _gatherActiveCameraRenderTargets;
  61968. }
  61969. }
  61970. declare module "babylonjs/Shaders/outline.fragment" {
  61971. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  61972. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  61973. /** @hidden */
  61974. export var outlinePixelShader: {
  61975. name: string;
  61976. shader: string;
  61977. };
  61978. }
  61979. declare module "babylonjs/Shaders/outline.vertex" {
  61980. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61981. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61982. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61983. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61984. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  61985. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61986. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61987. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61988. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  61989. /** @hidden */
  61990. export var outlineVertexShader: {
  61991. name: string;
  61992. shader: string;
  61993. };
  61994. }
  61995. declare module "babylonjs/Rendering/outlineRenderer" {
  61996. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61997. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  61998. import { Scene } from "babylonjs/scene";
  61999. import { ISceneComponent } from "babylonjs/sceneComponent";
  62000. import "babylonjs/Shaders/outline.fragment";
  62001. import "babylonjs/Shaders/outline.vertex";
  62002. module "babylonjs/scene" {
  62003. interface Scene {
  62004. /** @hidden */
  62005. _outlineRenderer: OutlineRenderer;
  62006. /**
  62007. * Gets the outline renderer associated with the scene
  62008. * @returns a OutlineRenderer
  62009. */
  62010. getOutlineRenderer(): OutlineRenderer;
  62011. }
  62012. }
  62013. module "babylonjs/Meshes/abstractMesh" {
  62014. interface AbstractMesh {
  62015. /** @hidden (Backing field) */
  62016. _renderOutline: boolean;
  62017. /**
  62018. * Gets or sets a boolean indicating if the outline must be rendered as well
  62019. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  62020. */
  62021. renderOutline: boolean;
  62022. /** @hidden (Backing field) */
  62023. _renderOverlay: boolean;
  62024. /**
  62025. * Gets or sets a boolean indicating if the overlay must be rendered as well
  62026. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  62027. */
  62028. renderOverlay: boolean;
  62029. }
  62030. }
  62031. /**
  62032. * This class is responsible to draw bothe outline/overlay of meshes.
  62033. * It should not be used directly but through the available method on mesh.
  62034. */
  62035. export class OutlineRenderer implements ISceneComponent {
  62036. /**
  62037. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  62038. */
  62039. private static _StencilReference;
  62040. /**
  62041. * The name of the component. Each component must have a unique name.
  62042. */
  62043. name: string;
  62044. /**
  62045. * The scene the component belongs to.
  62046. */
  62047. scene: Scene;
  62048. /**
  62049. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  62050. */
  62051. zOffset: number;
  62052. private _engine;
  62053. private _effect;
  62054. private _cachedDefines;
  62055. private _savedDepthWrite;
  62056. /**
  62057. * Instantiates a new outline renderer. (There could be only one per scene).
  62058. * @param scene Defines the scene it belongs to
  62059. */
  62060. constructor(scene: Scene);
  62061. /**
  62062. * Register the component to one instance of a scene.
  62063. */
  62064. register(): void;
  62065. /**
  62066. * Rebuilds the elements related to this component in case of
  62067. * context lost for instance.
  62068. */
  62069. rebuild(): void;
  62070. /**
  62071. * Disposes the component and the associated ressources.
  62072. */
  62073. dispose(): void;
  62074. /**
  62075. * Renders the outline in the canvas.
  62076. * @param subMesh Defines the sumesh to render
  62077. * @param batch Defines the batch of meshes in case of instances
  62078. * @param useOverlay Defines if the rendering is for the overlay or the outline
  62079. */
  62080. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  62081. /**
  62082. * Returns whether or not the outline renderer is ready for a given submesh.
  62083. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  62084. * @param subMesh Defines the submesh to check readyness for
  62085. * @param useInstances Defines wheter wee are trying to render instances or not
  62086. * @returns true if ready otherwise false
  62087. */
  62088. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62089. private _beforeRenderingMesh;
  62090. private _afterRenderingMesh;
  62091. }
  62092. }
  62093. declare module "babylonjs/Rendering/index" {
  62094. export * from "babylonjs/Rendering/boundingBoxRenderer";
  62095. export * from "babylonjs/Rendering/depthRenderer";
  62096. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  62097. export * from "babylonjs/Rendering/edgesRenderer";
  62098. export * from "babylonjs/Rendering/geometryBufferRenderer";
  62099. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  62100. export * from "babylonjs/Rendering/outlineRenderer";
  62101. export * from "babylonjs/Rendering/renderingGroup";
  62102. export * from "babylonjs/Rendering/renderingManager";
  62103. export * from "babylonjs/Rendering/utilityLayerRenderer";
  62104. }
  62105. declare module "babylonjs/Sprites/index" {
  62106. export * from "babylonjs/Sprites/sprite";
  62107. export * from "babylonjs/Sprites/spriteManager";
  62108. export * from "babylonjs/Sprites/spriteSceneComponent";
  62109. }
  62110. declare module "babylonjs/Misc/assetsManager" {
  62111. import { Scene } from "babylonjs/scene";
  62112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62113. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  62114. import { Skeleton } from "babylonjs/Bones/skeleton";
  62115. import { Observable } from "babylonjs/Misc/observable";
  62116. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62117. import { Texture } from "babylonjs/Materials/Textures/texture";
  62118. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  62119. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  62120. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  62121. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  62122. /**
  62123. * Defines the list of states available for a task inside a AssetsManager
  62124. */
  62125. export enum AssetTaskState {
  62126. /**
  62127. * Initialization
  62128. */
  62129. INIT = 0,
  62130. /**
  62131. * Running
  62132. */
  62133. RUNNING = 1,
  62134. /**
  62135. * Done
  62136. */
  62137. DONE = 2,
  62138. /**
  62139. * Error
  62140. */
  62141. ERROR = 3
  62142. }
  62143. /**
  62144. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  62145. */
  62146. export abstract class AbstractAssetTask {
  62147. /**
  62148. * Task name
  62149. */ name: string;
  62150. /**
  62151. * Callback called when the task is successful
  62152. */
  62153. onSuccess: (task: any) => void;
  62154. /**
  62155. * Callback called when the task is not successful
  62156. */
  62157. onError: (task: any, message?: string, exception?: any) => void;
  62158. /**
  62159. * Creates a new AssetsManager
  62160. * @param name defines the name of the task
  62161. */
  62162. constructor(
  62163. /**
  62164. * Task name
  62165. */ name: string);
  62166. private _isCompleted;
  62167. private _taskState;
  62168. private _errorObject;
  62169. /**
  62170. * Get if the task is completed
  62171. */
  62172. readonly isCompleted: boolean;
  62173. /**
  62174. * Gets the current state of the task
  62175. */
  62176. readonly taskState: AssetTaskState;
  62177. /**
  62178. * Gets the current error object (if task is in error)
  62179. */
  62180. readonly errorObject: {
  62181. message?: string;
  62182. exception?: any;
  62183. };
  62184. /**
  62185. * Internal only
  62186. * @hidden
  62187. */
  62188. _setErrorObject(message?: string, exception?: any): void;
  62189. /**
  62190. * Execute the current task
  62191. * @param scene defines the scene where you want your assets to be loaded
  62192. * @param onSuccess is a callback called when the task is successfully executed
  62193. * @param onError is a callback called if an error occurs
  62194. */
  62195. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62196. /**
  62197. * Execute the current task
  62198. * @param scene defines the scene where you want your assets to be loaded
  62199. * @param onSuccess is a callback called when the task is successfully executed
  62200. * @param onError is a callback called if an error occurs
  62201. */
  62202. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62203. /**
  62204. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  62205. * This can be used with failed tasks that have the reason for failure fixed.
  62206. */
  62207. reset(): void;
  62208. private onErrorCallback;
  62209. private onDoneCallback;
  62210. }
  62211. /**
  62212. * Define the interface used by progress events raised during assets loading
  62213. */
  62214. export interface IAssetsProgressEvent {
  62215. /**
  62216. * Defines the number of remaining tasks to process
  62217. */
  62218. remainingCount: number;
  62219. /**
  62220. * Defines the total number of tasks
  62221. */
  62222. totalCount: number;
  62223. /**
  62224. * Defines the task that was just processed
  62225. */
  62226. task: AbstractAssetTask;
  62227. }
  62228. /**
  62229. * Class used to share progress information about assets loading
  62230. */
  62231. export class AssetsProgressEvent implements IAssetsProgressEvent {
  62232. /**
  62233. * Defines the number of remaining tasks to process
  62234. */
  62235. remainingCount: number;
  62236. /**
  62237. * Defines the total number of tasks
  62238. */
  62239. totalCount: number;
  62240. /**
  62241. * Defines the task that was just processed
  62242. */
  62243. task: AbstractAssetTask;
  62244. /**
  62245. * Creates a AssetsProgressEvent
  62246. * @param remainingCount defines the number of remaining tasks to process
  62247. * @param totalCount defines the total number of tasks
  62248. * @param task defines the task that was just processed
  62249. */
  62250. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  62251. }
  62252. /**
  62253. * Define a task used by AssetsManager to load meshes
  62254. */
  62255. export class MeshAssetTask extends AbstractAssetTask {
  62256. /**
  62257. * Defines the name of the task
  62258. */
  62259. name: string;
  62260. /**
  62261. * Defines the list of mesh's names you want to load
  62262. */
  62263. meshesNames: any;
  62264. /**
  62265. * Defines the root url to use as a base to load your meshes and associated resources
  62266. */
  62267. rootUrl: string;
  62268. /**
  62269. * Defines the filename of the scene to load from
  62270. */
  62271. sceneFilename: string;
  62272. /**
  62273. * Gets the list of loaded meshes
  62274. */
  62275. loadedMeshes: Array<AbstractMesh>;
  62276. /**
  62277. * Gets the list of loaded particle systems
  62278. */
  62279. loadedParticleSystems: Array<IParticleSystem>;
  62280. /**
  62281. * Gets the list of loaded skeletons
  62282. */
  62283. loadedSkeletons: Array<Skeleton>;
  62284. /**
  62285. * Gets the list of loaded animation groups
  62286. */
  62287. loadedAnimationGroups: Array<AnimationGroup>;
  62288. /**
  62289. * Callback called when the task is successful
  62290. */
  62291. onSuccess: (task: MeshAssetTask) => void;
  62292. /**
  62293. * Callback called when the task is successful
  62294. */
  62295. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  62296. /**
  62297. * Creates a new MeshAssetTask
  62298. * @param name defines the name of the task
  62299. * @param meshesNames defines the list of mesh's names you want to load
  62300. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  62301. * @param sceneFilename defines the filename of the scene to load from
  62302. */
  62303. constructor(
  62304. /**
  62305. * Defines the name of the task
  62306. */
  62307. name: string,
  62308. /**
  62309. * Defines the list of mesh's names you want to load
  62310. */
  62311. meshesNames: any,
  62312. /**
  62313. * Defines the root url to use as a base to load your meshes and associated resources
  62314. */
  62315. rootUrl: string,
  62316. /**
  62317. * Defines the filename of the scene to load from
  62318. */
  62319. sceneFilename: string);
  62320. /**
  62321. * Execute the current task
  62322. * @param scene defines the scene where you want your assets to be loaded
  62323. * @param onSuccess is a callback called when the task is successfully executed
  62324. * @param onError is a callback called if an error occurs
  62325. */
  62326. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62327. }
  62328. /**
  62329. * Define a task used by AssetsManager to load text content
  62330. */
  62331. export class TextFileAssetTask extends AbstractAssetTask {
  62332. /**
  62333. * Defines the name of the task
  62334. */
  62335. name: string;
  62336. /**
  62337. * Defines the location of the file to load
  62338. */
  62339. url: string;
  62340. /**
  62341. * Gets the loaded text string
  62342. */
  62343. text: string;
  62344. /**
  62345. * Callback called when the task is successful
  62346. */
  62347. onSuccess: (task: TextFileAssetTask) => void;
  62348. /**
  62349. * Callback called when the task is successful
  62350. */
  62351. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  62352. /**
  62353. * Creates a new TextFileAssetTask object
  62354. * @param name defines the name of the task
  62355. * @param url defines the location of the file to load
  62356. */
  62357. constructor(
  62358. /**
  62359. * Defines the name of the task
  62360. */
  62361. name: string,
  62362. /**
  62363. * Defines the location of the file to load
  62364. */
  62365. url: string);
  62366. /**
  62367. * Execute the current task
  62368. * @param scene defines the scene where you want your assets to be loaded
  62369. * @param onSuccess is a callback called when the task is successfully executed
  62370. * @param onError is a callback called if an error occurs
  62371. */
  62372. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62373. }
  62374. /**
  62375. * Define a task used by AssetsManager to load binary data
  62376. */
  62377. export class BinaryFileAssetTask extends AbstractAssetTask {
  62378. /**
  62379. * Defines the name of the task
  62380. */
  62381. name: string;
  62382. /**
  62383. * Defines the location of the file to load
  62384. */
  62385. url: string;
  62386. /**
  62387. * Gets the lodaded data (as an array buffer)
  62388. */
  62389. data: ArrayBuffer;
  62390. /**
  62391. * Callback called when the task is successful
  62392. */
  62393. onSuccess: (task: BinaryFileAssetTask) => void;
  62394. /**
  62395. * Callback called when the task is successful
  62396. */
  62397. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  62398. /**
  62399. * Creates a new BinaryFileAssetTask object
  62400. * @param name defines the name of the new task
  62401. * @param url defines the location of the file to load
  62402. */
  62403. constructor(
  62404. /**
  62405. * Defines the name of the task
  62406. */
  62407. name: string,
  62408. /**
  62409. * Defines the location of the file to load
  62410. */
  62411. url: string);
  62412. /**
  62413. * Execute the current task
  62414. * @param scene defines the scene where you want your assets to be loaded
  62415. * @param onSuccess is a callback called when the task is successfully executed
  62416. * @param onError is a callback called if an error occurs
  62417. */
  62418. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62419. }
  62420. /**
  62421. * Define a task used by AssetsManager to load images
  62422. */
  62423. export class ImageAssetTask extends AbstractAssetTask {
  62424. /**
  62425. * Defines the name of the task
  62426. */
  62427. name: string;
  62428. /**
  62429. * Defines the location of the image to load
  62430. */
  62431. url: string;
  62432. /**
  62433. * Gets the loaded images
  62434. */
  62435. image: HTMLImageElement;
  62436. /**
  62437. * Callback called when the task is successful
  62438. */
  62439. onSuccess: (task: ImageAssetTask) => void;
  62440. /**
  62441. * Callback called when the task is successful
  62442. */
  62443. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  62444. /**
  62445. * Creates a new ImageAssetTask
  62446. * @param name defines the name of the task
  62447. * @param url defines the location of the image to load
  62448. */
  62449. constructor(
  62450. /**
  62451. * Defines the name of the task
  62452. */
  62453. name: string,
  62454. /**
  62455. * Defines the location of the image to load
  62456. */
  62457. url: string);
  62458. /**
  62459. * Execute the current task
  62460. * @param scene defines the scene where you want your assets to be loaded
  62461. * @param onSuccess is a callback called when the task is successfully executed
  62462. * @param onError is a callback called if an error occurs
  62463. */
  62464. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62465. }
  62466. /**
  62467. * Defines the interface used by texture loading tasks
  62468. */
  62469. export interface ITextureAssetTask<TEX extends BaseTexture> {
  62470. /**
  62471. * Gets the loaded texture
  62472. */
  62473. texture: TEX;
  62474. }
  62475. /**
  62476. * Define a task used by AssetsManager to load 2D textures
  62477. */
  62478. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  62479. /**
  62480. * Defines the name of the task
  62481. */
  62482. name: string;
  62483. /**
  62484. * Defines the location of the file to load
  62485. */
  62486. url: string;
  62487. /**
  62488. * Defines if mipmap should not be generated (default is false)
  62489. */
  62490. noMipmap?: boolean | undefined;
  62491. /**
  62492. * Defines if texture must be inverted on Y axis (default is false)
  62493. */
  62494. invertY?: boolean | undefined;
  62495. /**
  62496. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62497. */
  62498. samplingMode: number;
  62499. /**
  62500. * Gets the loaded texture
  62501. */
  62502. texture: Texture;
  62503. /**
  62504. * Callback called when the task is successful
  62505. */
  62506. onSuccess: (task: TextureAssetTask) => void;
  62507. /**
  62508. * Callback called when the task is successful
  62509. */
  62510. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  62511. /**
  62512. * Creates a new TextureAssetTask object
  62513. * @param name defines the name of the task
  62514. * @param url defines the location of the file to load
  62515. * @param noMipmap defines if mipmap should not be generated (default is false)
  62516. * @param invertY defines if texture must be inverted on Y axis (default is false)
  62517. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62518. */
  62519. constructor(
  62520. /**
  62521. * Defines the name of the task
  62522. */
  62523. name: string,
  62524. /**
  62525. * Defines the location of the file to load
  62526. */
  62527. url: string,
  62528. /**
  62529. * Defines if mipmap should not be generated (default is false)
  62530. */
  62531. noMipmap?: boolean | undefined,
  62532. /**
  62533. * Defines if texture must be inverted on Y axis (default is false)
  62534. */
  62535. invertY?: boolean | undefined,
  62536. /**
  62537. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62538. */
  62539. samplingMode?: number);
  62540. /**
  62541. * Execute the current task
  62542. * @param scene defines the scene where you want your assets to be loaded
  62543. * @param onSuccess is a callback called when the task is successfully executed
  62544. * @param onError is a callback called if an error occurs
  62545. */
  62546. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62547. }
  62548. /**
  62549. * Define a task used by AssetsManager to load cube textures
  62550. */
  62551. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  62552. /**
  62553. * Defines the name of the task
  62554. */
  62555. name: string;
  62556. /**
  62557. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62558. */
  62559. url: string;
  62560. /**
  62561. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62562. */
  62563. extensions?: string[] | undefined;
  62564. /**
  62565. * Defines if mipmaps should not be generated (default is false)
  62566. */
  62567. noMipmap?: boolean | undefined;
  62568. /**
  62569. * Defines the explicit list of files (undefined by default)
  62570. */
  62571. files?: string[] | undefined;
  62572. /**
  62573. * Gets the loaded texture
  62574. */
  62575. texture: CubeTexture;
  62576. /**
  62577. * Callback called when the task is successful
  62578. */
  62579. onSuccess: (task: CubeTextureAssetTask) => void;
  62580. /**
  62581. * Callback called when the task is successful
  62582. */
  62583. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  62584. /**
  62585. * Creates a new CubeTextureAssetTask
  62586. * @param name defines the name of the task
  62587. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62588. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62589. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62590. * @param files defines the explicit list of files (undefined by default)
  62591. */
  62592. constructor(
  62593. /**
  62594. * Defines the name of the task
  62595. */
  62596. name: string,
  62597. /**
  62598. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62599. */
  62600. url: string,
  62601. /**
  62602. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62603. */
  62604. extensions?: string[] | undefined,
  62605. /**
  62606. * Defines if mipmaps should not be generated (default is false)
  62607. */
  62608. noMipmap?: boolean | undefined,
  62609. /**
  62610. * Defines the explicit list of files (undefined by default)
  62611. */
  62612. files?: string[] | undefined);
  62613. /**
  62614. * Execute the current task
  62615. * @param scene defines the scene where you want your assets to be loaded
  62616. * @param onSuccess is a callback called when the task is successfully executed
  62617. * @param onError is a callback called if an error occurs
  62618. */
  62619. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62620. }
  62621. /**
  62622. * Define a task used by AssetsManager to load HDR cube textures
  62623. */
  62624. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  62625. /**
  62626. * Defines the name of the task
  62627. */
  62628. name: string;
  62629. /**
  62630. * Defines the location of the file to load
  62631. */
  62632. url: string;
  62633. /**
  62634. * Defines the desired size (the more it increases the longer the generation will be)
  62635. */
  62636. size: number;
  62637. /**
  62638. * Defines if mipmaps should not be generated (default is false)
  62639. */
  62640. noMipmap: boolean;
  62641. /**
  62642. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62643. */
  62644. generateHarmonics: boolean;
  62645. /**
  62646. * 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)
  62647. */
  62648. gammaSpace: boolean;
  62649. /**
  62650. * Internal Use Only
  62651. */
  62652. reserved: boolean;
  62653. /**
  62654. * Gets the loaded texture
  62655. */
  62656. texture: HDRCubeTexture;
  62657. /**
  62658. * Callback called when the task is successful
  62659. */
  62660. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  62661. /**
  62662. * Callback called when the task is successful
  62663. */
  62664. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  62665. /**
  62666. * Creates a new HDRCubeTextureAssetTask object
  62667. * @param name defines the name of the task
  62668. * @param url defines the location of the file to load
  62669. * @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.
  62670. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62671. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62672. * @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)
  62673. * @param reserved Internal use only
  62674. */
  62675. constructor(
  62676. /**
  62677. * Defines the name of the task
  62678. */
  62679. name: string,
  62680. /**
  62681. * Defines the location of the file to load
  62682. */
  62683. url: string,
  62684. /**
  62685. * Defines the desired size (the more it increases the longer the generation will be)
  62686. */
  62687. size: number,
  62688. /**
  62689. * Defines if mipmaps should not be generated (default is false)
  62690. */
  62691. noMipmap?: boolean,
  62692. /**
  62693. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62694. */
  62695. generateHarmonics?: boolean,
  62696. /**
  62697. * 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)
  62698. */
  62699. gammaSpace?: boolean,
  62700. /**
  62701. * Internal Use Only
  62702. */
  62703. reserved?: boolean);
  62704. /**
  62705. * Execute the current task
  62706. * @param scene defines the scene where you want your assets to be loaded
  62707. * @param onSuccess is a callback called when the task is successfully executed
  62708. * @param onError is a callback called if an error occurs
  62709. */
  62710. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62711. }
  62712. /**
  62713. * Define a task used by AssetsManager to load Equirectangular cube textures
  62714. */
  62715. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  62716. /**
  62717. * Defines the name of the task
  62718. */
  62719. name: string;
  62720. /**
  62721. * Defines the location of the file to load
  62722. */
  62723. url: string;
  62724. /**
  62725. * Defines the desired size (the more it increases the longer the generation will be)
  62726. */
  62727. size: number;
  62728. /**
  62729. * Defines if mipmaps should not be generated (default is false)
  62730. */
  62731. noMipmap: boolean;
  62732. /**
  62733. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62734. * but the standard material would require them in Gamma space) (default is true)
  62735. */
  62736. gammaSpace: boolean;
  62737. /**
  62738. * Gets the loaded texture
  62739. */
  62740. texture: EquiRectangularCubeTexture;
  62741. /**
  62742. * Callback called when the task is successful
  62743. */
  62744. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  62745. /**
  62746. * Callback called when the task is successful
  62747. */
  62748. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  62749. /**
  62750. * Creates a new EquiRectangularCubeTextureAssetTask object
  62751. * @param name defines the name of the task
  62752. * @param url defines the location of the file to load
  62753. * @param size defines the desired size (the more it increases the longer the generation will be)
  62754. * If the size is omitted this implies you are using a preprocessed cubemap.
  62755. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62756. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  62757. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  62758. * (default is true)
  62759. */
  62760. constructor(
  62761. /**
  62762. * Defines the name of the task
  62763. */
  62764. name: string,
  62765. /**
  62766. * Defines the location of the file to load
  62767. */
  62768. url: string,
  62769. /**
  62770. * Defines the desired size (the more it increases the longer the generation will be)
  62771. */
  62772. size: number,
  62773. /**
  62774. * Defines if mipmaps should not be generated (default is false)
  62775. */
  62776. noMipmap?: boolean,
  62777. /**
  62778. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62779. * but the standard material would require them in Gamma space) (default is true)
  62780. */
  62781. gammaSpace?: boolean);
  62782. /**
  62783. * Execute the current task
  62784. * @param scene defines the scene where you want your assets to be loaded
  62785. * @param onSuccess is a callback called when the task is successfully executed
  62786. * @param onError is a callback called if an error occurs
  62787. */
  62788. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62789. }
  62790. /**
  62791. * This class can be used to easily import assets into a scene
  62792. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  62793. */
  62794. export class AssetsManager {
  62795. private _scene;
  62796. private _isLoading;
  62797. protected _tasks: AbstractAssetTask[];
  62798. protected _waitingTasksCount: number;
  62799. protected _totalTasksCount: number;
  62800. /**
  62801. * Callback called when all tasks are processed
  62802. */
  62803. onFinish: (tasks: AbstractAssetTask[]) => void;
  62804. /**
  62805. * Callback called when a task is successful
  62806. */
  62807. onTaskSuccess: (task: AbstractAssetTask) => void;
  62808. /**
  62809. * Callback called when a task had an error
  62810. */
  62811. onTaskError: (task: AbstractAssetTask) => void;
  62812. /**
  62813. * Callback called when a task is done (whatever the result is)
  62814. */
  62815. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  62816. /**
  62817. * Observable called when all tasks are processed
  62818. */
  62819. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  62820. /**
  62821. * Observable called when a task had an error
  62822. */
  62823. onTaskErrorObservable: Observable<AbstractAssetTask>;
  62824. /**
  62825. * Observable called when all tasks were executed
  62826. */
  62827. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  62828. /**
  62829. * Observable called when a task is done (whatever the result is)
  62830. */
  62831. onProgressObservable: Observable<IAssetsProgressEvent>;
  62832. /**
  62833. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  62834. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  62835. */
  62836. useDefaultLoadingScreen: boolean;
  62837. /**
  62838. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  62839. * when all assets have been downloaded.
  62840. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  62841. */
  62842. autoHideLoadingUI: boolean;
  62843. /**
  62844. * Creates a new AssetsManager
  62845. * @param scene defines the scene to work on
  62846. */
  62847. constructor(scene: Scene);
  62848. /**
  62849. * Add a MeshAssetTask to the list of active tasks
  62850. * @param taskName defines the name of the new task
  62851. * @param meshesNames defines the name of meshes to load
  62852. * @param rootUrl defines the root url to use to locate files
  62853. * @param sceneFilename defines the filename of the scene file
  62854. * @returns a new MeshAssetTask object
  62855. */
  62856. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  62857. /**
  62858. * Add a TextFileAssetTask to the list of active tasks
  62859. * @param taskName defines the name of the new task
  62860. * @param url defines the url of the file to load
  62861. * @returns a new TextFileAssetTask object
  62862. */
  62863. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  62864. /**
  62865. * Add a BinaryFileAssetTask to the list of active tasks
  62866. * @param taskName defines the name of the new task
  62867. * @param url defines the url of the file to load
  62868. * @returns a new BinaryFileAssetTask object
  62869. */
  62870. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  62871. /**
  62872. * Add a ImageAssetTask to the list of active tasks
  62873. * @param taskName defines the name of the new task
  62874. * @param url defines the url of the file to load
  62875. * @returns a new ImageAssetTask object
  62876. */
  62877. addImageTask(taskName: string, url: string): ImageAssetTask;
  62878. /**
  62879. * Add a TextureAssetTask to the list of active tasks
  62880. * @param taskName defines the name of the new task
  62881. * @param url defines the url of the file to load
  62882. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62883. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  62884. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62885. * @returns a new TextureAssetTask object
  62886. */
  62887. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  62888. /**
  62889. * Add a CubeTextureAssetTask to the list of active tasks
  62890. * @param taskName defines the name of the new task
  62891. * @param url defines the url of the file to load
  62892. * @param extensions defines the extension to use to load the cube map (can be null)
  62893. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62894. * @param files defines the list of files to load (can be null)
  62895. * @returns a new CubeTextureAssetTask object
  62896. */
  62897. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  62898. /**
  62899. *
  62900. * Add a HDRCubeTextureAssetTask to the list of active tasks
  62901. * @param taskName defines the name of the new task
  62902. * @param url defines the url of the file to load
  62903. * @param size defines the size you want for the cubemap (can be null)
  62904. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62905. * @param generateHarmonics defines if you want to automatically generate (true by default)
  62906. * @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)
  62907. * @param reserved Internal use only
  62908. * @returns a new HDRCubeTextureAssetTask object
  62909. */
  62910. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  62911. /**
  62912. *
  62913. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  62914. * @param taskName defines the name of the new task
  62915. * @param url defines the url of the file to load
  62916. * @param size defines the size you want for the cubemap (can be null)
  62917. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62918. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62919. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62920. * @returns a new EquiRectangularCubeTextureAssetTask object
  62921. */
  62922. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  62923. /**
  62924. * Remove a task from the assets manager.
  62925. * @param task the task to remove
  62926. */
  62927. removeTask(task: AbstractAssetTask): void;
  62928. private _decreaseWaitingTasksCount;
  62929. private _runTask;
  62930. /**
  62931. * Reset the AssetsManager and remove all tasks
  62932. * @return the current instance of the AssetsManager
  62933. */
  62934. reset(): AssetsManager;
  62935. /**
  62936. * Start the loading process
  62937. * @return the current instance of the AssetsManager
  62938. */
  62939. load(): AssetsManager;
  62940. /**
  62941. * Start the loading process as an async operation
  62942. * @return a promise returning the list of failed tasks
  62943. */
  62944. loadAsync(): Promise<void>;
  62945. }
  62946. }
  62947. declare module "babylonjs/Misc/deferred" {
  62948. /**
  62949. * Wrapper class for promise with external resolve and reject.
  62950. */
  62951. export class Deferred<T> {
  62952. /**
  62953. * The promise associated with this deferred object.
  62954. */
  62955. readonly promise: Promise<T>;
  62956. private _resolve;
  62957. private _reject;
  62958. /**
  62959. * The resolve method of the promise associated with this deferred object.
  62960. */
  62961. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  62962. /**
  62963. * The reject method of the promise associated with this deferred object.
  62964. */
  62965. readonly reject: (reason?: any) => void;
  62966. /**
  62967. * Constructor for this deferred object.
  62968. */
  62969. constructor();
  62970. }
  62971. }
  62972. declare module "babylonjs/Misc/meshExploder" {
  62973. import { Mesh } from "babylonjs/Meshes/mesh";
  62974. /**
  62975. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  62976. */
  62977. export class MeshExploder {
  62978. private _centerMesh;
  62979. private _meshes;
  62980. private _meshesOrigins;
  62981. private _toCenterVectors;
  62982. private _scaledDirection;
  62983. private _newPosition;
  62984. private _centerPosition;
  62985. /**
  62986. * Explodes meshes from a center mesh.
  62987. * @param meshes The meshes to explode.
  62988. * @param centerMesh The mesh to be center of explosion.
  62989. */
  62990. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  62991. private _setCenterMesh;
  62992. /**
  62993. * Get class name
  62994. * @returns "MeshExploder"
  62995. */
  62996. getClassName(): string;
  62997. /**
  62998. * "Exploded meshes"
  62999. * @returns Array of meshes with the centerMesh at index 0.
  63000. */
  63001. getMeshes(): Array<Mesh>;
  63002. /**
  63003. * Explodes meshes giving a specific direction
  63004. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  63005. */
  63006. explode(direction?: number): void;
  63007. }
  63008. }
  63009. declare module "babylonjs/Misc/filesInput" {
  63010. import { Engine } from "babylonjs/Engines/engine";
  63011. import { Scene } from "babylonjs/scene";
  63012. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  63013. /**
  63014. * Class used to help managing file picking and drag'n'drop
  63015. */
  63016. export class FilesInput {
  63017. /**
  63018. * List of files ready to be loaded
  63019. */
  63020. static readonly FilesToLoad: {
  63021. [key: string]: File;
  63022. };
  63023. /**
  63024. * Callback called when a file is processed
  63025. */
  63026. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  63027. private _engine;
  63028. private _currentScene;
  63029. private _sceneLoadedCallback;
  63030. private _progressCallback;
  63031. private _additionalRenderLoopLogicCallback;
  63032. private _textureLoadingCallback;
  63033. private _startingProcessingFilesCallback;
  63034. private _onReloadCallback;
  63035. private _errorCallback;
  63036. private _elementToMonitor;
  63037. private _sceneFileToLoad;
  63038. private _filesToLoad;
  63039. /**
  63040. * Creates a new FilesInput
  63041. * @param engine defines the rendering engine
  63042. * @param scene defines the hosting scene
  63043. * @param sceneLoadedCallback callback called when scene is loaded
  63044. * @param progressCallback callback called to track progress
  63045. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  63046. * @param textureLoadingCallback callback called when a texture is loading
  63047. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  63048. * @param onReloadCallback callback called when a reload is requested
  63049. * @param errorCallback callback call if an error occurs
  63050. */
  63051. 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);
  63052. private _dragEnterHandler;
  63053. private _dragOverHandler;
  63054. private _dropHandler;
  63055. /**
  63056. * Calls this function to listen to drag'n'drop events on a specific DOM element
  63057. * @param elementToMonitor defines the DOM element to track
  63058. */
  63059. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  63060. /**
  63061. * Release all associated resources
  63062. */
  63063. dispose(): void;
  63064. private renderFunction;
  63065. private drag;
  63066. private drop;
  63067. private _traverseFolder;
  63068. private _processFiles;
  63069. /**
  63070. * Load files from a drop event
  63071. * @param event defines the drop event to use as source
  63072. */
  63073. loadFiles(event: any): void;
  63074. private _processReload;
  63075. /**
  63076. * Reload the current scene from the loaded files
  63077. */
  63078. reload(): void;
  63079. }
  63080. }
  63081. declare module "babylonjs/Misc/HighDynamicRange/index" {
  63082. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  63083. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  63084. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  63085. }
  63086. declare module "babylonjs/Misc/sceneOptimizer" {
  63087. import { Scene, IDisposable } from "babylonjs/scene";
  63088. import { Observable } from "babylonjs/Misc/observable";
  63089. /**
  63090. * Defines the root class used to create scene optimization to use with SceneOptimizer
  63091. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63092. */
  63093. export class SceneOptimization {
  63094. /**
  63095. * Defines the priority of this optimization (0 by default which means first in the list)
  63096. */
  63097. priority: number;
  63098. /**
  63099. * Gets a string describing the action executed by the current optimization
  63100. * @returns description string
  63101. */
  63102. getDescription(): string;
  63103. /**
  63104. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63105. * @param scene defines the current scene where to apply this optimization
  63106. * @param optimizer defines the current optimizer
  63107. * @returns true if everything that can be done was applied
  63108. */
  63109. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63110. /**
  63111. * Creates the SceneOptimization object
  63112. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63113. * @param desc defines the description associated with the optimization
  63114. */
  63115. constructor(
  63116. /**
  63117. * Defines the priority of this optimization (0 by default which means first in the list)
  63118. */
  63119. priority?: number);
  63120. }
  63121. /**
  63122. * Defines an optimization used to reduce the size of render target textures
  63123. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63124. */
  63125. export class TextureOptimization extends SceneOptimization {
  63126. /**
  63127. * Defines the priority of this optimization (0 by default which means first in the list)
  63128. */
  63129. priority: number;
  63130. /**
  63131. * 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
  63132. */
  63133. maximumSize: number;
  63134. /**
  63135. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63136. */
  63137. step: number;
  63138. /**
  63139. * Gets a string describing the action executed by the current optimization
  63140. * @returns description string
  63141. */
  63142. getDescription(): string;
  63143. /**
  63144. * Creates the TextureOptimization object
  63145. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63146. * @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
  63147. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63148. */
  63149. constructor(
  63150. /**
  63151. * Defines the priority of this optimization (0 by default which means first in the list)
  63152. */
  63153. priority?: number,
  63154. /**
  63155. * 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
  63156. */
  63157. maximumSize?: number,
  63158. /**
  63159. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63160. */
  63161. step?: number);
  63162. /**
  63163. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63164. * @param scene defines the current scene where to apply this optimization
  63165. * @param optimizer defines the current optimizer
  63166. * @returns true if everything that can be done was applied
  63167. */
  63168. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63169. }
  63170. /**
  63171. * Defines an optimization used to increase or decrease the rendering resolution
  63172. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63173. */
  63174. export class HardwareScalingOptimization extends SceneOptimization {
  63175. /**
  63176. * Defines the priority of this optimization (0 by default which means first in the list)
  63177. */
  63178. priority: number;
  63179. /**
  63180. * Defines the maximum scale to use (2 by default)
  63181. */
  63182. maximumScale: number;
  63183. /**
  63184. * Defines the step to use between two passes (0.5 by default)
  63185. */
  63186. step: number;
  63187. private _currentScale;
  63188. private _directionOffset;
  63189. /**
  63190. * Gets a string describing the action executed by the current optimization
  63191. * @return description string
  63192. */
  63193. getDescription(): string;
  63194. /**
  63195. * Creates the HardwareScalingOptimization object
  63196. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63197. * @param maximumScale defines the maximum scale to use (2 by default)
  63198. * @param step defines the step to use between two passes (0.5 by default)
  63199. */
  63200. constructor(
  63201. /**
  63202. * Defines the priority of this optimization (0 by default which means first in the list)
  63203. */
  63204. priority?: number,
  63205. /**
  63206. * Defines the maximum scale to use (2 by default)
  63207. */
  63208. maximumScale?: number,
  63209. /**
  63210. * Defines the step to use between two passes (0.5 by default)
  63211. */
  63212. step?: number);
  63213. /**
  63214. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63215. * @param scene defines the current scene where to apply this optimization
  63216. * @param optimizer defines the current optimizer
  63217. * @returns true if everything that can be done was applied
  63218. */
  63219. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63220. }
  63221. /**
  63222. * Defines an optimization used to remove shadows
  63223. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63224. */
  63225. export class ShadowsOptimization extends SceneOptimization {
  63226. /**
  63227. * Gets a string describing the action executed by the current optimization
  63228. * @return description string
  63229. */
  63230. getDescription(): string;
  63231. /**
  63232. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63233. * @param scene defines the current scene where to apply this optimization
  63234. * @param optimizer defines the current optimizer
  63235. * @returns true if everything that can be done was applied
  63236. */
  63237. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63238. }
  63239. /**
  63240. * Defines an optimization used to turn post-processes off
  63241. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63242. */
  63243. export class PostProcessesOptimization extends SceneOptimization {
  63244. /**
  63245. * Gets a string describing the action executed by the current optimization
  63246. * @return description string
  63247. */
  63248. getDescription(): string;
  63249. /**
  63250. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63251. * @param scene defines the current scene where to apply this optimization
  63252. * @param optimizer defines the current optimizer
  63253. * @returns true if everything that can be done was applied
  63254. */
  63255. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63256. }
  63257. /**
  63258. * Defines an optimization used to turn lens flares off
  63259. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63260. */
  63261. export class LensFlaresOptimization extends SceneOptimization {
  63262. /**
  63263. * Gets a string describing the action executed by the current optimization
  63264. * @return description string
  63265. */
  63266. getDescription(): string;
  63267. /**
  63268. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63269. * @param scene defines the current scene where to apply this optimization
  63270. * @param optimizer defines the current optimizer
  63271. * @returns true if everything that can be done was applied
  63272. */
  63273. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63274. }
  63275. /**
  63276. * Defines an optimization based on user defined callback.
  63277. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63278. */
  63279. export class CustomOptimization extends SceneOptimization {
  63280. /**
  63281. * Callback called to apply the custom optimization.
  63282. */
  63283. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  63284. /**
  63285. * Callback called to get custom description
  63286. */
  63287. onGetDescription: () => string;
  63288. /**
  63289. * Gets a string describing the action executed by the current optimization
  63290. * @returns description string
  63291. */
  63292. getDescription(): string;
  63293. /**
  63294. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63295. * @param scene defines the current scene where to apply this optimization
  63296. * @param optimizer defines the current optimizer
  63297. * @returns true if everything that can be done was applied
  63298. */
  63299. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63300. }
  63301. /**
  63302. * Defines an optimization used to turn particles off
  63303. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63304. */
  63305. export class ParticlesOptimization extends SceneOptimization {
  63306. /**
  63307. * Gets a string describing the action executed by the current optimization
  63308. * @return description string
  63309. */
  63310. getDescription(): string;
  63311. /**
  63312. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63313. * @param scene defines the current scene where to apply this optimization
  63314. * @param optimizer defines the current optimizer
  63315. * @returns true if everything that can be done was applied
  63316. */
  63317. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63318. }
  63319. /**
  63320. * Defines an optimization used to turn render targets off
  63321. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63322. */
  63323. export class RenderTargetsOptimization extends SceneOptimization {
  63324. /**
  63325. * Gets a string describing the action executed by the current optimization
  63326. * @return description string
  63327. */
  63328. getDescription(): string;
  63329. /**
  63330. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63331. * @param scene defines the current scene where to apply this optimization
  63332. * @param optimizer defines the current optimizer
  63333. * @returns true if everything that can be done was applied
  63334. */
  63335. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63336. }
  63337. /**
  63338. * Defines an optimization used to merge meshes with compatible materials
  63339. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63340. */
  63341. export class MergeMeshesOptimization extends SceneOptimization {
  63342. private static _UpdateSelectionTree;
  63343. /**
  63344. * Gets or sets a boolean which defines if optimization octree has to be updated
  63345. */
  63346. /**
  63347. * Gets or sets a boolean which defines if optimization octree has to be updated
  63348. */
  63349. static UpdateSelectionTree: boolean;
  63350. /**
  63351. * Gets a string describing the action executed by the current optimization
  63352. * @return description string
  63353. */
  63354. getDescription(): string;
  63355. private _canBeMerged;
  63356. /**
  63357. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63358. * @param scene defines the current scene where to apply this optimization
  63359. * @param optimizer defines the current optimizer
  63360. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  63361. * @returns true if everything that can be done was applied
  63362. */
  63363. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  63364. }
  63365. /**
  63366. * Defines a list of options used by SceneOptimizer
  63367. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63368. */
  63369. export class SceneOptimizerOptions {
  63370. /**
  63371. * Defines the target frame rate to reach (60 by default)
  63372. */
  63373. targetFrameRate: number;
  63374. /**
  63375. * Defines the interval between two checkes (2000ms by default)
  63376. */
  63377. trackerDuration: number;
  63378. /**
  63379. * Gets the list of optimizations to apply
  63380. */
  63381. optimizations: SceneOptimization[];
  63382. /**
  63383. * Creates a new list of options used by SceneOptimizer
  63384. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  63385. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  63386. */
  63387. constructor(
  63388. /**
  63389. * Defines the target frame rate to reach (60 by default)
  63390. */
  63391. targetFrameRate?: number,
  63392. /**
  63393. * Defines the interval between two checkes (2000ms by default)
  63394. */
  63395. trackerDuration?: number);
  63396. /**
  63397. * Add a new optimization
  63398. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  63399. * @returns the current SceneOptimizerOptions
  63400. */
  63401. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  63402. /**
  63403. * Add a new custom optimization
  63404. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  63405. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  63406. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63407. * @returns the current SceneOptimizerOptions
  63408. */
  63409. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  63410. /**
  63411. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  63412. * @param targetFrameRate defines the target frame rate (60 by default)
  63413. * @returns a SceneOptimizerOptions object
  63414. */
  63415. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63416. /**
  63417. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  63418. * @param targetFrameRate defines the target frame rate (60 by default)
  63419. * @returns a SceneOptimizerOptions object
  63420. */
  63421. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63422. /**
  63423. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  63424. * @param targetFrameRate defines the target frame rate (60 by default)
  63425. * @returns a SceneOptimizerOptions object
  63426. */
  63427. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63428. }
  63429. /**
  63430. * Class used to run optimizations in order to reach a target frame rate
  63431. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63432. */
  63433. export class SceneOptimizer implements IDisposable {
  63434. private _isRunning;
  63435. private _options;
  63436. private _scene;
  63437. private _currentPriorityLevel;
  63438. private _targetFrameRate;
  63439. private _trackerDuration;
  63440. private _currentFrameRate;
  63441. private _sceneDisposeObserver;
  63442. private _improvementMode;
  63443. /**
  63444. * Defines an observable called when the optimizer reaches the target frame rate
  63445. */
  63446. onSuccessObservable: Observable<SceneOptimizer>;
  63447. /**
  63448. * Defines an observable called when the optimizer enables an optimization
  63449. */
  63450. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  63451. /**
  63452. * Defines an observable called when the optimizer is not able to reach the target frame rate
  63453. */
  63454. onFailureObservable: Observable<SceneOptimizer>;
  63455. /**
  63456. * Gets a boolean indicating if the optimizer is in improvement mode
  63457. */
  63458. readonly isInImprovementMode: boolean;
  63459. /**
  63460. * Gets the current priority level (0 at start)
  63461. */
  63462. readonly currentPriorityLevel: number;
  63463. /**
  63464. * Gets the current frame rate checked by the SceneOptimizer
  63465. */
  63466. readonly currentFrameRate: number;
  63467. /**
  63468. * Gets or sets the current target frame rate (60 by default)
  63469. */
  63470. /**
  63471. * Gets or sets the current target frame rate (60 by default)
  63472. */
  63473. targetFrameRate: number;
  63474. /**
  63475. * Gets or sets the current interval between two checks (every 2000ms by default)
  63476. */
  63477. /**
  63478. * Gets or sets the current interval between two checks (every 2000ms by default)
  63479. */
  63480. trackerDuration: number;
  63481. /**
  63482. * Gets the list of active optimizations
  63483. */
  63484. readonly optimizations: SceneOptimization[];
  63485. /**
  63486. * Creates a new SceneOptimizer
  63487. * @param scene defines the scene to work on
  63488. * @param options defines the options to use with the SceneOptimizer
  63489. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  63490. * @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)
  63491. */
  63492. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  63493. /**
  63494. * Stops the current optimizer
  63495. */
  63496. stop(): void;
  63497. /**
  63498. * Reset the optimizer to initial step (current priority level = 0)
  63499. */
  63500. reset(): void;
  63501. /**
  63502. * Start the optimizer. By default it will try to reach a specific framerate
  63503. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  63504. */
  63505. start(): void;
  63506. private _checkCurrentState;
  63507. /**
  63508. * Release all resources
  63509. */
  63510. dispose(): void;
  63511. /**
  63512. * Helper function to create a SceneOptimizer with one single line of code
  63513. * @param scene defines the scene to work on
  63514. * @param options defines the options to use with the SceneOptimizer
  63515. * @param onSuccess defines a callback to call on success
  63516. * @param onFailure defines a callback to call on failure
  63517. * @returns the new SceneOptimizer object
  63518. */
  63519. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  63520. }
  63521. }
  63522. declare module "babylonjs/Misc/sceneSerializer" {
  63523. import { Scene } from "babylonjs/scene";
  63524. /**
  63525. * Class used to serialize a scene into a string
  63526. */
  63527. export class SceneSerializer {
  63528. /**
  63529. * Clear cache used by a previous serialization
  63530. */
  63531. static ClearCache(): void;
  63532. /**
  63533. * Serialize a scene into a JSON compatible object
  63534. * @param scene defines the scene to serialize
  63535. * @returns a JSON compatible object
  63536. */
  63537. static Serialize(scene: Scene): any;
  63538. /**
  63539. * Serialize a mesh into a JSON compatible object
  63540. * @param toSerialize defines the mesh to serialize
  63541. * @param withParents defines if parents must be serialized as well
  63542. * @param withChildren defines if children must be serialized as well
  63543. * @returns a JSON compatible object
  63544. */
  63545. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  63546. }
  63547. }
  63548. declare module "babylonjs/Misc/textureTools" {
  63549. import { Texture } from "babylonjs/Materials/Textures/texture";
  63550. /**
  63551. * Class used to host texture specific utilities
  63552. */
  63553. export class TextureTools {
  63554. /**
  63555. * Uses the GPU to create a copy texture rescaled at a given size
  63556. * @param texture Texture to copy from
  63557. * @param width defines the desired width
  63558. * @param height defines the desired height
  63559. * @param useBilinearMode defines if bilinear mode has to be used
  63560. * @return the generated texture
  63561. */
  63562. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  63563. }
  63564. }
  63565. declare module "babylonjs/Misc/videoRecorder" {
  63566. import { Nullable } from "babylonjs/types";
  63567. import { Engine } from "babylonjs/Engines/engine";
  63568. /**
  63569. * This represents the different options available for the video capture.
  63570. */
  63571. export interface VideoRecorderOptions {
  63572. /** Defines the mime type of the video. */
  63573. mimeType: string;
  63574. /** Defines the FPS the video should be recorded at. */
  63575. fps: number;
  63576. /** Defines the chunk size for the recording data. */
  63577. recordChunckSize: number;
  63578. /** The audio tracks to attach to the recording. */
  63579. audioTracks?: MediaStreamTrack[];
  63580. }
  63581. /**
  63582. * This can help with recording videos from BabylonJS.
  63583. * This is based on the available WebRTC functionalities of the browser.
  63584. *
  63585. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  63586. */
  63587. export class VideoRecorder {
  63588. private static readonly _defaultOptions;
  63589. /**
  63590. * Returns whether or not the VideoRecorder is available in your browser.
  63591. * @param engine Defines the Babylon Engine.
  63592. * @returns true if supported otherwise false.
  63593. */
  63594. static IsSupported(engine: Engine): boolean;
  63595. private readonly _options;
  63596. private _canvas;
  63597. private _mediaRecorder;
  63598. private _recordedChunks;
  63599. private _fileName;
  63600. private _resolve;
  63601. private _reject;
  63602. /**
  63603. * True when a recording is already in progress.
  63604. */
  63605. readonly isRecording: boolean;
  63606. /**
  63607. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  63608. * @param engine Defines the BabylonJS Engine you wish to record.
  63609. * @param options Defines options that can be used to customize the capture.
  63610. */
  63611. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  63612. /**
  63613. * Stops the current recording before the default capture timeout passed in the startRecording function.
  63614. */
  63615. stopRecording(): void;
  63616. /**
  63617. * Starts recording the canvas for a max duration specified in parameters.
  63618. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  63619. * If null no automatic download will start and you can rely on the promise to get the data back.
  63620. * @param maxDuration Defines the maximum recording time in seconds.
  63621. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  63622. * @return A promise callback at the end of the recording with the video data in Blob.
  63623. */
  63624. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  63625. /**
  63626. * Releases internal resources used during the recording.
  63627. */
  63628. dispose(): void;
  63629. private _handleDataAvailable;
  63630. private _handleError;
  63631. private _handleStop;
  63632. }
  63633. }
  63634. declare module "babylonjs/Misc/screenshotTools" {
  63635. import { Camera } from "babylonjs/Cameras/camera";
  63636. import { Engine } from "babylonjs/Engines/engine";
  63637. /**
  63638. * Class containing a set of static utilities functions for screenshots
  63639. */
  63640. export class ScreenshotTools {
  63641. /**
  63642. * Captures a screenshot of the current rendering
  63643. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63644. * @param engine defines the rendering engine
  63645. * @param camera defines the source camera
  63646. * @param size This parameter can be set to a single number or to an object with the
  63647. * following (optional) properties: precision, width, height. If a single number is passed,
  63648. * it will be used for both width and height. If an object is passed, the screenshot size
  63649. * will be derived from the parameters. The precision property is a multiplier allowing
  63650. * rendering at a higher or lower resolution
  63651. * @param successCallback defines the callback receives a single parameter which contains the
  63652. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63653. * src parameter of an <img> to display it
  63654. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63655. * Check your browser for supported MIME types
  63656. */
  63657. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  63658. /**
  63659. * Captures a screenshot of the current rendering
  63660. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63661. * @param engine defines the rendering engine
  63662. * @param camera defines the source camera
  63663. * @param size This parameter can be set to a single number or to an object with the
  63664. * following (optional) properties: precision, width, height. If a single number is passed,
  63665. * it will be used for both width and height. If an object is passed, the screenshot size
  63666. * will be derived from the parameters. The precision property is a multiplier allowing
  63667. * rendering at a higher or lower resolution
  63668. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63669. * Check your browser for supported MIME types
  63670. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63671. * to the src parameter of an <img> to display it
  63672. */
  63673. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  63674. /**
  63675. * Generates an image screenshot from the specified camera.
  63676. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63677. * @param engine The engine to use for rendering
  63678. * @param camera The camera to use for rendering
  63679. * @param size This parameter can be set to a single number or to an object with the
  63680. * following (optional) properties: precision, width, height. If a single number is passed,
  63681. * it will be used for both width and height. If an object is passed, the screenshot size
  63682. * will be derived from the parameters. The precision property is a multiplier allowing
  63683. * rendering at a higher or lower resolution
  63684. * @param successCallback The callback receives a single parameter which contains the
  63685. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63686. * src parameter of an <img> to display it
  63687. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63688. * Check your browser for supported MIME types
  63689. * @param samples Texture samples (default: 1)
  63690. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63691. * @param fileName A name for for the downloaded file.
  63692. */
  63693. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  63694. /**
  63695. * Generates an image screenshot from the specified camera.
  63696. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63697. * @param engine The engine to use for rendering
  63698. * @param camera The camera to use for rendering
  63699. * @param size This parameter can be set to a single number or to an object with the
  63700. * following (optional) properties: precision, width, height. If a single number is passed,
  63701. * it will be used for both width and height. If an object is passed, the screenshot size
  63702. * will be derived from the parameters. The precision property is a multiplier allowing
  63703. * rendering at a higher or lower resolution
  63704. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63705. * Check your browser for supported MIME types
  63706. * @param samples Texture samples (default: 1)
  63707. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63708. * @param fileName A name for for the downloaded file.
  63709. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63710. * to the src parameter of an <img> to display it
  63711. */
  63712. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  63713. }
  63714. }
  63715. declare module "babylonjs/Misc/index" {
  63716. export * from "babylonjs/Misc/andOrNotEvaluator";
  63717. export * from "babylonjs/Misc/assetsManager";
  63718. export * from "babylonjs/Misc/dds";
  63719. export * from "babylonjs/Misc/decorators";
  63720. export * from "babylonjs/Misc/deferred";
  63721. export * from "babylonjs/Misc/environmentTextureTools";
  63722. export * from "babylonjs/Misc/meshExploder";
  63723. export * from "babylonjs/Misc/filesInput";
  63724. export * from "babylonjs/Misc/HighDynamicRange/index";
  63725. export * from "babylonjs/Misc/khronosTextureContainer";
  63726. export * from "babylonjs/Misc/observable";
  63727. export * from "babylonjs/Misc/performanceMonitor";
  63728. export * from "babylonjs/Misc/promise";
  63729. export * from "babylonjs/Misc/sceneOptimizer";
  63730. export * from "babylonjs/Misc/sceneSerializer";
  63731. export * from "babylonjs/Misc/smartArray";
  63732. export * from "babylonjs/Misc/stringDictionary";
  63733. export * from "babylonjs/Misc/tags";
  63734. export * from "babylonjs/Misc/textureTools";
  63735. export * from "babylonjs/Misc/tga";
  63736. export * from "babylonjs/Misc/tools";
  63737. export * from "babylonjs/Misc/videoRecorder";
  63738. export * from "babylonjs/Misc/virtualJoystick";
  63739. export * from "babylonjs/Misc/workerPool";
  63740. export * from "babylonjs/Misc/logger";
  63741. export * from "babylonjs/Misc/typeStore";
  63742. export * from "babylonjs/Misc/filesInputStore";
  63743. export * from "babylonjs/Misc/deepCopier";
  63744. export * from "babylonjs/Misc/pivotTools";
  63745. export * from "babylonjs/Misc/precisionDate";
  63746. export * from "babylonjs/Misc/screenshotTools";
  63747. export * from "babylonjs/Misc/typeStore";
  63748. export * from "babylonjs/Misc/webRequest";
  63749. export * from "babylonjs/Misc/iInspectable";
  63750. export * from "babylonjs/Misc/brdfTextureTools";
  63751. export * from "babylonjs/Misc/gradients";
  63752. export * from "babylonjs/Misc/perfCounter";
  63753. export * from "babylonjs/Misc/fileRequest";
  63754. export * from "babylonjs/Misc/customAnimationFrameRequester";
  63755. export * from "babylonjs/Misc/retryStrategy";
  63756. export * from "babylonjs/Misc/loadFileError";
  63757. }
  63758. declare module "babylonjs/index" {
  63759. export * from "babylonjs/abstractScene";
  63760. export * from "babylonjs/Actions/index";
  63761. export * from "babylonjs/Animations/index";
  63762. export * from "babylonjs/assetContainer";
  63763. export * from "babylonjs/Audio/index";
  63764. export * from "babylonjs/Behaviors/index";
  63765. export * from "babylonjs/Bones/index";
  63766. export * from "babylonjs/Cameras/index";
  63767. export * from "babylonjs/Collisions/index";
  63768. export * from "babylonjs/Culling/index";
  63769. export * from "babylonjs/Debug/index";
  63770. export * from "babylonjs/Engines/index";
  63771. export * from "babylonjs/Events/index";
  63772. export * from "babylonjs/Gamepads/index";
  63773. export * from "babylonjs/Gizmos/index";
  63774. export * from "babylonjs/Helpers/index";
  63775. export * from "babylonjs/Instrumentation/index";
  63776. export * from "babylonjs/Layers/index";
  63777. export * from "babylonjs/LensFlares/index";
  63778. export * from "babylonjs/Lights/index";
  63779. export * from "babylonjs/Loading/index";
  63780. export * from "babylonjs/Materials/index";
  63781. export * from "babylonjs/Maths/index";
  63782. export * from "babylonjs/Meshes/index";
  63783. export * from "babylonjs/Morph/index";
  63784. export * from "babylonjs/Navigation/index";
  63785. export * from "babylonjs/node";
  63786. export * from "babylonjs/Offline/index";
  63787. export * from "babylonjs/Particles/index";
  63788. export * from "babylonjs/Physics/index";
  63789. export * from "babylonjs/PostProcesses/index";
  63790. export * from "babylonjs/Probes/index";
  63791. export * from "babylonjs/Rendering/index";
  63792. export * from "babylonjs/scene";
  63793. export * from "babylonjs/sceneComponent";
  63794. export * from "babylonjs/Sprites/index";
  63795. export * from "babylonjs/States/index";
  63796. export * from "babylonjs/Misc/index";
  63797. export * from "babylonjs/types";
  63798. }
  63799. declare module "babylonjs/Animations/pathCursor" {
  63800. import { Vector3 } from "babylonjs/Maths/math.vector";
  63801. import { Path2 } from "babylonjs/Maths/math.path";
  63802. /**
  63803. * A cursor which tracks a point on a path
  63804. */
  63805. export class PathCursor {
  63806. private path;
  63807. /**
  63808. * Stores path cursor callbacks for when an onchange event is triggered
  63809. */
  63810. private _onchange;
  63811. /**
  63812. * The value of the path cursor
  63813. */
  63814. value: number;
  63815. /**
  63816. * The animation array of the path cursor
  63817. */
  63818. animations: Animation[];
  63819. /**
  63820. * Initializes the path cursor
  63821. * @param path The path to track
  63822. */
  63823. constructor(path: Path2);
  63824. /**
  63825. * Gets the cursor point on the path
  63826. * @returns A point on the path cursor at the cursor location
  63827. */
  63828. getPoint(): Vector3;
  63829. /**
  63830. * Moves the cursor ahead by the step amount
  63831. * @param step The amount to move the cursor forward
  63832. * @returns This path cursor
  63833. */
  63834. moveAhead(step?: number): PathCursor;
  63835. /**
  63836. * Moves the cursor behind by the step amount
  63837. * @param step The amount to move the cursor back
  63838. * @returns This path cursor
  63839. */
  63840. moveBack(step?: number): PathCursor;
  63841. /**
  63842. * Moves the cursor by the step amount
  63843. * If the step amount is greater than one, an exception is thrown
  63844. * @param step The amount to move the cursor
  63845. * @returns This path cursor
  63846. */
  63847. move(step: number): PathCursor;
  63848. /**
  63849. * Ensures that the value is limited between zero and one
  63850. * @returns This path cursor
  63851. */
  63852. private ensureLimits;
  63853. /**
  63854. * Runs onchange callbacks on change (used by the animation engine)
  63855. * @returns This path cursor
  63856. */
  63857. private raiseOnChange;
  63858. /**
  63859. * Executes a function on change
  63860. * @param f A path cursor onchange callback
  63861. * @returns This path cursor
  63862. */
  63863. onchange(f: (cursor: PathCursor) => void): PathCursor;
  63864. }
  63865. }
  63866. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  63867. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  63868. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  63869. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  63870. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  63871. }
  63872. declare module "babylonjs/Engines/Processors/Expressions/index" {
  63873. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  63874. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  63875. }
  63876. declare module "babylonjs/Engines/Processors/index" {
  63877. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  63878. export * from "babylonjs/Engines/Processors/Expressions/index";
  63879. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  63880. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  63881. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  63882. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  63883. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  63884. export * from "babylonjs/Engines/Processors/shaderProcessor";
  63885. }
  63886. declare module "babylonjs/Legacy/legacy" {
  63887. import * as Babylon from "babylonjs/index";
  63888. export * from "babylonjs/index";
  63889. }
  63890. declare module "babylonjs/Shaders/blur.fragment" {
  63891. /** @hidden */
  63892. export var blurPixelShader: {
  63893. name: string;
  63894. shader: string;
  63895. };
  63896. }
  63897. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  63898. /** @hidden */
  63899. export var pointCloudVertexDeclaration: {
  63900. name: string;
  63901. shader: string;
  63902. };
  63903. }
  63904. declare module "babylonjs" {
  63905. export * from "babylonjs/Legacy/legacy";
  63906. }
  63907. declare module BABYLON {
  63908. /** Alias type for value that can be null */
  63909. export type Nullable<T> = T | null;
  63910. /**
  63911. * Alias type for number that are floats
  63912. * @ignorenaming
  63913. */
  63914. export type float = number;
  63915. /**
  63916. * Alias type for number that are doubles.
  63917. * @ignorenaming
  63918. */
  63919. export type double = number;
  63920. /**
  63921. * Alias type for number that are integer
  63922. * @ignorenaming
  63923. */
  63924. export type int = number;
  63925. /** Alias type for number array or Float32Array */
  63926. export type FloatArray = number[] | Float32Array;
  63927. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  63928. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  63929. /**
  63930. * Alias for types that can be used by a Buffer or VertexBuffer.
  63931. */
  63932. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  63933. /**
  63934. * Alias type for primitive types
  63935. * @ignorenaming
  63936. */
  63937. type Primitive = undefined | null | boolean | string | number | Function;
  63938. /**
  63939. * Type modifier to make all the properties of an object Readonly
  63940. */
  63941. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  63942. /**
  63943. * Type modifier to make all the properties of an object Readonly recursively
  63944. */
  63945. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  63946. /** @hidden */
  63947. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  63948. }
  63949. /** @hidden */
  63950. /** @hidden */
  63951. type DeepImmutableObject<T> = {
  63952. readonly [K in keyof T]: DeepImmutable<T[K]>;
  63953. };
  63954. }
  63955. declare module BABYLON {
  63956. /**
  63957. * A class serves as a medium between the observable and its observers
  63958. */
  63959. export class EventState {
  63960. /**
  63961. * Create a new EventState
  63962. * @param mask defines the mask associated with this state
  63963. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63964. * @param target defines the original target of the state
  63965. * @param currentTarget defines the current target of the state
  63966. */
  63967. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63968. /**
  63969. * Initialize the current event state
  63970. * @param mask defines the mask associated with this state
  63971. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63972. * @param target defines the original target of the state
  63973. * @param currentTarget defines the current target of the state
  63974. * @returns the current event state
  63975. */
  63976. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  63977. /**
  63978. * An Observer can set this property to true to prevent subsequent observers of being notified
  63979. */
  63980. skipNextObservers: boolean;
  63981. /**
  63982. * Get the mask value that were used to trigger the event corresponding to this EventState object
  63983. */
  63984. mask: number;
  63985. /**
  63986. * The object that originally notified the event
  63987. */
  63988. target?: any;
  63989. /**
  63990. * The current object in the bubbling phase
  63991. */
  63992. currentTarget?: any;
  63993. /**
  63994. * This will be populated with the return value of the last function that was executed.
  63995. * If it is the first function in the callback chain it will be the event data.
  63996. */
  63997. lastReturnValue?: any;
  63998. }
  63999. /**
  64000. * Represent an Observer registered to a given Observable object.
  64001. */
  64002. export class Observer<T> {
  64003. /**
  64004. * Defines the callback to call when the observer is notified
  64005. */
  64006. callback: (eventData: T, eventState: EventState) => void;
  64007. /**
  64008. * Defines the mask of the observer (used to filter notifications)
  64009. */
  64010. mask: number;
  64011. /**
  64012. * Defines the current scope used to restore the JS context
  64013. */
  64014. scope: any;
  64015. /** @hidden */
  64016. _willBeUnregistered: boolean;
  64017. /**
  64018. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  64019. */
  64020. unregisterOnNextCall: boolean;
  64021. /**
  64022. * Creates a new observer
  64023. * @param callback defines the callback to call when the observer is notified
  64024. * @param mask defines the mask of the observer (used to filter notifications)
  64025. * @param scope defines the current scope used to restore the JS context
  64026. */
  64027. constructor(
  64028. /**
  64029. * Defines the callback to call when the observer is notified
  64030. */
  64031. callback: (eventData: T, eventState: EventState) => void,
  64032. /**
  64033. * Defines the mask of the observer (used to filter notifications)
  64034. */
  64035. mask: number,
  64036. /**
  64037. * Defines the current scope used to restore the JS context
  64038. */
  64039. scope?: any);
  64040. }
  64041. /**
  64042. * Represent a list of observers registered to multiple Observables object.
  64043. */
  64044. export class MultiObserver<T> {
  64045. private _observers;
  64046. private _observables;
  64047. /**
  64048. * Release associated resources
  64049. */
  64050. dispose(): void;
  64051. /**
  64052. * Raise a callback when one of the observable will notify
  64053. * @param observables defines a list of observables to watch
  64054. * @param callback defines the callback to call on notification
  64055. * @param mask defines the mask used to filter notifications
  64056. * @param scope defines the current scope used to restore the JS context
  64057. * @returns the new MultiObserver
  64058. */
  64059. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  64060. }
  64061. /**
  64062. * The Observable class is a simple implementation of the Observable pattern.
  64063. *
  64064. * 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.
  64065. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  64066. * 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).
  64067. * 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.
  64068. */
  64069. export class Observable<T> {
  64070. private _observers;
  64071. private _eventState;
  64072. private _onObserverAdded;
  64073. /**
  64074. * Gets the list of observers
  64075. */
  64076. readonly observers: Array<Observer<T>>;
  64077. /**
  64078. * Creates a new observable
  64079. * @param onObserverAdded defines a callback to call when a new observer is added
  64080. */
  64081. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  64082. /**
  64083. * Create a new Observer with the specified callback
  64084. * @param callback the callback that will be executed for that Observer
  64085. * @param mask the mask used to filter observers
  64086. * @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.
  64087. * @param scope optional scope for the callback to be called from
  64088. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  64089. * @returns the new observer created for the callback
  64090. */
  64091. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  64092. /**
  64093. * Create a new Observer with the specified callback and unregisters after the next notification
  64094. * @param callback the callback that will be executed for that Observer
  64095. * @returns the new observer created for the callback
  64096. */
  64097. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  64098. /**
  64099. * Remove an Observer from the Observable object
  64100. * @param observer the instance of the Observer to remove
  64101. * @returns false if it doesn't belong to this Observable
  64102. */
  64103. remove(observer: Nullable<Observer<T>>): boolean;
  64104. /**
  64105. * Remove a callback from the Observable object
  64106. * @param callback the callback to remove
  64107. * @param scope optional scope. If used only the callbacks with this scope will be removed
  64108. * @returns false if it doesn't belong to this Observable
  64109. */
  64110. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  64111. private _deferUnregister;
  64112. private _remove;
  64113. /**
  64114. * Moves the observable to the top of the observer list making it get called first when notified
  64115. * @param observer the observer to move
  64116. */
  64117. makeObserverTopPriority(observer: Observer<T>): void;
  64118. /**
  64119. * Moves the observable to the bottom of the observer list making it get called last when notified
  64120. * @param observer the observer to move
  64121. */
  64122. makeObserverBottomPriority(observer: Observer<T>): void;
  64123. /**
  64124. * Notify all Observers by calling their respective callback with the given data
  64125. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  64126. * @param eventData defines the data to send to all observers
  64127. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  64128. * @param target defines the original target of the state
  64129. * @param currentTarget defines the current target of the state
  64130. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  64131. */
  64132. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  64133. /**
  64134. * Calling this will execute each callback, expecting it to be a promise or return a value.
  64135. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  64136. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  64137. * and it is crucial that all callbacks will be executed.
  64138. * The order of the callbacks is kept, callbacks are not executed parallel.
  64139. *
  64140. * @param eventData The data to be sent to each callback
  64141. * @param mask is used to filter observers defaults to -1
  64142. * @param target defines the callback target (see EventState)
  64143. * @param currentTarget defines he current object in the bubbling phase
  64144. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  64145. */
  64146. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  64147. /**
  64148. * Notify a specific observer
  64149. * @param observer defines the observer to notify
  64150. * @param eventData defines the data to be sent to each callback
  64151. * @param mask is used to filter observers defaults to -1
  64152. */
  64153. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  64154. /**
  64155. * Gets a boolean indicating if the observable has at least one observer
  64156. * @returns true is the Observable has at least one Observer registered
  64157. */
  64158. hasObservers(): boolean;
  64159. /**
  64160. * Clear the list of observers
  64161. */
  64162. clear(): void;
  64163. /**
  64164. * Clone the current observable
  64165. * @returns a new observable
  64166. */
  64167. clone(): Observable<T>;
  64168. /**
  64169. * Does this observable handles observer registered with a given mask
  64170. * @param mask defines the mask to be tested
  64171. * @return whether or not one observer registered with the given mask is handeled
  64172. **/
  64173. hasSpecificMask(mask?: number): boolean;
  64174. }
  64175. }
  64176. declare module BABYLON {
  64177. /**
  64178. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64179. * Babylon.js
  64180. */
  64181. export class DomManagement {
  64182. /**
  64183. * Checks if the window object exists
  64184. * @returns true if the window object exists
  64185. */
  64186. static IsWindowObjectExist(): boolean;
  64187. /**
  64188. * Extracts text content from a DOM element hierarchy
  64189. * @param element defines the root element
  64190. * @returns a string
  64191. */
  64192. static GetDOMTextContent(element: HTMLElement): string;
  64193. }
  64194. }
  64195. declare module BABYLON {
  64196. /**
  64197. * Logger used througouht the application to allow configuration of
  64198. * the log level required for the messages.
  64199. */
  64200. export class Logger {
  64201. /**
  64202. * No log
  64203. */
  64204. static readonly NoneLogLevel: number;
  64205. /**
  64206. * Only message logs
  64207. */
  64208. static readonly MessageLogLevel: number;
  64209. /**
  64210. * Only warning logs
  64211. */
  64212. static readonly WarningLogLevel: number;
  64213. /**
  64214. * Only error logs
  64215. */
  64216. static readonly ErrorLogLevel: number;
  64217. /**
  64218. * All logs
  64219. */
  64220. static readonly AllLogLevel: number;
  64221. private static _LogCache;
  64222. /**
  64223. * Gets a value indicating the number of loading errors
  64224. * @ignorenaming
  64225. */
  64226. static errorsCount: number;
  64227. /**
  64228. * Callback called when a new log is added
  64229. */
  64230. static OnNewCacheEntry: (entry: string) => void;
  64231. private static _AddLogEntry;
  64232. private static _FormatMessage;
  64233. private static _LogDisabled;
  64234. private static _LogEnabled;
  64235. private static _WarnDisabled;
  64236. private static _WarnEnabled;
  64237. private static _ErrorDisabled;
  64238. private static _ErrorEnabled;
  64239. /**
  64240. * Log a message to the console
  64241. */
  64242. static Log: (message: string) => void;
  64243. /**
  64244. * Write a warning message to the console
  64245. */
  64246. static Warn: (message: string) => void;
  64247. /**
  64248. * Write an error message to the console
  64249. */
  64250. static Error: (message: string) => void;
  64251. /**
  64252. * Gets current log cache (list of logs)
  64253. */
  64254. static readonly LogCache: string;
  64255. /**
  64256. * Clears the log cache
  64257. */
  64258. static ClearLogCache(): void;
  64259. /**
  64260. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64261. */
  64262. static LogLevels: number;
  64263. }
  64264. }
  64265. declare module BABYLON {
  64266. /** @hidden */
  64267. export class _TypeStore {
  64268. /** @hidden */
  64269. static RegisteredTypes: {
  64270. [key: string]: Object;
  64271. };
  64272. /** @hidden */
  64273. static GetClass(fqdn: string): any;
  64274. }
  64275. }
  64276. declare module BABYLON {
  64277. /**
  64278. * Class containing a set of static utilities functions for deep copy.
  64279. */
  64280. export class DeepCopier {
  64281. /**
  64282. * Tries to copy an object by duplicating every property
  64283. * @param source defines the source object
  64284. * @param destination defines the target object
  64285. * @param doNotCopyList defines a list of properties to avoid
  64286. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64287. */
  64288. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64289. }
  64290. }
  64291. declare module BABYLON {
  64292. /**
  64293. * Class containing a set of static utilities functions for precision date
  64294. */
  64295. export class PrecisionDate {
  64296. /**
  64297. * Gets either window.performance.now() if supported or Date.now() else
  64298. */
  64299. static readonly Now: number;
  64300. }
  64301. }
  64302. declare module BABYLON {
  64303. /** @hidden */
  64304. export class _DevTools {
  64305. static WarnImport(name: string): string;
  64306. }
  64307. }
  64308. declare module BABYLON {
  64309. /**
  64310. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64311. */
  64312. export class WebRequest {
  64313. private _xhr;
  64314. /**
  64315. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64316. * i.e. when loading files, where the server/service expects an Authorization header
  64317. */
  64318. static CustomRequestHeaders: {
  64319. [key: string]: string;
  64320. };
  64321. /**
  64322. * Add callback functions in this array to update all the requests before they get sent to the network
  64323. */
  64324. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  64325. private _injectCustomRequestHeaders;
  64326. /**
  64327. * Gets or sets a function to be called when loading progress changes
  64328. */
  64329. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64330. /**
  64331. * Returns client's state
  64332. */
  64333. readonly readyState: number;
  64334. /**
  64335. * Returns client's status
  64336. */
  64337. readonly status: number;
  64338. /**
  64339. * Returns client's status as a text
  64340. */
  64341. readonly statusText: string;
  64342. /**
  64343. * Returns client's response
  64344. */
  64345. readonly response: any;
  64346. /**
  64347. * Returns client's response url
  64348. */
  64349. readonly responseURL: string;
  64350. /**
  64351. * Returns client's response as text
  64352. */
  64353. readonly responseText: string;
  64354. /**
  64355. * Gets or sets the expected response type
  64356. */
  64357. responseType: XMLHttpRequestResponseType;
  64358. /** @hidden */
  64359. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64360. /** @hidden */
  64361. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64362. /**
  64363. * Cancels any network activity
  64364. */
  64365. abort(): void;
  64366. /**
  64367. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64368. * @param body defines an optional request body
  64369. */
  64370. send(body?: Document | BodyInit | null): void;
  64371. /**
  64372. * Sets the request method, request URL
  64373. * @param method defines the method to use (GET, POST, etc..)
  64374. * @param url defines the url to connect with
  64375. */
  64376. open(method: string, url: string): void;
  64377. }
  64378. }
  64379. declare module BABYLON {
  64380. /**
  64381. * File request interface
  64382. */
  64383. export interface IFileRequest {
  64384. /**
  64385. * Raised when the request is complete (success or error).
  64386. */
  64387. onCompleteObservable: Observable<IFileRequest>;
  64388. /**
  64389. * Aborts the request for a file.
  64390. */
  64391. abort: () => void;
  64392. }
  64393. }
  64394. declare module BABYLON {
  64395. /**
  64396. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  64397. */
  64398. export class PerformanceMonitor {
  64399. private _enabled;
  64400. private _rollingFrameTime;
  64401. private _lastFrameTimeMs;
  64402. /**
  64403. * constructor
  64404. * @param frameSampleSize The number of samples required to saturate the sliding window
  64405. */
  64406. constructor(frameSampleSize?: number);
  64407. /**
  64408. * Samples current frame
  64409. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  64410. */
  64411. sampleFrame(timeMs?: number): void;
  64412. /**
  64413. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64414. */
  64415. readonly averageFrameTime: number;
  64416. /**
  64417. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64418. */
  64419. readonly averageFrameTimeVariance: number;
  64420. /**
  64421. * Returns the frame time of the most recent frame
  64422. */
  64423. readonly instantaneousFrameTime: number;
  64424. /**
  64425. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  64426. */
  64427. readonly averageFPS: number;
  64428. /**
  64429. * Returns the average framerate in frames per second using the most recent frame time
  64430. */
  64431. readonly instantaneousFPS: number;
  64432. /**
  64433. * Returns true if enough samples have been taken to completely fill the sliding window
  64434. */
  64435. readonly isSaturated: boolean;
  64436. /**
  64437. * Enables contributions to the sliding window sample set
  64438. */
  64439. enable(): void;
  64440. /**
  64441. * Disables contributions to the sliding window sample set
  64442. * Samples will not be interpolated over the disabled period
  64443. */
  64444. disable(): void;
  64445. /**
  64446. * Returns true if sampling is enabled
  64447. */
  64448. readonly isEnabled: boolean;
  64449. /**
  64450. * Resets performance monitor
  64451. */
  64452. reset(): void;
  64453. }
  64454. /**
  64455. * RollingAverage
  64456. *
  64457. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  64458. */
  64459. export class RollingAverage {
  64460. /**
  64461. * Current average
  64462. */
  64463. average: number;
  64464. /**
  64465. * Current variance
  64466. */
  64467. variance: number;
  64468. protected _samples: Array<number>;
  64469. protected _sampleCount: number;
  64470. protected _pos: number;
  64471. protected _m2: number;
  64472. /**
  64473. * constructor
  64474. * @param length The number of samples required to saturate the sliding window
  64475. */
  64476. constructor(length: number);
  64477. /**
  64478. * Adds a sample to the sample set
  64479. * @param v The sample value
  64480. */
  64481. add(v: number): void;
  64482. /**
  64483. * Returns previously added values or null if outside of history or outside the sliding window domain
  64484. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  64485. * @return Value previously recorded with add() or null if outside of range
  64486. */
  64487. history(i: number): number;
  64488. /**
  64489. * Returns true if enough samples have been taken to completely fill the sliding window
  64490. * @return true if sample-set saturated
  64491. */
  64492. isSaturated(): boolean;
  64493. /**
  64494. * Resets the rolling average (equivalent to 0 samples taken so far)
  64495. */
  64496. reset(): void;
  64497. /**
  64498. * Wraps a value around the sample range boundaries
  64499. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  64500. * @return Wrapped position in sample range
  64501. */
  64502. protected _wrapPosition(i: number): number;
  64503. }
  64504. }
  64505. declare module BABYLON {
  64506. /**
  64507. * This class implement a typical dictionary using a string as key and the generic type T as value.
  64508. * The underlying implementation relies on an associative array to ensure the best performances.
  64509. * The value can be anything including 'null' but except 'undefined'
  64510. */
  64511. export class StringDictionary<T> {
  64512. /**
  64513. * This will clear this dictionary and copy the content from the 'source' one.
  64514. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  64515. * @param source the dictionary to take the content from and copy to this dictionary
  64516. */
  64517. copyFrom(source: StringDictionary<T>): void;
  64518. /**
  64519. * Get a value based from its key
  64520. * @param key the given key to get the matching value from
  64521. * @return the value if found, otherwise undefined is returned
  64522. */
  64523. get(key: string): T | undefined;
  64524. /**
  64525. * Get a value from its key or add it if it doesn't exist.
  64526. * This method will ensure you that a given key/data will be present in the dictionary.
  64527. * @param key the given key to get the matching value from
  64528. * @param factory the factory that will create the value if the key is not present in the dictionary.
  64529. * The factory will only be invoked if there's no data for the given key.
  64530. * @return the value corresponding to the key.
  64531. */
  64532. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  64533. /**
  64534. * Get a value from its key if present in the dictionary otherwise add it
  64535. * @param key the key to get the value from
  64536. * @param val if there's no such key/value pair in the dictionary add it with this value
  64537. * @return the value corresponding to the key
  64538. */
  64539. getOrAdd(key: string, val: T): T;
  64540. /**
  64541. * Check if there's a given key in the dictionary
  64542. * @param key the key to check for
  64543. * @return true if the key is present, false otherwise
  64544. */
  64545. contains(key: string): boolean;
  64546. /**
  64547. * Add a new key and its corresponding value
  64548. * @param key the key to add
  64549. * @param value the value corresponding to the key
  64550. * @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
  64551. */
  64552. add(key: string, value: T): boolean;
  64553. /**
  64554. * Update a specific value associated to a key
  64555. * @param key defines the key to use
  64556. * @param value defines the value to store
  64557. * @returns true if the value was updated (or false if the key was not found)
  64558. */
  64559. set(key: string, value: T): boolean;
  64560. /**
  64561. * Get the element of the given key and remove it from the dictionary
  64562. * @param key defines the key to search
  64563. * @returns the value associated with the key or null if not found
  64564. */
  64565. getAndRemove(key: string): Nullable<T>;
  64566. /**
  64567. * Remove a key/value from the dictionary.
  64568. * @param key the key to remove
  64569. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  64570. */
  64571. remove(key: string): boolean;
  64572. /**
  64573. * Clear the whole content of the dictionary
  64574. */
  64575. clear(): void;
  64576. /**
  64577. * Gets the current count
  64578. */
  64579. readonly count: number;
  64580. /**
  64581. * Execute a callback on each key/val of the dictionary.
  64582. * Note that you can remove any element in this dictionary in the callback implementation
  64583. * @param callback the callback to execute on a given key/value pair
  64584. */
  64585. forEach(callback: (key: string, val: T) => void): void;
  64586. /**
  64587. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  64588. * If the callback returns null or undefined the method will iterate to the next key/value pair
  64589. * Note that you can remove any element in this dictionary in the callback implementation
  64590. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  64591. * @returns the first item
  64592. */
  64593. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  64594. private _count;
  64595. private _data;
  64596. }
  64597. }
  64598. declare module BABYLON {
  64599. /**
  64600. * Class used to store gfx data (like WebGLBuffer)
  64601. */
  64602. export class DataBuffer {
  64603. /**
  64604. * Gets or sets the number of objects referencing this buffer
  64605. */
  64606. references: number;
  64607. /** Gets or sets the size of the underlying buffer */
  64608. capacity: number;
  64609. /**
  64610. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  64611. */
  64612. is32Bits: boolean;
  64613. /**
  64614. * Gets the underlying buffer
  64615. */
  64616. readonly underlyingResource: any;
  64617. }
  64618. }
  64619. declare module BABYLON {
  64620. /**
  64621. * Class used to store data that will be store in GPU memory
  64622. */
  64623. export class Buffer {
  64624. private _engine;
  64625. private _buffer;
  64626. /** @hidden */
  64627. _data: Nullable<DataArray>;
  64628. private _updatable;
  64629. private _instanced;
  64630. /**
  64631. * Gets the byte stride.
  64632. */
  64633. readonly byteStride: number;
  64634. /**
  64635. * Constructor
  64636. * @param engine the engine
  64637. * @param data the data to use for this buffer
  64638. * @param updatable whether the data is updatable
  64639. * @param stride the stride (optional)
  64640. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64641. * @param instanced whether the buffer is instanced (optional)
  64642. * @param useBytes set to true if the stride in in bytes (optional)
  64643. */
  64644. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  64645. /**
  64646. * Create a new VertexBuffer based on the current buffer
  64647. * @param kind defines the vertex buffer kind (position, normal, etc.)
  64648. * @param offset defines offset in the buffer (0 by default)
  64649. * @param size defines the size in floats of attributes (position is 3 for instance)
  64650. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  64651. * @param instanced defines if the vertex buffer contains indexed data
  64652. * @param useBytes defines if the offset and stride are in bytes
  64653. * @returns the new vertex buffer
  64654. */
  64655. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  64656. /**
  64657. * Gets a boolean indicating if the Buffer is updatable?
  64658. * @returns true if the buffer is updatable
  64659. */
  64660. isUpdatable(): boolean;
  64661. /**
  64662. * Gets current buffer's data
  64663. * @returns a DataArray or null
  64664. */
  64665. getData(): Nullable<DataArray>;
  64666. /**
  64667. * Gets underlying native buffer
  64668. * @returns underlying native buffer
  64669. */
  64670. getBuffer(): Nullable<DataBuffer>;
  64671. /**
  64672. * Gets the stride in float32 units (i.e. byte stride / 4).
  64673. * May not be an integer if the byte stride is not divisible by 4.
  64674. * DEPRECATED. Use byteStride instead.
  64675. * @returns the stride in float32 units
  64676. */
  64677. getStrideSize(): number;
  64678. /**
  64679. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64680. * @param data defines the data to store
  64681. */
  64682. create(data?: Nullable<DataArray>): void;
  64683. /** @hidden */
  64684. _rebuild(): void;
  64685. /**
  64686. * Update current buffer data
  64687. * @param data defines the data to store
  64688. */
  64689. update(data: DataArray): void;
  64690. /**
  64691. * Updates the data directly.
  64692. * @param data the new data
  64693. * @param offset the new offset
  64694. * @param vertexCount the vertex count (optional)
  64695. * @param useBytes set to true if the offset is in bytes
  64696. */
  64697. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  64698. /**
  64699. * Release all resources
  64700. */
  64701. dispose(): void;
  64702. }
  64703. /**
  64704. * Specialized buffer used to store vertex data
  64705. */
  64706. export class VertexBuffer {
  64707. /** @hidden */
  64708. _buffer: Buffer;
  64709. private _kind;
  64710. private _size;
  64711. private _ownsBuffer;
  64712. private _instanced;
  64713. private _instanceDivisor;
  64714. /**
  64715. * The byte type.
  64716. */
  64717. static readonly BYTE: number;
  64718. /**
  64719. * The unsigned byte type.
  64720. */
  64721. static readonly UNSIGNED_BYTE: number;
  64722. /**
  64723. * The short type.
  64724. */
  64725. static readonly SHORT: number;
  64726. /**
  64727. * The unsigned short type.
  64728. */
  64729. static readonly UNSIGNED_SHORT: number;
  64730. /**
  64731. * The integer type.
  64732. */
  64733. static readonly INT: number;
  64734. /**
  64735. * The unsigned integer type.
  64736. */
  64737. static readonly UNSIGNED_INT: number;
  64738. /**
  64739. * The float type.
  64740. */
  64741. static readonly FLOAT: number;
  64742. /**
  64743. * Gets or sets the instance divisor when in instanced mode
  64744. */
  64745. instanceDivisor: number;
  64746. /**
  64747. * Gets the byte stride.
  64748. */
  64749. readonly byteStride: number;
  64750. /**
  64751. * Gets the byte offset.
  64752. */
  64753. readonly byteOffset: number;
  64754. /**
  64755. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  64756. */
  64757. readonly normalized: boolean;
  64758. /**
  64759. * Gets the data type of each component in the array.
  64760. */
  64761. readonly type: number;
  64762. /**
  64763. * Constructor
  64764. * @param engine the engine
  64765. * @param data the data to use for this vertex buffer
  64766. * @param kind the vertex buffer kind
  64767. * @param updatable whether the data is updatable
  64768. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64769. * @param stride the stride (optional)
  64770. * @param instanced whether the buffer is instanced (optional)
  64771. * @param offset the offset of the data (optional)
  64772. * @param size the number of components (optional)
  64773. * @param type the type of the component (optional)
  64774. * @param normalized whether the data contains normalized data (optional)
  64775. * @param useBytes set to true if stride and offset are in bytes (optional)
  64776. */
  64777. 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);
  64778. /** @hidden */
  64779. _rebuild(): void;
  64780. /**
  64781. * Returns the kind of the VertexBuffer (string)
  64782. * @returns a string
  64783. */
  64784. getKind(): string;
  64785. /**
  64786. * Gets a boolean indicating if the VertexBuffer is updatable?
  64787. * @returns true if the buffer is updatable
  64788. */
  64789. isUpdatable(): boolean;
  64790. /**
  64791. * Gets current buffer's data
  64792. * @returns a DataArray or null
  64793. */
  64794. getData(): Nullable<DataArray>;
  64795. /**
  64796. * Gets underlying native buffer
  64797. * @returns underlying native buffer
  64798. */
  64799. getBuffer(): Nullable<DataBuffer>;
  64800. /**
  64801. * Gets the stride in float32 units (i.e. byte stride / 4).
  64802. * May not be an integer if the byte stride is not divisible by 4.
  64803. * DEPRECATED. Use byteStride instead.
  64804. * @returns the stride in float32 units
  64805. */
  64806. getStrideSize(): number;
  64807. /**
  64808. * Returns the offset as a multiple of the type byte length.
  64809. * DEPRECATED. Use byteOffset instead.
  64810. * @returns the offset in bytes
  64811. */
  64812. getOffset(): number;
  64813. /**
  64814. * Returns the number of components per vertex attribute (integer)
  64815. * @returns the size in float
  64816. */
  64817. getSize(): number;
  64818. /**
  64819. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  64820. * @returns true if this buffer is instanced
  64821. */
  64822. getIsInstanced(): boolean;
  64823. /**
  64824. * Returns the instancing divisor, zero for non-instanced (integer).
  64825. * @returns a number
  64826. */
  64827. getInstanceDivisor(): number;
  64828. /**
  64829. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64830. * @param data defines the data to store
  64831. */
  64832. create(data?: DataArray): void;
  64833. /**
  64834. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  64835. * This function will create a new buffer if the current one is not updatable
  64836. * @param data defines the data to store
  64837. */
  64838. update(data: DataArray): void;
  64839. /**
  64840. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  64841. * Returns the directly updated WebGLBuffer.
  64842. * @param data the new data
  64843. * @param offset the new offset
  64844. * @param useBytes set to true if the offset is in bytes
  64845. */
  64846. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  64847. /**
  64848. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  64849. */
  64850. dispose(): void;
  64851. /**
  64852. * Enumerates each value of this vertex buffer as numbers.
  64853. * @param count the number of values to enumerate
  64854. * @param callback the callback function called for each value
  64855. */
  64856. forEach(count: number, callback: (value: number, index: number) => void): void;
  64857. /**
  64858. * Positions
  64859. */
  64860. static readonly PositionKind: string;
  64861. /**
  64862. * Normals
  64863. */
  64864. static readonly NormalKind: string;
  64865. /**
  64866. * Tangents
  64867. */
  64868. static readonly TangentKind: string;
  64869. /**
  64870. * Texture coordinates
  64871. */
  64872. static readonly UVKind: string;
  64873. /**
  64874. * Texture coordinates 2
  64875. */
  64876. static readonly UV2Kind: string;
  64877. /**
  64878. * Texture coordinates 3
  64879. */
  64880. static readonly UV3Kind: string;
  64881. /**
  64882. * Texture coordinates 4
  64883. */
  64884. static readonly UV4Kind: string;
  64885. /**
  64886. * Texture coordinates 5
  64887. */
  64888. static readonly UV5Kind: string;
  64889. /**
  64890. * Texture coordinates 6
  64891. */
  64892. static readonly UV6Kind: string;
  64893. /**
  64894. * Colors
  64895. */
  64896. static readonly ColorKind: string;
  64897. /**
  64898. * Matrix indices (for bones)
  64899. */
  64900. static readonly MatricesIndicesKind: string;
  64901. /**
  64902. * Matrix weights (for bones)
  64903. */
  64904. static readonly MatricesWeightsKind: string;
  64905. /**
  64906. * Additional matrix indices (for bones)
  64907. */
  64908. static readonly MatricesIndicesExtraKind: string;
  64909. /**
  64910. * Additional matrix weights (for bones)
  64911. */
  64912. static readonly MatricesWeightsExtraKind: string;
  64913. /**
  64914. * Deduces the stride given a kind.
  64915. * @param kind The kind string to deduce
  64916. * @returns The deduced stride
  64917. */
  64918. static DeduceStride(kind: string): number;
  64919. /**
  64920. * Gets the byte length of the given type.
  64921. * @param type the type
  64922. * @returns the number of bytes
  64923. */
  64924. static GetTypeByteLength(type: number): number;
  64925. /**
  64926. * Enumerates each value of the given parameters as numbers.
  64927. * @param data the data to enumerate
  64928. * @param byteOffset the byte offset of the data
  64929. * @param byteStride the byte stride of the data
  64930. * @param componentCount the number of components per element
  64931. * @param componentType the type of the component
  64932. * @param count the number of values to enumerate
  64933. * @param normalized whether the data is normalized
  64934. * @param callback the callback function called for each value
  64935. */
  64936. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  64937. private static _GetFloatValue;
  64938. }
  64939. }
  64940. declare module BABYLON {
  64941. /**
  64942. * Scalar computation library
  64943. */
  64944. export class Scalar {
  64945. /**
  64946. * Two pi constants convenient for computation.
  64947. */
  64948. static TwoPi: number;
  64949. /**
  64950. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  64951. * @param a number
  64952. * @param b number
  64953. * @param epsilon (default = 1.401298E-45)
  64954. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  64955. */
  64956. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  64957. /**
  64958. * Returns a string : the upper case translation of the number i to hexadecimal.
  64959. * @param i number
  64960. * @returns the upper case translation of the number i to hexadecimal.
  64961. */
  64962. static ToHex(i: number): string;
  64963. /**
  64964. * Returns -1 if value is negative and +1 is value is positive.
  64965. * @param value the value
  64966. * @returns the value itself if it's equal to zero.
  64967. */
  64968. static Sign(value: number): number;
  64969. /**
  64970. * Returns the value itself if it's between min and max.
  64971. * Returns min if the value is lower than min.
  64972. * Returns max if the value is greater than max.
  64973. * @param value the value to clmap
  64974. * @param min the min value to clamp to (default: 0)
  64975. * @param max the max value to clamp to (default: 1)
  64976. * @returns the clamped value
  64977. */
  64978. static Clamp(value: number, min?: number, max?: number): number;
  64979. /**
  64980. * the log2 of value.
  64981. * @param value the value to compute log2 of
  64982. * @returns the log2 of value.
  64983. */
  64984. static Log2(value: number): number;
  64985. /**
  64986. * Loops the value, so that it is never larger than length and never smaller than 0.
  64987. *
  64988. * This is similar to the modulo operator but it works with floating point numbers.
  64989. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  64990. * With t = 5 and length = 2.5, the result would be 0.0.
  64991. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  64992. * @param value the value
  64993. * @param length the length
  64994. * @returns the looped value
  64995. */
  64996. static Repeat(value: number, length: number): number;
  64997. /**
  64998. * Normalize the value between 0.0 and 1.0 using min and max values
  64999. * @param value value to normalize
  65000. * @param min max to normalize between
  65001. * @param max min to normalize between
  65002. * @returns the normalized value
  65003. */
  65004. static Normalize(value: number, min: number, max: number): number;
  65005. /**
  65006. * Denormalize the value from 0.0 and 1.0 using min and max values
  65007. * @param normalized value to denormalize
  65008. * @param min max to denormalize between
  65009. * @param max min to denormalize between
  65010. * @returns the denormalized value
  65011. */
  65012. static Denormalize(normalized: number, min: number, max: number): number;
  65013. /**
  65014. * Calculates the shortest difference between two given angles given in degrees.
  65015. * @param current current angle in degrees
  65016. * @param target target angle in degrees
  65017. * @returns the delta
  65018. */
  65019. static DeltaAngle(current: number, target: number): number;
  65020. /**
  65021. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  65022. * @param tx value
  65023. * @param length length
  65024. * @returns The returned value will move back and forth between 0 and length
  65025. */
  65026. static PingPong(tx: number, length: number): number;
  65027. /**
  65028. * Interpolates between min and max with smoothing at the limits.
  65029. *
  65030. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  65031. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  65032. * @param from from
  65033. * @param to to
  65034. * @param tx value
  65035. * @returns the smooth stepped value
  65036. */
  65037. static SmoothStep(from: number, to: number, tx: number): number;
  65038. /**
  65039. * Moves a value current towards target.
  65040. *
  65041. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  65042. * Negative values of maxDelta pushes the value away from target.
  65043. * @param current current value
  65044. * @param target target value
  65045. * @param maxDelta max distance to move
  65046. * @returns resulting value
  65047. */
  65048. static MoveTowards(current: number, target: number, maxDelta: number): number;
  65049. /**
  65050. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  65051. *
  65052. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  65053. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  65054. * @param current current value
  65055. * @param target target value
  65056. * @param maxDelta max distance to move
  65057. * @returns resulting angle
  65058. */
  65059. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  65060. /**
  65061. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  65062. * @param start start value
  65063. * @param end target value
  65064. * @param amount amount to lerp between
  65065. * @returns the lerped value
  65066. */
  65067. static Lerp(start: number, end: number, amount: number): number;
  65068. /**
  65069. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  65070. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  65071. * @param start start value
  65072. * @param end target value
  65073. * @param amount amount to lerp between
  65074. * @returns the lerped value
  65075. */
  65076. static LerpAngle(start: number, end: number, amount: number): number;
  65077. /**
  65078. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  65079. * @param a start value
  65080. * @param b target value
  65081. * @param value value between a and b
  65082. * @returns the inverseLerp value
  65083. */
  65084. static InverseLerp(a: number, b: number, value: number): number;
  65085. /**
  65086. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  65087. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  65088. * @param value1 spline value
  65089. * @param tangent1 spline value
  65090. * @param value2 spline value
  65091. * @param tangent2 spline value
  65092. * @param amount input value
  65093. * @returns hermite result
  65094. */
  65095. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  65096. /**
  65097. * Returns a random float number between and min and max values
  65098. * @param min min value of random
  65099. * @param max max value of random
  65100. * @returns random value
  65101. */
  65102. static RandomRange(min: number, max: number): number;
  65103. /**
  65104. * This function returns percentage of a number in a given range.
  65105. *
  65106. * RangeToPercent(40,20,60) will return 0.5 (50%)
  65107. * RangeToPercent(34,0,100) will return 0.34 (34%)
  65108. * @param number to convert to percentage
  65109. * @param min min range
  65110. * @param max max range
  65111. * @returns the percentage
  65112. */
  65113. static RangeToPercent(number: number, min: number, max: number): number;
  65114. /**
  65115. * This function returns number that corresponds to the percentage in a given range.
  65116. *
  65117. * PercentToRange(0.34,0,100) will return 34.
  65118. * @param percent to convert to number
  65119. * @param min min range
  65120. * @param max max range
  65121. * @returns the number
  65122. */
  65123. static PercentToRange(percent: number, min: number, max: number): number;
  65124. /**
  65125. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  65126. * @param angle The angle to normalize in radian.
  65127. * @return The converted angle.
  65128. */
  65129. static NormalizeRadians(angle: number): number;
  65130. }
  65131. }
  65132. declare module BABYLON {
  65133. /**
  65134. * Constant used to convert a value to gamma space
  65135. * @ignorenaming
  65136. */
  65137. export const ToGammaSpace: number;
  65138. /**
  65139. * Constant used to convert a value to linear space
  65140. * @ignorenaming
  65141. */
  65142. export const ToLinearSpace = 2.2;
  65143. /**
  65144. * Constant used to define the minimal number value in Babylon.js
  65145. * @ignorenaming
  65146. */
  65147. let Epsilon: number;
  65148. }
  65149. declare module BABYLON {
  65150. /**
  65151. * Class used to represent a viewport on screen
  65152. */
  65153. export class Viewport {
  65154. /** viewport left coordinate */
  65155. x: number;
  65156. /** viewport top coordinate */
  65157. y: number;
  65158. /**viewport width */
  65159. width: number;
  65160. /** viewport height */
  65161. height: number;
  65162. /**
  65163. * Creates a Viewport object located at (x, y) and sized (width, height)
  65164. * @param x defines viewport left coordinate
  65165. * @param y defines viewport top coordinate
  65166. * @param width defines the viewport width
  65167. * @param height defines the viewport height
  65168. */
  65169. constructor(
  65170. /** viewport left coordinate */
  65171. x: number,
  65172. /** viewport top coordinate */
  65173. y: number,
  65174. /**viewport width */
  65175. width: number,
  65176. /** viewport height */
  65177. height: number);
  65178. /**
  65179. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  65180. * @param renderWidth defines the rendering width
  65181. * @param renderHeight defines the rendering height
  65182. * @returns a new Viewport
  65183. */
  65184. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  65185. /**
  65186. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  65187. * @param renderWidth defines the rendering width
  65188. * @param renderHeight defines the rendering height
  65189. * @param ref defines the target viewport
  65190. * @returns the current viewport
  65191. */
  65192. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  65193. /**
  65194. * Returns a new Viewport copied from the current one
  65195. * @returns a new Viewport
  65196. */
  65197. clone(): Viewport;
  65198. }
  65199. }
  65200. declare module BABYLON {
  65201. /**
  65202. * Class containing a set of static utilities functions for arrays.
  65203. */
  65204. export class ArrayTools {
  65205. /**
  65206. * Returns an array of the given size filled with element built from the given constructor and the paramters
  65207. * @param size the number of element to construct and put in the array
  65208. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  65209. * @returns a new array filled with new objects
  65210. */
  65211. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  65212. }
  65213. }
  65214. declare module BABYLON {
  65215. /**
  65216. * @hidden
  65217. */
  65218. export interface IColor4Like {
  65219. r: float;
  65220. g: float;
  65221. b: float;
  65222. a: float;
  65223. }
  65224. /**
  65225. * @hidden
  65226. */
  65227. export interface IColor3Like {
  65228. r: float;
  65229. g: float;
  65230. b: float;
  65231. }
  65232. /**
  65233. * @hidden
  65234. */
  65235. export interface IVector4Like {
  65236. x: float;
  65237. y: float;
  65238. z: float;
  65239. w: float;
  65240. }
  65241. /**
  65242. * @hidden
  65243. */
  65244. export interface IVector3Like {
  65245. x: float;
  65246. y: float;
  65247. z: float;
  65248. }
  65249. /**
  65250. * @hidden
  65251. */
  65252. export interface IVector2Like {
  65253. x: float;
  65254. y: float;
  65255. }
  65256. /**
  65257. * @hidden
  65258. */
  65259. export interface IMatrixLike {
  65260. toArray(): DeepImmutable<Float32Array>;
  65261. updateFlag: int;
  65262. }
  65263. /**
  65264. * @hidden
  65265. */
  65266. export interface IViewportLike {
  65267. x: float;
  65268. y: float;
  65269. width: float;
  65270. height: float;
  65271. }
  65272. /**
  65273. * @hidden
  65274. */
  65275. export interface IPlaneLike {
  65276. normal: IVector3Like;
  65277. d: float;
  65278. normalize(): void;
  65279. }
  65280. }
  65281. declare module BABYLON {
  65282. /**
  65283. * Class representing a vector containing 2 coordinates
  65284. */
  65285. export class Vector2 {
  65286. /** defines the first coordinate */
  65287. x: number;
  65288. /** defines the second coordinate */
  65289. y: number;
  65290. /**
  65291. * Creates a new Vector2 from the given x and y coordinates
  65292. * @param x defines the first coordinate
  65293. * @param y defines the second coordinate
  65294. */
  65295. constructor(
  65296. /** defines the first coordinate */
  65297. x?: number,
  65298. /** defines the second coordinate */
  65299. y?: number);
  65300. /**
  65301. * Gets a string with the Vector2 coordinates
  65302. * @returns a string with the Vector2 coordinates
  65303. */
  65304. toString(): string;
  65305. /**
  65306. * Gets class name
  65307. * @returns the string "Vector2"
  65308. */
  65309. getClassName(): string;
  65310. /**
  65311. * Gets current vector hash code
  65312. * @returns the Vector2 hash code as a number
  65313. */
  65314. getHashCode(): number;
  65315. /**
  65316. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  65317. * @param array defines the source array
  65318. * @param index defines the offset in source array
  65319. * @returns the current Vector2
  65320. */
  65321. toArray(array: FloatArray, index?: number): Vector2;
  65322. /**
  65323. * Copy the current vector to an array
  65324. * @returns a new array with 2 elements: the Vector2 coordinates.
  65325. */
  65326. asArray(): number[];
  65327. /**
  65328. * Sets the Vector2 coordinates with the given Vector2 coordinates
  65329. * @param source defines the source Vector2
  65330. * @returns the current updated Vector2
  65331. */
  65332. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  65333. /**
  65334. * Sets the Vector2 coordinates with the given floats
  65335. * @param x defines the first coordinate
  65336. * @param y defines the second coordinate
  65337. * @returns the current updated Vector2
  65338. */
  65339. copyFromFloats(x: number, y: number): Vector2;
  65340. /**
  65341. * Sets the Vector2 coordinates with the given floats
  65342. * @param x defines the first coordinate
  65343. * @param y defines the second coordinate
  65344. * @returns the current updated Vector2
  65345. */
  65346. set(x: number, y: number): Vector2;
  65347. /**
  65348. * Add another vector with the current one
  65349. * @param otherVector defines the other vector
  65350. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  65351. */
  65352. add(otherVector: DeepImmutable<Vector2>): Vector2;
  65353. /**
  65354. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  65355. * @param otherVector defines the other vector
  65356. * @param result defines the target vector
  65357. * @returns the unmodified current Vector2
  65358. */
  65359. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65360. /**
  65361. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  65362. * @param otherVector defines the other vector
  65363. * @returns the current updated Vector2
  65364. */
  65365. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65366. /**
  65367. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  65368. * @param otherVector defines the other vector
  65369. * @returns a new Vector2
  65370. */
  65371. addVector3(otherVector: Vector3): Vector2;
  65372. /**
  65373. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  65374. * @param otherVector defines the other vector
  65375. * @returns a new Vector2
  65376. */
  65377. subtract(otherVector: Vector2): Vector2;
  65378. /**
  65379. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  65380. * @param otherVector defines the other vector
  65381. * @param result defines the target vector
  65382. * @returns the unmodified current Vector2
  65383. */
  65384. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65385. /**
  65386. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  65387. * @param otherVector defines the other vector
  65388. * @returns the current updated Vector2
  65389. */
  65390. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65391. /**
  65392. * Multiplies in place the current Vector2 coordinates by the given ones
  65393. * @param otherVector defines the other vector
  65394. * @returns the current updated Vector2
  65395. */
  65396. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65397. /**
  65398. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  65399. * @param otherVector defines the other vector
  65400. * @returns a new Vector2
  65401. */
  65402. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  65403. /**
  65404. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  65405. * @param otherVector defines the other vector
  65406. * @param result defines the target vector
  65407. * @returns the unmodified current Vector2
  65408. */
  65409. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65410. /**
  65411. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  65412. * @param x defines the first coordinate
  65413. * @param y defines the second coordinate
  65414. * @returns a new Vector2
  65415. */
  65416. multiplyByFloats(x: number, y: number): Vector2;
  65417. /**
  65418. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  65419. * @param otherVector defines the other vector
  65420. * @returns a new Vector2
  65421. */
  65422. divide(otherVector: Vector2): Vector2;
  65423. /**
  65424. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  65425. * @param otherVector defines the other vector
  65426. * @param result defines the target vector
  65427. * @returns the unmodified current Vector2
  65428. */
  65429. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65430. /**
  65431. * Divides the current Vector2 coordinates by the given ones
  65432. * @param otherVector defines the other vector
  65433. * @returns the current updated Vector2
  65434. */
  65435. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65436. /**
  65437. * Gets a new Vector2 with current Vector2 negated coordinates
  65438. * @returns a new Vector2
  65439. */
  65440. negate(): Vector2;
  65441. /**
  65442. * Multiply the Vector2 coordinates by scale
  65443. * @param scale defines the scaling factor
  65444. * @returns the current updated Vector2
  65445. */
  65446. scaleInPlace(scale: number): Vector2;
  65447. /**
  65448. * Returns a new Vector2 scaled by "scale" from the current Vector2
  65449. * @param scale defines the scaling factor
  65450. * @returns a new Vector2
  65451. */
  65452. scale(scale: number): Vector2;
  65453. /**
  65454. * Scale the current Vector2 values by a factor to a given Vector2
  65455. * @param scale defines the scale factor
  65456. * @param result defines the Vector2 object where to store the result
  65457. * @returns the unmodified current Vector2
  65458. */
  65459. scaleToRef(scale: number, result: Vector2): Vector2;
  65460. /**
  65461. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  65462. * @param scale defines the scale factor
  65463. * @param result defines the Vector2 object where to store the result
  65464. * @returns the unmodified current Vector2
  65465. */
  65466. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  65467. /**
  65468. * Gets a boolean if two vectors are equals
  65469. * @param otherVector defines the other vector
  65470. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  65471. */
  65472. equals(otherVector: DeepImmutable<Vector2>): boolean;
  65473. /**
  65474. * Gets a boolean if two vectors are equals (using an epsilon value)
  65475. * @param otherVector defines the other vector
  65476. * @param epsilon defines the minimal distance to consider equality
  65477. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  65478. */
  65479. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  65480. /**
  65481. * Gets a new Vector2 from current Vector2 floored values
  65482. * @returns a new Vector2
  65483. */
  65484. floor(): Vector2;
  65485. /**
  65486. * Gets a new Vector2 from current Vector2 floored values
  65487. * @returns a new Vector2
  65488. */
  65489. fract(): Vector2;
  65490. /**
  65491. * Gets the length of the vector
  65492. * @returns the vector length (float)
  65493. */
  65494. length(): number;
  65495. /**
  65496. * Gets the vector squared length
  65497. * @returns the vector squared length (float)
  65498. */
  65499. lengthSquared(): number;
  65500. /**
  65501. * Normalize the vector
  65502. * @returns the current updated Vector2
  65503. */
  65504. normalize(): Vector2;
  65505. /**
  65506. * Gets a new Vector2 copied from the Vector2
  65507. * @returns a new Vector2
  65508. */
  65509. clone(): Vector2;
  65510. /**
  65511. * Gets a new Vector2(0, 0)
  65512. * @returns a new Vector2
  65513. */
  65514. static Zero(): Vector2;
  65515. /**
  65516. * Gets a new Vector2(1, 1)
  65517. * @returns a new Vector2
  65518. */
  65519. static One(): Vector2;
  65520. /**
  65521. * Gets a new Vector2 set from the given index element of the given array
  65522. * @param array defines the data source
  65523. * @param offset defines the offset in the data source
  65524. * @returns a new Vector2
  65525. */
  65526. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  65527. /**
  65528. * Sets "result" from the given index element of the given array
  65529. * @param array defines the data source
  65530. * @param offset defines the offset in the data source
  65531. * @param result defines the target vector
  65532. */
  65533. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  65534. /**
  65535. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  65536. * @param value1 defines 1st point of control
  65537. * @param value2 defines 2nd point of control
  65538. * @param value3 defines 3rd point of control
  65539. * @param value4 defines 4th point of control
  65540. * @param amount defines the interpolation factor
  65541. * @returns a new Vector2
  65542. */
  65543. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  65544. /**
  65545. * 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".
  65546. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  65547. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  65548. * @param value defines the value to clamp
  65549. * @param min defines the lower limit
  65550. * @param max defines the upper limit
  65551. * @returns a new Vector2
  65552. */
  65553. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  65554. /**
  65555. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  65556. * @param value1 defines the 1st control point
  65557. * @param tangent1 defines the outgoing tangent
  65558. * @param value2 defines the 2nd control point
  65559. * @param tangent2 defines the incoming tangent
  65560. * @param amount defines the interpolation factor
  65561. * @returns a new Vector2
  65562. */
  65563. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  65564. /**
  65565. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  65566. * @param start defines the start vector
  65567. * @param end defines the end vector
  65568. * @param amount defines the interpolation factor
  65569. * @returns a new Vector2
  65570. */
  65571. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  65572. /**
  65573. * Gets the dot product of the vector "left" and the vector "right"
  65574. * @param left defines first vector
  65575. * @param right defines second vector
  65576. * @returns the dot product (float)
  65577. */
  65578. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  65579. /**
  65580. * Returns a new Vector2 equal to the normalized given vector
  65581. * @param vector defines the vector to normalize
  65582. * @returns a new Vector2
  65583. */
  65584. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  65585. /**
  65586. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  65587. * @param left defines 1st vector
  65588. * @param right defines 2nd vector
  65589. * @returns a new Vector2
  65590. */
  65591. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  65592. /**
  65593. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  65594. * @param left defines 1st vector
  65595. * @param right defines 2nd vector
  65596. * @returns a new Vector2
  65597. */
  65598. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  65599. /**
  65600. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  65601. * @param vector defines the vector to transform
  65602. * @param transformation defines the matrix to apply
  65603. * @returns a new Vector2
  65604. */
  65605. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  65606. /**
  65607. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  65608. * @param vector defines the vector to transform
  65609. * @param transformation defines the matrix to apply
  65610. * @param result defines the target vector
  65611. */
  65612. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  65613. /**
  65614. * Determines if a given vector is included in a triangle
  65615. * @param p defines the vector to test
  65616. * @param p0 defines 1st triangle point
  65617. * @param p1 defines 2nd triangle point
  65618. * @param p2 defines 3rd triangle point
  65619. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  65620. */
  65621. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  65622. /**
  65623. * Gets the distance between the vectors "value1" and "value2"
  65624. * @param value1 defines first vector
  65625. * @param value2 defines second vector
  65626. * @returns the distance between vectors
  65627. */
  65628. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  65629. /**
  65630. * Returns the squared distance between the vectors "value1" and "value2"
  65631. * @param value1 defines first vector
  65632. * @param value2 defines second vector
  65633. * @returns the squared distance between vectors
  65634. */
  65635. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  65636. /**
  65637. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  65638. * @param value1 defines first vector
  65639. * @param value2 defines second vector
  65640. * @returns a new Vector2
  65641. */
  65642. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  65643. /**
  65644. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  65645. * @param p defines the middle point
  65646. * @param segA defines one point of the segment
  65647. * @param segB defines the other point of the segment
  65648. * @returns the shortest distance
  65649. */
  65650. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  65651. }
  65652. /**
  65653. * Classed used to store (x,y,z) vector representation
  65654. * A Vector3 is the main object used in 3D geometry
  65655. * It can represent etiher the coordinates of a point the space, either a direction
  65656. * Reminder: js uses a left handed forward facing system
  65657. */
  65658. export class Vector3 {
  65659. /**
  65660. * Defines the first coordinates (on X axis)
  65661. */
  65662. x: number;
  65663. /**
  65664. * Defines the second coordinates (on Y axis)
  65665. */
  65666. y: number;
  65667. /**
  65668. * Defines the third coordinates (on Z axis)
  65669. */
  65670. z: number;
  65671. private static _UpReadOnly;
  65672. private static _ZeroReadOnly;
  65673. /**
  65674. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  65675. * @param x defines the first coordinates (on X axis)
  65676. * @param y defines the second coordinates (on Y axis)
  65677. * @param z defines the third coordinates (on Z axis)
  65678. */
  65679. constructor(
  65680. /**
  65681. * Defines the first coordinates (on X axis)
  65682. */
  65683. x?: number,
  65684. /**
  65685. * Defines the second coordinates (on Y axis)
  65686. */
  65687. y?: number,
  65688. /**
  65689. * Defines the third coordinates (on Z axis)
  65690. */
  65691. z?: number);
  65692. /**
  65693. * Creates a string representation of the Vector3
  65694. * @returns a string with the Vector3 coordinates.
  65695. */
  65696. toString(): string;
  65697. /**
  65698. * Gets the class name
  65699. * @returns the string "Vector3"
  65700. */
  65701. getClassName(): string;
  65702. /**
  65703. * Creates the Vector3 hash code
  65704. * @returns a number which tends to be unique between Vector3 instances
  65705. */
  65706. getHashCode(): number;
  65707. /**
  65708. * Creates an array containing three elements : the coordinates of the Vector3
  65709. * @returns a new array of numbers
  65710. */
  65711. asArray(): number[];
  65712. /**
  65713. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  65714. * @param array defines the destination array
  65715. * @param index defines the offset in the destination array
  65716. * @returns the current Vector3
  65717. */
  65718. toArray(array: FloatArray, index?: number): Vector3;
  65719. /**
  65720. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  65721. * @returns a new Quaternion object, computed from the Vector3 coordinates
  65722. */
  65723. toQuaternion(): Quaternion;
  65724. /**
  65725. * Adds the given vector to the current Vector3
  65726. * @param otherVector defines the second operand
  65727. * @returns the current updated Vector3
  65728. */
  65729. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  65730. /**
  65731. * Adds the given coordinates to the current Vector3
  65732. * @param x defines the x coordinate of the operand
  65733. * @param y defines the y coordinate of the operand
  65734. * @param z defines the z coordinate of the operand
  65735. * @returns the current updated Vector3
  65736. */
  65737. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  65738. /**
  65739. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  65740. * @param otherVector defines the second operand
  65741. * @returns the resulting Vector3
  65742. */
  65743. add(otherVector: DeepImmutable<Vector3>): Vector3;
  65744. /**
  65745. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  65746. * @param otherVector defines the second operand
  65747. * @param result defines the Vector3 object where to store the result
  65748. * @returns the current Vector3
  65749. */
  65750. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  65751. /**
  65752. * Subtract the given vector from the current Vector3
  65753. * @param otherVector defines the second operand
  65754. * @returns the current updated Vector3
  65755. */
  65756. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  65757. /**
  65758. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  65759. * @param otherVector defines the second operand
  65760. * @returns the resulting Vector3
  65761. */
  65762. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  65763. /**
  65764. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  65765. * @param otherVector defines the second operand
  65766. * @param result defines the Vector3 object where to store the result
  65767. * @returns the current Vector3
  65768. */
  65769. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  65770. /**
  65771. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  65772. * @param x defines the x coordinate of the operand
  65773. * @param y defines the y coordinate of the operand
  65774. * @param z defines the z coordinate of the operand
  65775. * @returns the resulting Vector3
  65776. */
  65777. subtractFromFloats(x: number, y: number, z: number): Vector3;
  65778. /**
  65779. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  65780. * @param x defines the x coordinate of the operand
  65781. * @param y defines the y coordinate of the operand
  65782. * @param z defines the z coordinate of the operand
  65783. * @param result defines the Vector3 object where to store the result
  65784. * @returns the current Vector3
  65785. */
  65786. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  65787. /**
  65788. * Gets a new Vector3 set with the current Vector3 negated coordinates
  65789. * @returns a new Vector3
  65790. */
  65791. negate(): Vector3;
  65792. /**
  65793. * Multiplies the Vector3 coordinates by the float "scale"
  65794. * @param scale defines the multiplier factor
  65795. * @returns the current updated Vector3
  65796. */
  65797. scaleInPlace(scale: number): Vector3;
  65798. /**
  65799. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  65800. * @param scale defines the multiplier factor
  65801. * @returns a new Vector3
  65802. */
  65803. scale(scale: number): Vector3;
  65804. /**
  65805. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  65806. * @param scale defines the multiplier factor
  65807. * @param result defines the Vector3 object where to store the result
  65808. * @returns the current Vector3
  65809. */
  65810. scaleToRef(scale: number, result: Vector3): Vector3;
  65811. /**
  65812. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  65813. * @param scale defines the scale factor
  65814. * @param result defines the Vector3 object where to store the result
  65815. * @returns the unmodified current Vector3
  65816. */
  65817. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  65818. /**
  65819. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  65820. * @param otherVector defines the second operand
  65821. * @returns true if both vectors are equals
  65822. */
  65823. equals(otherVector: DeepImmutable<Vector3>): boolean;
  65824. /**
  65825. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  65826. * @param otherVector defines the second operand
  65827. * @param epsilon defines the minimal distance to define values as equals
  65828. * @returns true if both vectors are distant less than epsilon
  65829. */
  65830. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  65831. /**
  65832. * Returns true if the current Vector3 coordinates equals the given floats
  65833. * @param x defines the x coordinate of the operand
  65834. * @param y defines the y coordinate of the operand
  65835. * @param z defines the z coordinate of the operand
  65836. * @returns true if both vectors are equals
  65837. */
  65838. equalsToFloats(x: number, y: number, z: number): boolean;
  65839. /**
  65840. * Multiplies the current Vector3 coordinates by the given ones
  65841. * @param otherVector defines the second operand
  65842. * @returns the current updated Vector3
  65843. */
  65844. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  65845. /**
  65846. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  65847. * @param otherVector defines the second operand
  65848. * @returns the new Vector3
  65849. */
  65850. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  65851. /**
  65852. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  65853. * @param otherVector defines the second operand
  65854. * @param result defines the Vector3 object where to store the result
  65855. * @returns the current Vector3
  65856. */
  65857. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  65858. /**
  65859. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  65860. * @param x defines the x coordinate of the operand
  65861. * @param y defines the y coordinate of the operand
  65862. * @param z defines the z coordinate of the operand
  65863. * @returns the new Vector3
  65864. */
  65865. multiplyByFloats(x: number, y: number, z: number): Vector3;
  65866. /**
  65867. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  65868. * @param otherVector defines the second operand
  65869. * @returns the new Vector3
  65870. */
  65871. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  65872. /**
  65873. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  65874. * @param otherVector defines the second operand
  65875. * @param result defines the Vector3 object where to store the result
  65876. * @returns the current Vector3
  65877. */
  65878. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  65879. /**
  65880. * Divides the current Vector3 coordinates by the given ones.
  65881. * @param otherVector defines the second operand
  65882. * @returns the current updated Vector3
  65883. */
  65884. divideInPlace(otherVector: Vector3): Vector3;
  65885. /**
  65886. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  65887. * @param other defines the second operand
  65888. * @returns the current updated Vector3
  65889. */
  65890. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  65891. /**
  65892. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  65893. * @param other defines the second operand
  65894. * @returns the current updated Vector3
  65895. */
  65896. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  65897. /**
  65898. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  65899. * @param x defines the x coordinate of the operand
  65900. * @param y defines the y coordinate of the operand
  65901. * @param z defines the z coordinate of the operand
  65902. * @returns the current updated Vector3
  65903. */
  65904. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  65905. /**
  65906. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  65907. * @param x defines the x coordinate of the operand
  65908. * @param y defines the y coordinate of the operand
  65909. * @param z defines the z coordinate of the operand
  65910. * @returns the current updated Vector3
  65911. */
  65912. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  65913. /**
  65914. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  65915. * Check if is non uniform within a certain amount of decimal places to account for this
  65916. * @param epsilon the amount the values can differ
  65917. * @returns if the the vector is non uniform to a certain number of decimal places
  65918. */
  65919. isNonUniformWithinEpsilon(epsilon: number): boolean;
  65920. /**
  65921. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  65922. */
  65923. readonly isNonUniform: boolean;
  65924. /**
  65925. * Gets a new Vector3 from current Vector3 floored values
  65926. * @returns a new Vector3
  65927. */
  65928. floor(): Vector3;
  65929. /**
  65930. * Gets a new Vector3 from current Vector3 floored values
  65931. * @returns a new Vector3
  65932. */
  65933. fract(): Vector3;
  65934. /**
  65935. * Gets the length of the Vector3
  65936. * @returns the length of the Vector3
  65937. */
  65938. length(): number;
  65939. /**
  65940. * Gets the squared length of the Vector3
  65941. * @returns squared length of the Vector3
  65942. */
  65943. lengthSquared(): number;
  65944. /**
  65945. * Normalize the current Vector3.
  65946. * Please note that this is an in place operation.
  65947. * @returns the current updated Vector3
  65948. */
  65949. normalize(): Vector3;
  65950. /**
  65951. * Reorders the x y z properties of the vector in place
  65952. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  65953. * @returns the current updated vector
  65954. */
  65955. reorderInPlace(order: string): this;
  65956. /**
  65957. * Rotates the vector around 0,0,0 by a quaternion
  65958. * @param quaternion the rotation quaternion
  65959. * @param result vector to store the result
  65960. * @returns the resulting vector
  65961. */
  65962. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  65963. /**
  65964. * Rotates a vector around a given point
  65965. * @param quaternion the rotation quaternion
  65966. * @param point the point to rotate around
  65967. * @param result vector to store the result
  65968. * @returns the resulting vector
  65969. */
  65970. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  65971. /**
  65972. * Normalize the current Vector3 with the given input length.
  65973. * Please note that this is an in place operation.
  65974. * @param len the length of the vector
  65975. * @returns the current updated Vector3
  65976. */
  65977. normalizeFromLength(len: number): Vector3;
  65978. /**
  65979. * Normalize the current Vector3 to a new vector
  65980. * @returns the new Vector3
  65981. */
  65982. normalizeToNew(): Vector3;
  65983. /**
  65984. * Normalize the current Vector3 to the reference
  65985. * @param reference define the Vector3 to update
  65986. * @returns the updated Vector3
  65987. */
  65988. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  65989. /**
  65990. * Creates a new Vector3 copied from the current Vector3
  65991. * @returns the new Vector3
  65992. */
  65993. clone(): Vector3;
  65994. /**
  65995. * Copies the given vector coordinates to the current Vector3 ones
  65996. * @param source defines the source Vector3
  65997. * @returns the current updated Vector3
  65998. */
  65999. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  66000. /**
  66001. * Copies the given floats to the current Vector3 coordinates
  66002. * @param x defines the x coordinate of the operand
  66003. * @param y defines the y coordinate of the operand
  66004. * @param z defines the z coordinate of the operand
  66005. * @returns the current updated Vector3
  66006. */
  66007. copyFromFloats(x: number, y: number, z: number): Vector3;
  66008. /**
  66009. * Copies the given floats to the current Vector3 coordinates
  66010. * @param x defines the x coordinate of the operand
  66011. * @param y defines the y coordinate of the operand
  66012. * @param z defines the z coordinate of the operand
  66013. * @returns the current updated Vector3
  66014. */
  66015. set(x: number, y: number, z: number): Vector3;
  66016. /**
  66017. * Copies the given float to the current Vector3 coordinates
  66018. * @param v defines the x, y and z coordinates of the operand
  66019. * @returns the current updated Vector3
  66020. */
  66021. setAll(v: number): Vector3;
  66022. /**
  66023. * Get the clip factor between two vectors
  66024. * @param vector0 defines the first operand
  66025. * @param vector1 defines the second operand
  66026. * @param axis defines the axis to use
  66027. * @param size defines the size along the axis
  66028. * @returns the clip factor
  66029. */
  66030. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  66031. /**
  66032. * Get angle between two vectors
  66033. * @param vector0 angle between vector0 and vector1
  66034. * @param vector1 angle between vector0 and vector1
  66035. * @param normal direction of the normal
  66036. * @return the angle between vector0 and vector1
  66037. */
  66038. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  66039. /**
  66040. * Returns a new Vector3 set from the index "offset" of the given array
  66041. * @param array defines the source array
  66042. * @param offset defines the offset in the source array
  66043. * @returns the new Vector3
  66044. */
  66045. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  66046. /**
  66047. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  66048. * This function is deprecated. Use FromArray instead
  66049. * @param array defines the source array
  66050. * @param offset defines the offset in the source array
  66051. * @returns the new Vector3
  66052. */
  66053. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  66054. /**
  66055. * Sets the given vector "result" with the element values from the index "offset" of the given array
  66056. * @param array defines the source array
  66057. * @param offset defines the offset in the source array
  66058. * @param result defines the Vector3 where to store the result
  66059. */
  66060. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  66061. /**
  66062. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  66063. * This function is deprecated. Use FromArrayToRef instead.
  66064. * @param array defines the source array
  66065. * @param offset defines the offset in the source array
  66066. * @param result defines the Vector3 where to store the result
  66067. */
  66068. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  66069. /**
  66070. * Sets the given vector "result" with the given floats.
  66071. * @param x defines the x coordinate of the source
  66072. * @param y defines the y coordinate of the source
  66073. * @param z defines the z coordinate of the source
  66074. * @param result defines the Vector3 where to store the result
  66075. */
  66076. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  66077. /**
  66078. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  66079. * @returns a new empty Vector3
  66080. */
  66081. static Zero(): Vector3;
  66082. /**
  66083. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  66084. * @returns a new unit Vector3
  66085. */
  66086. static One(): Vector3;
  66087. /**
  66088. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  66089. * @returns a new up Vector3
  66090. */
  66091. static Up(): Vector3;
  66092. /**
  66093. * Gets a up Vector3 that must not be updated
  66094. */
  66095. static readonly UpReadOnly: DeepImmutable<Vector3>;
  66096. /**
  66097. * Gets a zero Vector3 that must not be updated
  66098. */
  66099. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  66100. /**
  66101. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  66102. * @returns a new down Vector3
  66103. */
  66104. static Down(): Vector3;
  66105. /**
  66106. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  66107. * @returns a new forward Vector3
  66108. */
  66109. static Forward(): Vector3;
  66110. /**
  66111. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  66112. * @returns a new forward Vector3
  66113. */
  66114. static Backward(): Vector3;
  66115. /**
  66116. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  66117. * @returns a new right Vector3
  66118. */
  66119. static Right(): Vector3;
  66120. /**
  66121. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  66122. * @returns a new left Vector3
  66123. */
  66124. static Left(): Vector3;
  66125. /**
  66126. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  66127. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  66128. * @param vector defines the Vector3 to transform
  66129. * @param transformation defines the transformation matrix
  66130. * @returns the transformed Vector3
  66131. */
  66132. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  66133. /**
  66134. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  66135. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  66136. * @param vector defines the Vector3 to transform
  66137. * @param transformation defines the transformation matrix
  66138. * @param result defines the Vector3 where to store the result
  66139. */
  66140. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66141. /**
  66142. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  66143. * This method computes tranformed coordinates only, not transformed direction vectors
  66144. * @param x define the x coordinate of the source vector
  66145. * @param y define the y coordinate of the source vector
  66146. * @param z define the z coordinate of the source vector
  66147. * @param transformation defines the transformation matrix
  66148. * @param result defines the Vector3 where to store the result
  66149. */
  66150. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66151. /**
  66152. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  66153. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66154. * @param vector defines the Vector3 to transform
  66155. * @param transformation defines the transformation matrix
  66156. * @returns the new Vector3
  66157. */
  66158. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  66159. /**
  66160. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  66161. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66162. * @param vector defines the Vector3 to transform
  66163. * @param transformation defines the transformation matrix
  66164. * @param result defines the Vector3 where to store the result
  66165. */
  66166. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66167. /**
  66168. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  66169. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66170. * @param x define the x coordinate of the source vector
  66171. * @param y define the y coordinate of the source vector
  66172. * @param z define the z coordinate of the source vector
  66173. * @param transformation defines the transformation matrix
  66174. * @param result defines the Vector3 where to store the result
  66175. */
  66176. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66177. /**
  66178. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  66179. * @param value1 defines the first control point
  66180. * @param value2 defines the second control point
  66181. * @param value3 defines the third control point
  66182. * @param value4 defines the fourth control point
  66183. * @param amount defines the amount on the spline to use
  66184. * @returns the new Vector3
  66185. */
  66186. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  66187. /**
  66188. * 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"
  66189. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  66190. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  66191. * @param value defines the current value
  66192. * @param min defines the lower range value
  66193. * @param max defines the upper range value
  66194. * @returns the new Vector3
  66195. */
  66196. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  66197. /**
  66198. * 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"
  66199. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  66200. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  66201. * @param value defines the current value
  66202. * @param min defines the lower range value
  66203. * @param max defines the upper range value
  66204. * @param result defines the Vector3 where to store the result
  66205. */
  66206. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  66207. /**
  66208. * Checks if a given vector is inside a specific range
  66209. * @param v defines the vector to test
  66210. * @param min defines the minimum range
  66211. * @param max defines the maximum range
  66212. */
  66213. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  66214. /**
  66215. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  66216. * @param value1 defines the first control point
  66217. * @param tangent1 defines the first tangent vector
  66218. * @param value2 defines the second control point
  66219. * @param tangent2 defines the second tangent vector
  66220. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  66221. * @returns the new Vector3
  66222. */
  66223. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  66224. /**
  66225. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  66226. * @param start defines the start value
  66227. * @param end defines the end value
  66228. * @param amount max defines amount between both (between 0 and 1)
  66229. * @returns the new Vector3
  66230. */
  66231. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  66232. /**
  66233. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  66234. * @param start defines the start value
  66235. * @param end defines the end value
  66236. * @param amount max defines amount between both (between 0 and 1)
  66237. * @param result defines the Vector3 where to store the result
  66238. */
  66239. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  66240. /**
  66241. * Returns the dot product (float) between the vectors "left" and "right"
  66242. * @param left defines the left operand
  66243. * @param right defines the right operand
  66244. * @returns the dot product
  66245. */
  66246. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  66247. /**
  66248. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  66249. * The cross product is then orthogonal to both "left" and "right"
  66250. * @param left defines the left operand
  66251. * @param right defines the right operand
  66252. * @returns the cross product
  66253. */
  66254. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66255. /**
  66256. * Sets the given vector "result" with the cross product of "left" and "right"
  66257. * The cross product is then orthogonal to both "left" and "right"
  66258. * @param left defines the left operand
  66259. * @param right defines the right operand
  66260. * @param result defines the Vector3 where to store the result
  66261. */
  66262. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  66263. /**
  66264. * Returns a new Vector3 as the normalization of the given vector
  66265. * @param vector defines the Vector3 to normalize
  66266. * @returns the new Vector3
  66267. */
  66268. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  66269. /**
  66270. * Sets the given vector "result" with the normalization of the given first vector
  66271. * @param vector defines the Vector3 to normalize
  66272. * @param result defines the Vector3 where to store the result
  66273. */
  66274. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  66275. /**
  66276. * Project a Vector3 onto screen space
  66277. * @param vector defines the Vector3 to project
  66278. * @param world defines the world matrix to use
  66279. * @param transform defines the transform (view x projection) matrix to use
  66280. * @param viewport defines the screen viewport to use
  66281. * @returns the new Vector3
  66282. */
  66283. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  66284. /** @hidden */
  66285. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  66286. /**
  66287. * Unproject from screen space to object space
  66288. * @param source defines the screen space Vector3 to use
  66289. * @param viewportWidth defines the current width of the viewport
  66290. * @param viewportHeight defines the current height of the viewport
  66291. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66292. * @param transform defines the transform (view x projection) matrix to use
  66293. * @returns the new Vector3
  66294. */
  66295. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  66296. /**
  66297. * Unproject from screen space to object space
  66298. * @param source defines the screen space Vector3 to use
  66299. * @param viewportWidth defines the current width of the viewport
  66300. * @param viewportHeight defines the current height of the viewport
  66301. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66302. * @param view defines the view matrix to use
  66303. * @param projection defines the projection matrix to use
  66304. * @returns the new Vector3
  66305. */
  66306. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  66307. /**
  66308. * Unproject from screen space to object space
  66309. * @param source defines the screen space Vector3 to use
  66310. * @param viewportWidth defines the current width of the viewport
  66311. * @param viewportHeight defines the current height of the viewport
  66312. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66313. * @param view defines the view matrix to use
  66314. * @param projection defines the projection matrix to use
  66315. * @param result defines the Vector3 where to store the result
  66316. */
  66317. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  66318. /**
  66319. * Unproject from screen space to object space
  66320. * @param sourceX defines the screen space x coordinate to use
  66321. * @param sourceY defines the screen space y coordinate to use
  66322. * @param sourceZ defines the screen space z coordinate to use
  66323. * @param viewportWidth defines the current width of the viewport
  66324. * @param viewportHeight defines the current height of the viewport
  66325. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66326. * @param view defines the view matrix to use
  66327. * @param projection defines the projection matrix to use
  66328. * @param result defines the Vector3 where to store the result
  66329. */
  66330. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  66331. /**
  66332. * Gets the minimal coordinate values between two Vector3
  66333. * @param left defines the first operand
  66334. * @param right defines the second operand
  66335. * @returns the new Vector3
  66336. */
  66337. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66338. /**
  66339. * Gets the maximal coordinate values between two Vector3
  66340. * @param left defines the first operand
  66341. * @param right defines the second operand
  66342. * @returns the new Vector3
  66343. */
  66344. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66345. /**
  66346. * Returns the distance between the vectors "value1" and "value2"
  66347. * @param value1 defines the first operand
  66348. * @param value2 defines the second operand
  66349. * @returns the distance
  66350. */
  66351. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  66352. /**
  66353. * Returns the squared distance between the vectors "value1" and "value2"
  66354. * @param value1 defines the first operand
  66355. * @param value2 defines the second operand
  66356. * @returns the squared distance
  66357. */
  66358. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  66359. /**
  66360. * Returns a new Vector3 located at the center between "value1" and "value2"
  66361. * @param value1 defines the first operand
  66362. * @param value2 defines the second operand
  66363. * @returns the new Vector3
  66364. */
  66365. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  66366. /**
  66367. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  66368. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  66369. * to something in order to rotate it from its local system to the given target system
  66370. * Note: axis1, axis2 and axis3 are normalized during this operation
  66371. * @param axis1 defines the first axis
  66372. * @param axis2 defines the second axis
  66373. * @param axis3 defines the third axis
  66374. * @returns a new Vector3
  66375. */
  66376. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  66377. /**
  66378. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  66379. * @param axis1 defines the first axis
  66380. * @param axis2 defines the second axis
  66381. * @param axis3 defines the third axis
  66382. * @param ref defines the Vector3 where to store the result
  66383. */
  66384. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  66385. }
  66386. /**
  66387. * Vector4 class created for EulerAngle class conversion to Quaternion
  66388. */
  66389. export class Vector4 {
  66390. /** x value of the vector */
  66391. x: number;
  66392. /** y value of the vector */
  66393. y: number;
  66394. /** z value of the vector */
  66395. z: number;
  66396. /** w value of the vector */
  66397. w: number;
  66398. /**
  66399. * Creates a Vector4 object from the given floats.
  66400. * @param x x value of the vector
  66401. * @param y y value of the vector
  66402. * @param z z value of the vector
  66403. * @param w w value of the vector
  66404. */
  66405. constructor(
  66406. /** x value of the vector */
  66407. x: number,
  66408. /** y value of the vector */
  66409. y: number,
  66410. /** z value of the vector */
  66411. z: number,
  66412. /** w value of the vector */
  66413. w: number);
  66414. /**
  66415. * Returns the string with the Vector4 coordinates.
  66416. * @returns a string containing all the vector values
  66417. */
  66418. toString(): string;
  66419. /**
  66420. * Returns the string "Vector4".
  66421. * @returns "Vector4"
  66422. */
  66423. getClassName(): string;
  66424. /**
  66425. * Returns the Vector4 hash code.
  66426. * @returns a unique hash code
  66427. */
  66428. getHashCode(): number;
  66429. /**
  66430. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  66431. * @returns the resulting array
  66432. */
  66433. asArray(): number[];
  66434. /**
  66435. * Populates the given array from the given index with the Vector4 coordinates.
  66436. * @param array array to populate
  66437. * @param index index of the array to start at (default: 0)
  66438. * @returns the Vector4.
  66439. */
  66440. toArray(array: FloatArray, index?: number): Vector4;
  66441. /**
  66442. * Adds the given vector to the current Vector4.
  66443. * @param otherVector the vector to add
  66444. * @returns the updated Vector4.
  66445. */
  66446. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  66447. /**
  66448. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  66449. * @param otherVector the vector to add
  66450. * @returns the resulting vector
  66451. */
  66452. add(otherVector: DeepImmutable<Vector4>): Vector4;
  66453. /**
  66454. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  66455. * @param otherVector the vector to add
  66456. * @param result the vector to store the result
  66457. * @returns the current Vector4.
  66458. */
  66459. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66460. /**
  66461. * Subtract in place the given vector from the current Vector4.
  66462. * @param otherVector the vector to subtract
  66463. * @returns the updated Vector4.
  66464. */
  66465. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  66466. /**
  66467. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  66468. * @param otherVector the vector to add
  66469. * @returns the new vector with the result
  66470. */
  66471. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  66472. /**
  66473. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  66474. * @param otherVector the vector to subtract
  66475. * @param result the vector to store the result
  66476. * @returns the current Vector4.
  66477. */
  66478. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66479. /**
  66480. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  66481. */
  66482. /**
  66483. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  66484. * @param x value to subtract
  66485. * @param y value to subtract
  66486. * @param z value to subtract
  66487. * @param w value to subtract
  66488. * @returns new vector containing the result
  66489. */
  66490. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  66491. /**
  66492. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  66493. * @param x value to subtract
  66494. * @param y value to subtract
  66495. * @param z value to subtract
  66496. * @param w value to subtract
  66497. * @param result the vector to store the result in
  66498. * @returns the current Vector4.
  66499. */
  66500. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  66501. /**
  66502. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  66503. * @returns a new vector with the negated values
  66504. */
  66505. negate(): Vector4;
  66506. /**
  66507. * Multiplies the current Vector4 coordinates by scale (float).
  66508. * @param scale the number to scale with
  66509. * @returns the updated Vector4.
  66510. */
  66511. scaleInPlace(scale: number): Vector4;
  66512. /**
  66513. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  66514. * @param scale the number to scale with
  66515. * @returns a new vector with the result
  66516. */
  66517. scale(scale: number): Vector4;
  66518. /**
  66519. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  66520. * @param scale the number to scale with
  66521. * @param result a vector to store the result in
  66522. * @returns the current Vector4.
  66523. */
  66524. scaleToRef(scale: number, result: Vector4): Vector4;
  66525. /**
  66526. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  66527. * @param scale defines the scale factor
  66528. * @param result defines the Vector4 object where to store the result
  66529. * @returns the unmodified current Vector4
  66530. */
  66531. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  66532. /**
  66533. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  66534. * @param otherVector the vector to compare against
  66535. * @returns true if they are equal
  66536. */
  66537. equals(otherVector: DeepImmutable<Vector4>): boolean;
  66538. /**
  66539. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  66540. * @param otherVector vector to compare against
  66541. * @param epsilon (Default: very small number)
  66542. * @returns true if they are equal
  66543. */
  66544. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  66545. /**
  66546. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  66547. * @param x x value to compare against
  66548. * @param y y value to compare against
  66549. * @param z z value to compare against
  66550. * @param w w value to compare against
  66551. * @returns true if equal
  66552. */
  66553. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  66554. /**
  66555. * Multiplies in place the current Vector4 by the given one.
  66556. * @param otherVector vector to multiple with
  66557. * @returns the updated Vector4.
  66558. */
  66559. multiplyInPlace(otherVector: Vector4): Vector4;
  66560. /**
  66561. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  66562. * @param otherVector vector to multiple with
  66563. * @returns resulting new vector
  66564. */
  66565. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  66566. /**
  66567. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  66568. * @param otherVector vector to multiple with
  66569. * @param result vector to store the result
  66570. * @returns the current Vector4.
  66571. */
  66572. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66573. /**
  66574. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  66575. * @param x x value multiply with
  66576. * @param y y value multiply with
  66577. * @param z z value multiply with
  66578. * @param w w value multiply with
  66579. * @returns resulting new vector
  66580. */
  66581. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  66582. /**
  66583. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  66584. * @param otherVector vector to devide with
  66585. * @returns resulting new vector
  66586. */
  66587. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  66588. /**
  66589. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  66590. * @param otherVector vector to devide with
  66591. * @param result vector to store the result
  66592. * @returns the current Vector4.
  66593. */
  66594. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66595. /**
  66596. * Divides the current Vector3 coordinates by the given ones.
  66597. * @param otherVector vector to devide with
  66598. * @returns the updated Vector3.
  66599. */
  66600. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  66601. /**
  66602. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  66603. * @param other defines the second operand
  66604. * @returns the current updated Vector4
  66605. */
  66606. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  66607. /**
  66608. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  66609. * @param other defines the second operand
  66610. * @returns the current updated Vector4
  66611. */
  66612. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  66613. /**
  66614. * Gets a new Vector4 from current Vector4 floored values
  66615. * @returns a new Vector4
  66616. */
  66617. floor(): Vector4;
  66618. /**
  66619. * Gets a new Vector4 from current Vector3 floored values
  66620. * @returns a new Vector4
  66621. */
  66622. fract(): Vector4;
  66623. /**
  66624. * Returns the Vector4 length (float).
  66625. * @returns the length
  66626. */
  66627. length(): number;
  66628. /**
  66629. * Returns the Vector4 squared length (float).
  66630. * @returns the length squared
  66631. */
  66632. lengthSquared(): number;
  66633. /**
  66634. * Normalizes in place the Vector4.
  66635. * @returns the updated Vector4.
  66636. */
  66637. normalize(): Vector4;
  66638. /**
  66639. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  66640. * @returns this converted to a new vector3
  66641. */
  66642. toVector3(): Vector3;
  66643. /**
  66644. * Returns a new Vector4 copied from the current one.
  66645. * @returns the new cloned vector
  66646. */
  66647. clone(): Vector4;
  66648. /**
  66649. * Updates the current Vector4 with the given one coordinates.
  66650. * @param source the source vector to copy from
  66651. * @returns the updated Vector4.
  66652. */
  66653. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  66654. /**
  66655. * Updates the current Vector4 coordinates with the given floats.
  66656. * @param x float to copy from
  66657. * @param y float to copy from
  66658. * @param z float to copy from
  66659. * @param w float to copy from
  66660. * @returns the updated Vector4.
  66661. */
  66662. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  66663. /**
  66664. * Updates the current Vector4 coordinates with the given floats.
  66665. * @param x float to set from
  66666. * @param y float to set from
  66667. * @param z float to set from
  66668. * @param w float to set from
  66669. * @returns the updated Vector4.
  66670. */
  66671. set(x: number, y: number, z: number, w: number): Vector4;
  66672. /**
  66673. * Copies the given float to the current Vector3 coordinates
  66674. * @param v defines the x, y, z and w coordinates of the operand
  66675. * @returns the current updated Vector3
  66676. */
  66677. setAll(v: number): Vector4;
  66678. /**
  66679. * Returns a new Vector4 set from the starting index of the given array.
  66680. * @param array the array to pull values from
  66681. * @param offset the offset into the array to start at
  66682. * @returns the new vector
  66683. */
  66684. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  66685. /**
  66686. * Updates the given vector "result" from the starting index of the given array.
  66687. * @param array the array to pull values from
  66688. * @param offset the offset into the array to start at
  66689. * @param result the vector to store the result in
  66690. */
  66691. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  66692. /**
  66693. * Updates the given vector "result" from the starting index of the given Float32Array.
  66694. * @param array the array to pull values from
  66695. * @param offset the offset into the array to start at
  66696. * @param result the vector to store the result in
  66697. */
  66698. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  66699. /**
  66700. * Updates the given vector "result" coordinates from the given floats.
  66701. * @param x float to set from
  66702. * @param y float to set from
  66703. * @param z float to set from
  66704. * @param w float to set from
  66705. * @param result the vector to the floats in
  66706. */
  66707. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  66708. /**
  66709. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  66710. * @returns the new vector
  66711. */
  66712. static Zero(): Vector4;
  66713. /**
  66714. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  66715. * @returns the new vector
  66716. */
  66717. static One(): Vector4;
  66718. /**
  66719. * Returns a new normalized Vector4 from the given one.
  66720. * @param vector the vector to normalize
  66721. * @returns the vector
  66722. */
  66723. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  66724. /**
  66725. * Updates the given vector "result" from the normalization of the given one.
  66726. * @param vector the vector to normalize
  66727. * @param result the vector to store the result in
  66728. */
  66729. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  66730. /**
  66731. * Returns a vector with the minimum values from the left and right vectors
  66732. * @param left left vector to minimize
  66733. * @param right right vector to minimize
  66734. * @returns a new vector with the minimum of the left and right vector values
  66735. */
  66736. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  66737. /**
  66738. * Returns a vector with the maximum values from the left and right vectors
  66739. * @param left left vector to maximize
  66740. * @param right right vector to maximize
  66741. * @returns a new vector with the maximum of the left and right vector values
  66742. */
  66743. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  66744. /**
  66745. * Returns the distance (float) between the vectors "value1" and "value2".
  66746. * @param value1 value to calulate the distance between
  66747. * @param value2 value to calulate the distance between
  66748. * @return the distance between the two vectors
  66749. */
  66750. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  66751. /**
  66752. * Returns the squared distance (float) between the vectors "value1" and "value2".
  66753. * @param value1 value to calulate the distance between
  66754. * @param value2 value to calulate the distance between
  66755. * @return the distance between the two vectors squared
  66756. */
  66757. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  66758. /**
  66759. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  66760. * @param value1 value to calulate the center between
  66761. * @param value2 value to calulate the center between
  66762. * @return the center between the two vectors
  66763. */
  66764. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  66765. /**
  66766. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  66767. * This methods computes transformed normalized direction vectors only.
  66768. * @param vector the vector to transform
  66769. * @param transformation the transformation matrix to apply
  66770. * @returns the new vector
  66771. */
  66772. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  66773. /**
  66774. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  66775. * This methods computes transformed normalized direction vectors only.
  66776. * @param vector the vector to transform
  66777. * @param transformation the transformation matrix to apply
  66778. * @param result the vector to store the result in
  66779. */
  66780. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  66781. /**
  66782. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  66783. * This methods computes transformed normalized direction vectors only.
  66784. * @param x value to transform
  66785. * @param y value to transform
  66786. * @param z value to transform
  66787. * @param w value to transform
  66788. * @param transformation the transformation matrix to apply
  66789. * @param result the vector to store the results in
  66790. */
  66791. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  66792. /**
  66793. * Creates a new Vector4 from a Vector3
  66794. * @param source defines the source data
  66795. * @param w defines the 4th component (default is 0)
  66796. * @returns a new Vector4
  66797. */
  66798. static FromVector3(source: Vector3, w?: number): Vector4;
  66799. }
  66800. /**
  66801. * Class used to store quaternion data
  66802. * @see https://en.wikipedia.org/wiki/Quaternion
  66803. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  66804. */
  66805. export class Quaternion {
  66806. /** defines the first component (0 by default) */
  66807. x: number;
  66808. /** defines the second component (0 by default) */
  66809. y: number;
  66810. /** defines the third component (0 by default) */
  66811. z: number;
  66812. /** defines the fourth component (1.0 by default) */
  66813. w: number;
  66814. /**
  66815. * Creates a new Quaternion from the given floats
  66816. * @param x defines the first component (0 by default)
  66817. * @param y defines the second component (0 by default)
  66818. * @param z defines the third component (0 by default)
  66819. * @param w defines the fourth component (1.0 by default)
  66820. */
  66821. constructor(
  66822. /** defines the first component (0 by default) */
  66823. x?: number,
  66824. /** defines the second component (0 by default) */
  66825. y?: number,
  66826. /** defines the third component (0 by default) */
  66827. z?: number,
  66828. /** defines the fourth component (1.0 by default) */
  66829. w?: number);
  66830. /**
  66831. * Gets a string representation for the current quaternion
  66832. * @returns a string with the Quaternion coordinates
  66833. */
  66834. toString(): string;
  66835. /**
  66836. * Gets the class name of the quaternion
  66837. * @returns the string "Quaternion"
  66838. */
  66839. getClassName(): string;
  66840. /**
  66841. * Gets a hash code for this quaternion
  66842. * @returns the quaternion hash code
  66843. */
  66844. getHashCode(): number;
  66845. /**
  66846. * Copy the quaternion to an array
  66847. * @returns a new array populated with 4 elements from the quaternion coordinates
  66848. */
  66849. asArray(): number[];
  66850. /**
  66851. * Check if two quaternions are equals
  66852. * @param otherQuaternion defines the second operand
  66853. * @return true if the current quaternion and the given one coordinates are strictly equals
  66854. */
  66855. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  66856. /**
  66857. * Clone the current quaternion
  66858. * @returns a new quaternion copied from the current one
  66859. */
  66860. clone(): Quaternion;
  66861. /**
  66862. * Copy a quaternion to the current one
  66863. * @param other defines the other quaternion
  66864. * @returns the updated current quaternion
  66865. */
  66866. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  66867. /**
  66868. * Updates the current quaternion with the given float coordinates
  66869. * @param x defines the x coordinate
  66870. * @param y defines the y coordinate
  66871. * @param z defines the z coordinate
  66872. * @param w defines the w coordinate
  66873. * @returns the updated current quaternion
  66874. */
  66875. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  66876. /**
  66877. * Updates the current quaternion from the given float coordinates
  66878. * @param x defines the x coordinate
  66879. * @param y defines the y coordinate
  66880. * @param z defines the z coordinate
  66881. * @param w defines the w coordinate
  66882. * @returns the updated current quaternion
  66883. */
  66884. set(x: number, y: number, z: number, w: number): Quaternion;
  66885. /**
  66886. * Adds two quaternions
  66887. * @param other defines the second operand
  66888. * @returns a new quaternion as the addition result of the given one and the current quaternion
  66889. */
  66890. add(other: DeepImmutable<Quaternion>): Quaternion;
  66891. /**
  66892. * Add a quaternion to the current one
  66893. * @param other defines the quaternion to add
  66894. * @returns the current quaternion
  66895. */
  66896. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  66897. /**
  66898. * Subtract two quaternions
  66899. * @param other defines the second operand
  66900. * @returns a new quaternion as the subtraction result of the given one from the current one
  66901. */
  66902. subtract(other: Quaternion): Quaternion;
  66903. /**
  66904. * Multiplies the current quaternion by a scale factor
  66905. * @param value defines the scale factor
  66906. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  66907. */
  66908. scale(value: number): Quaternion;
  66909. /**
  66910. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  66911. * @param scale defines the scale factor
  66912. * @param result defines the Quaternion object where to store the result
  66913. * @returns the unmodified current quaternion
  66914. */
  66915. scaleToRef(scale: number, result: Quaternion): Quaternion;
  66916. /**
  66917. * Multiplies in place the current quaternion by a scale factor
  66918. * @param value defines the scale factor
  66919. * @returns the current modified quaternion
  66920. */
  66921. scaleInPlace(value: number): Quaternion;
  66922. /**
  66923. * Scale the current quaternion values by a factor and add the result to a given quaternion
  66924. * @param scale defines the scale factor
  66925. * @param result defines the Quaternion object where to store the result
  66926. * @returns the unmodified current quaternion
  66927. */
  66928. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  66929. /**
  66930. * Multiplies two quaternions
  66931. * @param q1 defines the second operand
  66932. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  66933. */
  66934. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  66935. /**
  66936. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  66937. * @param q1 defines the second operand
  66938. * @param result defines the target quaternion
  66939. * @returns the current quaternion
  66940. */
  66941. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  66942. /**
  66943. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  66944. * @param q1 defines the second operand
  66945. * @returns the currentupdated quaternion
  66946. */
  66947. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  66948. /**
  66949. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  66950. * @param ref defines the target quaternion
  66951. * @returns the current quaternion
  66952. */
  66953. conjugateToRef(ref: Quaternion): Quaternion;
  66954. /**
  66955. * Conjugates in place (1-q) the current quaternion
  66956. * @returns the current updated quaternion
  66957. */
  66958. conjugateInPlace(): Quaternion;
  66959. /**
  66960. * Conjugates in place (1-q) the current quaternion
  66961. * @returns a new quaternion
  66962. */
  66963. conjugate(): Quaternion;
  66964. /**
  66965. * Gets length of current quaternion
  66966. * @returns the quaternion length (float)
  66967. */
  66968. length(): number;
  66969. /**
  66970. * Normalize in place the current quaternion
  66971. * @returns the current updated quaternion
  66972. */
  66973. normalize(): Quaternion;
  66974. /**
  66975. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  66976. * @param order is a reserved parameter and is ignore for now
  66977. * @returns a new Vector3 containing the Euler angles
  66978. */
  66979. toEulerAngles(order?: string): Vector3;
  66980. /**
  66981. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  66982. * @param result defines the vector which will be filled with the Euler angles
  66983. * @param order is a reserved parameter and is ignore for now
  66984. * @returns the current unchanged quaternion
  66985. */
  66986. toEulerAnglesToRef(result: Vector3): Quaternion;
  66987. /**
  66988. * Updates the given rotation matrix with the current quaternion values
  66989. * @param result defines the target matrix
  66990. * @returns the current unchanged quaternion
  66991. */
  66992. toRotationMatrix(result: Matrix): Quaternion;
  66993. /**
  66994. * Updates the current quaternion from the given rotation matrix values
  66995. * @param matrix defines the source matrix
  66996. * @returns the current updated quaternion
  66997. */
  66998. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  66999. /**
  67000. * Creates a new quaternion from a rotation matrix
  67001. * @param matrix defines the source matrix
  67002. * @returns a new quaternion created from the given rotation matrix values
  67003. */
  67004. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  67005. /**
  67006. * Updates the given quaternion with the given rotation matrix values
  67007. * @param matrix defines the source matrix
  67008. * @param result defines the target quaternion
  67009. */
  67010. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  67011. /**
  67012. * Returns the dot product (float) between the quaternions "left" and "right"
  67013. * @param left defines the left operand
  67014. * @param right defines the right operand
  67015. * @returns the dot product
  67016. */
  67017. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  67018. /**
  67019. * Checks if the two quaternions are close to each other
  67020. * @param quat0 defines the first quaternion to check
  67021. * @param quat1 defines the second quaternion to check
  67022. * @returns true if the two quaternions are close to each other
  67023. */
  67024. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  67025. /**
  67026. * Creates an empty quaternion
  67027. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  67028. */
  67029. static Zero(): Quaternion;
  67030. /**
  67031. * Inverse a given quaternion
  67032. * @param q defines the source quaternion
  67033. * @returns a new quaternion as the inverted current quaternion
  67034. */
  67035. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  67036. /**
  67037. * Inverse a given quaternion
  67038. * @param q defines the source quaternion
  67039. * @param result the quaternion the result will be stored in
  67040. * @returns the result quaternion
  67041. */
  67042. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  67043. /**
  67044. * Creates an identity quaternion
  67045. * @returns the identity quaternion
  67046. */
  67047. static Identity(): Quaternion;
  67048. /**
  67049. * Gets a boolean indicating if the given quaternion is identity
  67050. * @param quaternion defines the quaternion to check
  67051. * @returns true if the quaternion is identity
  67052. */
  67053. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  67054. /**
  67055. * Creates a quaternion from a rotation around an axis
  67056. * @param axis defines the axis to use
  67057. * @param angle defines the angle to use
  67058. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  67059. */
  67060. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  67061. /**
  67062. * Creates a rotation around an axis and stores it into the given quaternion
  67063. * @param axis defines the axis to use
  67064. * @param angle defines the angle to use
  67065. * @param result defines the target quaternion
  67066. * @returns the target quaternion
  67067. */
  67068. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  67069. /**
  67070. * Creates a new quaternion from data stored into an array
  67071. * @param array defines the data source
  67072. * @param offset defines the offset in the source array where the data starts
  67073. * @returns a new quaternion
  67074. */
  67075. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  67076. /**
  67077. * Create a quaternion from Euler rotation angles
  67078. * @param x Pitch
  67079. * @param y Yaw
  67080. * @param z Roll
  67081. * @returns the new Quaternion
  67082. */
  67083. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  67084. /**
  67085. * Updates a quaternion from Euler rotation angles
  67086. * @param x Pitch
  67087. * @param y Yaw
  67088. * @param z Roll
  67089. * @param result the quaternion to store the result
  67090. * @returns the updated quaternion
  67091. */
  67092. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  67093. /**
  67094. * Create a quaternion from Euler rotation vector
  67095. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  67096. * @returns the new Quaternion
  67097. */
  67098. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  67099. /**
  67100. * Updates a quaternion from Euler rotation vector
  67101. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  67102. * @param result the quaternion to store the result
  67103. * @returns the updated quaternion
  67104. */
  67105. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  67106. /**
  67107. * Creates a new quaternion from the given Euler float angles (y, x, z)
  67108. * @param yaw defines the rotation around Y axis
  67109. * @param pitch defines the rotation around X axis
  67110. * @param roll defines the rotation around Z axis
  67111. * @returns the new quaternion
  67112. */
  67113. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  67114. /**
  67115. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  67116. * @param yaw defines the rotation around Y axis
  67117. * @param pitch defines the rotation around X axis
  67118. * @param roll defines the rotation around Z axis
  67119. * @param result defines the target quaternion
  67120. */
  67121. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  67122. /**
  67123. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  67124. * @param alpha defines the rotation around first axis
  67125. * @param beta defines the rotation around second axis
  67126. * @param gamma defines the rotation around third axis
  67127. * @returns the new quaternion
  67128. */
  67129. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  67130. /**
  67131. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  67132. * @param alpha defines the rotation around first axis
  67133. * @param beta defines the rotation around second axis
  67134. * @param gamma defines the rotation around third axis
  67135. * @param result defines the target quaternion
  67136. */
  67137. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  67138. /**
  67139. * 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)
  67140. * @param axis1 defines the first axis
  67141. * @param axis2 defines the second axis
  67142. * @param axis3 defines the third axis
  67143. * @returns the new quaternion
  67144. */
  67145. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  67146. /**
  67147. * 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
  67148. * @param axis1 defines the first axis
  67149. * @param axis2 defines the second axis
  67150. * @param axis3 defines the third axis
  67151. * @param ref defines the target quaternion
  67152. */
  67153. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  67154. /**
  67155. * Interpolates between two quaternions
  67156. * @param left defines first quaternion
  67157. * @param right defines second quaternion
  67158. * @param amount defines the gradient to use
  67159. * @returns the new interpolated quaternion
  67160. */
  67161. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  67162. /**
  67163. * Interpolates between two quaternions and stores it into a target quaternion
  67164. * @param left defines first quaternion
  67165. * @param right defines second quaternion
  67166. * @param amount defines the gradient to use
  67167. * @param result defines the target quaternion
  67168. */
  67169. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  67170. /**
  67171. * Interpolate between two quaternions using Hermite interpolation
  67172. * @param value1 defines first quaternion
  67173. * @param tangent1 defines the incoming tangent
  67174. * @param value2 defines second quaternion
  67175. * @param tangent2 defines the outgoing tangent
  67176. * @param amount defines the target quaternion
  67177. * @returns the new interpolated quaternion
  67178. */
  67179. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  67180. }
  67181. /**
  67182. * Class used to store matrix data (4x4)
  67183. */
  67184. export class Matrix {
  67185. private static _updateFlagSeed;
  67186. private static _identityReadOnly;
  67187. private _isIdentity;
  67188. private _isIdentityDirty;
  67189. private _isIdentity3x2;
  67190. private _isIdentity3x2Dirty;
  67191. /**
  67192. * Gets the update flag of the matrix which is an unique number for the matrix.
  67193. * It will be incremented every time the matrix data change.
  67194. * You can use it to speed the comparison between two versions of the same matrix.
  67195. */
  67196. updateFlag: number;
  67197. private readonly _m;
  67198. /**
  67199. * Gets the internal data of the matrix
  67200. */
  67201. readonly m: DeepImmutable<Float32Array>;
  67202. /** @hidden */
  67203. _markAsUpdated(): void;
  67204. /** @hidden */
  67205. private _updateIdentityStatus;
  67206. /**
  67207. * Creates an empty matrix (filled with zeros)
  67208. */
  67209. constructor();
  67210. /**
  67211. * Check if the current matrix is identity
  67212. * @returns true is the matrix is the identity matrix
  67213. */
  67214. isIdentity(): boolean;
  67215. /**
  67216. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  67217. * @returns true is the matrix is the identity matrix
  67218. */
  67219. isIdentityAs3x2(): boolean;
  67220. /**
  67221. * Gets the determinant of the matrix
  67222. * @returns the matrix determinant
  67223. */
  67224. determinant(): number;
  67225. /**
  67226. * Returns the matrix as a Float32Array
  67227. * @returns the matrix underlying array
  67228. */
  67229. toArray(): DeepImmutable<Float32Array>;
  67230. /**
  67231. * Returns the matrix as a Float32Array
  67232. * @returns the matrix underlying array.
  67233. */
  67234. asArray(): DeepImmutable<Float32Array>;
  67235. /**
  67236. * Inverts the current matrix in place
  67237. * @returns the current inverted matrix
  67238. */
  67239. invert(): Matrix;
  67240. /**
  67241. * Sets all the matrix elements to zero
  67242. * @returns the current matrix
  67243. */
  67244. reset(): Matrix;
  67245. /**
  67246. * Adds the current matrix with a second one
  67247. * @param other defines the matrix to add
  67248. * @returns a new matrix as the addition of the current matrix and the given one
  67249. */
  67250. add(other: DeepImmutable<Matrix>): Matrix;
  67251. /**
  67252. * Sets the given matrix "result" to the addition of the current matrix and the given one
  67253. * @param other defines the matrix to add
  67254. * @param result defines the target matrix
  67255. * @returns the current matrix
  67256. */
  67257. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  67258. /**
  67259. * Adds in place the given matrix to the current matrix
  67260. * @param other defines the second operand
  67261. * @returns the current updated matrix
  67262. */
  67263. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  67264. /**
  67265. * Sets the given matrix to the current inverted Matrix
  67266. * @param other defines the target matrix
  67267. * @returns the unmodified current matrix
  67268. */
  67269. invertToRef(other: Matrix): Matrix;
  67270. /**
  67271. * add a value at the specified position in the current Matrix
  67272. * @param index the index of the value within the matrix. between 0 and 15.
  67273. * @param value the value to be added
  67274. * @returns the current updated matrix
  67275. */
  67276. addAtIndex(index: number, value: number): Matrix;
  67277. /**
  67278. * mutiply the specified position in the current Matrix by a value
  67279. * @param index the index of the value within the matrix. between 0 and 15.
  67280. * @param value the value to be added
  67281. * @returns the current updated matrix
  67282. */
  67283. multiplyAtIndex(index: number, value: number): Matrix;
  67284. /**
  67285. * Inserts the translation vector (using 3 floats) in the current matrix
  67286. * @param x defines the 1st component of the translation
  67287. * @param y defines the 2nd component of the translation
  67288. * @param z defines the 3rd component of the translation
  67289. * @returns the current updated matrix
  67290. */
  67291. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  67292. /**
  67293. * Adds the translation vector (using 3 floats) in the current matrix
  67294. * @param x defines the 1st component of the translation
  67295. * @param y defines the 2nd component of the translation
  67296. * @param z defines the 3rd component of the translation
  67297. * @returns the current updated matrix
  67298. */
  67299. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  67300. /**
  67301. * Inserts the translation vector in the current matrix
  67302. * @param vector3 defines the translation to insert
  67303. * @returns the current updated matrix
  67304. */
  67305. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  67306. /**
  67307. * Gets the translation value of the current matrix
  67308. * @returns a new Vector3 as the extracted translation from the matrix
  67309. */
  67310. getTranslation(): Vector3;
  67311. /**
  67312. * Fill a Vector3 with the extracted translation from the matrix
  67313. * @param result defines the Vector3 where to store the translation
  67314. * @returns the current matrix
  67315. */
  67316. getTranslationToRef(result: Vector3): Matrix;
  67317. /**
  67318. * Remove rotation and scaling part from the matrix
  67319. * @returns the updated matrix
  67320. */
  67321. removeRotationAndScaling(): Matrix;
  67322. /**
  67323. * Multiply two matrices
  67324. * @param other defines the second operand
  67325. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  67326. */
  67327. multiply(other: DeepImmutable<Matrix>): Matrix;
  67328. /**
  67329. * Copy the current matrix from the given one
  67330. * @param other defines the source matrix
  67331. * @returns the current updated matrix
  67332. */
  67333. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  67334. /**
  67335. * Populates the given array from the starting index with the current matrix values
  67336. * @param array defines the target array
  67337. * @param offset defines the offset in the target array where to start storing values
  67338. * @returns the current matrix
  67339. */
  67340. copyToArray(array: Float32Array, offset?: number): Matrix;
  67341. /**
  67342. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  67343. * @param other defines the second operand
  67344. * @param result defines the matrix where to store the multiplication
  67345. * @returns the current matrix
  67346. */
  67347. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  67348. /**
  67349. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  67350. * @param other defines the second operand
  67351. * @param result defines the array where to store the multiplication
  67352. * @param offset defines the offset in the target array where to start storing values
  67353. * @returns the current matrix
  67354. */
  67355. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  67356. /**
  67357. * Check equality between this matrix and a second one
  67358. * @param value defines the second matrix to compare
  67359. * @returns true is the current matrix and the given one values are strictly equal
  67360. */
  67361. equals(value: DeepImmutable<Matrix>): boolean;
  67362. /**
  67363. * Clone the current matrix
  67364. * @returns a new matrix from the current matrix
  67365. */
  67366. clone(): Matrix;
  67367. /**
  67368. * Returns the name of the current matrix class
  67369. * @returns the string "Matrix"
  67370. */
  67371. getClassName(): string;
  67372. /**
  67373. * Gets the hash code of the current matrix
  67374. * @returns the hash code
  67375. */
  67376. getHashCode(): number;
  67377. /**
  67378. * Decomposes the current Matrix into a translation, rotation and scaling components
  67379. * @param scale defines the scale vector3 given as a reference to update
  67380. * @param rotation defines the rotation quaternion given as a reference to update
  67381. * @param translation defines the translation vector3 given as a reference to update
  67382. * @returns true if operation was successful
  67383. */
  67384. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  67385. /**
  67386. * Gets specific row of the matrix
  67387. * @param index defines the number of the row to get
  67388. * @returns the index-th row of the current matrix as a new Vector4
  67389. */
  67390. getRow(index: number): Nullable<Vector4>;
  67391. /**
  67392. * Sets the index-th row of the current matrix to the vector4 values
  67393. * @param index defines the number of the row to set
  67394. * @param row defines the target vector4
  67395. * @returns the updated current matrix
  67396. */
  67397. setRow(index: number, row: Vector4): Matrix;
  67398. /**
  67399. * Compute the transpose of the matrix
  67400. * @returns the new transposed matrix
  67401. */
  67402. transpose(): Matrix;
  67403. /**
  67404. * Compute the transpose of the matrix and store it in a given matrix
  67405. * @param result defines the target matrix
  67406. * @returns the current matrix
  67407. */
  67408. transposeToRef(result: Matrix): Matrix;
  67409. /**
  67410. * Sets the index-th row of the current matrix with the given 4 x float values
  67411. * @param index defines the row index
  67412. * @param x defines the x component to set
  67413. * @param y defines the y component to set
  67414. * @param z defines the z component to set
  67415. * @param w defines the w component to set
  67416. * @returns the updated current matrix
  67417. */
  67418. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  67419. /**
  67420. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  67421. * @param scale defines the scale factor
  67422. * @returns a new matrix
  67423. */
  67424. scale(scale: number): Matrix;
  67425. /**
  67426. * Scale the current matrix values by a factor to a given result matrix
  67427. * @param scale defines the scale factor
  67428. * @param result defines the matrix to store the result
  67429. * @returns the current matrix
  67430. */
  67431. scaleToRef(scale: number, result: Matrix): Matrix;
  67432. /**
  67433. * Scale the current matrix values by a factor and add the result to a given matrix
  67434. * @param scale defines the scale factor
  67435. * @param result defines the Matrix to store the result
  67436. * @returns the current matrix
  67437. */
  67438. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  67439. /**
  67440. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  67441. * @param ref matrix to store the result
  67442. */
  67443. toNormalMatrix(ref: Matrix): void;
  67444. /**
  67445. * Gets only rotation part of the current matrix
  67446. * @returns a new matrix sets to the extracted rotation matrix from the current one
  67447. */
  67448. getRotationMatrix(): Matrix;
  67449. /**
  67450. * Extracts the rotation matrix from the current one and sets it as the given "result"
  67451. * @param result defines the target matrix to store data to
  67452. * @returns the current matrix
  67453. */
  67454. getRotationMatrixToRef(result: Matrix): Matrix;
  67455. /**
  67456. * Toggles model matrix from being right handed to left handed in place and vice versa
  67457. */
  67458. toggleModelMatrixHandInPlace(): void;
  67459. /**
  67460. * Toggles projection matrix from being right handed to left handed in place and vice versa
  67461. */
  67462. toggleProjectionMatrixHandInPlace(): void;
  67463. /**
  67464. * Creates a matrix from an array
  67465. * @param array defines the source array
  67466. * @param offset defines an offset in the source array
  67467. * @returns a new Matrix set from the starting index of the given array
  67468. */
  67469. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  67470. /**
  67471. * Copy the content of an array into a given matrix
  67472. * @param array defines the source array
  67473. * @param offset defines an offset in the source array
  67474. * @param result defines the target matrix
  67475. */
  67476. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  67477. /**
  67478. * Stores an array into a matrix after having multiplied each component by a given factor
  67479. * @param array defines the source array
  67480. * @param offset defines the offset in the source array
  67481. * @param scale defines the scaling factor
  67482. * @param result defines the target matrix
  67483. */
  67484. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  67485. /**
  67486. * Gets an identity matrix that must not be updated
  67487. */
  67488. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  67489. /**
  67490. * Stores a list of values (16) inside a given matrix
  67491. * @param initialM11 defines 1st value of 1st row
  67492. * @param initialM12 defines 2nd value of 1st row
  67493. * @param initialM13 defines 3rd value of 1st row
  67494. * @param initialM14 defines 4th value of 1st row
  67495. * @param initialM21 defines 1st value of 2nd row
  67496. * @param initialM22 defines 2nd value of 2nd row
  67497. * @param initialM23 defines 3rd value of 2nd row
  67498. * @param initialM24 defines 4th value of 2nd row
  67499. * @param initialM31 defines 1st value of 3rd row
  67500. * @param initialM32 defines 2nd value of 3rd row
  67501. * @param initialM33 defines 3rd value of 3rd row
  67502. * @param initialM34 defines 4th value of 3rd row
  67503. * @param initialM41 defines 1st value of 4th row
  67504. * @param initialM42 defines 2nd value of 4th row
  67505. * @param initialM43 defines 3rd value of 4th row
  67506. * @param initialM44 defines 4th value of 4th row
  67507. * @param result defines the target matrix
  67508. */
  67509. 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;
  67510. /**
  67511. * Creates new matrix from a list of values (16)
  67512. * @param initialM11 defines 1st value of 1st row
  67513. * @param initialM12 defines 2nd value of 1st row
  67514. * @param initialM13 defines 3rd value of 1st row
  67515. * @param initialM14 defines 4th value of 1st row
  67516. * @param initialM21 defines 1st value of 2nd row
  67517. * @param initialM22 defines 2nd value of 2nd row
  67518. * @param initialM23 defines 3rd value of 2nd row
  67519. * @param initialM24 defines 4th value of 2nd row
  67520. * @param initialM31 defines 1st value of 3rd row
  67521. * @param initialM32 defines 2nd value of 3rd row
  67522. * @param initialM33 defines 3rd value of 3rd row
  67523. * @param initialM34 defines 4th value of 3rd row
  67524. * @param initialM41 defines 1st value of 4th row
  67525. * @param initialM42 defines 2nd value of 4th row
  67526. * @param initialM43 defines 3rd value of 4th row
  67527. * @param initialM44 defines 4th value of 4th row
  67528. * @returns the new matrix
  67529. */
  67530. 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;
  67531. /**
  67532. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  67533. * @param scale defines the scale vector3
  67534. * @param rotation defines the rotation quaternion
  67535. * @param translation defines the translation vector3
  67536. * @returns a new matrix
  67537. */
  67538. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  67539. /**
  67540. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  67541. * @param scale defines the scale vector3
  67542. * @param rotation defines the rotation quaternion
  67543. * @param translation defines the translation vector3
  67544. * @param result defines the target matrix
  67545. */
  67546. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  67547. /**
  67548. * Creates a new identity matrix
  67549. * @returns a new identity matrix
  67550. */
  67551. static Identity(): Matrix;
  67552. /**
  67553. * Creates a new identity matrix and stores the result in a given matrix
  67554. * @param result defines the target matrix
  67555. */
  67556. static IdentityToRef(result: Matrix): void;
  67557. /**
  67558. * Creates a new zero matrix
  67559. * @returns a new zero matrix
  67560. */
  67561. static Zero(): Matrix;
  67562. /**
  67563. * Creates a new rotation matrix for "angle" radians around the X axis
  67564. * @param angle defines the angle (in radians) to use
  67565. * @return the new matrix
  67566. */
  67567. static RotationX(angle: number): Matrix;
  67568. /**
  67569. * Creates a new matrix as the invert of a given matrix
  67570. * @param source defines the source matrix
  67571. * @returns the new matrix
  67572. */
  67573. static Invert(source: DeepImmutable<Matrix>): Matrix;
  67574. /**
  67575. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  67576. * @param angle defines the angle (in radians) to use
  67577. * @param result defines the target matrix
  67578. */
  67579. static RotationXToRef(angle: number, result: Matrix): void;
  67580. /**
  67581. * Creates a new rotation matrix for "angle" radians around the Y axis
  67582. * @param angle defines the angle (in radians) to use
  67583. * @return the new matrix
  67584. */
  67585. static RotationY(angle: number): Matrix;
  67586. /**
  67587. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  67588. * @param angle defines the angle (in radians) to use
  67589. * @param result defines the target matrix
  67590. */
  67591. static RotationYToRef(angle: number, result: Matrix): void;
  67592. /**
  67593. * Creates a new rotation matrix for "angle" radians around the Z axis
  67594. * @param angle defines the angle (in radians) to use
  67595. * @return the new matrix
  67596. */
  67597. static RotationZ(angle: number): Matrix;
  67598. /**
  67599. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  67600. * @param angle defines the angle (in radians) to use
  67601. * @param result defines the target matrix
  67602. */
  67603. static RotationZToRef(angle: number, result: Matrix): void;
  67604. /**
  67605. * Creates a new rotation matrix for "angle" radians around the given axis
  67606. * @param axis defines the axis to use
  67607. * @param angle defines the angle (in radians) to use
  67608. * @return the new matrix
  67609. */
  67610. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  67611. /**
  67612. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  67613. * @param axis defines the axis to use
  67614. * @param angle defines the angle (in radians) to use
  67615. * @param result defines the target matrix
  67616. */
  67617. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  67618. /**
  67619. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  67620. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  67621. * @param from defines the vector to align
  67622. * @param to defines the vector to align to
  67623. * @param result defines the target matrix
  67624. */
  67625. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  67626. /**
  67627. * Creates a rotation matrix
  67628. * @param yaw defines the yaw angle in radians (Y axis)
  67629. * @param pitch defines the pitch angle in radians (X axis)
  67630. * @param roll defines the roll angle in radians (X axis)
  67631. * @returns the new rotation matrix
  67632. */
  67633. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  67634. /**
  67635. * Creates a rotation matrix and stores it in a given matrix
  67636. * @param yaw defines the yaw angle in radians (Y axis)
  67637. * @param pitch defines the pitch angle in radians (X axis)
  67638. * @param roll defines the roll angle in radians (X axis)
  67639. * @param result defines the target matrix
  67640. */
  67641. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  67642. /**
  67643. * Creates a scaling matrix
  67644. * @param x defines the scale factor on X axis
  67645. * @param y defines the scale factor on Y axis
  67646. * @param z defines the scale factor on Z axis
  67647. * @returns the new matrix
  67648. */
  67649. static Scaling(x: number, y: number, z: number): Matrix;
  67650. /**
  67651. * Creates a scaling matrix and stores it in a given matrix
  67652. * @param x defines the scale factor on X axis
  67653. * @param y defines the scale factor on Y axis
  67654. * @param z defines the scale factor on Z axis
  67655. * @param result defines the target matrix
  67656. */
  67657. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  67658. /**
  67659. * Creates a translation matrix
  67660. * @param x defines the translation on X axis
  67661. * @param y defines the translation on Y axis
  67662. * @param z defines the translationon Z axis
  67663. * @returns the new matrix
  67664. */
  67665. static Translation(x: number, y: number, z: number): Matrix;
  67666. /**
  67667. * Creates a translation matrix and stores it in a given matrix
  67668. * @param x defines the translation on X axis
  67669. * @param y defines the translation on Y axis
  67670. * @param z defines the translationon Z axis
  67671. * @param result defines the target matrix
  67672. */
  67673. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  67674. /**
  67675. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  67676. * @param startValue defines the start value
  67677. * @param endValue defines the end value
  67678. * @param gradient defines the gradient factor
  67679. * @returns the new matrix
  67680. */
  67681. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  67682. /**
  67683. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  67684. * @param startValue defines the start value
  67685. * @param endValue defines the end value
  67686. * @param gradient defines the gradient factor
  67687. * @param result defines the Matrix object where to store data
  67688. */
  67689. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  67690. /**
  67691. * Builds a new matrix whose values are computed by:
  67692. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  67693. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  67694. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  67695. * @param startValue defines the first matrix
  67696. * @param endValue defines the second matrix
  67697. * @param gradient defines the gradient between the two matrices
  67698. * @returns the new matrix
  67699. */
  67700. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  67701. /**
  67702. * Update a matrix to values which are computed by:
  67703. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  67704. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  67705. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  67706. * @param startValue defines the first matrix
  67707. * @param endValue defines the second matrix
  67708. * @param gradient defines the gradient between the two matrices
  67709. * @param result defines the target matrix
  67710. */
  67711. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  67712. /**
  67713. * 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"
  67714. * This function works in left handed mode
  67715. * @param eye defines the final position of the entity
  67716. * @param target defines where the entity should look at
  67717. * @param up defines the up vector for the entity
  67718. * @returns the new matrix
  67719. */
  67720. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  67721. /**
  67722. * 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".
  67723. * This function works in left handed mode
  67724. * @param eye defines the final position of the entity
  67725. * @param target defines where the entity should look at
  67726. * @param up defines the up vector for the entity
  67727. * @param result defines the target matrix
  67728. */
  67729. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  67730. /**
  67731. * 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"
  67732. * This function works in right handed mode
  67733. * @param eye defines the final position of the entity
  67734. * @param target defines where the entity should look at
  67735. * @param up defines the up vector for the entity
  67736. * @returns the new matrix
  67737. */
  67738. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  67739. /**
  67740. * 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".
  67741. * This function works in right handed mode
  67742. * @param eye defines the final position of the entity
  67743. * @param target defines where the entity should look at
  67744. * @param up defines the up vector for the entity
  67745. * @param result defines the target matrix
  67746. */
  67747. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  67748. /**
  67749. * Create a left-handed orthographic projection matrix
  67750. * @param width defines the viewport width
  67751. * @param height defines the viewport height
  67752. * @param znear defines the near clip plane
  67753. * @param zfar defines the far clip plane
  67754. * @returns a new matrix as a left-handed orthographic projection matrix
  67755. */
  67756. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  67757. /**
  67758. * Store a left-handed orthographic projection to a given matrix
  67759. * @param width defines the viewport width
  67760. * @param height defines the viewport height
  67761. * @param znear defines the near clip plane
  67762. * @param zfar defines the far clip plane
  67763. * @param result defines the target matrix
  67764. */
  67765. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  67766. /**
  67767. * Create a left-handed orthographic projection matrix
  67768. * @param left defines the viewport left coordinate
  67769. * @param right defines the viewport right coordinate
  67770. * @param bottom defines the viewport bottom coordinate
  67771. * @param top defines the viewport top coordinate
  67772. * @param znear defines the near clip plane
  67773. * @param zfar defines the far clip plane
  67774. * @returns a new matrix as a left-handed orthographic projection matrix
  67775. */
  67776. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  67777. /**
  67778. * Stores a left-handed orthographic projection into a given matrix
  67779. * @param left defines the viewport left coordinate
  67780. * @param right defines the viewport right coordinate
  67781. * @param bottom defines the viewport bottom coordinate
  67782. * @param top defines the viewport top coordinate
  67783. * @param znear defines the near clip plane
  67784. * @param zfar defines the far clip plane
  67785. * @param result defines the target matrix
  67786. */
  67787. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  67788. /**
  67789. * Creates a right-handed orthographic projection matrix
  67790. * @param left defines the viewport left coordinate
  67791. * @param right defines the viewport right coordinate
  67792. * @param bottom defines the viewport bottom coordinate
  67793. * @param top defines the viewport top coordinate
  67794. * @param znear defines the near clip plane
  67795. * @param zfar defines the far clip plane
  67796. * @returns a new matrix as a right-handed orthographic projection matrix
  67797. */
  67798. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  67799. /**
  67800. * Stores a right-handed orthographic projection into a given matrix
  67801. * @param left defines the viewport left coordinate
  67802. * @param right defines the viewport right coordinate
  67803. * @param bottom defines the viewport bottom coordinate
  67804. * @param top defines the viewport top coordinate
  67805. * @param znear defines the near clip plane
  67806. * @param zfar defines the far clip plane
  67807. * @param result defines the target matrix
  67808. */
  67809. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  67810. /**
  67811. * Creates a left-handed perspective projection matrix
  67812. * @param width defines the viewport width
  67813. * @param height defines the viewport height
  67814. * @param znear defines the near clip plane
  67815. * @param zfar defines the far clip plane
  67816. * @returns a new matrix as a left-handed perspective projection matrix
  67817. */
  67818. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  67819. /**
  67820. * Creates a left-handed perspective projection matrix
  67821. * @param fov defines the horizontal field of view
  67822. * @param aspect defines the aspect ratio
  67823. * @param znear defines the near clip plane
  67824. * @param zfar defines the far clip plane
  67825. * @returns a new matrix as a left-handed perspective projection matrix
  67826. */
  67827. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  67828. /**
  67829. * Stores a left-handed perspective projection into a given matrix
  67830. * @param fov defines the horizontal field of view
  67831. * @param aspect defines the aspect ratio
  67832. * @param znear defines the near clip plane
  67833. * @param zfar defines the far clip plane
  67834. * @param result defines the target matrix
  67835. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  67836. */
  67837. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  67838. /**
  67839. * Creates a right-handed perspective projection matrix
  67840. * @param fov defines the horizontal field of view
  67841. * @param aspect defines the aspect ratio
  67842. * @param znear defines the near clip plane
  67843. * @param zfar defines the far clip plane
  67844. * @returns a new matrix as a right-handed perspective projection matrix
  67845. */
  67846. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  67847. /**
  67848. * Stores a right-handed perspective projection into a given matrix
  67849. * @param fov defines the horizontal field of view
  67850. * @param aspect defines the aspect ratio
  67851. * @param znear defines the near clip plane
  67852. * @param zfar defines the far clip plane
  67853. * @param result defines the target matrix
  67854. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  67855. */
  67856. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  67857. /**
  67858. * Stores a perspective projection for WebVR info a given matrix
  67859. * @param fov defines the field of view
  67860. * @param znear defines the near clip plane
  67861. * @param zfar defines the far clip plane
  67862. * @param result defines the target matrix
  67863. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  67864. */
  67865. static PerspectiveFovWebVRToRef(fov: {
  67866. upDegrees: number;
  67867. downDegrees: number;
  67868. leftDegrees: number;
  67869. rightDegrees: number;
  67870. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  67871. /**
  67872. * Computes a complete transformation matrix
  67873. * @param viewport defines the viewport to use
  67874. * @param world defines the world matrix
  67875. * @param view defines the view matrix
  67876. * @param projection defines the projection matrix
  67877. * @param zmin defines the near clip plane
  67878. * @param zmax defines the far clip plane
  67879. * @returns the transformation matrix
  67880. */
  67881. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  67882. /**
  67883. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  67884. * @param matrix defines the matrix to use
  67885. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  67886. */
  67887. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  67888. /**
  67889. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  67890. * @param matrix defines the matrix to use
  67891. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  67892. */
  67893. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  67894. /**
  67895. * Compute the transpose of a given matrix
  67896. * @param matrix defines the matrix to transpose
  67897. * @returns the new matrix
  67898. */
  67899. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  67900. /**
  67901. * Compute the transpose of a matrix and store it in a target matrix
  67902. * @param matrix defines the matrix to transpose
  67903. * @param result defines the target matrix
  67904. */
  67905. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  67906. /**
  67907. * Computes a reflection matrix from a plane
  67908. * @param plane defines the reflection plane
  67909. * @returns a new matrix
  67910. */
  67911. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  67912. /**
  67913. * Computes a reflection matrix from a plane
  67914. * @param plane defines the reflection plane
  67915. * @param result defines the target matrix
  67916. */
  67917. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  67918. /**
  67919. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  67920. * @param xaxis defines the value of the 1st axis
  67921. * @param yaxis defines the value of the 2nd axis
  67922. * @param zaxis defines the value of the 3rd axis
  67923. * @param result defines the target matrix
  67924. */
  67925. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  67926. /**
  67927. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  67928. * @param quat defines the quaternion to use
  67929. * @param result defines the target matrix
  67930. */
  67931. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  67932. }
  67933. /**
  67934. * @hidden
  67935. */
  67936. export class TmpVectors {
  67937. static Vector2: Vector2[];
  67938. static Vector3: Vector3[];
  67939. static Vector4: Vector4[];
  67940. static Quaternion: Quaternion[];
  67941. static Matrix: Matrix[];
  67942. }
  67943. }
  67944. declare module BABYLON {
  67945. /** Defines the cross module used constants to avoid circular dependncies */
  67946. export class Constants {
  67947. /** Defines that alpha blending is disabled */
  67948. static readonly ALPHA_DISABLE: number;
  67949. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  67950. static readonly ALPHA_ADD: number;
  67951. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  67952. static readonly ALPHA_COMBINE: number;
  67953. /** Defines that alpha blending to DEST - SRC * DEST */
  67954. static readonly ALPHA_SUBTRACT: number;
  67955. /** Defines that alpha blending to SRC * DEST */
  67956. static readonly ALPHA_MULTIPLY: number;
  67957. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  67958. static readonly ALPHA_MAXIMIZED: number;
  67959. /** Defines that alpha blending to SRC + DEST */
  67960. static readonly ALPHA_ONEONE: number;
  67961. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  67962. static readonly ALPHA_PREMULTIPLIED: number;
  67963. /**
  67964. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  67965. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  67966. */
  67967. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  67968. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  67969. static readonly ALPHA_INTERPOLATE: number;
  67970. /**
  67971. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  67972. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  67973. */
  67974. static readonly ALPHA_SCREENMODE: number;
  67975. /** Defines that the ressource is not delayed*/
  67976. static readonly DELAYLOADSTATE_NONE: number;
  67977. /** Defines that the ressource was successfully delay loaded */
  67978. static readonly DELAYLOADSTATE_LOADED: number;
  67979. /** Defines that the ressource is currently delay loading */
  67980. static readonly DELAYLOADSTATE_LOADING: number;
  67981. /** Defines that the ressource is delayed and has not started loading */
  67982. static readonly DELAYLOADSTATE_NOTLOADED: number;
  67983. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  67984. static readonly NEVER: number;
  67985. /** 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 */
  67986. static readonly ALWAYS: number;
  67987. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  67988. static readonly LESS: number;
  67989. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  67990. static readonly EQUAL: number;
  67991. /** 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 */
  67992. static readonly LEQUAL: number;
  67993. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  67994. static readonly GREATER: number;
  67995. /** 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 */
  67996. static readonly GEQUAL: number;
  67997. /** 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 */
  67998. static readonly NOTEQUAL: number;
  67999. /** Passed to stencilOperation to specify that stencil value must be kept */
  68000. static readonly KEEP: number;
  68001. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68002. static readonly REPLACE: number;
  68003. /** Passed to stencilOperation to specify that stencil value must be incremented */
  68004. static readonly INCR: number;
  68005. /** Passed to stencilOperation to specify that stencil value must be decremented */
  68006. static readonly DECR: number;
  68007. /** Passed to stencilOperation to specify that stencil value must be inverted */
  68008. static readonly INVERT: number;
  68009. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  68010. static readonly INCR_WRAP: number;
  68011. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  68012. static readonly DECR_WRAP: number;
  68013. /** Texture is not repeating outside of 0..1 UVs */
  68014. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  68015. /** Texture is repeating outside of 0..1 UVs */
  68016. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  68017. /** Texture is repeating and mirrored */
  68018. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  68019. /** ALPHA */
  68020. static readonly TEXTUREFORMAT_ALPHA: number;
  68021. /** LUMINANCE */
  68022. static readonly TEXTUREFORMAT_LUMINANCE: number;
  68023. /** LUMINANCE_ALPHA */
  68024. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  68025. /** RGB */
  68026. static readonly TEXTUREFORMAT_RGB: number;
  68027. /** RGBA */
  68028. static readonly TEXTUREFORMAT_RGBA: number;
  68029. /** RED */
  68030. static readonly TEXTUREFORMAT_RED: number;
  68031. /** RED (2nd reference) */
  68032. static readonly TEXTUREFORMAT_R: number;
  68033. /** RG */
  68034. static readonly TEXTUREFORMAT_RG: number;
  68035. /** RED_INTEGER */
  68036. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  68037. /** RED_INTEGER (2nd reference) */
  68038. static readonly TEXTUREFORMAT_R_INTEGER: number;
  68039. /** RG_INTEGER */
  68040. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  68041. /** RGB_INTEGER */
  68042. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  68043. /** RGBA_INTEGER */
  68044. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  68045. /** UNSIGNED_BYTE */
  68046. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  68047. /** UNSIGNED_BYTE (2nd reference) */
  68048. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  68049. /** FLOAT */
  68050. static readonly TEXTURETYPE_FLOAT: number;
  68051. /** HALF_FLOAT */
  68052. static readonly TEXTURETYPE_HALF_FLOAT: number;
  68053. /** BYTE */
  68054. static readonly TEXTURETYPE_BYTE: number;
  68055. /** SHORT */
  68056. static readonly TEXTURETYPE_SHORT: number;
  68057. /** UNSIGNED_SHORT */
  68058. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  68059. /** INT */
  68060. static readonly TEXTURETYPE_INT: number;
  68061. /** UNSIGNED_INT */
  68062. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  68063. /** UNSIGNED_SHORT_4_4_4_4 */
  68064. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  68065. /** UNSIGNED_SHORT_5_5_5_1 */
  68066. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  68067. /** UNSIGNED_SHORT_5_6_5 */
  68068. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  68069. /** UNSIGNED_INT_2_10_10_10_REV */
  68070. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  68071. /** UNSIGNED_INT_24_8 */
  68072. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  68073. /** UNSIGNED_INT_10F_11F_11F_REV */
  68074. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  68075. /** UNSIGNED_INT_5_9_9_9_REV */
  68076. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  68077. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  68078. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  68079. /** nearest is mag = nearest and min = nearest and mip = linear */
  68080. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  68081. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68082. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  68083. /** Trilinear is mag = linear and min = linear and mip = linear */
  68084. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  68085. /** nearest is mag = nearest and min = nearest and mip = linear */
  68086. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  68087. /** Bilinear is mag = linear and min = linear and mip = nearest */
  68088. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  68089. /** Trilinear is mag = linear and min = linear and mip = linear */
  68090. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  68091. /** mag = nearest and min = nearest and mip = nearest */
  68092. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  68093. /** mag = nearest and min = linear and mip = nearest */
  68094. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  68095. /** mag = nearest and min = linear and mip = linear */
  68096. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  68097. /** mag = nearest and min = linear and mip = none */
  68098. static readonly TEXTURE_NEAREST_LINEAR: number;
  68099. /** mag = nearest and min = nearest and mip = none */
  68100. static readonly TEXTURE_NEAREST_NEAREST: number;
  68101. /** mag = linear and min = nearest and mip = nearest */
  68102. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  68103. /** mag = linear and min = nearest and mip = linear */
  68104. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  68105. /** mag = linear and min = linear and mip = none */
  68106. static readonly TEXTURE_LINEAR_LINEAR: number;
  68107. /** mag = linear and min = nearest and mip = none */
  68108. static readonly TEXTURE_LINEAR_NEAREST: number;
  68109. /** Explicit coordinates mode */
  68110. static readonly TEXTURE_EXPLICIT_MODE: number;
  68111. /** Spherical coordinates mode */
  68112. static readonly TEXTURE_SPHERICAL_MODE: number;
  68113. /** Planar coordinates mode */
  68114. static readonly TEXTURE_PLANAR_MODE: number;
  68115. /** Cubic coordinates mode */
  68116. static readonly TEXTURE_CUBIC_MODE: number;
  68117. /** Projection coordinates mode */
  68118. static readonly TEXTURE_PROJECTION_MODE: number;
  68119. /** Skybox coordinates mode */
  68120. static readonly TEXTURE_SKYBOX_MODE: number;
  68121. /** Inverse Cubic coordinates mode */
  68122. static readonly TEXTURE_INVCUBIC_MODE: number;
  68123. /** Equirectangular coordinates mode */
  68124. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  68125. /** Equirectangular Fixed coordinates mode */
  68126. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  68127. /** Equirectangular Fixed Mirrored coordinates mode */
  68128. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  68129. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  68130. static readonly SCALEMODE_FLOOR: number;
  68131. /** Defines that texture rescaling will look for the nearest power of 2 size */
  68132. static readonly SCALEMODE_NEAREST: number;
  68133. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  68134. static readonly SCALEMODE_CEILING: number;
  68135. /**
  68136. * The dirty texture flag value
  68137. */
  68138. static readonly MATERIAL_TextureDirtyFlag: number;
  68139. /**
  68140. * The dirty light flag value
  68141. */
  68142. static readonly MATERIAL_LightDirtyFlag: number;
  68143. /**
  68144. * The dirty fresnel flag value
  68145. */
  68146. static readonly MATERIAL_FresnelDirtyFlag: number;
  68147. /**
  68148. * The dirty attribute flag value
  68149. */
  68150. static readonly MATERIAL_AttributesDirtyFlag: number;
  68151. /**
  68152. * The dirty misc flag value
  68153. */
  68154. static readonly MATERIAL_MiscDirtyFlag: number;
  68155. /**
  68156. * The all dirty flag value
  68157. */
  68158. static readonly MATERIAL_AllDirtyFlag: number;
  68159. /**
  68160. * Returns the triangle fill mode
  68161. */
  68162. static readonly MATERIAL_TriangleFillMode: number;
  68163. /**
  68164. * Returns the wireframe mode
  68165. */
  68166. static readonly MATERIAL_WireFrameFillMode: number;
  68167. /**
  68168. * Returns the point fill mode
  68169. */
  68170. static readonly MATERIAL_PointFillMode: number;
  68171. /**
  68172. * Returns the point list draw mode
  68173. */
  68174. static readonly MATERIAL_PointListDrawMode: number;
  68175. /**
  68176. * Returns the line list draw mode
  68177. */
  68178. static readonly MATERIAL_LineListDrawMode: number;
  68179. /**
  68180. * Returns the line loop draw mode
  68181. */
  68182. static readonly MATERIAL_LineLoopDrawMode: number;
  68183. /**
  68184. * Returns the line strip draw mode
  68185. */
  68186. static readonly MATERIAL_LineStripDrawMode: number;
  68187. /**
  68188. * Returns the triangle strip draw mode
  68189. */
  68190. static readonly MATERIAL_TriangleStripDrawMode: number;
  68191. /**
  68192. * Returns the triangle fan draw mode
  68193. */
  68194. static readonly MATERIAL_TriangleFanDrawMode: number;
  68195. /**
  68196. * Stores the clock-wise side orientation
  68197. */
  68198. static readonly MATERIAL_ClockWiseSideOrientation: number;
  68199. /**
  68200. * Stores the counter clock-wise side orientation
  68201. */
  68202. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  68203. /**
  68204. * Nothing
  68205. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68206. */
  68207. static readonly ACTION_NothingTrigger: number;
  68208. /**
  68209. * On pick
  68210. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68211. */
  68212. static readonly ACTION_OnPickTrigger: number;
  68213. /**
  68214. * On left pick
  68215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68216. */
  68217. static readonly ACTION_OnLeftPickTrigger: number;
  68218. /**
  68219. * On right pick
  68220. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68221. */
  68222. static readonly ACTION_OnRightPickTrigger: number;
  68223. /**
  68224. * On center pick
  68225. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68226. */
  68227. static readonly ACTION_OnCenterPickTrigger: number;
  68228. /**
  68229. * On pick down
  68230. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68231. */
  68232. static readonly ACTION_OnPickDownTrigger: number;
  68233. /**
  68234. * On double pick
  68235. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68236. */
  68237. static readonly ACTION_OnDoublePickTrigger: number;
  68238. /**
  68239. * On pick up
  68240. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68241. */
  68242. static readonly ACTION_OnPickUpTrigger: number;
  68243. /**
  68244. * On pick out.
  68245. * This trigger will only be raised if you also declared a OnPickDown
  68246. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68247. */
  68248. static readonly ACTION_OnPickOutTrigger: number;
  68249. /**
  68250. * On long press
  68251. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68252. */
  68253. static readonly ACTION_OnLongPressTrigger: number;
  68254. /**
  68255. * On pointer over
  68256. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68257. */
  68258. static readonly ACTION_OnPointerOverTrigger: number;
  68259. /**
  68260. * On pointer out
  68261. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68262. */
  68263. static readonly ACTION_OnPointerOutTrigger: number;
  68264. /**
  68265. * On every frame
  68266. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68267. */
  68268. static readonly ACTION_OnEveryFrameTrigger: number;
  68269. /**
  68270. * On intersection enter
  68271. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68272. */
  68273. static readonly ACTION_OnIntersectionEnterTrigger: number;
  68274. /**
  68275. * On intersection exit
  68276. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68277. */
  68278. static readonly ACTION_OnIntersectionExitTrigger: number;
  68279. /**
  68280. * On key down
  68281. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68282. */
  68283. static readonly ACTION_OnKeyDownTrigger: number;
  68284. /**
  68285. * On key up
  68286. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68287. */
  68288. static readonly ACTION_OnKeyUpTrigger: number;
  68289. /**
  68290. * Billboard mode will only apply to Y axis
  68291. */
  68292. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  68293. /**
  68294. * Billboard mode will apply to all axes
  68295. */
  68296. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  68297. /**
  68298. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  68299. */
  68300. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  68301. /**
  68302. * Gets or sets base Assets URL
  68303. */
  68304. static PARTICLES_BaseAssetsUrl: string;
  68305. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  68306. * Test order :
  68307. * Is the bounding sphere outside the frustum ?
  68308. * If not, are the bounding box vertices outside the frustum ?
  68309. * It not, then the cullable object is in the frustum.
  68310. */
  68311. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  68312. /** Culling strategy : Bounding Sphere Only.
  68313. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  68314. * It's also less accurate than the standard because some not visible objects can still be selected.
  68315. * Test : is the bounding sphere outside the frustum ?
  68316. * If not, then the cullable object is in the frustum.
  68317. */
  68318. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  68319. /** Culling strategy : Optimistic Inclusion.
  68320. * This in an inclusion test first, then the standard exclusion test.
  68321. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  68322. * 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.
  68323. * Anyway, it's as accurate as the standard strategy.
  68324. * Test :
  68325. * Is the cullable object bounding sphere center in the frustum ?
  68326. * If not, apply the default culling strategy.
  68327. */
  68328. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  68329. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  68330. * This in an inclusion test first, then the bounding sphere only exclusion test.
  68331. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  68332. * 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.
  68333. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  68334. * Test :
  68335. * Is the cullable object bounding sphere center in the frustum ?
  68336. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  68337. */
  68338. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  68339. /**
  68340. * No logging while loading
  68341. */
  68342. static readonly SCENELOADER_NO_LOGGING: number;
  68343. /**
  68344. * Minimal logging while loading
  68345. */
  68346. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  68347. /**
  68348. * Summary logging while loading
  68349. */
  68350. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  68351. /**
  68352. * Detailled logging while loading
  68353. */
  68354. static readonly SCENELOADER_DETAILED_LOGGING: number;
  68355. }
  68356. }
  68357. declare module BABYLON {
  68358. /**
  68359. * Class used to store and describe the pipeline context associated with an effect
  68360. */
  68361. export interface IPipelineContext {
  68362. /**
  68363. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  68364. */
  68365. isAsync: boolean;
  68366. /**
  68367. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  68368. */
  68369. isReady: boolean;
  68370. /** @hidden */
  68371. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  68372. }
  68373. }
  68374. declare module BABYLON {
  68375. /** @hidden */
  68376. export interface IShaderProcessor {
  68377. attributeProcessor?: (attribute: string) => string;
  68378. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  68379. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  68380. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  68381. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  68382. lineProcessor?: (line: string, isFragment: boolean) => string;
  68383. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68384. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68385. }
  68386. }
  68387. declare module BABYLON {
  68388. /** @hidden */
  68389. export interface ProcessingOptions {
  68390. defines: string[];
  68391. indexParameters: any;
  68392. isFragment: boolean;
  68393. shouldUseHighPrecisionShader: boolean;
  68394. supportsUniformBuffers: boolean;
  68395. shadersRepository: string;
  68396. includesShadersStore: {
  68397. [key: string]: string;
  68398. };
  68399. processor?: IShaderProcessor;
  68400. version: string;
  68401. platformName: string;
  68402. lookForClosingBracketForUniformBuffer?: boolean;
  68403. }
  68404. }
  68405. declare module BABYLON {
  68406. /**
  68407. * Helper to manipulate strings
  68408. */
  68409. export class StringTools {
  68410. /**
  68411. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  68412. * @param str Source string
  68413. * @param suffix Suffix to search for in the source string
  68414. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68415. */
  68416. static EndsWith(str: string, suffix: string): boolean;
  68417. /**
  68418. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  68419. * @param str Source string
  68420. * @param suffix Suffix to search for in the source string
  68421. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68422. */
  68423. static StartsWith(str: string, suffix: string): boolean;
  68424. }
  68425. }
  68426. declare module BABYLON {
  68427. /** @hidden */
  68428. export class ShaderCodeNode {
  68429. line: string;
  68430. children: ShaderCodeNode[];
  68431. additionalDefineKey?: string;
  68432. additionalDefineValue?: string;
  68433. isValid(preprocessors: {
  68434. [key: string]: string;
  68435. }): boolean;
  68436. process(preprocessors: {
  68437. [key: string]: string;
  68438. }, options: ProcessingOptions): string;
  68439. }
  68440. }
  68441. declare module BABYLON {
  68442. /** @hidden */
  68443. export class ShaderCodeCursor {
  68444. private _lines;
  68445. lineIndex: number;
  68446. readonly currentLine: string;
  68447. readonly canRead: boolean;
  68448. lines: string[];
  68449. }
  68450. }
  68451. declare module BABYLON {
  68452. /** @hidden */
  68453. export class ShaderCodeConditionNode extends ShaderCodeNode {
  68454. process(preprocessors: {
  68455. [key: string]: string;
  68456. }, options: ProcessingOptions): string;
  68457. }
  68458. }
  68459. declare module BABYLON {
  68460. /** @hidden */
  68461. export class ShaderDefineExpression {
  68462. isTrue(preprocessors: {
  68463. [key: string]: string;
  68464. }): boolean;
  68465. }
  68466. }
  68467. declare module BABYLON {
  68468. /** @hidden */
  68469. export class ShaderCodeTestNode extends ShaderCodeNode {
  68470. testExpression: ShaderDefineExpression;
  68471. isValid(preprocessors: {
  68472. [key: string]: string;
  68473. }): boolean;
  68474. }
  68475. }
  68476. declare module BABYLON {
  68477. /** @hidden */
  68478. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  68479. define: string;
  68480. not: boolean;
  68481. constructor(define: string, not?: boolean);
  68482. isTrue(preprocessors: {
  68483. [key: string]: string;
  68484. }): boolean;
  68485. }
  68486. }
  68487. declare module BABYLON {
  68488. /** @hidden */
  68489. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68490. leftOperand: ShaderDefineExpression;
  68491. rightOperand: ShaderDefineExpression;
  68492. isTrue(preprocessors: {
  68493. [key: string]: string;
  68494. }): boolean;
  68495. }
  68496. }
  68497. declare module BABYLON {
  68498. /** @hidden */
  68499. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68500. leftOperand: ShaderDefineExpression;
  68501. rightOperand: ShaderDefineExpression;
  68502. isTrue(preprocessors: {
  68503. [key: string]: string;
  68504. }): boolean;
  68505. }
  68506. }
  68507. declare module BABYLON {
  68508. /** @hidden */
  68509. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68510. define: string;
  68511. operand: string;
  68512. testValue: string;
  68513. constructor(define: string, operand: string, testValue: string);
  68514. isTrue(preprocessors: {
  68515. [key: string]: string;
  68516. }): boolean;
  68517. }
  68518. }
  68519. declare module BABYLON {
  68520. /**
  68521. * @ignore
  68522. * Application error to support additional information when loading a file
  68523. */
  68524. export class LoadFileError extends Error {
  68525. /** defines the optional web request */
  68526. request?: WebRequest | undefined;
  68527. private static _setPrototypeOf;
  68528. /**
  68529. * Creates a new LoadFileError
  68530. * @param message defines the message of the error
  68531. * @param request defines the optional web request
  68532. */
  68533. constructor(message: string,
  68534. /** defines the optional web request */
  68535. request?: WebRequest | undefined);
  68536. }
  68537. }
  68538. declare module BABYLON {
  68539. /**
  68540. * Class used to enable access to offline support
  68541. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68542. */
  68543. export interface IOfflineProvider {
  68544. /**
  68545. * Gets a boolean indicating if scene must be saved in the database
  68546. */
  68547. enableSceneOffline: boolean;
  68548. /**
  68549. * Gets a boolean indicating if textures must be saved in the database
  68550. */
  68551. enableTexturesOffline: boolean;
  68552. /**
  68553. * Open the offline support and make it available
  68554. * @param successCallback defines the callback to call on success
  68555. * @param errorCallback defines the callback to call on error
  68556. */
  68557. open(successCallback: () => void, errorCallback: () => void): void;
  68558. /**
  68559. * Loads an image from the offline support
  68560. * @param url defines the url to load from
  68561. * @param image defines the target DOM image
  68562. */
  68563. loadImage(url: string, image: HTMLImageElement): void;
  68564. /**
  68565. * Loads a file from offline support
  68566. * @param url defines the URL to load from
  68567. * @param sceneLoaded defines a callback to call on success
  68568. * @param progressCallBack defines a callback to call when progress changed
  68569. * @param errorCallback defines a callback to call on error
  68570. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68571. */
  68572. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68573. }
  68574. }
  68575. declare module BABYLON {
  68576. /**
  68577. * Class used to help managing file picking and drag'n'drop
  68578. * File Storage
  68579. */
  68580. export class FilesInputStore {
  68581. /**
  68582. * List of files ready to be loaded
  68583. */
  68584. static FilesToLoad: {
  68585. [key: string]: File;
  68586. };
  68587. }
  68588. }
  68589. declare module BABYLON {
  68590. /**
  68591. * Class used to define a retry strategy when error happens while loading assets
  68592. */
  68593. export class RetryStrategy {
  68594. /**
  68595. * Function used to defines an exponential back off strategy
  68596. * @param maxRetries defines the maximum number of retries (3 by default)
  68597. * @param baseInterval defines the interval between retries
  68598. * @returns the strategy function to use
  68599. */
  68600. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  68601. }
  68602. }
  68603. declare module BABYLON {
  68604. /**
  68605. * @hidden
  68606. */
  68607. export class FileTools {
  68608. /**
  68609. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  68610. */
  68611. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  68612. /**
  68613. * Gets or sets the base URL to use to load assets
  68614. */
  68615. static BaseUrl: string;
  68616. /**
  68617. * Default behaviour for cors in the application.
  68618. * It can be a string if the expected behavior is identical in the entire app.
  68619. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  68620. */
  68621. static CorsBehavior: string | ((url: string | string[]) => string);
  68622. /**
  68623. * Gets or sets a function used to pre-process url before using them to load assets
  68624. */
  68625. static PreprocessUrl: (url: string) => string;
  68626. /**
  68627. * Removes unwanted characters from an url
  68628. * @param url defines the url to clean
  68629. * @returns the cleaned url
  68630. */
  68631. private static _CleanUrl;
  68632. /**
  68633. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  68634. * @param url define the url we are trying
  68635. * @param element define the dom element where to configure the cors policy
  68636. */
  68637. static SetCorsBehavior(url: string | string[], element: {
  68638. crossOrigin: string | null;
  68639. }): void;
  68640. /**
  68641. * Loads an image as an HTMLImageElement.
  68642. * @param input url string, ArrayBuffer, or Blob to load
  68643. * @param onLoad callback called when the image successfully loads
  68644. * @param onError callback called when the image fails to load
  68645. * @param offlineProvider offline provider for caching
  68646. * @returns the HTMLImageElement of the loaded image
  68647. */
  68648. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  68649. /**
  68650. * Loads a file
  68651. * @param fileToLoad defines the file to load
  68652. * @param callback defines the callback to call when data is loaded
  68653. * @param progressCallBack defines the callback to call during loading process
  68654. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  68655. * @returns a file request object
  68656. */
  68657. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  68658. /**
  68659. * Loads a file
  68660. * @param url url string, ArrayBuffer, or Blob to load
  68661. * @param onSuccess callback called when the file successfully loads
  68662. * @param onProgress callback called while file is loading (if the server supports this mode)
  68663. * @param offlineProvider defines the offline provider for caching
  68664. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  68665. * @param onError callback called when the file fails to load
  68666. * @returns a file request object
  68667. */
  68668. 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;
  68669. /**
  68670. * Checks if the loaded document was accessed via `file:`-Protocol.
  68671. * @returns boolean
  68672. */
  68673. static IsFileURL(): boolean;
  68674. }
  68675. }
  68676. declare module BABYLON {
  68677. /** @hidden */
  68678. export class ShaderProcessor {
  68679. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68680. private static _ProcessPrecision;
  68681. private static _ExtractOperation;
  68682. private static _BuildSubExpression;
  68683. private static _BuildExpression;
  68684. private static _MoveCursorWithinIf;
  68685. private static _MoveCursor;
  68686. private static _EvaluatePreProcessors;
  68687. private static _PreparePreProcessors;
  68688. private static _ProcessShaderConversion;
  68689. private static _ProcessIncludes;
  68690. }
  68691. }
  68692. declare module BABYLON {
  68693. /**
  68694. * Class used to hold a RBG color
  68695. */
  68696. export class Color3 {
  68697. /**
  68698. * Defines the red component (between 0 and 1, default is 0)
  68699. */
  68700. r: number;
  68701. /**
  68702. * Defines the green component (between 0 and 1, default is 0)
  68703. */
  68704. g: number;
  68705. /**
  68706. * Defines the blue component (between 0 and 1, default is 0)
  68707. */
  68708. b: number;
  68709. /**
  68710. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  68711. * @param r defines the red component (between 0 and 1, default is 0)
  68712. * @param g defines the green component (between 0 and 1, default is 0)
  68713. * @param b defines the blue component (between 0 and 1, default is 0)
  68714. */
  68715. constructor(
  68716. /**
  68717. * Defines the red component (between 0 and 1, default is 0)
  68718. */
  68719. r?: number,
  68720. /**
  68721. * Defines the green component (between 0 and 1, default is 0)
  68722. */
  68723. g?: number,
  68724. /**
  68725. * Defines the blue component (between 0 and 1, default is 0)
  68726. */
  68727. b?: number);
  68728. /**
  68729. * Creates a string with the Color3 current values
  68730. * @returns the string representation of the Color3 object
  68731. */
  68732. toString(): string;
  68733. /**
  68734. * Returns the string "Color3"
  68735. * @returns "Color3"
  68736. */
  68737. getClassName(): string;
  68738. /**
  68739. * Compute the Color3 hash code
  68740. * @returns an unique number that can be used to hash Color3 objects
  68741. */
  68742. getHashCode(): number;
  68743. /**
  68744. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  68745. * @param array defines the array where to store the r,g,b components
  68746. * @param index defines an optional index in the target array to define where to start storing values
  68747. * @returns the current Color3 object
  68748. */
  68749. toArray(array: FloatArray, index?: number): Color3;
  68750. /**
  68751. * Returns a new Color4 object from the current Color3 and the given alpha
  68752. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  68753. * @returns a new Color4 object
  68754. */
  68755. toColor4(alpha?: number): Color4;
  68756. /**
  68757. * Returns a new array populated with 3 numeric elements : red, green and blue values
  68758. * @returns the new array
  68759. */
  68760. asArray(): number[];
  68761. /**
  68762. * Returns the luminance value
  68763. * @returns a float value
  68764. */
  68765. toLuminance(): number;
  68766. /**
  68767. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  68768. * @param otherColor defines the second operand
  68769. * @returns the new Color3 object
  68770. */
  68771. multiply(otherColor: DeepImmutable<Color3>): Color3;
  68772. /**
  68773. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  68774. * @param otherColor defines the second operand
  68775. * @param result defines the Color3 object where to store the result
  68776. * @returns the current Color3
  68777. */
  68778. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  68779. /**
  68780. * Determines equality between Color3 objects
  68781. * @param otherColor defines the second operand
  68782. * @returns true if the rgb values are equal to the given ones
  68783. */
  68784. equals(otherColor: DeepImmutable<Color3>): boolean;
  68785. /**
  68786. * Determines equality between the current Color3 object and a set of r,b,g values
  68787. * @param r defines the red component to check
  68788. * @param g defines the green component to check
  68789. * @param b defines the blue component to check
  68790. * @returns true if the rgb values are equal to the given ones
  68791. */
  68792. equalsFloats(r: number, g: number, b: number): boolean;
  68793. /**
  68794. * Multiplies in place each rgb value by scale
  68795. * @param scale defines the scaling factor
  68796. * @returns the updated Color3
  68797. */
  68798. scale(scale: number): Color3;
  68799. /**
  68800. * Multiplies the rgb values by scale and stores the result into "result"
  68801. * @param scale defines the scaling factor
  68802. * @param result defines the Color3 object where to store the result
  68803. * @returns the unmodified current Color3
  68804. */
  68805. scaleToRef(scale: number, result: Color3): Color3;
  68806. /**
  68807. * Scale the current Color3 values by a factor and add the result to a given Color3
  68808. * @param scale defines the scale factor
  68809. * @param result defines color to store the result into
  68810. * @returns the unmodified current Color3
  68811. */
  68812. scaleAndAddToRef(scale: number, result: Color3): Color3;
  68813. /**
  68814. * Clamps the rgb values by the min and max values and stores the result into "result"
  68815. * @param min defines minimum clamping value (default is 0)
  68816. * @param max defines maximum clamping value (default is 1)
  68817. * @param result defines color to store the result into
  68818. * @returns the original Color3
  68819. */
  68820. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  68821. /**
  68822. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  68823. * @param otherColor defines the second operand
  68824. * @returns the new Color3
  68825. */
  68826. add(otherColor: DeepImmutable<Color3>): Color3;
  68827. /**
  68828. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  68829. * @param otherColor defines the second operand
  68830. * @param result defines Color3 object to store the result into
  68831. * @returns the unmodified current Color3
  68832. */
  68833. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  68834. /**
  68835. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  68836. * @param otherColor defines the second operand
  68837. * @returns the new Color3
  68838. */
  68839. subtract(otherColor: DeepImmutable<Color3>): Color3;
  68840. /**
  68841. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  68842. * @param otherColor defines the second operand
  68843. * @param result defines Color3 object to store the result into
  68844. * @returns the unmodified current Color3
  68845. */
  68846. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  68847. /**
  68848. * Copy the current object
  68849. * @returns a new Color3 copied the current one
  68850. */
  68851. clone(): Color3;
  68852. /**
  68853. * Copies the rgb values from the source in the current Color3
  68854. * @param source defines the source Color3 object
  68855. * @returns the updated Color3 object
  68856. */
  68857. copyFrom(source: DeepImmutable<Color3>): Color3;
  68858. /**
  68859. * Updates the Color3 rgb values from the given floats
  68860. * @param r defines the red component to read from
  68861. * @param g defines the green component to read from
  68862. * @param b defines the blue component to read from
  68863. * @returns the current Color3 object
  68864. */
  68865. copyFromFloats(r: number, g: number, b: number): Color3;
  68866. /**
  68867. * Updates the Color3 rgb values from the given floats
  68868. * @param r defines the red component to read from
  68869. * @param g defines the green component to read from
  68870. * @param b defines the blue component to read from
  68871. * @returns the current Color3 object
  68872. */
  68873. set(r: number, g: number, b: number): Color3;
  68874. /**
  68875. * Compute the Color3 hexadecimal code as a string
  68876. * @returns a string containing the hexadecimal representation of the Color3 object
  68877. */
  68878. toHexString(): string;
  68879. /**
  68880. * Computes a new Color3 converted from the current one to linear space
  68881. * @returns a new Color3 object
  68882. */
  68883. toLinearSpace(): Color3;
  68884. /**
  68885. * Converts current color in rgb space to HSV values
  68886. * @returns a new color3 representing the HSV values
  68887. */
  68888. toHSV(): Color3;
  68889. /**
  68890. * Converts current color in rgb space to HSV values
  68891. * @param result defines the Color3 where to store the HSV values
  68892. */
  68893. toHSVToRef(result: Color3): void;
  68894. /**
  68895. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  68896. * @param convertedColor defines the Color3 object where to store the linear space version
  68897. * @returns the unmodified Color3
  68898. */
  68899. toLinearSpaceToRef(convertedColor: Color3): Color3;
  68900. /**
  68901. * Computes a new Color3 converted from the current one to gamma space
  68902. * @returns a new Color3 object
  68903. */
  68904. toGammaSpace(): Color3;
  68905. /**
  68906. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  68907. * @param convertedColor defines the Color3 object where to store the gamma space version
  68908. * @returns the unmodified Color3
  68909. */
  68910. toGammaSpaceToRef(convertedColor: Color3): Color3;
  68911. private static _BlackReadOnly;
  68912. /**
  68913. * Convert Hue, saturation and value to a Color3 (RGB)
  68914. * @param hue defines the hue
  68915. * @param saturation defines the saturation
  68916. * @param value defines the value
  68917. * @param result defines the Color3 where to store the RGB values
  68918. */
  68919. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  68920. /**
  68921. * Creates a new Color3 from the string containing valid hexadecimal values
  68922. * @param hex defines a string containing valid hexadecimal values
  68923. * @returns a new Color3 object
  68924. */
  68925. static FromHexString(hex: string): Color3;
  68926. /**
  68927. * Creates a new Color3 from the starting index of the given array
  68928. * @param array defines the source array
  68929. * @param offset defines an offset in the source array
  68930. * @returns a new Color3 object
  68931. */
  68932. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  68933. /**
  68934. * Creates a new Color3 from integer values (< 256)
  68935. * @param r defines the red component to read from (value between 0 and 255)
  68936. * @param g defines the green component to read from (value between 0 and 255)
  68937. * @param b defines the blue component to read from (value between 0 and 255)
  68938. * @returns a new Color3 object
  68939. */
  68940. static FromInts(r: number, g: number, b: number): Color3;
  68941. /**
  68942. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  68943. * @param start defines the start Color3 value
  68944. * @param end defines the end Color3 value
  68945. * @param amount defines the gradient value between start and end
  68946. * @returns a new Color3 object
  68947. */
  68948. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  68949. /**
  68950. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  68951. * @param left defines the start value
  68952. * @param right defines the end value
  68953. * @param amount defines the gradient factor
  68954. * @param result defines the Color3 object where to store the result
  68955. */
  68956. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  68957. /**
  68958. * Returns a Color3 value containing a red color
  68959. * @returns a new Color3 object
  68960. */
  68961. static Red(): Color3;
  68962. /**
  68963. * Returns a Color3 value containing a green color
  68964. * @returns a new Color3 object
  68965. */
  68966. static Green(): Color3;
  68967. /**
  68968. * Returns a Color3 value containing a blue color
  68969. * @returns a new Color3 object
  68970. */
  68971. static Blue(): Color3;
  68972. /**
  68973. * Returns a Color3 value containing a black color
  68974. * @returns a new Color3 object
  68975. */
  68976. static Black(): Color3;
  68977. /**
  68978. * Gets a Color3 value containing a black color that must not be updated
  68979. */
  68980. static readonly BlackReadOnly: DeepImmutable<Color3>;
  68981. /**
  68982. * Returns a Color3 value containing a white color
  68983. * @returns a new Color3 object
  68984. */
  68985. static White(): Color3;
  68986. /**
  68987. * Returns a Color3 value containing a purple color
  68988. * @returns a new Color3 object
  68989. */
  68990. static Purple(): Color3;
  68991. /**
  68992. * Returns a Color3 value containing a magenta color
  68993. * @returns a new Color3 object
  68994. */
  68995. static Magenta(): Color3;
  68996. /**
  68997. * Returns a Color3 value containing a yellow color
  68998. * @returns a new Color3 object
  68999. */
  69000. static Yellow(): Color3;
  69001. /**
  69002. * Returns a Color3 value containing a gray color
  69003. * @returns a new Color3 object
  69004. */
  69005. static Gray(): Color3;
  69006. /**
  69007. * Returns a Color3 value containing a teal color
  69008. * @returns a new Color3 object
  69009. */
  69010. static Teal(): Color3;
  69011. /**
  69012. * Returns a Color3 value containing a random color
  69013. * @returns a new Color3 object
  69014. */
  69015. static Random(): Color3;
  69016. }
  69017. /**
  69018. * Class used to hold a RBGA color
  69019. */
  69020. export class Color4 {
  69021. /**
  69022. * Defines the red component (between 0 and 1, default is 0)
  69023. */
  69024. r: number;
  69025. /**
  69026. * Defines the green component (between 0 and 1, default is 0)
  69027. */
  69028. g: number;
  69029. /**
  69030. * Defines the blue component (between 0 and 1, default is 0)
  69031. */
  69032. b: number;
  69033. /**
  69034. * Defines the alpha component (between 0 and 1, default is 1)
  69035. */
  69036. a: number;
  69037. /**
  69038. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  69039. * @param r defines the red component (between 0 and 1, default is 0)
  69040. * @param g defines the green component (between 0 and 1, default is 0)
  69041. * @param b defines the blue component (between 0 and 1, default is 0)
  69042. * @param a defines the alpha component (between 0 and 1, default is 1)
  69043. */
  69044. constructor(
  69045. /**
  69046. * Defines the red component (between 0 and 1, default is 0)
  69047. */
  69048. r?: number,
  69049. /**
  69050. * Defines the green component (between 0 and 1, default is 0)
  69051. */
  69052. g?: number,
  69053. /**
  69054. * Defines the blue component (between 0 and 1, default is 0)
  69055. */
  69056. b?: number,
  69057. /**
  69058. * Defines the alpha component (between 0 and 1, default is 1)
  69059. */
  69060. a?: number);
  69061. /**
  69062. * Adds in place the given Color4 values to the current Color4 object
  69063. * @param right defines the second operand
  69064. * @returns the current updated Color4 object
  69065. */
  69066. addInPlace(right: DeepImmutable<Color4>): Color4;
  69067. /**
  69068. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  69069. * @returns the new array
  69070. */
  69071. asArray(): number[];
  69072. /**
  69073. * Stores from the starting index in the given array the Color4 successive values
  69074. * @param array defines the array where to store the r,g,b components
  69075. * @param index defines an optional index in the target array to define where to start storing values
  69076. * @returns the current Color4 object
  69077. */
  69078. toArray(array: number[], index?: number): Color4;
  69079. /**
  69080. * Determines equality between Color4 objects
  69081. * @param otherColor defines the second operand
  69082. * @returns true if the rgba values are equal to the given ones
  69083. */
  69084. equals(otherColor: DeepImmutable<Color4>): boolean;
  69085. /**
  69086. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  69087. * @param right defines the second operand
  69088. * @returns a new Color4 object
  69089. */
  69090. add(right: DeepImmutable<Color4>): Color4;
  69091. /**
  69092. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  69093. * @param right defines the second operand
  69094. * @returns a new Color4 object
  69095. */
  69096. subtract(right: DeepImmutable<Color4>): Color4;
  69097. /**
  69098. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  69099. * @param right defines the second operand
  69100. * @param result defines the Color4 object where to store the result
  69101. * @returns the current Color4 object
  69102. */
  69103. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  69104. /**
  69105. * Creates a new Color4 with the current Color4 values multiplied by scale
  69106. * @param scale defines the scaling factor to apply
  69107. * @returns a new Color4 object
  69108. */
  69109. scale(scale: number): Color4;
  69110. /**
  69111. * Multiplies the current Color4 values by scale and stores the result in "result"
  69112. * @param scale defines the scaling factor to apply
  69113. * @param result defines the Color4 object where to store the result
  69114. * @returns the current unmodified Color4
  69115. */
  69116. scaleToRef(scale: number, result: Color4): Color4;
  69117. /**
  69118. * Scale the current Color4 values by a factor and add the result to a given Color4
  69119. * @param scale defines the scale factor
  69120. * @param result defines the Color4 object where to store the result
  69121. * @returns the unmodified current Color4
  69122. */
  69123. scaleAndAddToRef(scale: number, result: Color4): Color4;
  69124. /**
  69125. * Clamps the rgb values by the min and max values and stores the result into "result"
  69126. * @param min defines minimum clamping value (default is 0)
  69127. * @param max defines maximum clamping value (default is 1)
  69128. * @param result defines color to store the result into.
  69129. * @returns the cuurent Color4
  69130. */
  69131. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  69132. /**
  69133. * Multipy an Color4 value by another and return a new Color4 object
  69134. * @param color defines the Color4 value to multiply by
  69135. * @returns a new Color4 object
  69136. */
  69137. multiply(color: Color4): Color4;
  69138. /**
  69139. * Multipy a Color4 value by another and push the result in a reference value
  69140. * @param color defines the Color4 value to multiply by
  69141. * @param result defines the Color4 to fill the result in
  69142. * @returns the result Color4
  69143. */
  69144. multiplyToRef(color: Color4, result: Color4): Color4;
  69145. /**
  69146. * Creates a string with the Color4 current values
  69147. * @returns the string representation of the Color4 object
  69148. */
  69149. toString(): string;
  69150. /**
  69151. * Returns the string "Color4"
  69152. * @returns "Color4"
  69153. */
  69154. getClassName(): string;
  69155. /**
  69156. * Compute the Color4 hash code
  69157. * @returns an unique number that can be used to hash Color4 objects
  69158. */
  69159. getHashCode(): number;
  69160. /**
  69161. * Creates a new Color4 copied from the current one
  69162. * @returns a new Color4 object
  69163. */
  69164. clone(): Color4;
  69165. /**
  69166. * Copies the given Color4 values into the current one
  69167. * @param source defines the source Color4 object
  69168. * @returns the current updated Color4 object
  69169. */
  69170. copyFrom(source: Color4): Color4;
  69171. /**
  69172. * Copies the given float values into the current one
  69173. * @param r defines the red component to read from
  69174. * @param g defines the green component to read from
  69175. * @param b defines the blue component to read from
  69176. * @param a defines the alpha component to read from
  69177. * @returns the current updated Color4 object
  69178. */
  69179. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  69180. /**
  69181. * Copies the given float values into the current one
  69182. * @param r defines the red component to read from
  69183. * @param g defines the green component to read from
  69184. * @param b defines the blue component to read from
  69185. * @param a defines the alpha component to read from
  69186. * @returns the current updated Color4 object
  69187. */
  69188. set(r: number, g: number, b: number, a: number): Color4;
  69189. /**
  69190. * Compute the Color4 hexadecimal code as a string
  69191. * @returns a string containing the hexadecimal representation of the Color4 object
  69192. */
  69193. toHexString(): string;
  69194. /**
  69195. * Computes a new Color4 converted from the current one to linear space
  69196. * @returns a new Color4 object
  69197. */
  69198. toLinearSpace(): Color4;
  69199. /**
  69200. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  69201. * @param convertedColor defines the Color4 object where to store the linear space version
  69202. * @returns the unmodified Color4
  69203. */
  69204. toLinearSpaceToRef(convertedColor: Color4): Color4;
  69205. /**
  69206. * Computes a new Color4 converted from the current one to gamma space
  69207. * @returns a new Color4 object
  69208. */
  69209. toGammaSpace(): Color4;
  69210. /**
  69211. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  69212. * @param convertedColor defines the Color4 object where to store the gamma space version
  69213. * @returns the unmodified Color4
  69214. */
  69215. toGammaSpaceToRef(convertedColor: Color4): Color4;
  69216. /**
  69217. * Creates a new Color4 from the string containing valid hexadecimal values
  69218. * @param hex defines a string containing valid hexadecimal values
  69219. * @returns a new Color4 object
  69220. */
  69221. static FromHexString(hex: string): Color4;
  69222. /**
  69223. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  69224. * @param left defines the start value
  69225. * @param right defines the end value
  69226. * @param amount defines the gradient factor
  69227. * @returns a new Color4 object
  69228. */
  69229. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  69230. /**
  69231. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  69232. * @param left defines the start value
  69233. * @param right defines the end value
  69234. * @param amount defines the gradient factor
  69235. * @param result defines the Color4 object where to store data
  69236. */
  69237. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  69238. /**
  69239. * Creates a new Color4 from a Color3 and an alpha value
  69240. * @param color3 defines the source Color3 to read from
  69241. * @param alpha defines the alpha component (1.0 by default)
  69242. * @returns a new Color4 object
  69243. */
  69244. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  69245. /**
  69246. * Creates a new Color4 from the starting index element of the given array
  69247. * @param array defines the source array to read from
  69248. * @param offset defines the offset in the source array
  69249. * @returns a new Color4 object
  69250. */
  69251. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  69252. /**
  69253. * Creates a new Color3 from integer values (< 256)
  69254. * @param r defines the red component to read from (value between 0 and 255)
  69255. * @param g defines the green component to read from (value between 0 and 255)
  69256. * @param b defines the blue component to read from (value between 0 and 255)
  69257. * @param a defines the alpha component to read from (value between 0 and 255)
  69258. * @returns a new Color3 object
  69259. */
  69260. static FromInts(r: number, g: number, b: number, a: number): Color4;
  69261. /**
  69262. * Check the content of a given array and convert it to an array containing RGBA data
  69263. * If the original array was already containing count * 4 values then it is returned directly
  69264. * @param colors defines the array to check
  69265. * @param count defines the number of RGBA data to expect
  69266. * @returns an array containing count * 4 values (RGBA)
  69267. */
  69268. static CheckColors4(colors: number[], count: number): number[];
  69269. }
  69270. /**
  69271. * @hidden
  69272. */
  69273. export class TmpColors {
  69274. static Color3: Color3[];
  69275. static Color4: Color4[];
  69276. }
  69277. }
  69278. declare module BABYLON {
  69279. /**
  69280. * Class representing spherical harmonics coefficients to the 3rd degree
  69281. */
  69282. export class SphericalHarmonics {
  69283. /**
  69284. * Defines whether or not the harmonics have been prescaled for rendering.
  69285. */
  69286. preScaled: boolean;
  69287. /**
  69288. * The l0,0 coefficients of the spherical harmonics
  69289. */
  69290. l00: Vector3;
  69291. /**
  69292. * The l1,-1 coefficients of the spherical harmonics
  69293. */
  69294. l1_1: Vector3;
  69295. /**
  69296. * The l1,0 coefficients of the spherical harmonics
  69297. */
  69298. l10: Vector3;
  69299. /**
  69300. * The l1,1 coefficients of the spherical harmonics
  69301. */
  69302. l11: Vector3;
  69303. /**
  69304. * The l2,-2 coefficients of the spherical harmonics
  69305. */
  69306. l2_2: Vector3;
  69307. /**
  69308. * The l2,-1 coefficients of the spherical harmonics
  69309. */
  69310. l2_1: Vector3;
  69311. /**
  69312. * The l2,0 coefficients of the spherical harmonics
  69313. */
  69314. l20: Vector3;
  69315. /**
  69316. * The l2,1 coefficients of the spherical harmonics
  69317. */
  69318. l21: Vector3;
  69319. /**
  69320. * The l2,2 coefficients of the spherical harmonics
  69321. */
  69322. l22: Vector3;
  69323. /**
  69324. * Adds a light to the spherical harmonics
  69325. * @param direction the direction of the light
  69326. * @param color the color of the light
  69327. * @param deltaSolidAngle the delta solid angle of the light
  69328. */
  69329. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  69330. /**
  69331. * Scales the spherical harmonics by the given amount
  69332. * @param scale the amount to scale
  69333. */
  69334. scaleInPlace(scale: number): void;
  69335. /**
  69336. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  69337. *
  69338. * ```
  69339. * E_lm = A_l * L_lm
  69340. * ```
  69341. *
  69342. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  69343. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  69344. * the scaling factors are given in equation 9.
  69345. */
  69346. convertIncidentRadianceToIrradiance(): void;
  69347. /**
  69348. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  69349. *
  69350. * ```
  69351. * L = (1/pi) * E * rho
  69352. * ```
  69353. *
  69354. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  69355. */
  69356. convertIrradianceToLambertianRadiance(): void;
  69357. /**
  69358. * Integrates the reconstruction coefficients directly in to the SH preventing further
  69359. * required operations at run time.
  69360. *
  69361. * This is simply done by scaling back the SH with Ylm constants parameter.
  69362. * The trigonometric part being applied by the shader at run time.
  69363. */
  69364. preScaleForRendering(): void;
  69365. /**
  69366. * Constructs a spherical harmonics from an array.
  69367. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  69368. * @returns the spherical harmonics
  69369. */
  69370. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  69371. /**
  69372. * Gets the spherical harmonics from polynomial
  69373. * @param polynomial the spherical polynomial
  69374. * @returns the spherical harmonics
  69375. */
  69376. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  69377. }
  69378. /**
  69379. * Class representing spherical polynomial coefficients to the 3rd degree
  69380. */
  69381. export class SphericalPolynomial {
  69382. private _harmonics;
  69383. /**
  69384. * The spherical harmonics used to create the polynomials.
  69385. */
  69386. readonly preScaledHarmonics: SphericalHarmonics;
  69387. /**
  69388. * The x coefficients of the spherical polynomial
  69389. */
  69390. x: Vector3;
  69391. /**
  69392. * The y coefficients of the spherical polynomial
  69393. */
  69394. y: Vector3;
  69395. /**
  69396. * The z coefficients of the spherical polynomial
  69397. */
  69398. z: Vector3;
  69399. /**
  69400. * The xx coefficients of the spherical polynomial
  69401. */
  69402. xx: Vector3;
  69403. /**
  69404. * The yy coefficients of the spherical polynomial
  69405. */
  69406. yy: Vector3;
  69407. /**
  69408. * The zz coefficients of the spherical polynomial
  69409. */
  69410. zz: Vector3;
  69411. /**
  69412. * The xy coefficients of the spherical polynomial
  69413. */
  69414. xy: Vector3;
  69415. /**
  69416. * The yz coefficients of the spherical polynomial
  69417. */
  69418. yz: Vector3;
  69419. /**
  69420. * The zx coefficients of the spherical polynomial
  69421. */
  69422. zx: Vector3;
  69423. /**
  69424. * Adds an ambient color to the spherical polynomial
  69425. * @param color the color to add
  69426. */
  69427. addAmbient(color: Color3): void;
  69428. /**
  69429. * Scales the spherical polynomial by the given amount
  69430. * @param scale the amount to scale
  69431. */
  69432. scaleInPlace(scale: number): void;
  69433. /**
  69434. * Gets the spherical polynomial from harmonics
  69435. * @param harmonics the spherical harmonics
  69436. * @returns the spherical polynomial
  69437. */
  69438. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  69439. /**
  69440. * Constructs a spherical polynomial from an array.
  69441. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  69442. * @returns the spherical polynomial
  69443. */
  69444. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  69445. }
  69446. }
  69447. declare module BABYLON {
  69448. /**
  69449. * Define options used to create a render target texture
  69450. */
  69451. export class RenderTargetCreationOptions {
  69452. /**
  69453. * Specifies is mipmaps must be generated
  69454. */
  69455. generateMipMaps?: boolean;
  69456. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  69457. generateDepthBuffer?: boolean;
  69458. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  69459. generateStencilBuffer?: boolean;
  69460. /** Defines texture type (int by default) */
  69461. type?: number;
  69462. /** Defines sampling mode (trilinear by default) */
  69463. samplingMode?: number;
  69464. /** Defines format (RGBA by default) */
  69465. format?: number;
  69466. }
  69467. }
  69468. declare module BABYLON {
  69469. /**
  69470. * @hidden
  69471. **/
  69472. export class _AlphaState {
  69473. private _isAlphaBlendDirty;
  69474. private _isBlendFunctionParametersDirty;
  69475. private _isBlendEquationParametersDirty;
  69476. private _isBlendConstantsDirty;
  69477. private _alphaBlend;
  69478. private _blendFunctionParameters;
  69479. private _blendEquationParameters;
  69480. private _blendConstants;
  69481. /**
  69482. * Initializes the state.
  69483. */
  69484. constructor();
  69485. readonly isDirty: boolean;
  69486. alphaBlend: boolean;
  69487. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  69488. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  69489. setAlphaEquationParameters(rgb: number, alpha: number): void;
  69490. reset(): void;
  69491. apply(gl: WebGLRenderingContext): void;
  69492. }
  69493. }
  69494. declare module BABYLON {
  69495. /**
  69496. * @hidden
  69497. **/
  69498. export class _DepthCullingState {
  69499. private _isDepthTestDirty;
  69500. private _isDepthMaskDirty;
  69501. private _isDepthFuncDirty;
  69502. private _isCullFaceDirty;
  69503. private _isCullDirty;
  69504. private _isZOffsetDirty;
  69505. private _isFrontFaceDirty;
  69506. private _depthTest;
  69507. private _depthMask;
  69508. private _depthFunc;
  69509. private _cull;
  69510. private _cullFace;
  69511. private _zOffset;
  69512. private _frontFace;
  69513. /**
  69514. * Initializes the state.
  69515. */
  69516. constructor();
  69517. readonly isDirty: boolean;
  69518. zOffset: number;
  69519. cullFace: Nullable<number>;
  69520. cull: Nullable<boolean>;
  69521. depthFunc: Nullable<number>;
  69522. depthMask: boolean;
  69523. depthTest: boolean;
  69524. frontFace: Nullable<number>;
  69525. reset(): void;
  69526. apply(gl: WebGLRenderingContext): void;
  69527. }
  69528. }
  69529. declare module BABYLON {
  69530. /**
  69531. * @hidden
  69532. **/
  69533. export class _StencilState {
  69534. /** 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 */
  69535. static readonly ALWAYS: number;
  69536. /** Passed to stencilOperation to specify that stencil value must be kept */
  69537. static readonly KEEP: number;
  69538. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69539. static readonly REPLACE: number;
  69540. private _isStencilTestDirty;
  69541. private _isStencilMaskDirty;
  69542. private _isStencilFuncDirty;
  69543. private _isStencilOpDirty;
  69544. private _stencilTest;
  69545. private _stencilMask;
  69546. private _stencilFunc;
  69547. private _stencilFuncRef;
  69548. private _stencilFuncMask;
  69549. private _stencilOpStencilFail;
  69550. private _stencilOpDepthFail;
  69551. private _stencilOpStencilDepthPass;
  69552. readonly isDirty: boolean;
  69553. stencilFunc: number;
  69554. stencilFuncRef: number;
  69555. stencilFuncMask: number;
  69556. stencilOpStencilFail: number;
  69557. stencilOpDepthFail: number;
  69558. stencilOpStencilDepthPass: number;
  69559. stencilMask: number;
  69560. stencilTest: boolean;
  69561. constructor();
  69562. reset(): void;
  69563. apply(gl: WebGLRenderingContext): void;
  69564. }
  69565. }
  69566. declare module BABYLON {
  69567. /**
  69568. * @hidden
  69569. **/
  69570. export class _TimeToken {
  69571. _startTimeQuery: Nullable<WebGLQuery>;
  69572. _endTimeQuery: Nullable<WebGLQuery>;
  69573. _timeElapsedQuery: Nullable<WebGLQuery>;
  69574. _timeElapsedQueryEnded: boolean;
  69575. }
  69576. }
  69577. declare module BABYLON {
  69578. /**
  69579. * Class used to evalaute queries containing `and` and `or` operators
  69580. */
  69581. export class AndOrNotEvaluator {
  69582. /**
  69583. * Evaluate a query
  69584. * @param query defines the query to evaluate
  69585. * @param evaluateCallback defines the callback used to filter result
  69586. * @returns true if the query matches
  69587. */
  69588. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  69589. private static _HandleParenthesisContent;
  69590. private static _SimplifyNegation;
  69591. }
  69592. }
  69593. declare module BABYLON {
  69594. /**
  69595. * Class used to store custom tags
  69596. */
  69597. export class Tags {
  69598. /**
  69599. * Adds support for tags on the given object
  69600. * @param obj defines the object to use
  69601. */
  69602. static EnableFor(obj: any): void;
  69603. /**
  69604. * Removes tags support
  69605. * @param obj defines the object to use
  69606. */
  69607. static DisableFor(obj: any): void;
  69608. /**
  69609. * Gets a boolean indicating if the given object has tags
  69610. * @param obj defines the object to use
  69611. * @returns a boolean
  69612. */
  69613. static HasTags(obj: any): boolean;
  69614. /**
  69615. * Gets the tags available on a given object
  69616. * @param obj defines the object to use
  69617. * @param asString defines if the tags must be returned as a string instead of an array of strings
  69618. * @returns the tags
  69619. */
  69620. static GetTags(obj: any, asString?: boolean): any;
  69621. /**
  69622. * Adds tags to an object
  69623. * @param obj defines the object to use
  69624. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  69625. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  69626. */
  69627. static AddTagsTo(obj: any, tagsString: string): void;
  69628. /**
  69629. * @hidden
  69630. */
  69631. static _AddTagTo(obj: any, tag: string): void;
  69632. /**
  69633. * Removes specific tags from a specific object
  69634. * @param obj defines the object to use
  69635. * @param tagsString defines the tags to remove
  69636. */
  69637. static RemoveTagsFrom(obj: any, tagsString: string): void;
  69638. /**
  69639. * @hidden
  69640. */
  69641. static _RemoveTagFrom(obj: any, tag: string): void;
  69642. /**
  69643. * Defines if tags hosted on an object match a given query
  69644. * @param obj defines the object to use
  69645. * @param tagsQuery defines the tag query
  69646. * @returns a boolean
  69647. */
  69648. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  69649. }
  69650. }
  69651. declare module BABYLON {
  69652. /**
  69653. * Defines potential orientation for back face culling
  69654. */
  69655. export enum Orientation {
  69656. /**
  69657. * Clockwise
  69658. */
  69659. CW = 0,
  69660. /** Counter clockwise */
  69661. CCW = 1
  69662. }
  69663. /** Class used to represent a Bezier curve */
  69664. export class BezierCurve {
  69665. /**
  69666. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  69667. * @param t defines the time
  69668. * @param x1 defines the left coordinate on X axis
  69669. * @param y1 defines the left coordinate on Y axis
  69670. * @param x2 defines the right coordinate on X axis
  69671. * @param y2 defines the right coordinate on Y axis
  69672. * @returns the interpolated value
  69673. */
  69674. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  69675. }
  69676. /**
  69677. * Defines angle representation
  69678. */
  69679. export class Angle {
  69680. private _radians;
  69681. /**
  69682. * Creates an Angle object of "radians" radians (float).
  69683. * @param radians the angle in radians
  69684. */
  69685. constructor(radians: number);
  69686. /**
  69687. * Get value in degrees
  69688. * @returns the Angle value in degrees (float)
  69689. */
  69690. degrees(): number;
  69691. /**
  69692. * Get value in radians
  69693. * @returns the Angle value in radians (float)
  69694. */
  69695. radians(): number;
  69696. /**
  69697. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  69698. * @param a defines first vector
  69699. * @param b defines second vector
  69700. * @returns a new Angle
  69701. */
  69702. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  69703. /**
  69704. * Gets a new Angle object from the given float in radians
  69705. * @param radians defines the angle value in radians
  69706. * @returns a new Angle
  69707. */
  69708. static FromRadians(radians: number): Angle;
  69709. /**
  69710. * Gets a new Angle object from the given float in degrees
  69711. * @param degrees defines the angle value in degrees
  69712. * @returns a new Angle
  69713. */
  69714. static FromDegrees(degrees: number): Angle;
  69715. }
  69716. /**
  69717. * This represents an arc in a 2d space.
  69718. */
  69719. export class Arc2 {
  69720. /** Defines the start point of the arc */
  69721. startPoint: Vector2;
  69722. /** Defines the mid point of the arc */
  69723. midPoint: Vector2;
  69724. /** Defines the end point of the arc */
  69725. endPoint: Vector2;
  69726. /**
  69727. * Defines the center point of the arc.
  69728. */
  69729. centerPoint: Vector2;
  69730. /**
  69731. * Defines the radius of the arc.
  69732. */
  69733. radius: number;
  69734. /**
  69735. * Defines the angle of the arc (from mid point to end point).
  69736. */
  69737. angle: Angle;
  69738. /**
  69739. * Defines the start angle of the arc (from start point to middle point).
  69740. */
  69741. startAngle: Angle;
  69742. /**
  69743. * Defines the orientation of the arc (clock wise/counter clock wise).
  69744. */
  69745. orientation: Orientation;
  69746. /**
  69747. * Creates an Arc object from the three given points : start, middle and end.
  69748. * @param startPoint Defines the start point of the arc
  69749. * @param midPoint Defines the midlle point of the arc
  69750. * @param endPoint Defines the end point of the arc
  69751. */
  69752. constructor(
  69753. /** Defines the start point of the arc */
  69754. startPoint: Vector2,
  69755. /** Defines the mid point of the arc */
  69756. midPoint: Vector2,
  69757. /** Defines the end point of the arc */
  69758. endPoint: Vector2);
  69759. }
  69760. /**
  69761. * Represents a 2D path made up of multiple 2D points
  69762. */
  69763. export class Path2 {
  69764. private _points;
  69765. private _length;
  69766. /**
  69767. * If the path start and end point are the same
  69768. */
  69769. closed: boolean;
  69770. /**
  69771. * Creates a Path2 object from the starting 2D coordinates x and y.
  69772. * @param x the starting points x value
  69773. * @param y the starting points y value
  69774. */
  69775. constructor(x: number, y: number);
  69776. /**
  69777. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  69778. * @param x the added points x value
  69779. * @param y the added points y value
  69780. * @returns the updated Path2.
  69781. */
  69782. addLineTo(x: number, y: number): Path2;
  69783. /**
  69784. * 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.
  69785. * @param midX middle point x value
  69786. * @param midY middle point y value
  69787. * @param endX end point x value
  69788. * @param endY end point y value
  69789. * @param numberOfSegments (default: 36)
  69790. * @returns the updated Path2.
  69791. */
  69792. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  69793. /**
  69794. * Closes the Path2.
  69795. * @returns the Path2.
  69796. */
  69797. close(): Path2;
  69798. /**
  69799. * Gets the sum of the distance between each sequential point in the path
  69800. * @returns the Path2 total length (float).
  69801. */
  69802. length(): number;
  69803. /**
  69804. * Gets the points which construct the path
  69805. * @returns the Path2 internal array of points.
  69806. */
  69807. getPoints(): Vector2[];
  69808. /**
  69809. * Retreives the point at the distance aways from the starting point
  69810. * @param normalizedLengthPosition the length along the path to retreive the point from
  69811. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  69812. */
  69813. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  69814. /**
  69815. * Creates a new path starting from an x and y position
  69816. * @param x starting x value
  69817. * @param y starting y value
  69818. * @returns a new Path2 starting at the coordinates (x, y).
  69819. */
  69820. static StartingAt(x: number, y: number): Path2;
  69821. }
  69822. /**
  69823. * Represents a 3D path made up of multiple 3D points
  69824. */
  69825. export class Path3D {
  69826. /**
  69827. * an array of Vector3, the curve axis of the Path3D
  69828. */
  69829. path: Vector3[];
  69830. private _curve;
  69831. private _distances;
  69832. private _tangents;
  69833. private _normals;
  69834. private _binormals;
  69835. private _raw;
  69836. /**
  69837. * new Path3D(path, normal, raw)
  69838. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  69839. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  69840. * @param path an array of Vector3, the curve axis of the Path3D
  69841. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  69842. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  69843. */
  69844. constructor(
  69845. /**
  69846. * an array of Vector3, the curve axis of the Path3D
  69847. */
  69848. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  69849. /**
  69850. * Returns the Path3D array of successive Vector3 designing its curve.
  69851. * @returns the Path3D array of successive Vector3 designing its curve.
  69852. */
  69853. getCurve(): Vector3[];
  69854. /**
  69855. * Returns an array populated with tangent vectors on each Path3D curve point.
  69856. * @returns an array populated with tangent vectors on each Path3D curve point.
  69857. */
  69858. getTangents(): Vector3[];
  69859. /**
  69860. * Returns an array populated with normal vectors on each Path3D curve point.
  69861. * @returns an array populated with normal vectors on each Path3D curve point.
  69862. */
  69863. getNormals(): Vector3[];
  69864. /**
  69865. * Returns an array populated with binormal vectors on each Path3D curve point.
  69866. * @returns an array populated with binormal vectors on each Path3D curve point.
  69867. */
  69868. getBinormals(): Vector3[];
  69869. /**
  69870. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  69871. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  69872. */
  69873. getDistances(): number[];
  69874. /**
  69875. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  69876. * @param path path which all values are copied into the curves points
  69877. * @param firstNormal which should be projected onto the curve
  69878. * @returns the same object updated.
  69879. */
  69880. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  69881. private _compute;
  69882. private _getFirstNonNullVector;
  69883. private _getLastNonNullVector;
  69884. private _normalVector;
  69885. }
  69886. /**
  69887. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  69888. * A Curve3 is designed from a series of successive Vector3.
  69889. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  69890. */
  69891. export class Curve3 {
  69892. private _points;
  69893. private _length;
  69894. /**
  69895. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  69896. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  69897. * @param v1 (Vector3) the control point
  69898. * @param v2 (Vector3) the end point of the Quadratic Bezier
  69899. * @param nbPoints (integer) the wanted number of points in the curve
  69900. * @returns the created Curve3
  69901. */
  69902. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  69903. /**
  69904. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  69905. * @param v0 (Vector3) the origin point of the Cubic Bezier
  69906. * @param v1 (Vector3) the first control point
  69907. * @param v2 (Vector3) the second control point
  69908. * @param v3 (Vector3) the end point of the Cubic Bezier
  69909. * @param nbPoints (integer) the wanted number of points in the curve
  69910. * @returns the created Curve3
  69911. */
  69912. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  69913. /**
  69914. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  69915. * @param p1 (Vector3) the origin point of the Hermite Spline
  69916. * @param t1 (Vector3) the tangent vector at the origin point
  69917. * @param p2 (Vector3) the end point of the Hermite Spline
  69918. * @param t2 (Vector3) the tangent vector at the end point
  69919. * @param nbPoints (integer) the wanted number of points in the curve
  69920. * @returns the created Curve3
  69921. */
  69922. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  69923. /**
  69924. * Returns a Curve3 object along a CatmullRom Spline curve :
  69925. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  69926. * @param nbPoints (integer) the wanted number of points between each curve control points
  69927. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  69928. * @returns the created Curve3
  69929. */
  69930. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  69931. /**
  69932. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  69933. * A Curve3 is designed from a series of successive Vector3.
  69934. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  69935. * @param points points which make up the curve
  69936. */
  69937. constructor(points: Vector3[]);
  69938. /**
  69939. * @returns the Curve3 stored array of successive Vector3
  69940. */
  69941. getPoints(): Vector3[];
  69942. /**
  69943. * @returns the computed length (float) of the curve.
  69944. */
  69945. length(): number;
  69946. /**
  69947. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  69948. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  69949. * curveA and curveB keep unchanged.
  69950. * @param curve the curve to continue from this curve
  69951. * @returns the newly constructed curve
  69952. */
  69953. continue(curve: DeepImmutable<Curve3>): Curve3;
  69954. private _computeLength;
  69955. }
  69956. }
  69957. declare module BABYLON {
  69958. /**
  69959. * This represents the main contract an easing function should follow.
  69960. * Easing functions are used throughout the animation system.
  69961. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69962. */
  69963. export interface IEasingFunction {
  69964. /**
  69965. * Given an input gradient between 0 and 1, this returns the corrseponding value
  69966. * of the easing function.
  69967. * The link below provides some of the most common examples of easing functions.
  69968. * @see https://easings.net/
  69969. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69970. * @returns the corresponding value on the curve defined by the easing function
  69971. */
  69972. ease(gradient: number): number;
  69973. }
  69974. /**
  69975. * Base class used for every default easing function.
  69976. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69977. */
  69978. export class EasingFunction implements IEasingFunction {
  69979. /**
  69980. * Interpolation follows the mathematical formula associated with the easing function.
  69981. */
  69982. static readonly EASINGMODE_EASEIN: number;
  69983. /**
  69984. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  69985. */
  69986. static readonly EASINGMODE_EASEOUT: number;
  69987. /**
  69988. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  69989. */
  69990. static readonly EASINGMODE_EASEINOUT: number;
  69991. private _easingMode;
  69992. /**
  69993. * Sets the easing mode of the current function.
  69994. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  69995. */
  69996. setEasingMode(easingMode: number): void;
  69997. /**
  69998. * Gets the current easing mode.
  69999. * @returns the easing mode
  70000. */
  70001. getEasingMode(): number;
  70002. /**
  70003. * @hidden
  70004. */
  70005. easeInCore(gradient: number): number;
  70006. /**
  70007. * Given an input gradient between 0 and 1, this returns the corresponding value
  70008. * of the easing function.
  70009. * @param gradient Defines the value between 0 and 1 we want the easing value for
  70010. * @returns the corresponding value on the curve defined by the easing function
  70011. */
  70012. ease(gradient: number): number;
  70013. }
  70014. /**
  70015. * Easing function with a circle shape (see link below).
  70016. * @see https://easings.net/#easeInCirc
  70017. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70018. */
  70019. export class CircleEase extends EasingFunction implements IEasingFunction {
  70020. /** @hidden */
  70021. easeInCore(gradient: number): number;
  70022. }
  70023. /**
  70024. * Easing function with a ease back shape (see link below).
  70025. * @see https://easings.net/#easeInBack
  70026. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70027. */
  70028. export class BackEase extends EasingFunction implements IEasingFunction {
  70029. /** Defines the amplitude of the function */
  70030. amplitude: number;
  70031. /**
  70032. * Instantiates a back ease easing
  70033. * @see https://easings.net/#easeInBack
  70034. * @param amplitude Defines the amplitude of the function
  70035. */
  70036. constructor(
  70037. /** Defines the amplitude of the function */
  70038. amplitude?: number);
  70039. /** @hidden */
  70040. easeInCore(gradient: number): number;
  70041. }
  70042. /**
  70043. * Easing function with a bouncing shape (see link below).
  70044. * @see https://easings.net/#easeInBounce
  70045. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70046. */
  70047. export class BounceEase extends EasingFunction implements IEasingFunction {
  70048. /** Defines the number of bounces */
  70049. bounces: number;
  70050. /** Defines the amplitude of the bounce */
  70051. bounciness: number;
  70052. /**
  70053. * Instantiates a bounce easing
  70054. * @see https://easings.net/#easeInBounce
  70055. * @param bounces Defines the number of bounces
  70056. * @param bounciness Defines the amplitude of the bounce
  70057. */
  70058. constructor(
  70059. /** Defines the number of bounces */
  70060. bounces?: number,
  70061. /** Defines the amplitude of the bounce */
  70062. bounciness?: number);
  70063. /** @hidden */
  70064. easeInCore(gradient: number): number;
  70065. }
  70066. /**
  70067. * Easing function with a power of 3 shape (see link below).
  70068. * @see https://easings.net/#easeInCubic
  70069. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70070. */
  70071. export class CubicEase extends EasingFunction implements IEasingFunction {
  70072. /** @hidden */
  70073. easeInCore(gradient: number): number;
  70074. }
  70075. /**
  70076. * Easing function with an elastic shape (see link below).
  70077. * @see https://easings.net/#easeInElastic
  70078. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70079. */
  70080. export class ElasticEase extends EasingFunction implements IEasingFunction {
  70081. /** Defines the number of oscillations*/
  70082. oscillations: number;
  70083. /** Defines the amplitude of the oscillations*/
  70084. springiness: number;
  70085. /**
  70086. * Instantiates an elastic easing function
  70087. * @see https://easings.net/#easeInElastic
  70088. * @param oscillations Defines the number of oscillations
  70089. * @param springiness Defines the amplitude of the oscillations
  70090. */
  70091. constructor(
  70092. /** Defines the number of oscillations*/
  70093. oscillations?: number,
  70094. /** Defines the amplitude of the oscillations*/
  70095. springiness?: number);
  70096. /** @hidden */
  70097. easeInCore(gradient: number): number;
  70098. }
  70099. /**
  70100. * Easing function with an exponential shape (see link below).
  70101. * @see https://easings.net/#easeInExpo
  70102. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70103. */
  70104. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  70105. /** Defines the exponent of the function */
  70106. exponent: number;
  70107. /**
  70108. * Instantiates an exponential easing function
  70109. * @see https://easings.net/#easeInExpo
  70110. * @param exponent Defines the exponent of the function
  70111. */
  70112. constructor(
  70113. /** Defines the exponent of the function */
  70114. exponent?: number);
  70115. /** @hidden */
  70116. easeInCore(gradient: number): number;
  70117. }
  70118. /**
  70119. * Easing function with a power shape (see link below).
  70120. * @see https://easings.net/#easeInQuad
  70121. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70122. */
  70123. export class PowerEase extends EasingFunction implements IEasingFunction {
  70124. /** Defines the power of the function */
  70125. power: number;
  70126. /**
  70127. * Instantiates an power base easing function
  70128. * @see https://easings.net/#easeInQuad
  70129. * @param power Defines the power of the function
  70130. */
  70131. constructor(
  70132. /** Defines the power of the function */
  70133. power?: number);
  70134. /** @hidden */
  70135. easeInCore(gradient: number): number;
  70136. }
  70137. /**
  70138. * Easing function with a power of 2 shape (see link below).
  70139. * @see https://easings.net/#easeInQuad
  70140. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70141. */
  70142. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  70143. /** @hidden */
  70144. easeInCore(gradient: number): number;
  70145. }
  70146. /**
  70147. * Easing function with a power of 4 shape (see link below).
  70148. * @see https://easings.net/#easeInQuart
  70149. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70150. */
  70151. export class QuarticEase extends EasingFunction implements IEasingFunction {
  70152. /** @hidden */
  70153. easeInCore(gradient: number): number;
  70154. }
  70155. /**
  70156. * Easing function with a power of 5 shape (see link below).
  70157. * @see https://easings.net/#easeInQuint
  70158. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70159. */
  70160. export class QuinticEase extends EasingFunction implements IEasingFunction {
  70161. /** @hidden */
  70162. easeInCore(gradient: number): number;
  70163. }
  70164. /**
  70165. * Easing function with a sin shape (see link below).
  70166. * @see https://easings.net/#easeInSine
  70167. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70168. */
  70169. export class SineEase extends EasingFunction implements IEasingFunction {
  70170. /** @hidden */
  70171. easeInCore(gradient: number): number;
  70172. }
  70173. /**
  70174. * Easing function with a bezier shape (see link below).
  70175. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  70176. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70177. */
  70178. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  70179. /** Defines the x component of the start tangent in the bezier curve */
  70180. x1: number;
  70181. /** Defines the y component of the start tangent in the bezier curve */
  70182. y1: number;
  70183. /** Defines the x component of the end tangent in the bezier curve */
  70184. x2: number;
  70185. /** Defines the y component of the end tangent in the bezier curve */
  70186. y2: number;
  70187. /**
  70188. * Instantiates a bezier function
  70189. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  70190. * @param x1 Defines the x component of the start tangent in the bezier curve
  70191. * @param y1 Defines the y component of the start tangent in the bezier curve
  70192. * @param x2 Defines the x component of the end tangent in the bezier curve
  70193. * @param y2 Defines the y component of the end tangent in the bezier curve
  70194. */
  70195. constructor(
  70196. /** Defines the x component of the start tangent in the bezier curve */
  70197. x1?: number,
  70198. /** Defines the y component of the start tangent in the bezier curve */
  70199. y1?: number,
  70200. /** Defines the x component of the end tangent in the bezier curve */
  70201. x2?: number,
  70202. /** Defines the y component of the end tangent in the bezier curve */
  70203. y2?: number);
  70204. /** @hidden */
  70205. easeInCore(gradient: number): number;
  70206. }
  70207. }
  70208. declare module BABYLON {
  70209. /**
  70210. * Defines an interface which represents an animation key frame
  70211. */
  70212. export interface IAnimationKey {
  70213. /**
  70214. * Frame of the key frame
  70215. */
  70216. frame: number;
  70217. /**
  70218. * Value at the specifies key frame
  70219. */
  70220. value: any;
  70221. /**
  70222. * The input tangent for the cubic hermite spline
  70223. */
  70224. inTangent?: any;
  70225. /**
  70226. * The output tangent for the cubic hermite spline
  70227. */
  70228. outTangent?: any;
  70229. /**
  70230. * The animation interpolation type
  70231. */
  70232. interpolation?: AnimationKeyInterpolation;
  70233. }
  70234. /**
  70235. * Enum for the animation key frame interpolation type
  70236. */
  70237. export enum AnimationKeyInterpolation {
  70238. /**
  70239. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  70240. */
  70241. STEP = 1
  70242. }
  70243. }
  70244. declare module BABYLON {
  70245. /**
  70246. * Represents the range of an animation
  70247. */
  70248. export class AnimationRange {
  70249. /**The name of the animation range**/
  70250. name: string;
  70251. /**The starting frame of the animation */
  70252. from: number;
  70253. /**The ending frame of the animation*/
  70254. to: number;
  70255. /**
  70256. * Initializes the range of an animation
  70257. * @param name The name of the animation range
  70258. * @param from The starting frame of the animation
  70259. * @param to The ending frame of the animation
  70260. */
  70261. constructor(
  70262. /**The name of the animation range**/
  70263. name: string,
  70264. /**The starting frame of the animation */
  70265. from: number,
  70266. /**The ending frame of the animation*/
  70267. to: number);
  70268. /**
  70269. * Makes a copy of the animation range
  70270. * @returns A copy of the animation range
  70271. */
  70272. clone(): AnimationRange;
  70273. }
  70274. }
  70275. declare module BABYLON {
  70276. /**
  70277. * Composed of a frame, and an action function
  70278. */
  70279. export class AnimationEvent {
  70280. /** The frame for which the event is triggered **/
  70281. frame: number;
  70282. /** The event to perform when triggered **/
  70283. action: (currentFrame: number) => void;
  70284. /** Specifies if the event should be triggered only once**/
  70285. onlyOnce?: boolean | undefined;
  70286. /**
  70287. * Specifies if the animation event is done
  70288. */
  70289. isDone: boolean;
  70290. /**
  70291. * Initializes the animation event
  70292. * @param frame The frame for which the event is triggered
  70293. * @param action The event to perform when triggered
  70294. * @param onlyOnce Specifies if the event should be triggered only once
  70295. */
  70296. constructor(
  70297. /** The frame for which the event is triggered **/
  70298. frame: number,
  70299. /** The event to perform when triggered **/
  70300. action: (currentFrame: number) => void,
  70301. /** Specifies if the event should be triggered only once**/
  70302. onlyOnce?: boolean | undefined);
  70303. /** @hidden */
  70304. _clone(): AnimationEvent;
  70305. }
  70306. }
  70307. declare module BABYLON {
  70308. /**
  70309. * Interface used to define a behavior
  70310. */
  70311. export interface Behavior<T> {
  70312. /** gets or sets behavior's name */
  70313. name: string;
  70314. /**
  70315. * Function called when the behavior needs to be initialized (after attaching it to a target)
  70316. */
  70317. init(): void;
  70318. /**
  70319. * Called when the behavior is attached to a target
  70320. * @param target defines the target where the behavior is attached to
  70321. */
  70322. attach(target: T): void;
  70323. /**
  70324. * Called when the behavior is detached from its target
  70325. */
  70326. detach(): void;
  70327. }
  70328. /**
  70329. * Interface implemented by classes supporting behaviors
  70330. */
  70331. export interface IBehaviorAware<T> {
  70332. /**
  70333. * Attach a behavior
  70334. * @param behavior defines the behavior to attach
  70335. * @returns the current host
  70336. */
  70337. addBehavior(behavior: Behavior<T>): T;
  70338. /**
  70339. * Remove a behavior from the current object
  70340. * @param behavior defines the behavior to detach
  70341. * @returns the current host
  70342. */
  70343. removeBehavior(behavior: Behavior<T>): T;
  70344. /**
  70345. * Gets a behavior using its name to search
  70346. * @param name defines the name to search
  70347. * @returns the behavior or null if not found
  70348. */
  70349. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  70350. }
  70351. }
  70352. declare module BABYLON {
  70353. /**
  70354. * Defines an array and its length.
  70355. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  70356. */
  70357. export interface ISmartArrayLike<T> {
  70358. /**
  70359. * The data of the array.
  70360. */
  70361. data: Array<T>;
  70362. /**
  70363. * The active length of the array.
  70364. */
  70365. length: number;
  70366. }
  70367. /**
  70368. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70369. */
  70370. export class SmartArray<T> implements ISmartArrayLike<T> {
  70371. /**
  70372. * The full set of data from the array.
  70373. */
  70374. data: Array<T>;
  70375. /**
  70376. * The active length of the array.
  70377. */
  70378. length: number;
  70379. protected _id: number;
  70380. /**
  70381. * Instantiates a Smart Array.
  70382. * @param capacity defines the default capacity of the array.
  70383. */
  70384. constructor(capacity: number);
  70385. /**
  70386. * Pushes a value at the end of the active data.
  70387. * @param value defines the object to push in the array.
  70388. */
  70389. push(value: T): void;
  70390. /**
  70391. * Iterates over the active data and apply the lambda to them.
  70392. * @param func defines the action to apply on each value.
  70393. */
  70394. forEach(func: (content: T) => void): void;
  70395. /**
  70396. * Sorts the full sets of data.
  70397. * @param compareFn defines the comparison function to apply.
  70398. */
  70399. sort(compareFn: (a: T, b: T) => number): void;
  70400. /**
  70401. * Resets the active data to an empty array.
  70402. */
  70403. reset(): void;
  70404. /**
  70405. * Releases all the data from the array as well as the array.
  70406. */
  70407. dispose(): void;
  70408. /**
  70409. * Concats the active data with a given array.
  70410. * @param array defines the data to concatenate with.
  70411. */
  70412. concat(array: any): void;
  70413. /**
  70414. * Returns the position of a value in the active data.
  70415. * @param value defines the value to find the index for
  70416. * @returns the index if found in the active data otherwise -1
  70417. */
  70418. indexOf(value: T): number;
  70419. /**
  70420. * Returns whether an element is part of the active data.
  70421. * @param value defines the value to look for
  70422. * @returns true if found in the active data otherwise false
  70423. */
  70424. contains(value: T): boolean;
  70425. private static _GlobalId;
  70426. }
  70427. /**
  70428. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70429. * The data in this array can only be present once
  70430. */
  70431. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  70432. private _duplicateId;
  70433. /**
  70434. * Pushes a value at the end of the active data.
  70435. * THIS DOES NOT PREVENT DUPPLICATE DATA
  70436. * @param value defines the object to push in the array.
  70437. */
  70438. push(value: T): void;
  70439. /**
  70440. * Pushes a value at the end of the active data.
  70441. * If the data is already present, it won t be added again
  70442. * @param value defines the object to push in the array.
  70443. * @returns true if added false if it was already present
  70444. */
  70445. pushNoDuplicate(value: T): boolean;
  70446. /**
  70447. * Resets the active data to an empty array.
  70448. */
  70449. reset(): void;
  70450. /**
  70451. * Concats the active data with a given array.
  70452. * This ensures no dupplicate will be present in the result.
  70453. * @param array defines the data to concatenate with.
  70454. */
  70455. concatWithNoDuplicate(array: any): void;
  70456. }
  70457. }
  70458. declare module BABYLON {
  70459. /**
  70460. * @ignore
  70461. * This is a list of all the different input types that are available in the application.
  70462. * Fo instance: ArcRotateCameraGamepadInput...
  70463. */
  70464. export var CameraInputTypes: {};
  70465. /**
  70466. * This is the contract to implement in order to create a new input class.
  70467. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  70468. */
  70469. export interface ICameraInput<TCamera extends Camera> {
  70470. /**
  70471. * Defines the camera the input is attached to.
  70472. */
  70473. camera: Nullable<TCamera>;
  70474. /**
  70475. * Gets the class name of the current intput.
  70476. * @returns the class name
  70477. */
  70478. getClassName(): string;
  70479. /**
  70480. * Get the friendly name associated with the input class.
  70481. * @returns the input friendly name
  70482. */
  70483. getSimpleName(): string;
  70484. /**
  70485. * Attach the input controls to a specific dom element to get the input from.
  70486. * @param element Defines the element the controls should be listened from
  70487. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70488. */
  70489. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70490. /**
  70491. * Detach the current controls from the specified dom element.
  70492. * @param element Defines the element to stop listening the inputs from
  70493. */
  70494. detachControl(element: Nullable<HTMLElement>): void;
  70495. /**
  70496. * Update the current camera state depending on the inputs that have been used this frame.
  70497. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70498. */
  70499. checkInputs?: () => void;
  70500. }
  70501. /**
  70502. * Represents a map of input types to input instance or input index to input instance.
  70503. */
  70504. export interface CameraInputsMap<TCamera extends Camera> {
  70505. /**
  70506. * Accessor to the input by input type.
  70507. */
  70508. [name: string]: ICameraInput<TCamera>;
  70509. /**
  70510. * Accessor to the input by input index.
  70511. */
  70512. [idx: number]: ICameraInput<TCamera>;
  70513. }
  70514. /**
  70515. * This represents the input manager used within a camera.
  70516. * It helps dealing with all the different kind of input attached to a camera.
  70517. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70518. */
  70519. export class CameraInputsManager<TCamera extends Camera> {
  70520. /**
  70521. * Defines the list of inputs attahed to the camera.
  70522. */
  70523. attached: CameraInputsMap<TCamera>;
  70524. /**
  70525. * Defines the dom element the camera is collecting inputs from.
  70526. * This is null if the controls have not been attached.
  70527. */
  70528. attachedElement: Nullable<HTMLElement>;
  70529. /**
  70530. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70531. */
  70532. noPreventDefault: boolean;
  70533. /**
  70534. * Defined the camera the input manager belongs to.
  70535. */
  70536. camera: TCamera;
  70537. /**
  70538. * Update the current camera state depending on the inputs that have been used this frame.
  70539. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70540. */
  70541. checkInputs: () => void;
  70542. /**
  70543. * Instantiate a new Camera Input Manager.
  70544. * @param camera Defines the camera the input manager blongs to
  70545. */
  70546. constructor(camera: TCamera);
  70547. /**
  70548. * Add an input method to a camera
  70549. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70550. * @param input camera input method
  70551. */
  70552. add(input: ICameraInput<TCamera>): void;
  70553. /**
  70554. * Remove a specific input method from a camera
  70555. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  70556. * @param inputToRemove camera input method
  70557. */
  70558. remove(inputToRemove: ICameraInput<TCamera>): void;
  70559. /**
  70560. * Remove a specific input type from a camera
  70561. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  70562. * @param inputType the type of the input to remove
  70563. */
  70564. removeByType(inputType: string): void;
  70565. private _addCheckInputs;
  70566. /**
  70567. * Attach the input controls to the currently attached dom element to listen the events from.
  70568. * @param input Defines the input to attach
  70569. */
  70570. attachInput(input: ICameraInput<TCamera>): void;
  70571. /**
  70572. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  70573. * @param element Defines the dom element to collect the events from
  70574. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70575. */
  70576. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  70577. /**
  70578. * Detach the current manager inputs controls from a specific dom element.
  70579. * @param element Defines the dom element to collect the events from
  70580. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  70581. */
  70582. detachElement(element: HTMLElement, disconnect?: boolean): void;
  70583. /**
  70584. * Rebuild the dynamic inputCheck function from the current list of
  70585. * defined inputs in the manager.
  70586. */
  70587. rebuildInputCheck(): void;
  70588. /**
  70589. * Remove all attached input methods from a camera
  70590. */
  70591. clear(): void;
  70592. /**
  70593. * Serialize the current input manager attached to a camera.
  70594. * This ensures than once parsed,
  70595. * the input associated to the camera will be identical to the current ones
  70596. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  70597. */
  70598. serialize(serializedCamera: any): void;
  70599. /**
  70600. * Parses an input manager serialized JSON to restore the previous list of inputs
  70601. * and states associated to a camera.
  70602. * @param parsedCamera Defines the JSON to parse
  70603. */
  70604. parse(parsedCamera: any): void;
  70605. }
  70606. }
  70607. declare module BABYLON {
  70608. /**
  70609. * @hidden
  70610. */
  70611. export class IntersectionInfo {
  70612. bu: Nullable<number>;
  70613. bv: Nullable<number>;
  70614. distance: number;
  70615. faceId: number;
  70616. subMeshId: number;
  70617. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  70618. }
  70619. }
  70620. declare module BABYLON {
  70621. /**
  70622. * Represens a plane by the equation ax + by + cz + d = 0
  70623. */
  70624. export class Plane {
  70625. private static _TmpMatrix;
  70626. /**
  70627. * Normal of the plane (a,b,c)
  70628. */
  70629. normal: Vector3;
  70630. /**
  70631. * d component of the plane
  70632. */
  70633. d: number;
  70634. /**
  70635. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  70636. * @param a a component of the plane
  70637. * @param b b component of the plane
  70638. * @param c c component of the plane
  70639. * @param d d component of the plane
  70640. */
  70641. constructor(a: number, b: number, c: number, d: number);
  70642. /**
  70643. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  70644. */
  70645. asArray(): number[];
  70646. /**
  70647. * @returns a new plane copied from the current Plane.
  70648. */
  70649. clone(): Plane;
  70650. /**
  70651. * @returns the string "Plane".
  70652. */
  70653. getClassName(): string;
  70654. /**
  70655. * @returns the Plane hash code.
  70656. */
  70657. getHashCode(): number;
  70658. /**
  70659. * Normalize the current Plane in place.
  70660. * @returns the updated Plane.
  70661. */
  70662. normalize(): Plane;
  70663. /**
  70664. * Applies a transformation the plane and returns the result
  70665. * @param transformation the transformation matrix to be applied to the plane
  70666. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  70667. */
  70668. transform(transformation: DeepImmutable<Matrix>): Plane;
  70669. /**
  70670. * Calcualtte the dot product between the point and the plane normal
  70671. * @param point point to calculate the dot product with
  70672. * @returns the dot product (float) of the point coordinates and the plane normal.
  70673. */
  70674. dotCoordinate(point: DeepImmutable<Vector3>): number;
  70675. /**
  70676. * Updates the current Plane from the plane defined by the three given points.
  70677. * @param point1 one of the points used to contruct the plane
  70678. * @param point2 one of the points used to contruct the plane
  70679. * @param point3 one of the points used to contruct the plane
  70680. * @returns the updated Plane.
  70681. */
  70682. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  70683. /**
  70684. * Checks if the plane is facing a given direction
  70685. * @param direction the direction to check if the plane is facing
  70686. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  70687. * @returns True is the vector "direction" is the same side than the plane normal.
  70688. */
  70689. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  70690. /**
  70691. * Calculates the distance to a point
  70692. * @param point point to calculate distance to
  70693. * @returns the signed distance (float) from the given point to the Plane.
  70694. */
  70695. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  70696. /**
  70697. * Creates a plane from an array
  70698. * @param array the array to create a plane from
  70699. * @returns a new Plane from the given array.
  70700. */
  70701. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  70702. /**
  70703. * Creates a plane from three points
  70704. * @param point1 point used to create the plane
  70705. * @param point2 point used to create the plane
  70706. * @param point3 point used to create the plane
  70707. * @returns a new Plane defined by the three given points.
  70708. */
  70709. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  70710. /**
  70711. * Creates a plane from an origin point and a normal
  70712. * @param origin origin of the plane to be constructed
  70713. * @param normal normal of the plane to be constructed
  70714. * @returns a new Plane the normal vector to this plane at the given origin point.
  70715. * Note : the vector "normal" is updated because normalized.
  70716. */
  70717. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  70718. /**
  70719. * Calculates the distance from a plane and a point
  70720. * @param origin origin of the plane to be constructed
  70721. * @param normal normal of the plane to be constructed
  70722. * @param point point to calculate distance to
  70723. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  70724. */
  70725. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  70726. }
  70727. }
  70728. declare module BABYLON {
  70729. /**
  70730. * Class used to store bounding sphere information
  70731. */
  70732. export class BoundingSphere {
  70733. /**
  70734. * Gets the center of the bounding sphere in local space
  70735. */
  70736. readonly center: Vector3;
  70737. /**
  70738. * Radius of the bounding sphere in local space
  70739. */
  70740. radius: number;
  70741. /**
  70742. * Gets the center of the bounding sphere in world space
  70743. */
  70744. readonly centerWorld: Vector3;
  70745. /**
  70746. * Radius of the bounding sphere in world space
  70747. */
  70748. radiusWorld: number;
  70749. /**
  70750. * Gets the minimum vector in local space
  70751. */
  70752. readonly minimum: Vector3;
  70753. /**
  70754. * Gets the maximum vector in local space
  70755. */
  70756. readonly maximum: Vector3;
  70757. private _worldMatrix;
  70758. private static readonly TmpVector3;
  70759. /**
  70760. * Creates a new bounding sphere
  70761. * @param min defines the minimum vector (in local space)
  70762. * @param max defines the maximum vector (in local space)
  70763. * @param worldMatrix defines the new world matrix
  70764. */
  70765. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70766. /**
  70767. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  70768. * @param min defines the new minimum vector (in local space)
  70769. * @param max defines the new maximum vector (in local space)
  70770. * @param worldMatrix defines the new world matrix
  70771. */
  70772. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70773. /**
  70774. * Scale the current bounding sphere by applying a scale factor
  70775. * @param factor defines the scale factor to apply
  70776. * @returns the current bounding box
  70777. */
  70778. scale(factor: number): BoundingSphere;
  70779. /**
  70780. * Gets the world matrix of the bounding box
  70781. * @returns a matrix
  70782. */
  70783. getWorldMatrix(): DeepImmutable<Matrix>;
  70784. /** @hidden */
  70785. _update(worldMatrix: DeepImmutable<Matrix>): void;
  70786. /**
  70787. * Tests if the bounding sphere is intersecting the frustum planes
  70788. * @param frustumPlanes defines the frustum planes to test
  70789. * @returns true if there is an intersection
  70790. */
  70791. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70792. /**
  70793. * Tests if the bounding sphere center is in between the frustum planes.
  70794. * Used for optimistic fast inclusion.
  70795. * @param frustumPlanes defines the frustum planes to test
  70796. * @returns true if the sphere center is in between the frustum planes
  70797. */
  70798. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70799. /**
  70800. * Tests if a point is inside the bounding sphere
  70801. * @param point defines the point to test
  70802. * @returns true if the point is inside the bounding sphere
  70803. */
  70804. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70805. /**
  70806. * Checks if two sphere intersct
  70807. * @param sphere0 sphere 0
  70808. * @param sphere1 sphere 1
  70809. * @returns true if the speres intersect
  70810. */
  70811. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  70812. }
  70813. }
  70814. declare module BABYLON {
  70815. /**
  70816. * Class used to store bounding box information
  70817. */
  70818. export class BoundingBox implements ICullable {
  70819. /**
  70820. * Gets the 8 vectors representing the bounding box in local space
  70821. */
  70822. readonly vectors: Vector3[];
  70823. /**
  70824. * Gets the center of the bounding box in local space
  70825. */
  70826. readonly center: Vector3;
  70827. /**
  70828. * Gets the center of the bounding box in world space
  70829. */
  70830. readonly centerWorld: Vector3;
  70831. /**
  70832. * Gets the extend size in local space
  70833. */
  70834. readonly extendSize: Vector3;
  70835. /**
  70836. * Gets the extend size in world space
  70837. */
  70838. readonly extendSizeWorld: Vector3;
  70839. /**
  70840. * Gets the OBB (object bounding box) directions
  70841. */
  70842. readonly directions: Vector3[];
  70843. /**
  70844. * Gets the 8 vectors representing the bounding box in world space
  70845. */
  70846. readonly vectorsWorld: Vector3[];
  70847. /**
  70848. * Gets the minimum vector in world space
  70849. */
  70850. readonly minimumWorld: Vector3;
  70851. /**
  70852. * Gets the maximum vector in world space
  70853. */
  70854. readonly maximumWorld: Vector3;
  70855. /**
  70856. * Gets the minimum vector in local space
  70857. */
  70858. readonly minimum: Vector3;
  70859. /**
  70860. * Gets the maximum vector in local space
  70861. */
  70862. readonly maximum: Vector3;
  70863. private _worldMatrix;
  70864. private static readonly TmpVector3;
  70865. /**
  70866. * @hidden
  70867. */
  70868. _tag: number;
  70869. /**
  70870. * Creates a new bounding box
  70871. * @param min defines the minimum vector (in local space)
  70872. * @param max defines the maximum vector (in local space)
  70873. * @param worldMatrix defines the new world matrix
  70874. */
  70875. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70876. /**
  70877. * Recreates the entire bounding box from scratch as if we call the constructor in place
  70878. * @param min defines the new minimum vector (in local space)
  70879. * @param max defines the new maximum vector (in local space)
  70880. * @param worldMatrix defines the new world matrix
  70881. */
  70882. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70883. /**
  70884. * Scale the current bounding box by applying a scale factor
  70885. * @param factor defines the scale factor to apply
  70886. * @returns the current bounding box
  70887. */
  70888. scale(factor: number): BoundingBox;
  70889. /**
  70890. * Gets the world matrix of the bounding box
  70891. * @returns a matrix
  70892. */
  70893. getWorldMatrix(): DeepImmutable<Matrix>;
  70894. /** @hidden */
  70895. _update(world: DeepImmutable<Matrix>): void;
  70896. /**
  70897. * Tests if the bounding box is intersecting the frustum planes
  70898. * @param frustumPlanes defines the frustum planes to test
  70899. * @returns true if there is an intersection
  70900. */
  70901. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70902. /**
  70903. * Tests if the bounding box is entirely inside the frustum planes
  70904. * @param frustumPlanes defines the frustum planes to test
  70905. * @returns true if there is an inclusion
  70906. */
  70907. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70908. /**
  70909. * Tests if a point is inside the bounding box
  70910. * @param point defines the point to test
  70911. * @returns true if the point is inside the bounding box
  70912. */
  70913. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70914. /**
  70915. * Tests if the bounding box intersects with a bounding sphere
  70916. * @param sphere defines the sphere to test
  70917. * @returns true if there is an intersection
  70918. */
  70919. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  70920. /**
  70921. * Tests if the bounding box intersects with a box defined by a min and max vectors
  70922. * @param min defines the min vector to use
  70923. * @param max defines the max vector to use
  70924. * @returns true if there is an intersection
  70925. */
  70926. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  70927. /**
  70928. * Tests if two bounding boxes are intersections
  70929. * @param box0 defines the first box to test
  70930. * @param box1 defines the second box to test
  70931. * @returns true if there is an intersection
  70932. */
  70933. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  70934. /**
  70935. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  70936. * @param minPoint defines the minimum vector of the bounding box
  70937. * @param maxPoint defines the maximum vector of the bounding box
  70938. * @param sphereCenter defines the sphere center
  70939. * @param sphereRadius defines the sphere radius
  70940. * @returns true if there is an intersection
  70941. */
  70942. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  70943. /**
  70944. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  70945. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  70946. * @param frustumPlanes defines the frustum planes to test
  70947. * @return true if there is an inclusion
  70948. */
  70949. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70950. /**
  70951. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  70952. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  70953. * @param frustumPlanes defines the frustum planes to test
  70954. * @return true if there is an intersection
  70955. */
  70956. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70957. }
  70958. }
  70959. declare module BABYLON {
  70960. /** @hidden */
  70961. export class Collider {
  70962. /** Define if a collision was found */
  70963. collisionFound: boolean;
  70964. /**
  70965. * Define last intersection point in local space
  70966. */
  70967. intersectionPoint: Vector3;
  70968. /**
  70969. * Define last collided mesh
  70970. */
  70971. collidedMesh: Nullable<AbstractMesh>;
  70972. private _collisionPoint;
  70973. private _planeIntersectionPoint;
  70974. private _tempVector;
  70975. private _tempVector2;
  70976. private _tempVector3;
  70977. private _tempVector4;
  70978. private _edge;
  70979. private _baseToVertex;
  70980. private _destinationPoint;
  70981. private _slidePlaneNormal;
  70982. private _displacementVector;
  70983. /** @hidden */
  70984. _radius: Vector3;
  70985. /** @hidden */
  70986. _retry: number;
  70987. private _velocity;
  70988. private _basePoint;
  70989. private _epsilon;
  70990. /** @hidden */
  70991. _velocityWorldLength: number;
  70992. /** @hidden */
  70993. _basePointWorld: Vector3;
  70994. private _velocityWorld;
  70995. private _normalizedVelocity;
  70996. /** @hidden */
  70997. _initialVelocity: Vector3;
  70998. /** @hidden */
  70999. _initialPosition: Vector3;
  71000. private _nearestDistance;
  71001. private _collisionMask;
  71002. collisionMask: number;
  71003. /**
  71004. * Gets the plane normal used to compute the sliding response (in local space)
  71005. */
  71006. readonly slidePlaneNormal: Vector3;
  71007. /** @hidden */
  71008. _initialize(source: Vector3, dir: Vector3, e: number): void;
  71009. /** @hidden */
  71010. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  71011. /** @hidden */
  71012. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  71013. /** @hidden */
  71014. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  71015. /** @hidden */
  71016. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  71017. /** @hidden */
  71018. _getResponse(pos: Vector3, vel: Vector3): void;
  71019. }
  71020. }
  71021. declare module BABYLON {
  71022. /**
  71023. * Interface for cullable objects
  71024. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  71025. */
  71026. export interface ICullable {
  71027. /**
  71028. * Checks if the object or part of the object is in the frustum
  71029. * @param frustumPlanes Camera near/planes
  71030. * @returns true if the object is in frustum otherwise false
  71031. */
  71032. isInFrustum(frustumPlanes: Plane[]): boolean;
  71033. /**
  71034. * Checks if a cullable object (mesh...) is in the camera frustum
  71035. * Unlike isInFrustum this cheks the full bounding box
  71036. * @param frustumPlanes Camera near/planes
  71037. * @returns true if the object is in frustum otherwise false
  71038. */
  71039. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  71040. }
  71041. /**
  71042. * Info for a bounding data of a mesh
  71043. */
  71044. export class BoundingInfo implements ICullable {
  71045. /**
  71046. * Bounding box for the mesh
  71047. */
  71048. readonly boundingBox: BoundingBox;
  71049. /**
  71050. * Bounding sphere for the mesh
  71051. */
  71052. readonly boundingSphere: BoundingSphere;
  71053. private _isLocked;
  71054. private static readonly TmpVector3;
  71055. /**
  71056. * Constructs bounding info
  71057. * @param minimum min vector of the bounding box/sphere
  71058. * @param maximum max vector of the bounding box/sphere
  71059. * @param worldMatrix defines the new world matrix
  71060. */
  71061. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  71062. /**
  71063. * Recreates the entire bounding info from scratch as if we call the constructor in place
  71064. * @param min defines the new minimum vector (in local space)
  71065. * @param max defines the new maximum vector (in local space)
  71066. * @param worldMatrix defines the new world matrix
  71067. */
  71068. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  71069. /**
  71070. * min vector of the bounding box/sphere
  71071. */
  71072. readonly minimum: Vector3;
  71073. /**
  71074. * max vector of the bounding box/sphere
  71075. */
  71076. readonly maximum: Vector3;
  71077. /**
  71078. * If the info is locked and won't be updated to avoid perf overhead
  71079. */
  71080. isLocked: boolean;
  71081. /**
  71082. * Updates the bounding sphere and box
  71083. * @param world world matrix to be used to update
  71084. */
  71085. update(world: DeepImmutable<Matrix>): void;
  71086. /**
  71087. * Recreate the bounding info to be centered around a specific point given a specific extend.
  71088. * @param center New center of the bounding info
  71089. * @param extend New extend of the bounding info
  71090. * @returns the current bounding info
  71091. */
  71092. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  71093. /**
  71094. * Scale the current bounding info by applying a scale factor
  71095. * @param factor defines the scale factor to apply
  71096. * @returns the current bounding info
  71097. */
  71098. scale(factor: number): BoundingInfo;
  71099. /**
  71100. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  71101. * @param frustumPlanes defines the frustum to test
  71102. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  71103. * @returns true if the bounding info is in the frustum planes
  71104. */
  71105. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  71106. /**
  71107. * Gets the world distance between the min and max points of the bounding box
  71108. */
  71109. readonly diagonalLength: number;
  71110. /**
  71111. * Checks if a cullable object (mesh...) is in the camera frustum
  71112. * Unlike isInFrustum this cheks the full bounding box
  71113. * @param frustumPlanes Camera near/planes
  71114. * @returns true if the object is in frustum otherwise false
  71115. */
  71116. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  71117. /** @hidden */
  71118. _checkCollision(collider: Collider): boolean;
  71119. /**
  71120. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  71121. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  71122. * @param point the point to check intersection with
  71123. * @returns if the point intersects
  71124. */
  71125. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  71126. /**
  71127. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  71128. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  71129. * @param boundingInfo the bounding info to check intersection with
  71130. * @param precise if the intersection should be done using OBB
  71131. * @returns if the bounding info intersects
  71132. */
  71133. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  71134. }
  71135. }
  71136. declare module BABYLON {
  71137. /**
  71138. * Extracts minimum and maximum values from a list of indexed positions
  71139. * @param positions defines the positions to use
  71140. * @param indices defines the indices to the positions
  71141. * @param indexStart defines the start index
  71142. * @param indexCount defines the end index
  71143. * @param bias defines bias value to add to the result
  71144. * @return minimum and maximum values
  71145. */
  71146. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  71147. minimum: Vector3;
  71148. maximum: Vector3;
  71149. };
  71150. /**
  71151. * Extracts minimum and maximum values from a list of positions
  71152. * @param positions defines the positions to use
  71153. * @param start defines the start index in the positions array
  71154. * @param count defines the number of positions to handle
  71155. * @param bias defines bias value to add to the result
  71156. * @param stride defines the stride size to use (distance between two positions in the positions array)
  71157. * @return minimum and maximum values
  71158. */
  71159. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  71160. minimum: Vector3;
  71161. maximum: Vector3;
  71162. };
  71163. }
  71164. declare module BABYLON {
  71165. /**
  71166. * Enum that determines the text-wrapping mode to use.
  71167. */
  71168. export enum InspectableType {
  71169. /**
  71170. * Checkbox for booleans
  71171. */
  71172. Checkbox = 0,
  71173. /**
  71174. * Sliders for numbers
  71175. */
  71176. Slider = 1,
  71177. /**
  71178. * Vector3
  71179. */
  71180. Vector3 = 2,
  71181. /**
  71182. * Quaternions
  71183. */
  71184. Quaternion = 3,
  71185. /**
  71186. * Color3
  71187. */
  71188. Color3 = 4,
  71189. /**
  71190. * String
  71191. */
  71192. String = 5
  71193. }
  71194. /**
  71195. * Interface used to define custom inspectable properties.
  71196. * This interface is used by the inspector to display custom property grids
  71197. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71198. */
  71199. export interface IInspectable {
  71200. /**
  71201. * Gets the label to display
  71202. */
  71203. label: string;
  71204. /**
  71205. * Gets the name of the property to edit
  71206. */
  71207. propertyName: string;
  71208. /**
  71209. * Gets the type of the editor to use
  71210. */
  71211. type: InspectableType;
  71212. /**
  71213. * Gets the minimum value of the property when using in "slider" mode
  71214. */
  71215. min?: number;
  71216. /**
  71217. * Gets the maximum value of the property when using in "slider" mode
  71218. */
  71219. max?: number;
  71220. /**
  71221. * Gets the setp to use when using in "slider" mode
  71222. */
  71223. step?: number;
  71224. }
  71225. }
  71226. declare module BABYLON {
  71227. /**
  71228. * Class used to provide helper for timing
  71229. */
  71230. export class TimingTools {
  71231. /**
  71232. * Polyfill for setImmediate
  71233. * @param action defines the action to execute after the current execution block
  71234. */
  71235. static SetImmediate(action: () => void): void;
  71236. }
  71237. }
  71238. declare module BABYLON {
  71239. /**
  71240. * Class used to enable instatition of objects by class name
  71241. */
  71242. export class InstantiationTools {
  71243. /**
  71244. * Use this object to register external classes like custom textures or material
  71245. * to allow the laoders to instantiate them
  71246. */
  71247. static RegisteredExternalClasses: {
  71248. [key: string]: Object;
  71249. };
  71250. /**
  71251. * Tries to instantiate a new object from a given class name
  71252. * @param className defines the class name to instantiate
  71253. * @returns the new object or null if the system was not able to do the instantiation
  71254. */
  71255. static Instantiate(className: string): any;
  71256. }
  71257. }
  71258. declare module BABYLON {
  71259. /**
  71260. * This represents the required contract to create a new type of texture loader.
  71261. */
  71262. export interface IInternalTextureLoader {
  71263. /**
  71264. * Defines wether the loader supports cascade loading the different faces.
  71265. */
  71266. supportCascades: boolean;
  71267. /**
  71268. * This returns if the loader support the current file information.
  71269. * @param extension defines the file extension of the file being loaded
  71270. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71271. * @param fallback defines the fallback internal texture if any
  71272. * @param isBase64 defines whether the texture is encoded as a base64
  71273. * @param isBuffer defines whether the texture data are stored as a buffer
  71274. * @returns true if the loader can load the specified file
  71275. */
  71276. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  71277. /**
  71278. * Transform the url before loading if required.
  71279. * @param rootUrl the url of the texture
  71280. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71281. * @returns the transformed texture
  71282. */
  71283. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  71284. /**
  71285. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  71286. * @param rootUrl the url of the texture
  71287. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71288. * @returns the fallback texture
  71289. */
  71290. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  71291. /**
  71292. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  71293. * @param data contains the texture data
  71294. * @param texture defines the BabylonJS internal texture
  71295. * @param createPolynomials will be true if polynomials have been requested
  71296. * @param onLoad defines the callback to trigger once the texture is ready
  71297. * @param onError defines the callback to trigger in case of error
  71298. */
  71299. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  71300. /**
  71301. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  71302. * @param data contains the texture data
  71303. * @param texture defines the BabylonJS internal texture
  71304. * @param callback defines the method to call once ready to upload
  71305. */
  71306. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  71307. }
  71308. }
  71309. declare module BABYLON {
  71310. interface Engine {
  71311. /**
  71312. * Creates a depth stencil cube texture.
  71313. * This is only available in WebGL 2.
  71314. * @param size The size of face edge in the cube texture.
  71315. * @param options The options defining the cube texture.
  71316. * @returns The cube texture
  71317. */
  71318. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  71319. /**
  71320. * Creates a cube texture
  71321. * @param rootUrl defines the url where the files to load is located
  71322. * @param scene defines the current scene
  71323. * @param files defines the list of files to load (1 per face)
  71324. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71325. * @param onLoad defines an optional callback raised when the texture is loaded
  71326. * @param onError defines an optional callback raised if there is an issue to load the texture
  71327. * @param format defines the format of the data
  71328. * @param forcedExtension defines the extension to use to pick the right loader
  71329. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  71330. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71331. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71332. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  71333. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  71334. * @returns the cube texture as an InternalTexture
  71335. */
  71336. 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;
  71337. /**
  71338. * Creates a cube texture
  71339. * @param rootUrl defines the url where the files to load is located
  71340. * @param scene defines the current scene
  71341. * @param files defines the list of files to load (1 per face)
  71342. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71343. * @param onLoad defines an optional callback raised when the texture is loaded
  71344. * @param onError defines an optional callback raised if there is an issue to load the texture
  71345. * @param format defines the format of the data
  71346. * @param forcedExtension defines the extension to use to pick the right loader
  71347. * @returns the cube texture as an InternalTexture
  71348. */
  71349. 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;
  71350. /**
  71351. * Creates a cube texture
  71352. * @param rootUrl defines the url where the files to load is located
  71353. * @param scene defines the current scene
  71354. * @param files defines the list of files to load (1 per face)
  71355. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71356. * @param onLoad defines an optional callback raised when the texture is loaded
  71357. * @param onError defines an optional callback raised if there is an issue to load the texture
  71358. * @param format defines the format of the data
  71359. * @param forcedExtension defines the extension to use to pick the right loader
  71360. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  71361. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71362. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71363. * @returns the cube texture as an InternalTexture
  71364. */
  71365. 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;
  71366. /** @hidden */
  71367. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  71368. /** @hidden */
  71369. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  71370. /** @hidden */
  71371. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  71372. /** @hidden */
  71373. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  71374. }
  71375. }
  71376. declare module BABYLON {
  71377. /**
  71378. * Class for creating a cube texture
  71379. */
  71380. export class CubeTexture extends BaseTexture {
  71381. private _delayedOnLoad;
  71382. /**
  71383. * The url of the texture
  71384. */
  71385. url: string;
  71386. /**
  71387. * Gets or sets the center of the bounding box associated with the cube texture.
  71388. * It must define where the camera used to render the texture was set
  71389. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  71390. */
  71391. boundingBoxPosition: Vector3;
  71392. private _boundingBoxSize;
  71393. /**
  71394. * Gets or sets the size of the bounding box associated with the cube texture
  71395. * When defined, the cubemap will switch to local mode
  71396. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  71397. * @example https://www.babylonjs-playground.com/#RNASML
  71398. */
  71399. /**
  71400. * Returns the bounding box size
  71401. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  71402. */
  71403. boundingBoxSize: Vector3;
  71404. protected _rotationY: number;
  71405. /**
  71406. * Sets texture matrix rotation angle around Y axis in radians.
  71407. */
  71408. /**
  71409. * Gets texture matrix rotation angle around Y axis radians.
  71410. */
  71411. rotationY: number;
  71412. /**
  71413. * Are mip maps generated for this texture or not.
  71414. */
  71415. readonly noMipmap: boolean;
  71416. private _noMipmap;
  71417. private _files;
  71418. private _extensions;
  71419. private _textureMatrix;
  71420. private _format;
  71421. private _createPolynomials;
  71422. /** @hidden */
  71423. _prefiltered: boolean;
  71424. /**
  71425. * Creates a cube texture from an array of image urls
  71426. * @param files defines an array of image urls
  71427. * @param scene defines the hosting scene
  71428. * @param noMipmap specifies if mip maps are not used
  71429. * @returns a cube texture
  71430. */
  71431. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  71432. /**
  71433. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  71434. * @param url defines the url of the prefiltered texture
  71435. * @param scene defines the scene the texture is attached to
  71436. * @param forcedExtension defines the extension of the file if different from the url
  71437. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  71438. * @return the prefiltered texture
  71439. */
  71440. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  71441. /**
  71442. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  71443. * as prefiltered data.
  71444. * @param rootUrl defines the url of the texture or the root name of the six images
  71445. * @param scene defines the scene the texture is attached to
  71446. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  71447. * @param noMipmap defines if mipmaps should be created or not
  71448. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  71449. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  71450. * @param onError defines a callback triggered in case of error during load
  71451. * @param format defines the internal format to use for the texture once loaded
  71452. * @param prefiltered defines whether or not the texture is created from prefiltered data
  71453. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  71454. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  71455. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71456. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71457. * @return the cube texture
  71458. */
  71459. 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);
  71460. /**
  71461. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  71462. */
  71463. readonly isPrefiltered: boolean;
  71464. /**
  71465. * Get the current class name of the texture useful for serialization or dynamic coding.
  71466. * @returns "CubeTexture"
  71467. */
  71468. getClassName(): string;
  71469. /**
  71470. * Update the url (and optional buffer) of this texture if url was null during construction.
  71471. * @param url the url of the texture
  71472. * @param forcedExtension defines the extension to use
  71473. * @param onLoad callback called when the texture is loaded (defaults to null)
  71474. */
  71475. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  71476. /**
  71477. * Delays loading of the cube texture
  71478. * @param forcedExtension defines the extension to use
  71479. */
  71480. delayLoad(forcedExtension?: string): void;
  71481. /**
  71482. * Returns the reflection texture matrix
  71483. * @returns the reflection texture matrix
  71484. */
  71485. getReflectionTextureMatrix(): Matrix;
  71486. /**
  71487. * Sets the reflection texture matrix
  71488. * @param value Reflection texture matrix
  71489. */
  71490. setReflectionTextureMatrix(value: Matrix): void;
  71491. /**
  71492. * Parses text to create a cube texture
  71493. * @param parsedTexture define the serialized text to read from
  71494. * @param scene defines the hosting scene
  71495. * @param rootUrl defines the root url of the cube texture
  71496. * @returns a cube texture
  71497. */
  71498. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  71499. /**
  71500. * Makes a clone, or deep copy, of the cube texture
  71501. * @returns a new cube texture
  71502. */
  71503. clone(): CubeTexture;
  71504. }
  71505. }
  71506. declare module BABYLON {
  71507. /**
  71508. * Manages the defines for the Material
  71509. */
  71510. export class MaterialDefines {
  71511. /** @hidden */
  71512. protected _keys: string[];
  71513. private _isDirty;
  71514. /** @hidden */
  71515. _renderId: number;
  71516. /** @hidden */
  71517. _areLightsDirty: boolean;
  71518. /** @hidden */
  71519. _areAttributesDirty: boolean;
  71520. /** @hidden */
  71521. _areTexturesDirty: boolean;
  71522. /** @hidden */
  71523. _areFresnelDirty: boolean;
  71524. /** @hidden */
  71525. _areMiscDirty: boolean;
  71526. /** @hidden */
  71527. _areImageProcessingDirty: boolean;
  71528. /** @hidden */
  71529. _normals: boolean;
  71530. /** @hidden */
  71531. _uvs: boolean;
  71532. /** @hidden */
  71533. _needNormals: boolean;
  71534. /** @hidden */
  71535. _needUVs: boolean;
  71536. [id: string]: any;
  71537. /**
  71538. * Specifies if the material needs to be re-calculated
  71539. */
  71540. readonly isDirty: boolean;
  71541. /**
  71542. * Marks the material to indicate that it has been re-calculated
  71543. */
  71544. markAsProcessed(): void;
  71545. /**
  71546. * Marks the material to indicate that it needs to be re-calculated
  71547. */
  71548. markAsUnprocessed(): void;
  71549. /**
  71550. * Marks the material to indicate all of its defines need to be re-calculated
  71551. */
  71552. markAllAsDirty(): void;
  71553. /**
  71554. * Marks the material to indicate that image processing needs to be re-calculated
  71555. */
  71556. markAsImageProcessingDirty(): void;
  71557. /**
  71558. * Marks the material to indicate the lights need to be re-calculated
  71559. */
  71560. markAsLightDirty(): void;
  71561. /**
  71562. * Marks the attribute state as changed
  71563. */
  71564. markAsAttributesDirty(): void;
  71565. /**
  71566. * Marks the texture state as changed
  71567. */
  71568. markAsTexturesDirty(): void;
  71569. /**
  71570. * Marks the fresnel state as changed
  71571. */
  71572. markAsFresnelDirty(): void;
  71573. /**
  71574. * Marks the misc state as changed
  71575. */
  71576. markAsMiscDirty(): void;
  71577. /**
  71578. * Rebuilds the material defines
  71579. */
  71580. rebuild(): void;
  71581. /**
  71582. * Specifies if two material defines are equal
  71583. * @param other - A material define instance to compare to
  71584. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  71585. */
  71586. isEqual(other: MaterialDefines): boolean;
  71587. /**
  71588. * Clones this instance's defines to another instance
  71589. * @param other - material defines to clone values to
  71590. */
  71591. cloneTo(other: MaterialDefines): void;
  71592. /**
  71593. * Resets the material define values
  71594. */
  71595. reset(): void;
  71596. /**
  71597. * Converts the material define values to a string
  71598. * @returns - String of material define information
  71599. */
  71600. toString(): string;
  71601. }
  71602. }
  71603. declare module BABYLON {
  71604. /**
  71605. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  71606. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  71607. * 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;
  71608. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  71609. */
  71610. export class ColorCurves {
  71611. private _dirty;
  71612. private _tempColor;
  71613. private _globalCurve;
  71614. private _highlightsCurve;
  71615. private _midtonesCurve;
  71616. private _shadowsCurve;
  71617. private _positiveCurve;
  71618. private _negativeCurve;
  71619. private _globalHue;
  71620. private _globalDensity;
  71621. private _globalSaturation;
  71622. private _globalExposure;
  71623. /**
  71624. * Gets the global Hue value.
  71625. * 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).
  71626. */
  71627. /**
  71628. * Sets the global Hue value.
  71629. * 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).
  71630. */
  71631. globalHue: number;
  71632. /**
  71633. * Gets the global Density value.
  71634. * 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.
  71635. * Values less than zero provide a filter of opposite hue.
  71636. */
  71637. /**
  71638. * Sets the global Density value.
  71639. * 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.
  71640. * Values less than zero provide a filter of opposite hue.
  71641. */
  71642. globalDensity: number;
  71643. /**
  71644. * Gets the global Saturation value.
  71645. * 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.
  71646. */
  71647. /**
  71648. * Sets the global Saturation value.
  71649. * 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.
  71650. */
  71651. globalSaturation: number;
  71652. /**
  71653. * Gets the global Exposure value.
  71654. * 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.
  71655. */
  71656. /**
  71657. * Sets the global Exposure value.
  71658. * 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.
  71659. */
  71660. globalExposure: number;
  71661. private _highlightsHue;
  71662. private _highlightsDensity;
  71663. private _highlightsSaturation;
  71664. private _highlightsExposure;
  71665. /**
  71666. * Gets the highlights Hue value.
  71667. * 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).
  71668. */
  71669. /**
  71670. * Sets the highlights Hue value.
  71671. * 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).
  71672. */
  71673. highlightsHue: number;
  71674. /**
  71675. * Gets the highlights Density value.
  71676. * 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.
  71677. * Values less than zero provide a filter of opposite hue.
  71678. */
  71679. /**
  71680. * Sets the highlights Density value.
  71681. * 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.
  71682. * Values less than zero provide a filter of opposite hue.
  71683. */
  71684. highlightsDensity: number;
  71685. /**
  71686. * Gets the highlights Saturation value.
  71687. * 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.
  71688. */
  71689. /**
  71690. * Sets the highlights Saturation value.
  71691. * 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.
  71692. */
  71693. highlightsSaturation: number;
  71694. /**
  71695. * Gets the highlights Exposure value.
  71696. * 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.
  71697. */
  71698. /**
  71699. * Sets the highlights Exposure value.
  71700. * 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.
  71701. */
  71702. highlightsExposure: number;
  71703. private _midtonesHue;
  71704. private _midtonesDensity;
  71705. private _midtonesSaturation;
  71706. private _midtonesExposure;
  71707. /**
  71708. * Gets the midtones Hue value.
  71709. * 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).
  71710. */
  71711. /**
  71712. * Sets the midtones Hue value.
  71713. * 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).
  71714. */
  71715. midtonesHue: number;
  71716. /**
  71717. * Gets the midtones Density value.
  71718. * 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.
  71719. * Values less than zero provide a filter of opposite hue.
  71720. */
  71721. /**
  71722. * Sets the midtones Density value.
  71723. * 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.
  71724. * Values less than zero provide a filter of opposite hue.
  71725. */
  71726. midtonesDensity: number;
  71727. /**
  71728. * Gets the midtones Saturation value.
  71729. * 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.
  71730. */
  71731. /**
  71732. * Sets the midtones Saturation value.
  71733. * 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.
  71734. */
  71735. midtonesSaturation: number;
  71736. /**
  71737. * Gets the midtones Exposure value.
  71738. * 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.
  71739. */
  71740. /**
  71741. * Sets the midtones Exposure value.
  71742. * 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.
  71743. */
  71744. midtonesExposure: number;
  71745. private _shadowsHue;
  71746. private _shadowsDensity;
  71747. private _shadowsSaturation;
  71748. private _shadowsExposure;
  71749. /**
  71750. * Gets the shadows Hue value.
  71751. * 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).
  71752. */
  71753. /**
  71754. * Sets the shadows Hue value.
  71755. * 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).
  71756. */
  71757. shadowsHue: number;
  71758. /**
  71759. * Gets the shadows Density value.
  71760. * 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.
  71761. * Values less than zero provide a filter of opposite hue.
  71762. */
  71763. /**
  71764. * Sets the shadows Density value.
  71765. * 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.
  71766. * Values less than zero provide a filter of opposite hue.
  71767. */
  71768. shadowsDensity: number;
  71769. /**
  71770. * Gets the shadows Saturation value.
  71771. * 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.
  71772. */
  71773. /**
  71774. * Sets the shadows Saturation value.
  71775. * 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.
  71776. */
  71777. shadowsSaturation: number;
  71778. /**
  71779. * Gets the shadows Exposure value.
  71780. * 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.
  71781. */
  71782. /**
  71783. * Sets the shadows Exposure value.
  71784. * 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.
  71785. */
  71786. shadowsExposure: number;
  71787. /**
  71788. * Returns the class name
  71789. * @returns The class name
  71790. */
  71791. getClassName(): string;
  71792. /**
  71793. * Binds the color curves to the shader.
  71794. * @param colorCurves The color curve to bind
  71795. * @param effect The effect to bind to
  71796. * @param positiveUniform The positive uniform shader parameter
  71797. * @param neutralUniform The neutral uniform shader parameter
  71798. * @param negativeUniform The negative uniform shader parameter
  71799. */
  71800. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  71801. /**
  71802. * Prepare the list of uniforms associated with the ColorCurves effects.
  71803. * @param uniformsList The list of uniforms used in the effect
  71804. */
  71805. static PrepareUniforms(uniformsList: string[]): void;
  71806. /**
  71807. * Returns color grading data based on a hue, density, saturation and exposure value.
  71808. * @param filterHue The hue of the color filter.
  71809. * @param filterDensity The density of the color filter.
  71810. * @param saturation The saturation.
  71811. * @param exposure The exposure.
  71812. * @param result The result data container.
  71813. */
  71814. private getColorGradingDataToRef;
  71815. /**
  71816. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  71817. * @param value The input slider value in range [-100,100].
  71818. * @returns Adjusted value.
  71819. */
  71820. private static applyColorGradingSliderNonlinear;
  71821. /**
  71822. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  71823. * @param hue The hue (H) input.
  71824. * @param saturation The saturation (S) input.
  71825. * @param brightness The brightness (B) input.
  71826. * @result An RGBA color represented as Vector4.
  71827. */
  71828. private static fromHSBToRef;
  71829. /**
  71830. * Returns a value clamped between min and max
  71831. * @param value The value to clamp
  71832. * @param min The minimum of value
  71833. * @param max The maximum of value
  71834. * @returns The clamped value.
  71835. */
  71836. private static clamp;
  71837. /**
  71838. * Clones the current color curve instance.
  71839. * @return The cloned curves
  71840. */
  71841. clone(): ColorCurves;
  71842. /**
  71843. * Serializes the current color curve instance to a json representation.
  71844. * @return a JSON representation
  71845. */
  71846. serialize(): any;
  71847. /**
  71848. * Parses the color curve from a json representation.
  71849. * @param source the JSON source to parse
  71850. * @return The parsed curves
  71851. */
  71852. static Parse(source: any): ColorCurves;
  71853. }
  71854. }
  71855. declare module BABYLON {
  71856. /**
  71857. * Interface to follow in your material defines to integrate easily the
  71858. * Image proccessing functions.
  71859. * @hidden
  71860. */
  71861. export interface IImageProcessingConfigurationDefines {
  71862. IMAGEPROCESSING: boolean;
  71863. VIGNETTE: boolean;
  71864. VIGNETTEBLENDMODEMULTIPLY: boolean;
  71865. VIGNETTEBLENDMODEOPAQUE: boolean;
  71866. TONEMAPPING: boolean;
  71867. TONEMAPPING_ACES: boolean;
  71868. CONTRAST: boolean;
  71869. EXPOSURE: boolean;
  71870. COLORCURVES: boolean;
  71871. COLORGRADING: boolean;
  71872. COLORGRADING3D: boolean;
  71873. SAMPLER3DGREENDEPTH: boolean;
  71874. SAMPLER3DBGRMAP: boolean;
  71875. IMAGEPROCESSINGPOSTPROCESS: boolean;
  71876. }
  71877. /**
  71878. * @hidden
  71879. */
  71880. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  71881. IMAGEPROCESSING: boolean;
  71882. VIGNETTE: boolean;
  71883. VIGNETTEBLENDMODEMULTIPLY: boolean;
  71884. VIGNETTEBLENDMODEOPAQUE: boolean;
  71885. TONEMAPPING: boolean;
  71886. TONEMAPPING_ACES: boolean;
  71887. CONTRAST: boolean;
  71888. COLORCURVES: boolean;
  71889. COLORGRADING: boolean;
  71890. COLORGRADING3D: boolean;
  71891. SAMPLER3DGREENDEPTH: boolean;
  71892. SAMPLER3DBGRMAP: boolean;
  71893. IMAGEPROCESSINGPOSTPROCESS: boolean;
  71894. EXPOSURE: boolean;
  71895. constructor();
  71896. }
  71897. /**
  71898. * This groups together the common properties used for image processing either in direct forward pass
  71899. * or through post processing effect depending on the use of the image processing pipeline in your scene
  71900. * or not.
  71901. */
  71902. export class ImageProcessingConfiguration {
  71903. /**
  71904. * Default tone mapping applied in BabylonJS.
  71905. */
  71906. static readonly TONEMAPPING_STANDARD: number;
  71907. /**
  71908. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  71909. * to other engines rendering to increase portability.
  71910. */
  71911. static readonly TONEMAPPING_ACES: number;
  71912. /**
  71913. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  71914. */
  71915. colorCurves: Nullable<ColorCurves>;
  71916. private _colorCurvesEnabled;
  71917. /**
  71918. * Gets wether the color curves effect is enabled.
  71919. */
  71920. /**
  71921. * Sets wether the color curves effect is enabled.
  71922. */
  71923. colorCurvesEnabled: boolean;
  71924. private _colorGradingTexture;
  71925. /**
  71926. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  71927. */
  71928. /**
  71929. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  71930. */
  71931. colorGradingTexture: Nullable<BaseTexture>;
  71932. private _colorGradingEnabled;
  71933. /**
  71934. * Gets wether the color grading effect is enabled.
  71935. */
  71936. /**
  71937. * Sets wether the color grading effect is enabled.
  71938. */
  71939. colorGradingEnabled: boolean;
  71940. private _colorGradingWithGreenDepth;
  71941. /**
  71942. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  71943. */
  71944. /**
  71945. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  71946. */
  71947. colorGradingWithGreenDepth: boolean;
  71948. private _colorGradingBGR;
  71949. /**
  71950. * Gets wether the color grading texture contains BGR values.
  71951. */
  71952. /**
  71953. * Sets wether the color grading texture contains BGR values.
  71954. */
  71955. colorGradingBGR: boolean;
  71956. /** @hidden */
  71957. _exposure: number;
  71958. /**
  71959. * Gets the Exposure used in the effect.
  71960. */
  71961. /**
  71962. * Sets the Exposure used in the effect.
  71963. */
  71964. exposure: number;
  71965. private _toneMappingEnabled;
  71966. /**
  71967. * Gets wether the tone mapping effect is enabled.
  71968. */
  71969. /**
  71970. * Sets wether the tone mapping effect is enabled.
  71971. */
  71972. toneMappingEnabled: boolean;
  71973. private _toneMappingType;
  71974. /**
  71975. * Gets the type of tone mapping effect.
  71976. */
  71977. /**
  71978. * Sets the type of tone mapping effect used in BabylonJS.
  71979. */
  71980. toneMappingType: number;
  71981. protected _contrast: number;
  71982. /**
  71983. * Gets the contrast used in the effect.
  71984. */
  71985. /**
  71986. * Sets the contrast used in the effect.
  71987. */
  71988. contrast: number;
  71989. /**
  71990. * Vignette stretch size.
  71991. */
  71992. vignetteStretch: number;
  71993. /**
  71994. * Vignette centre X Offset.
  71995. */
  71996. vignetteCentreX: number;
  71997. /**
  71998. * Vignette centre Y Offset.
  71999. */
  72000. vignetteCentreY: number;
  72001. /**
  72002. * Vignette weight or intensity of the vignette effect.
  72003. */
  72004. vignetteWeight: number;
  72005. /**
  72006. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  72007. * if vignetteEnabled is set to true.
  72008. */
  72009. vignetteColor: Color4;
  72010. /**
  72011. * Camera field of view used by the Vignette effect.
  72012. */
  72013. vignetteCameraFov: number;
  72014. private _vignetteBlendMode;
  72015. /**
  72016. * Gets the vignette blend mode allowing different kind of effect.
  72017. */
  72018. /**
  72019. * Sets the vignette blend mode allowing different kind of effect.
  72020. */
  72021. vignetteBlendMode: number;
  72022. private _vignetteEnabled;
  72023. /**
  72024. * Gets wether the vignette effect is enabled.
  72025. */
  72026. /**
  72027. * Sets wether the vignette effect is enabled.
  72028. */
  72029. vignetteEnabled: boolean;
  72030. private _applyByPostProcess;
  72031. /**
  72032. * Gets wether the image processing is applied through a post process or not.
  72033. */
  72034. /**
  72035. * Sets wether the image processing is applied through a post process or not.
  72036. */
  72037. applyByPostProcess: boolean;
  72038. private _isEnabled;
  72039. /**
  72040. * Gets wether the image processing is enabled or not.
  72041. */
  72042. /**
  72043. * Sets wether the image processing is enabled or not.
  72044. */
  72045. isEnabled: boolean;
  72046. /**
  72047. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  72048. */
  72049. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  72050. /**
  72051. * Method called each time the image processing information changes requires to recompile the effect.
  72052. */
  72053. protected _updateParameters(): void;
  72054. /**
  72055. * Gets the current class name.
  72056. * @return "ImageProcessingConfiguration"
  72057. */
  72058. getClassName(): string;
  72059. /**
  72060. * Prepare the list of uniforms associated with the Image Processing effects.
  72061. * @param uniforms The list of uniforms used in the effect
  72062. * @param defines the list of defines currently in use
  72063. */
  72064. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  72065. /**
  72066. * Prepare the list of samplers associated with the Image Processing effects.
  72067. * @param samplersList The list of uniforms used in the effect
  72068. * @param defines the list of defines currently in use
  72069. */
  72070. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  72071. /**
  72072. * Prepare the list of defines associated to the shader.
  72073. * @param defines the list of defines to complete
  72074. * @param forPostProcess Define if we are currently in post process mode or not
  72075. */
  72076. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  72077. /**
  72078. * Returns true if all the image processing information are ready.
  72079. * @returns True if ready, otherwise, false
  72080. */
  72081. isReady(): boolean;
  72082. /**
  72083. * Binds the image processing to the shader.
  72084. * @param effect The effect to bind to
  72085. * @param aspectRatio Define the current aspect ratio of the effect
  72086. */
  72087. bind(effect: Effect, aspectRatio?: number): void;
  72088. /**
  72089. * Clones the current image processing instance.
  72090. * @return The cloned image processing
  72091. */
  72092. clone(): ImageProcessingConfiguration;
  72093. /**
  72094. * Serializes the current image processing instance to a json representation.
  72095. * @return a JSON representation
  72096. */
  72097. serialize(): any;
  72098. /**
  72099. * Parses the image processing from a json representation.
  72100. * @param source the JSON source to parse
  72101. * @return The parsed image processing
  72102. */
  72103. static Parse(source: any): ImageProcessingConfiguration;
  72104. private static _VIGNETTEMODE_MULTIPLY;
  72105. private static _VIGNETTEMODE_OPAQUE;
  72106. /**
  72107. * Used to apply the vignette as a mix with the pixel color.
  72108. */
  72109. static readonly VIGNETTEMODE_MULTIPLY: number;
  72110. /**
  72111. * Used to apply the vignette as a replacement of the pixel color.
  72112. */
  72113. static readonly VIGNETTEMODE_OPAQUE: number;
  72114. }
  72115. }
  72116. declare module BABYLON {
  72117. /** @hidden */
  72118. export var postprocessVertexShader: {
  72119. name: string;
  72120. shader: string;
  72121. };
  72122. }
  72123. declare module BABYLON {
  72124. /** Defines supported spaces */
  72125. export enum Space {
  72126. /** Local (object) space */
  72127. LOCAL = 0,
  72128. /** World space */
  72129. WORLD = 1,
  72130. /** Bone space */
  72131. BONE = 2
  72132. }
  72133. /** Defines the 3 main axes */
  72134. export class Axis {
  72135. /** X axis */
  72136. static X: Vector3;
  72137. /** Y axis */
  72138. static Y: Vector3;
  72139. /** Z axis */
  72140. static Z: Vector3;
  72141. }
  72142. }
  72143. declare module BABYLON {
  72144. /**
  72145. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  72146. * This is the base of the follow, arc rotate cameras and Free camera
  72147. * @see http://doc.babylonjs.com/features/cameras
  72148. */
  72149. export class TargetCamera extends Camera {
  72150. private static _RigCamTransformMatrix;
  72151. private static _TargetTransformMatrix;
  72152. private static _TargetFocalPoint;
  72153. /**
  72154. * Define the current direction the camera is moving to
  72155. */
  72156. cameraDirection: Vector3;
  72157. /**
  72158. * Define the current rotation the camera is rotating to
  72159. */
  72160. cameraRotation: Vector2;
  72161. /**
  72162. * When set, the up vector of the camera will be updated by the rotation of the camera
  72163. */
  72164. updateUpVectorFromRotation: boolean;
  72165. private _tmpQuaternion;
  72166. /**
  72167. * Define the current rotation of the camera
  72168. */
  72169. rotation: Vector3;
  72170. /**
  72171. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  72172. */
  72173. rotationQuaternion: Quaternion;
  72174. /**
  72175. * Define the current speed of the camera
  72176. */
  72177. speed: number;
  72178. /**
  72179. * Add cconstraint to the camera to prevent it to move freely in all directions and
  72180. * around all axis.
  72181. */
  72182. noRotationConstraint: boolean;
  72183. /**
  72184. * Define the current target of the camera as an object or a position.
  72185. */
  72186. lockedTarget: any;
  72187. /** @hidden */
  72188. _currentTarget: Vector3;
  72189. /** @hidden */
  72190. _initialFocalDistance: number;
  72191. /** @hidden */
  72192. _viewMatrix: Matrix;
  72193. /** @hidden */
  72194. _camMatrix: Matrix;
  72195. /** @hidden */
  72196. _cameraTransformMatrix: Matrix;
  72197. /** @hidden */
  72198. _cameraRotationMatrix: Matrix;
  72199. /** @hidden */
  72200. _referencePoint: Vector3;
  72201. /** @hidden */
  72202. _transformedReferencePoint: Vector3;
  72203. protected _globalCurrentTarget: Vector3;
  72204. protected _globalCurrentUpVector: Vector3;
  72205. /** @hidden */
  72206. _reset: () => void;
  72207. private _defaultUp;
  72208. /**
  72209. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  72210. * This is the base of the follow, arc rotate cameras and Free camera
  72211. * @see http://doc.babylonjs.com/features/cameras
  72212. * @param name Defines the name of the camera in the scene
  72213. * @param position Defines the start position of the camera in the scene
  72214. * @param scene Defines the scene the camera belongs to
  72215. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  72216. */
  72217. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  72218. /**
  72219. * Gets the position in front of the camera at a given distance.
  72220. * @param distance The distance from the camera we want the position to be
  72221. * @returns the position
  72222. */
  72223. getFrontPosition(distance: number): Vector3;
  72224. /** @hidden */
  72225. _getLockedTargetPosition(): Nullable<Vector3>;
  72226. private _storedPosition;
  72227. private _storedRotation;
  72228. private _storedRotationQuaternion;
  72229. /**
  72230. * Store current camera state of the camera (fov, position, rotation, etc..)
  72231. * @returns the camera
  72232. */
  72233. storeState(): Camera;
  72234. /**
  72235. * Restored camera state. You must call storeState() first
  72236. * @returns whether it was successful or not
  72237. * @hidden
  72238. */
  72239. _restoreStateValues(): boolean;
  72240. /** @hidden */
  72241. _initCache(): void;
  72242. /** @hidden */
  72243. _updateCache(ignoreParentClass?: boolean): void;
  72244. /** @hidden */
  72245. _isSynchronizedViewMatrix(): boolean;
  72246. /** @hidden */
  72247. _computeLocalCameraSpeed(): number;
  72248. /**
  72249. * Defines the target the camera should look at.
  72250. * @param target Defines the new target as a Vector or a mesh
  72251. */
  72252. setTarget(target: Vector3): void;
  72253. /**
  72254. * Return the current target position of the camera. This value is expressed in local space.
  72255. * @returns the target position
  72256. */
  72257. getTarget(): Vector3;
  72258. /** @hidden */
  72259. _decideIfNeedsToMove(): boolean;
  72260. /** @hidden */
  72261. _updatePosition(): void;
  72262. /** @hidden */
  72263. _checkInputs(): void;
  72264. protected _updateCameraRotationMatrix(): void;
  72265. /**
  72266. * 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)
  72267. * @returns the current camera
  72268. */
  72269. private _rotateUpVectorWithCameraRotationMatrix;
  72270. private _cachedRotationZ;
  72271. private _cachedQuaternionRotationZ;
  72272. /** @hidden */
  72273. _getViewMatrix(): Matrix;
  72274. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  72275. /**
  72276. * @hidden
  72277. */
  72278. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  72279. /**
  72280. * @hidden
  72281. */
  72282. _updateRigCameras(): void;
  72283. private _getRigCamPositionAndTarget;
  72284. /**
  72285. * Gets the current object class name.
  72286. * @return the class name
  72287. */
  72288. getClassName(): string;
  72289. }
  72290. }
  72291. declare module BABYLON {
  72292. /**
  72293. * Gather the list of keyboard event types as constants.
  72294. */
  72295. export class KeyboardEventTypes {
  72296. /**
  72297. * The keydown event is fired when a key becomes active (pressed).
  72298. */
  72299. static readonly KEYDOWN: number;
  72300. /**
  72301. * The keyup event is fired when a key has been released.
  72302. */
  72303. static readonly KEYUP: number;
  72304. }
  72305. /**
  72306. * This class is used to store keyboard related info for the onKeyboardObservable event.
  72307. */
  72308. export class KeyboardInfo {
  72309. /**
  72310. * Defines the type of event (KeyboardEventTypes)
  72311. */
  72312. type: number;
  72313. /**
  72314. * Defines the related dom event
  72315. */
  72316. event: KeyboardEvent;
  72317. /**
  72318. * Instantiates a new keyboard info.
  72319. * This class is used to store keyboard related info for the onKeyboardObservable event.
  72320. * @param type Defines the type of event (KeyboardEventTypes)
  72321. * @param event Defines the related dom event
  72322. */
  72323. constructor(
  72324. /**
  72325. * Defines the type of event (KeyboardEventTypes)
  72326. */
  72327. type: number,
  72328. /**
  72329. * Defines the related dom event
  72330. */
  72331. event: KeyboardEvent);
  72332. }
  72333. /**
  72334. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  72335. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  72336. */
  72337. export class KeyboardInfoPre extends KeyboardInfo {
  72338. /**
  72339. * Defines the type of event (KeyboardEventTypes)
  72340. */
  72341. type: number;
  72342. /**
  72343. * Defines the related dom event
  72344. */
  72345. event: KeyboardEvent;
  72346. /**
  72347. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  72348. */
  72349. skipOnPointerObservable: boolean;
  72350. /**
  72351. * Instantiates a new keyboard pre info.
  72352. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  72353. * @param type Defines the type of event (KeyboardEventTypes)
  72354. * @param event Defines the related dom event
  72355. */
  72356. constructor(
  72357. /**
  72358. * Defines the type of event (KeyboardEventTypes)
  72359. */
  72360. type: number,
  72361. /**
  72362. * Defines the related dom event
  72363. */
  72364. event: KeyboardEvent);
  72365. }
  72366. }
  72367. declare module BABYLON {
  72368. /**
  72369. * Manage the keyboard inputs to control the movement of a free camera.
  72370. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72371. */
  72372. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  72373. /**
  72374. * Defines the camera the input is attached to.
  72375. */
  72376. camera: FreeCamera;
  72377. /**
  72378. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  72379. */
  72380. keysUp: number[];
  72381. /**
  72382. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  72383. */
  72384. keysDown: number[];
  72385. /**
  72386. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  72387. */
  72388. keysLeft: number[];
  72389. /**
  72390. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  72391. */
  72392. keysRight: number[];
  72393. private _keys;
  72394. private _onCanvasBlurObserver;
  72395. private _onKeyboardObserver;
  72396. private _engine;
  72397. private _scene;
  72398. /**
  72399. * Attach the input controls to a specific dom element to get the input from.
  72400. * @param element Defines the element the controls should be listened from
  72401. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72402. */
  72403. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72404. /**
  72405. * Detach the current controls from the specified dom element.
  72406. * @param element Defines the element to stop listening the inputs from
  72407. */
  72408. detachControl(element: Nullable<HTMLElement>): void;
  72409. /**
  72410. * Update the current camera state depending on the inputs that have been used this frame.
  72411. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72412. */
  72413. checkInputs(): void;
  72414. /**
  72415. * Gets the class name of the current intput.
  72416. * @returns the class name
  72417. */
  72418. getClassName(): string;
  72419. /** @hidden */
  72420. _onLostFocus(): void;
  72421. /**
  72422. * Get the friendly name associated with the input class.
  72423. * @returns the input friendly name
  72424. */
  72425. getSimpleName(): string;
  72426. }
  72427. }
  72428. declare module BABYLON {
  72429. /**
  72430. * Interface describing all the common properties and methods a shadow light needs to implement.
  72431. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  72432. * as well as binding the different shadow properties to the effects.
  72433. */
  72434. export interface IShadowLight extends Light {
  72435. /**
  72436. * The light id in the scene (used in scene.findLighById for instance)
  72437. */
  72438. id: string;
  72439. /**
  72440. * The position the shdow will be casted from.
  72441. */
  72442. position: Vector3;
  72443. /**
  72444. * In 2d mode (needCube being false), the direction used to cast the shadow.
  72445. */
  72446. direction: Vector3;
  72447. /**
  72448. * The transformed position. Position of the light in world space taking parenting in account.
  72449. */
  72450. transformedPosition: Vector3;
  72451. /**
  72452. * The transformed direction. Direction of the light in world space taking parenting in account.
  72453. */
  72454. transformedDirection: Vector3;
  72455. /**
  72456. * The friendly name of the light in the scene.
  72457. */
  72458. name: string;
  72459. /**
  72460. * Defines the shadow projection clipping minimum z value.
  72461. */
  72462. shadowMinZ: number;
  72463. /**
  72464. * Defines the shadow projection clipping maximum z value.
  72465. */
  72466. shadowMaxZ: number;
  72467. /**
  72468. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  72469. * @returns true if the information has been computed, false if it does not need to (no parenting)
  72470. */
  72471. computeTransformedInformation(): boolean;
  72472. /**
  72473. * Gets the scene the light belongs to.
  72474. * @returns The scene
  72475. */
  72476. getScene(): Scene;
  72477. /**
  72478. * Callback defining a custom Projection Matrix Builder.
  72479. * This can be used to override the default projection matrix computation.
  72480. */
  72481. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  72482. /**
  72483. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  72484. * @param matrix The materix to updated with the projection information
  72485. * @param viewMatrix The transform matrix of the light
  72486. * @param renderList The list of mesh to render in the map
  72487. * @returns The current light
  72488. */
  72489. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  72490. /**
  72491. * Gets the current depth scale used in ESM.
  72492. * @returns The scale
  72493. */
  72494. getDepthScale(): number;
  72495. /**
  72496. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  72497. * @returns true if a cube texture needs to be use
  72498. */
  72499. needCube(): boolean;
  72500. /**
  72501. * Detects if the projection matrix requires to be recomputed this frame.
  72502. * @returns true if it requires to be recomputed otherwise, false.
  72503. */
  72504. needProjectionMatrixCompute(): boolean;
  72505. /**
  72506. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  72507. */
  72508. forceProjectionMatrixCompute(): void;
  72509. /**
  72510. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  72511. * @param faceIndex The index of the face we are computed the direction to generate shadow
  72512. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  72513. */
  72514. getShadowDirection(faceIndex?: number): Vector3;
  72515. /**
  72516. * Gets the minZ used for shadow according to both the scene and the light.
  72517. * @param activeCamera The camera we are returning the min for
  72518. * @returns the depth min z
  72519. */
  72520. getDepthMinZ(activeCamera: Camera): number;
  72521. /**
  72522. * Gets the maxZ used for shadow according to both the scene and the light.
  72523. * @param activeCamera The camera we are returning the max for
  72524. * @returns the depth max z
  72525. */
  72526. getDepthMaxZ(activeCamera: Camera): number;
  72527. }
  72528. /**
  72529. * Base implementation IShadowLight
  72530. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  72531. */
  72532. export abstract class ShadowLight extends Light implements IShadowLight {
  72533. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  72534. protected _position: Vector3;
  72535. protected _setPosition(value: Vector3): void;
  72536. /**
  72537. * Sets the position the shadow will be casted from. Also use as the light position for both
  72538. * point and spot lights.
  72539. */
  72540. /**
  72541. * Sets the position the shadow will be casted from. Also use as the light position for both
  72542. * point and spot lights.
  72543. */
  72544. position: Vector3;
  72545. protected _direction: Vector3;
  72546. protected _setDirection(value: Vector3): void;
  72547. /**
  72548. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  72549. * Also use as the light direction on spot and directional lights.
  72550. */
  72551. /**
  72552. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  72553. * Also use as the light direction on spot and directional lights.
  72554. */
  72555. direction: Vector3;
  72556. private _shadowMinZ;
  72557. /**
  72558. * Gets the shadow projection clipping minimum z value.
  72559. */
  72560. /**
  72561. * Sets the shadow projection clipping minimum z value.
  72562. */
  72563. shadowMinZ: number;
  72564. private _shadowMaxZ;
  72565. /**
  72566. * Sets the shadow projection clipping maximum z value.
  72567. */
  72568. /**
  72569. * Gets the shadow projection clipping maximum z value.
  72570. */
  72571. shadowMaxZ: number;
  72572. /**
  72573. * Callback defining a custom Projection Matrix Builder.
  72574. * This can be used to override the default projection matrix computation.
  72575. */
  72576. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  72577. /**
  72578. * The transformed position. Position of the light in world space taking parenting in account.
  72579. */
  72580. transformedPosition: Vector3;
  72581. /**
  72582. * The transformed direction. Direction of the light in world space taking parenting in account.
  72583. */
  72584. transformedDirection: Vector3;
  72585. private _needProjectionMatrixCompute;
  72586. /**
  72587. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  72588. * @returns true if the information has been computed, false if it does not need to (no parenting)
  72589. */
  72590. computeTransformedInformation(): boolean;
  72591. /**
  72592. * Return the depth scale used for the shadow map.
  72593. * @returns the depth scale.
  72594. */
  72595. getDepthScale(): number;
  72596. /**
  72597. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  72598. * @param faceIndex The index of the face we are computed the direction to generate shadow
  72599. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  72600. */
  72601. getShadowDirection(faceIndex?: number): Vector3;
  72602. /**
  72603. * Returns the ShadowLight absolute position in the World.
  72604. * @returns the position vector in world space
  72605. */
  72606. getAbsolutePosition(): Vector3;
  72607. /**
  72608. * Sets the ShadowLight direction toward the passed target.
  72609. * @param target The point to target in local space
  72610. * @returns the updated ShadowLight direction
  72611. */
  72612. setDirectionToTarget(target: Vector3): Vector3;
  72613. /**
  72614. * Returns the light rotation in euler definition.
  72615. * @returns the x y z rotation in local space.
  72616. */
  72617. getRotation(): Vector3;
  72618. /**
  72619. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  72620. * @returns true if a cube texture needs to be use
  72621. */
  72622. needCube(): boolean;
  72623. /**
  72624. * Detects if the projection matrix requires to be recomputed this frame.
  72625. * @returns true if it requires to be recomputed otherwise, false.
  72626. */
  72627. needProjectionMatrixCompute(): boolean;
  72628. /**
  72629. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  72630. */
  72631. forceProjectionMatrixCompute(): void;
  72632. /** @hidden */
  72633. _initCache(): void;
  72634. /** @hidden */
  72635. _isSynchronized(): boolean;
  72636. /**
  72637. * Computes the world matrix of the node
  72638. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  72639. * @returns the world matrix
  72640. */
  72641. computeWorldMatrix(force?: boolean): Matrix;
  72642. /**
  72643. * Gets the minZ used for shadow according to both the scene and the light.
  72644. * @param activeCamera The camera we are returning the min for
  72645. * @returns the depth min z
  72646. */
  72647. getDepthMinZ(activeCamera: Camera): number;
  72648. /**
  72649. * Gets the maxZ used for shadow according to both the scene and the light.
  72650. * @param activeCamera The camera we are returning the max for
  72651. * @returns the depth max z
  72652. */
  72653. getDepthMaxZ(activeCamera: Camera): number;
  72654. /**
  72655. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  72656. * @param matrix The materix to updated with the projection information
  72657. * @param viewMatrix The transform matrix of the light
  72658. * @param renderList The list of mesh to render in the map
  72659. * @returns The current light
  72660. */
  72661. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  72662. }
  72663. }
  72664. declare module BABYLON {
  72665. /**
  72666. * "Static Class" containing the most commonly used helper while dealing with material for
  72667. * rendering purpose.
  72668. *
  72669. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  72670. *
  72671. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  72672. */
  72673. export class MaterialHelper {
  72674. /**
  72675. * Bind the current view position to an effect.
  72676. * @param effect The effect to be bound
  72677. * @param scene The scene the eyes position is used from
  72678. */
  72679. static BindEyePosition(effect: Effect, scene: Scene): void;
  72680. /**
  72681. * Helps preparing the defines values about the UVs in used in the effect.
  72682. * UVs are shared as much as we can accross channels in the shaders.
  72683. * @param texture The texture we are preparing the UVs for
  72684. * @param defines The defines to update
  72685. * @param key The channel key "diffuse", "specular"... used in the shader
  72686. */
  72687. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  72688. /**
  72689. * Binds a texture matrix value to its corrsponding uniform
  72690. * @param texture The texture to bind the matrix for
  72691. * @param uniformBuffer The uniform buffer receivin the data
  72692. * @param key The channel key "diffuse", "specular"... used in the shader
  72693. */
  72694. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  72695. /**
  72696. * Gets the current status of the fog (should it be enabled?)
  72697. * @param mesh defines the mesh to evaluate for fog support
  72698. * @param scene defines the hosting scene
  72699. * @returns true if fog must be enabled
  72700. */
  72701. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  72702. /**
  72703. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  72704. * @param mesh defines the current mesh
  72705. * @param scene defines the current scene
  72706. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  72707. * @param pointsCloud defines if point cloud rendering has to be turned on
  72708. * @param fogEnabled defines if fog has to be turned on
  72709. * @param alphaTest defines if alpha testing has to be turned on
  72710. * @param defines defines the current list of defines
  72711. */
  72712. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  72713. /**
  72714. * Helper used to prepare the list of defines associated with frame values for shader compilation
  72715. * @param scene defines the current scene
  72716. * @param engine defines the current engine
  72717. * @param defines specifies the list of active defines
  72718. * @param useInstances defines if instances have to be turned on
  72719. * @param useClipPlane defines if clip plane have to be turned on
  72720. */
  72721. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  72722. /**
  72723. * Prepares the defines for bones
  72724. * @param mesh The mesh containing the geometry data we will draw
  72725. * @param defines The defines to update
  72726. */
  72727. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  72728. /**
  72729. * Prepares the defines for morph targets
  72730. * @param mesh The mesh containing the geometry data we will draw
  72731. * @param defines The defines to update
  72732. */
  72733. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  72734. /**
  72735. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  72736. * @param mesh The mesh containing the geometry data we will draw
  72737. * @param defines The defines to update
  72738. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  72739. * @param useBones Precise whether bones should be used or not (override mesh info)
  72740. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  72741. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  72742. * @returns false if defines are considered not dirty and have not been checked
  72743. */
  72744. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  72745. /**
  72746. * Prepares the defines related to multiview
  72747. * @param scene The scene we are intending to draw
  72748. * @param defines The defines to update
  72749. */
  72750. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  72751. /**
  72752. * Prepares the defines related to the light information passed in parameter
  72753. * @param scene The scene we are intending to draw
  72754. * @param mesh The mesh the effect is compiling for
  72755. * @param light The light the effect is compiling for
  72756. * @param lightIndex The index of the light
  72757. * @param defines The defines to update
  72758. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  72759. * @param state Defines the current state regarding what is needed (normals, etc...)
  72760. */
  72761. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  72762. needNormals: boolean;
  72763. needRebuild: boolean;
  72764. shadowEnabled: boolean;
  72765. specularEnabled: boolean;
  72766. lightmapMode: boolean;
  72767. }): void;
  72768. /**
  72769. * Prepares the defines related to the light information passed in parameter
  72770. * @param scene The scene we are intending to draw
  72771. * @param mesh The mesh the effect is compiling for
  72772. * @param defines The defines to update
  72773. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  72774. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  72775. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  72776. * @returns true if normals will be required for the rest of the effect
  72777. */
  72778. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  72779. /**
  72780. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  72781. * @param lightIndex defines the light index
  72782. * @param uniformsList The uniform list
  72783. * @param samplersList The sampler list
  72784. * @param projectedLightTexture defines if projected texture must be used
  72785. * @param uniformBuffersList defines an optional list of uniform buffers
  72786. */
  72787. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  72788. /**
  72789. * Prepares the uniforms and samplers list to be used in the effect
  72790. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  72791. * @param samplersList The sampler list
  72792. * @param defines The defines helping in the list generation
  72793. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  72794. */
  72795. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  72796. /**
  72797. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  72798. * @param defines The defines to update while falling back
  72799. * @param fallbacks The authorized effect fallbacks
  72800. * @param maxSimultaneousLights The maximum number of lights allowed
  72801. * @param rank the current rank of the Effect
  72802. * @returns The newly affected rank
  72803. */
  72804. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  72805. private static _TmpMorphInfluencers;
  72806. /**
  72807. * Prepares the list of attributes required for morph targets according to the effect defines.
  72808. * @param attribs The current list of supported attribs
  72809. * @param mesh The mesh to prepare the morph targets attributes for
  72810. * @param influencers The number of influencers
  72811. */
  72812. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  72813. /**
  72814. * Prepares the list of attributes required for morph targets according to the effect defines.
  72815. * @param attribs The current list of supported attribs
  72816. * @param mesh The mesh to prepare the morph targets attributes for
  72817. * @param defines The current Defines of the effect
  72818. */
  72819. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  72820. /**
  72821. * Prepares the list of attributes required for bones according to the effect defines.
  72822. * @param attribs The current list of supported attribs
  72823. * @param mesh The mesh to prepare the bones attributes for
  72824. * @param defines The current Defines of the effect
  72825. * @param fallbacks The current efffect fallback strategy
  72826. */
  72827. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  72828. /**
  72829. * Check and prepare the list of attributes required for instances according to the effect defines.
  72830. * @param attribs The current list of supported attribs
  72831. * @param defines The current MaterialDefines of the effect
  72832. */
  72833. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  72834. /**
  72835. * Add the list of attributes required for instances to the attribs array.
  72836. * @param attribs The current list of supported attribs
  72837. */
  72838. static PushAttributesForInstances(attribs: string[]): void;
  72839. /**
  72840. * Binds the light shadow information to the effect for the given mesh.
  72841. * @param light The light containing the generator
  72842. * @param scene The scene the lights belongs to
  72843. * @param mesh The mesh we are binding the information to render
  72844. * @param lightIndex The light index in the effect used to render the mesh
  72845. * @param effect The effect we are binding the data to
  72846. */
  72847. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  72848. /**
  72849. * Binds the light information to the effect.
  72850. * @param light The light containing the generator
  72851. * @param effect The effect we are binding the data to
  72852. * @param lightIndex The light index in the effect used to render
  72853. */
  72854. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  72855. /**
  72856. * Binds the lights information from the scene to the effect for the given mesh.
  72857. * @param light Light to bind
  72858. * @param lightIndex Light index
  72859. * @param scene The scene where the light belongs to
  72860. * @param mesh The mesh we are binding the information to render
  72861. * @param effect The effect we are binding the data to
  72862. * @param useSpecular Defines if specular is supported
  72863. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  72864. */
  72865. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  72866. /**
  72867. * Binds the lights information from the scene to the effect for the given mesh.
  72868. * @param scene The scene the lights belongs to
  72869. * @param mesh The mesh we are binding the information to render
  72870. * @param effect The effect we are binding the data to
  72871. * @param defines The generated defines for the effect
  72872. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  72873. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  72874. */
  72875. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  72876. private static _tempFogColor;
  72877. /**
  72878. * Binds the fog information from the scene to the effect for the given mesh.
  72879. * @param scene The scene the lights belongs to
  72880. * @param mesh The mesh we are binding the information to render
  72881. * @param effect The effect we are binding the data to
  72882. * @param linearSpace Defines if the fog effect is applied in linear space
  72883. */
  72884. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  72885. /**
  72886. * Binds the bones information from the mesh to the effect.
  72887. * @param mesh The mesh we are binding the information to render
  72888. * @param effect The effect we are binding the data to
  72889. */
  72890. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  72891. /**
  72892. * Binds the morph targets information from the mesh to the effect.
  72893. * @param abstractMesh The mesh we are binding the information to render
  72894. * @param effect The effect we are binding the data to
  72895. */
  72896. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  72897. /**
  72898. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  72899. * @param defines The generated defines used in the effect
  72900. * @param effect The effect we are binding the data to
  72901. * @param scene The scene we are willing to render with logarithmic scale for
  72902. */
  72903. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  72904. /**
  72905. * Binds the clip plane information from the scene to the effect.
  72906. * @param scene The scene the clip plane information are extracted from
  72907. * @param effect The effect we are binding the data to
  72908. */
  72909. static BindClipPlane(effect: Effect, scene: Scene): void;
  72910. }
  72911. }
  72912. declare module BABYLON {
  72913. /** @hidden */
  72914. export var packingFunctions: {
  72915. name: string;
  72916. shader: string;
  72917. };
  72918. }
  72919. declare module BABYLON {
  72920. /** @hidden */
  72921. export var shadowMapPixelShader: {
  72922. name: string;
  72923. shader: string;
  72924. };
  72925. }
  72926. declare module BABYLON {
  72927. /** @hidden */
  72928. export var bonesDeclaration: {
  72929. name: string;
  72930. shader: string;
  72931. };
  72932. }
  72933. declare module BABYLON {
  72934. /** @hidden */
  72935. export var morphTargetsVertexGlobalDeclaration: {
  72936. name: string;
  72937. shader: string;
  72938. };
  72939. }
  72940. declare module BABYLON {
  72941. /** @hidden */
  72942. export var morphTargetsVertexDeclaration: {
  72943. name: string;
  72944. shader: string;
  72945. };
  72946. }
  72947. declare module BABYLON {
  72948. /** @hidden */
  72949. export var instancesDeclaration: {
  72950. name: string;
  72951. shader: string;
  72952. };
  72953. }
  72954. declare module BABYLON {
  72955. /** @hidden */
  72956. export var helperFunctions: {
  72957. name: string;
  72958. shader: string;
  72959. };
  72960. }
  72961. declare module BABYLON {
  72962. /** @hidden */
  72963. export var morphTargetsVertex: {
  72964. name: string;
  72965. shader: string;
  72966. };
  72967. }
  72968. declare module BABYLON {
  72969. /** @hidden */
  72970. export var instancesVertex: {
  72971. name: string;
  72972. shader: string;
  72973. };
  72974. }
  72975. declare module BABYLON {
  72976. /** @hidden */
  72977. export var bonesVertex: {
  72978. name: string;
  72979. shader: string;
  72980. };
  72981. }
  72982. declare module BABYLON {
  72983. /** @hidden */
  72984. export var shadowMapVertexShader: {
  72985. name: string;
  72986. shader: string;
  72987. };
  72988. }
  72989. declare module BABYLON {
  72990. /** @hidden */
  72991. export var depthBoxBlurPixelShader: {
  72992. name: string;
  72993. shader: string;
  72994. };
  72995. }
  72996. declare module BABYLON {
  72997. /**
  72998. * Defines the options associated with the creation of a custom shader for a shadow generator.
  72999. */
  73000. export interface ICustomShaderOptions {
  73001. /**
  73002. * Gets or sets the custom shader name to use
  73003. */
  73004. shaderName: string;
  73005. /**
  73006. * The list of attribute names used in the shader
  73007. */
  73008. attributes?: string[];
  73009. /**
  73010. * The list of unifrom names used in the shader
  73011. */
  73012. uniforms?: string[];
  73013. /**
  73014. * The list of sampler names used in the shader
  73015. */
  73016. samplers?: string[];
  73017. /**
  73018. * The list of defines used in the shader
  73019. */
  73020. defines?: string[];
  73021. }
  73022. /**
  73023. * Interface to implement to create a shadow generator compatible with BJS.
  73024. */
  73025. export interface IShadowGenerator {
  73026. /**
  73027. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  73028. * @returns The render target texture if present otherwise, null
  73029. */
  73030. getShadowMap(): Nullable<RenderTargetTexture>;
  73031. /**
  73032. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  73033. * @returns The render target texture if the shadow map is present otherwise, null
  73034. */
  73035. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  73036. /**
  73037. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  73038. * @param subMesh The submesh we want to render in the shadow map
  73039. * @param useInstances Defines wether will draw in the map using instances
  73040. * @returns true if ready otherwise, false
  73041. */
  73042. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73043. /**
  73044. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  73045. * @param defines Defines of the material we want to update
  73046. * @param lightIndex Index of the light in the enabled light list of the material
  73047. */
  73048. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  73049. /**
  73050. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  73051. * defined in the generator but impacting the effect).
  73052. * It implies the unifroms available on the materials are the standard BJS ones.
  73053. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  73054. * @param effect The effect we are binfing the information for
  73055. */
  73056. bindShadowLight(lightIndex: string, effect: Effect): void;
  73057. /**
  73058. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  73059. * (eq to shadow prjection matrix * light transform matrix)
  73060. * @returns The transform matrix used to create the shadow map
  73061. */
  73062. getTransformMatrix(): Matrix;
  73063. /**
  73064. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  73065. * Cube and 2D textures for instance.
  73066. */
  73067. recreateShadowMap(): void;
  73068. /**
  73069. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73070. * @param onCompiled Callback triggered at the and of the effects compilation
  73071. * @param options Sets of optional options forcing the compilation with different modes
  73072. */
  73073. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  73074. useInstances: boolean;
  73075. }>): void;
  73076. /**
  73077. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73078. * @param options Sets of optional options forcing the compilation with different modes
  73079. * @returns A promise that resolves when the compilation completes
  73080. */
  73081. forceCompilationAsync(options?: Partial<{
  73082. useInstances: boolean;
  73083. }>): Promise<void>;
  73084. /**
  73085. * Serializes the shadow generator setup to a json object.
  73086. * @returns The serialized JSON object
  73087. */
  73088. serialize(): any;
  73089. /**
  73090. * Disposes the Shadow map and related Textures and effects.
  73091. */
  73092. dispose(): void;
  73093. }
  73094. /**
  73095. * Default implementation IShadowGenerator.
  73096. * This is the main object responsible of generating shadows in the framework.
  73097. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  73098. */
  73099. export class ShadowGenerator implements IShadowGenerator {
  73100. /**
  73101. * Shadow generator mode None: no filtering applied.
  73102. */
  73103. static readonly FILTER_NONE: number;
  73104. /**
  73105. * Shadow generator mode ESM: Exponential Shadow Mapping.
  73106. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73107. */
  73108. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  73109. /**
  73110. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  73111. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  73112. */
  73113. static readonly FILTER_POISSONSAMPLING: number;
  73114. /**
  73115. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  73116. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73117. */
  73118. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  73119. /**
  73120. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  73121. * edge artifacts on steep falloff.
  73122. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73123. */
  73124. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  73125. /**
  73126. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  73127. * edge artifacts on steep falloff.
  73128. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73129. */
  73130. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  73131. /**
  73132. * Shadow generator mode PCF: Percentage Closer Filtering
  73133. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73134. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  73135. */
  73136. static readonly FILTER_PCF: number;
  73137. /**
  73138. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  73139. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73140. * Contact Hardening
  73141. */
  73142. static readonly FILTER_PCSS: number;
  73143. /**
  73144. * Reserved for PCF and PCSS
  73145. * Highest Quality.
  73146. *
  73147. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  73148. *
  73149. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  73150. */
  73151. static readonly QUALITY_HIGH: number;
  73152. /**
  73153. * Reserved for PCF and PCSS
  73154. * Good tradeoff for quality/perf cross devices
  73155. *
  73156. * Execute PCF on a 3*3 kernel.
  73157. *
  73158. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  73159. */
  73160. static readonly QUALITY_MEDIUM: number;
  73161. /**
  73162. * Reserved for PCF and PCSS
  73163. * The lowest quality but the fastest.
  73164. *
  73165. * Execute PCF on a 1*1 kernel.
  73166. *
  73167. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  73168. */
  73169. static readonly QUALITY_LOW: number;
  73170. /** Gets or sets the custom shader name to use */
  73171. customShaderOptions: ICustomShaderOptions;
  73172. /**
  73173. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  73174. */
  73175. onBeforeShadowMapRenderObservable: Observable<Effect>;
  73176. /**
  73177. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  73178. */
  73179. onAfterShadowMapRenderObservable: Observable<Effect>;
  73180. /**
  73181. * Observable triggered before a mesh is rendered in the shadow map.
  73182. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  73183. */
  73184. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  73185. /**
  73186. * Observable triggered after a mesh is rendered in the shadow map.
  73187. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  73188. */
  73189. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  73190. private _bias;
  73191. /**
  73192. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  73193. */
  73194. /**
  73195. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  73196. */
  73197. bias: number;
  73198. private _normalBias;
  73199. /**
  73200. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73201. */
  73202. /**
  73203. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73204. */
  73205. normalBias: number;
  73206. private _blurBoxOffset;
  73207. /**
  73208. * Gets the blur box offset: offset applied during the blur pass.
  73209. * Only useful if useKernelBlur = false
  73210. */
  73211. /**
  73212. * Sets the blur box offset: offset applied during the blur pass.
  73213. * Only useful if useKernelBlur = false
  73214. */
  73215. blurBoxOffset: number;
  73216. private _blurScale;
  73217. /**
  73218. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  73219. * 2 means half of the size.
  73220. */
  73221. /**
  73222. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  73223. * 2 means half of the size.
  73224. */
  73225. blurScale: number;
  73226. private _blurKernel;
  73227. /**
  73228. * Gets the blur kernel: kernel size of the blur pass.
  73229. * Only useful if useKernelBlur = true
  73230. */
  73231. /**
  73232. * Sets the blur kernel: kernel size of the blur pass.
  73233. * Only useful if useKernelBlur = true
  73234. */
  73235. blurKernel: number;
  73236. private _useKernelBlur;
  73237. /**
  73238. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  73239. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  73240. */
  73241. /**
  73242. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  73243. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  73244. */
  73245. useKernelBlur: boolean;
  73246. private _depthScale;
  73247. /**
  73248. * Gets the depth scale used in ESM mode.
  73249. */
  73250. /**
  73251. * Sets the depth scale used in ESM mode.
  73252. * This can override the scale stored on the light.
  73253. */
  73254. depthScale: number;
  73255. private _filter;
  73256. /**
  73257. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  73258. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  73259. */
  73260. /**
  73261. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  73262. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  73263. */
  73264. filter: number;
  73265. /**
  73266. * Gets if the current filter is set to Poisson Sampling.
  73267. */
  73268. /**
  73269. * Sets the current filter to Poisson Sampling.
  73270. */
  73271. usePoissonSampling: boolean;
  73272. /**
  73273. * Gets if the current filter is set to ESM.
  73274. */
  73275. /**
  73276. * Sets the current filter is to ESM.
  73277. */
  73278. useExponentialShadowMap: boolean;
  73279. /**
  73280. * Gets if the current filter is set to filtered ESM.
  73281. */
  73282. /**
  73283. * Gets if the current filter is set to filtered ESM.
  73284. */
  73285. useBlurExponentialShadowMap: boolean;
  73286. /**
  73287. * Gets if the current filter is set to "close ESM" (using the inverse of the
  73288. * exponential to prevent steep falloff artifacts).
  73289. */
  73290. /**
  73291. * Sets the current filter to "close ESM" (using the inverse of the
  73292. * exponential to prevent steep falloff artifacts).
  73293. */
  73294. useCloseExponentialShadowMap: boolean;
  73295. /**
  73296. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  73297. * exponential to prevent steep falloff artifacts).
  73298. */
  73299. /**
  73300. * Sets the current filter to filtered "close ESM" (using the inverse of the
  73301. * exponential to prevent steep falloff artifacts).
  73302. */
  73303. useBlurCloseExponentialShadowMap: boolean;
  73304. /**
  73305. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  73306. */
  73307. /**
  73308. * Sets the current filter to "PCF" (percentage closer filtering).
  73309. */
  73310. usePercentageCloserFiltering: boolean;
  73311. private _filteringQuality;
  73312. /**
  73313. * Gets the PCF or PCSS Quality.
  73314. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  73315. */
  73316. /**
  73317. * Sets the PCF or PCSS Quality.
  73318. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  73319. */
  73320. filteringQuality: number;
  73321. /**
  73322. * Gets if the current filter is set to "PCSS" (contact hardening).
  73323. */
  73324. /**
  73325. * Sets the current filter to "PCSS" (contact hardening).
  73326. */
  73327. useContactHardeningShadow: boolean;
  73328. private _contactHardeningLightSizeUVRatio;
  73329. /**
  73330. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  73331. * Using a ratio helps keeping shape stability independently of the map size.
  73332. *
  73333. * It does not account for the light projection as it was having too much
  73334. * instability during the light setup or during light position changes.
  73335. *
  73336. * Only valid if useContactHardeningShadow is true.
  73337. */
  73338. /**
  73339. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  73340. * Using a ratio helps keeping shape stability independently of the map size.
  73341. *
  73342. * It does not account for the light projection as it was having too much
  73343. * instability during the light setup or during light position changes.
  73344. *
  73345. * Only valid if useContactHardeningShadow is true.
  73346. */
  73347. contactHardeningLightSizeUVRatio: number;
  73348. private _darkness;
  73349. /** Gets or sets the actual darkness of a shadow */
  73350. darkness: number;
  73351. /**
  73352. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  73353. * 0 means strongest and 1 would means no shadow.
  73354. * @returns the darkness.
  73355. */
  73356. getDarkness(): number;
  73357. /**
  73358. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  73359. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  73360. * @returns the shadow generator allowing fluent coding.
  73361. */
  73362. setDarkness(darkness: number): ShadowGenerator;
  73363. private _transparencyShadow;
  73364. /** Gets or sets the ability to have transparent shadow */
  73365. transparencyShadow: boolean;
  73366. /**
  73367. * Sets the ability to have transparent shadow (boolean).
  73368. * @param transparent True if transparent else False
  73369. * @returns the shadow generator allowing fluent coding
  73370. */
  73371. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  73372. private _shadowMap;
  73373. private _shadowMap2;
  73374. /**
  73375. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  73376. * @returns The render target texture if present otherwise, null
  73377. */
  73378. getShadowMap(): Nullable<RenderTargetTexture>;
  73379. /**
  73380. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  73381. * @returns The render target texture if the shadow map is present otherwise, null
  73382. */
  73383. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  73384. /**
  73385. * Gets the class name of that object
  73386. * @returns "ShadowGenerator"
  73387. */
  73388. getClassName(): string;
  73389. /**
  73390. * Helper function to add a mesh and its descendants to the list of shadow casters.
  73391. * @param mesh Mesh to add
  73392. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  73393. * @returns the Shadow Generator itself
  73394. */
  73395. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  73396. /**
  73397. * Helper function to remove a mesh and its descendants from the list of shadow casters
  73398. * @param mesh Mesh to remove
  73399. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  73400. * @returns the Shadow Generator itself
  73401. */
  73402. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  73403. /**
  73404. * Controls the extent to which the shadows fade out at the edge of the frustum
  73405. * Used only by directionals and spots
  73406. */
  73407. frustumEdgeFalloff: number;
  73408. private _light;
  73409. /**
  73410. * Returns the associated light object.
  73411. * @returns the light generating the shadow
  73412. */
  73413. getLight(): IShadowLight;
  73414. /**
  73415. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  73416. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  73417. * It might on the other hand introduce peter panning.
  73418. */
  73419. forceBackFacesOnly: boolean;
  73420. private _scene;
  73421. private _lightDirection;
  73422. private _effect;
  73423. private _viewMatrix;
  73424. private _projectionMatrix;
  73425. private _transformMatrix;
  73426. private _cachedPosition;
  73427. private _cachedDirection;
  73428. private _cachedDefines;
  73429. private _currentRenderID;
  73430. private _boxBlurPostprocess;
  73431. private _kernelBlurXPostprocess;
  73432. private _kernelBlurYPostprocess;
  73433. private _blurPostProcesses;
  73434. private _mapSize;
  73435. private _currentFaceIndex;
  73436. private _currentFaceIndexCache;
  73437. private _textureType;
  73438. private _defaultTextureMatrix;
  73439. /** @hidden */
  73440. static _SceneComponentInitialization: (scene: Scene) => void;
  73441. /**
  73442. * Creates a ShadowGenerator object.
  73443. * A ShadowGenerator is the required tool to use the shadows.
  73444. * Each light casting shadows needs to use its own ShadowGenerator.
  73445. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  73446. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  73447. * @param light The light object generating the shadows.
  73448. * @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.
  73449. */
  73450. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  73451. private _initializeGenerator;
  73452. private _initializeShadowMap;
  73453. private _initializeBlurRTTAndPostProcesses;
  73454. private _renderForShadowMap;
  73455. private _renderSubMeshForShadowMap;
  73456. private _applyFilterValues;
  73457. /**
  73458. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73459. * @param onCompiled Callback triggered at the and of the effects compilation
  73460. * @param options Sets of optional options forcing the compilation with different modes
  73461. */
  73462. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  73463. useInstances: boolean;
  73464. }>): void;
  73465. /**
  73466. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73467. * @param options Sets of optional options forcing the compilation with different modes
  73468. * @returns A promise that resolves when the compilation completes
  73469. */
  73470. forceCompilationAsync(options?: Partial<{
  73471. useInstances: boolean;
  73472. }>): Promise<void>;
  73473. /**
  73474. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  73475. * @param subMesh The submesh we want to render in the shadow map
  73476. * @param useInstances Defines wether will draw in the map using instances
  73477. * @returns true if ready otherwise, false
  73478. */
  73479. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73480. /**
  73481. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  73482. * @param defines Defines of the material we want to update
  73483. * @param lightIndex Index of the light in the enabled light list of the material
  73484. */
  73485. prepareDefines(defines: any, lightIndex: number): void;
  73486. /**
  73487. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  73488. * defined in the generator but impacting the effect).
  73489. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  73490. * @param effect The effect we are binfing the information for
  73491. */
  73492. bindShadowLight(lightIndex: string, effect: Effect): void;
  73493. /**
  73494. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  73495. * (eq to shadow prjection matrix * light transform matrix)
  73496. * @returns The transform matrix used to create the shadow map
  73497. */
  73498. getTransformMatrix(): Matrix;
  73499. /**
  73500. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  73501. * Cube and 2D textures for instance.
  73502. */
  73503. recreateShadowMap(): void;
  73504. private _disposeBlurPostProcesses;
  73505. private _disposeRTTandPostProcesses;
  73506. /**
  73507. * Disposes the ShadowGenerator.
  73508. * Returns nothing.
  73509. */
  73510. dispose(): void;
  73511. /**
  73512. * Serializes the shadow generator setup to a json object.
  73513. * @returns The serialized JSON object
  73514. */
  73515. serialize(): any;
  73516. /**
  73517. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  73518. * @param parsedShadowGenerator The JSON object to parse
  73519. * @param scene The scene to create the shadow map for
  73520. * @returns The parsed shadow generator
  73521. */
  73522. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  73523. }
  73524. }
  73525. declare module BABYLON {
  73526. /**
  73527. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  73528. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  73529. * 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.
  73530. */
  73531. export abstract class Light extends Node {
  73532. /**
  73533. * Falloff Default: light is falling off following the material specification:
  73534. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  73535. */
  73536. static readonly FALLOFF_DEFAULT: number;
  73537. /**
  73538. * Falloff Physical: light is falling off following the inverse squared distance law.
  73539. */
  73540. static readonly FALLOFF_PHYSICAL: number;
  73541. /**
  73542. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  73543. * to enhance interoperability with other engines.
  73544. */
  73545. static readonly FALLOFF_GLTF: number;
  73546. /**
  73547. * Falloff Standard: light is falling off like in the standard material
  73548. * to enhance interoperability with other materials.
  73549. */
  73550. static readonly FALLOFF_STANDARD: number;
  73551. /**
  73552. * If every light affecting the material is in this lightmapMode,
  73553. * material.lightmapTexture adds or multiplies
  73554. * (depends on material.useLightmapAsShadowmap)
  73555. * after every other light calculations.
  73556. */
  73557. static readonly LIGHTMAP_DEFAULT: number;
  73558. /**
  73559. * material.lightmapTexture as only diffuse lighting from this light
  73560. * adds only specular lighting from this light
  73561. * adds dynamic shadows
  73562. */
  73563. static readonly LIGHTMAP_SPECULAR: number;
  73564. /**
  73565. * material.lightmapTexture as only lighting
  73566. * no light calculation from this light
  73567. * only adds dynamic shadows from this light
  73568. */
  73569. static readonly LIGHTMAP_SHADOWSONLY: number;
  73570. /**
  73571. * Each light type uses the default quantity according to its type:
  73572. * point/spot lights use luminous intensity
  73573. * directional lights use illuminance
  73574. */
  73575. static readonly INTENSITYMODE_AUTOMATIC: number;
  73576. /**
  73577. * lumen (lm)
  73578. */
  73579. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  73580. /**
  73581. * candela (lm/sr)
  73582. */
  73583. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  73584. /**
  73585. * lux (lm/m^2)
  73586. */
  73587. static readonly INTENSITYMODE_ILLUMINANCE: number;
  73588. /**
  73589. * nit (cd/m^2)
  73590. */
  73591. static readonly INTENSITYMODE_LUMINANCE: number;
  73592. /**
  73593. * Light type const id of the point light.
  73594. */
  73595. static readonly LIGHTTYPEID_POINTLIGHT: number;
  73596. /**
  73597. * Light type const id of the directional light.
  73598. */
  73599. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  73600. /**
  73601. * Light type const id of the spot light.
  73602. */
  73603. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  73604. /**
  73605. * Light type const id of the hemispheric light.
  73606. */
  73607. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  73608. /**
  73609. * Diffuse gives the basic color to an object.
  73610. */
  73611. diffuse: Color3;
  73612. /**
  73613. * Specular produces a highlight color on an object.
  73614. * Note: This is note affecting PBR materials.
  73615. */
  73616. specular: Color3;
  73617. /**
  73618. * Defines the falloff type for this light. This lets overrriding how punctual light are
  73619. * falling off base on range or angle.
  73620. * This can be set to any values in Light.FALLOFF_x.
  73621. *
  73622. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  73623. * other types of materials.
  73624. */
  73625. falloffType: number;
  73626. /**
  73627. * Strength of the light.
  73628. * Note: By default it is define in the framework own unit.
  73629. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  73630. */
  73631. intensity: number;
  73632. private _range;
  73633. protected _inverseSquaredRange: number;
  73634. /**
  73635. * Defines how far from the source the light is impacting in scene units.
  73636. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  73637. */
  73638. /**
  73639. * Defines how far from the source the light is impacting in scene units.
  73640. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  73641. */
  73642. range: number;
  73643. /**
  73644. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  73645. * of light.
  73646. */
  73647. private _photometricScale;
  73648. private _intensityMode;
  73649. /**
  73650. * Gets the photometric scale used to interpret the intensity.
  73651. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  73652. */
  73653. /**
  73654. * Sets the photometric scale used to interpret the intensity.
  73655. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  73656. */
  73657. intensityMode: number;
  73658. private _radius;
  73659. /**
  73660. * Gets the light radius used by PBR Materials to simulate soft area lights.
  73661. */
  73662. /**
  73663. * sets the light radius used by PBR Materials to simulate soft area lights.
  73664. */
  73665. radius: number;
  73666. private _renderPriority;
  73667. /**
  73668. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  73669. * exceeding the number allowed of the materials.
  73670. */
  73671. renderPriority: number;
  73672. private _shadowEnabled;
  73673. /**
  73674. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  73675. * the current shadow generator.
  73676. */
  73677. /**
  73678. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  73679. * the current shadow generator.
  73680. */
  73681. shadowEnabled: boolean;
  73682. private _includedOnlyMeshes;
  73683. /**
  73684. * Gets the only meshes impacted by this light.
  73685. */
  73686. /**
  73687. * Sets the only meshes impacted by this light.
  73688. */
  73689. includedOnlyMeshes: AbstractMesh[];
  73690. private _excludedMeshes;
  73691. /**
  73692. * Gets the meshes not impacted by this light.
  73693. */
  73694. /**
  73695. * Sets the meshes not impacted by this light.
  73696. */
  73697. excludedMeshes: AbstractMesh[];
  73698. private _excludeWithLayerMask;
  73699. /**
  73700. * Gets the layer id use to find what meshes are not impacted by the light.
  73701. * Inactive if 0
  73702. */
  73703. /**
  73704. * Sets the layer id use to find what meshes are not impacted by the light.
  73705. * Inactive if 0
  73706. */
  73707. excludeWithLayerMask: number;
  73708. private _includeOnlyWithLayerMask;
  73709. /**
  73710. * Gets the layer id use to find what meshes are impacted by the light.
  73711. * Inactive if 0
  73712. */
  73713. /**
  73714. * Sets the layer id use to find what meshes are impacted by the light.
  73715. * Inactive if 0
  73716. */
  73717. includeOnlyWithLayerMask: number;
  73718. private _lightmapMode;
  73719. /**
  73720. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  73721. */
  73722. /**
  73723. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  73724. */
  73725. lightmapMode: number;
  73726. /**
  73727. * Shadow generator associted to the light.
  73728. * @hidden Internal use only.
  73729. */
  73730. _shadowGenerator: Nullable<IShadowGenerator>;
  73731. /**
  73732. * @hidden Internal use only.
  73733. */
  73734. _excludedMeshesIds: string[];
  73735. /**
  73736. * @hidden Internal use only.
  73737. */
  73738. _includedOnlyMeshesIds: string[];
  73739. /**
  73740. * The current light unifom buffer.
  73741. * @hidden Internal use only.
  73742. */
  73743. _uniformBuffer: UniformBuffer;
  73744. /**
  73745. * Creates a Light object in the scene.
  73746. * Documentation : https://doc.babylonjs.com/babylon101/lights
  73747. * @param name The firendly name of the light
  73748. * @param scene The scene the light belongs too
  73749. */
  73750. constructor(name: string, scene: Scene);
  73751. protected abstract _buildUniformLayout(): void;
  73752. /**
  73753. * Sets the passed Effect "effect" with the Light information.
  73754. * @param effect The effect to update
  73755. * @param lightIndex The index of the light in the effect to update
  73756. * @returns The light
  73757. */
  73758. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  73759. /**
  73760. * Returns the string "Light".
  73761. * @returns the class name
  73762. */
  73763. getClassName(): string;
  73764. /** @hidden */
  73765. readonly _isLight: boolean;
  73766. /**
  73767. * Converts the light information to a readable string for debug purpose.
  73768. * @param fullDetails Supports for multiple levels of logging within scene loading
  73769. * @returns the human readable light info
  73770. */
  73771. toString(fullDetails?: boolean): string;
  73772. /** @hidden */
  73773. protected _syncParentEnabledState(): void;
  73774. /**
  73775. * Set the enabled state of this node.
  73776. * @param value - the new enabled state
  73777. */
  73778. setEnabled(value: boolean): void;
  73779. /**
  73780. * Returns the Light associated shadow generator if any.
  73781. * @return the associated shadow generator.
  73782. */
  73783. getShadowGenerator(): Nullable<IShadowGenerator>;
  73784. /**
  73785. * Returns a Vector3, the absolute light position in the World.
  73786. * @returns the world space position of the light
  73787. */
  73788. getAbsolutePosition(): Vector3;
  73789. /**
  73790. * Specifies if the light will affect the passed mesh.
  73791. * @param mesh The mesh to test against the light
  73792. * @return true the mesh is affected otherwise, false.
  73793. */
  73794. canAffectMesh(mesh: AbstractMesh): boolean;
  73795. /**
  73796. * Sort function to order lights for rendering.
  73797. * @param a First Light object to compare to second.
  73798. * @param b Second Light object to compare first.
  73799. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  73800. */
  73801. static CompareLightsPriority(a: Light, b: Light): number;
  73802. /**
  73803. * Releases resources associated with this node.
  73804. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  73805. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  73806. */
  73807. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  73808. /**
  73809. * Returns the light type ID (integer).
  73810. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  73811. */
  73812. getTypeID(): number;
  73813. /**
  73814. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  73815. * @returns the scaled intensity in intensity mode unit
  73816. */
  73817. getScaledIntensity(): number;
  73818. /**
  73819. * Returns a new Light object, named "name", from the current one.
  73820. * @param name The name of the cloned light
  73821. * @returns the new created light
  73822. */
  73823. clone(name: string): Nullable<Light>;
  73824. /**
  73825. * Serializes the current light into a Serialization object.
  73826. * @returns the serialized object.
  73827. */
  73828. serialize(): any;
  73829. /**
  73830. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  73831. * This new light is named "name" and added to the passed scene.
  73832. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  73833. * @param name The friendly name of the light
  73834. * @param scene The scene the new light will belong to
  73835. * @returns the constructor function
  73836. */
  73837. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  73838. /**
  73839. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  73840. * @param parsedLight The JSON representation of the light
  73841. * @param scene The scene to create the parsed light in
  73842. * @returns the created light after parsing
  73843. */
  73844. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  73845. private _hookArrayForExcluded;
  73846. private _hookArrayForIncludedOnly;
  73847. private _resyncMeshes;
  73848. /**
  73849. * Forces the meshes to update their light related information in their rendering used effects
  73850. * @hidden Internal Use Only
  73851. */
  73852. _markMeshesAsLightDirty(): void;
  73853. /**
  73854. * Recomputes the cached photometric scale if needed.
  73855. */
  73856. private _computePhotometricScale;
  73857. /**
  73858. * Returns the Photometric Scale according to the light type and intensity mode.
  73859. */
  73860. private _getPhotometricScale;
  73861. /**
  73862. * Reorder the light in the scene according to their defined priority.
  73863. * @hidden Internal Use Only
  73864. */
  73865. _reorderLightsInScene(): void;
  73866. /**
  73867. * Prepares the list of defines specific to the light type.
  73868. * @param defines the list of defines
  73869. * @param lightIndex defines the index of the light for the effect
  73870. */
  73871. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  73872. }
  73873. }
  73874. declare module BABYLON {
  73875. /**
  73876. * Interface used to define Action
  73877. */
  73878. export interface IAction {
  73879. /**
  73880. * Trigger for the action
  73881. */
  73882. trigger: number;
  73883. /** Options of the trigger */
  73884. triggerOptions: any;
  73885. /**
  73886. * Gets the trigger parameters
  73887. * @returns the trigger parameters
  73888. */
  73889. getTriggerParameter(): any;
  73890. /**
  73891. * Internal only - executes current action event
  73892. * @hidden
  73893. */
  73894. _executeCurrent(evt?: ActionEvent): void;
  73895. /**
  73896. * Serialize placeholder for child classes
  73897. * @param parent of child
  73898. * @returns the serialized object
  73899. */
  73900. serialize(parent: any): any;
  73901. /**
  73902. * Internal only
  73903. * @hidden
  73904. */
  73905. _prepare(): void;
  73906. /**
  73907. * Internal only - manager for action
  73908. * @hidden
  73909. */
  73910. _actionManager: AbstractActionManager;
  73911. /**
  73912. * Adds action to chain of actions, may be a DoNothingAction
  73913. * @param action defines the next action to execute
  73914. * @returns The action passed in
  73915. * @see https://www.babylonjs-playground.com/#1T30HR#0
  73916. */
  73917. then(action: IAction): IAction;
  73918. }
  73919. /**
  73920. * The action to be carried out following a trigger
  73921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  73922. */
  73923. export class Action implements IAction {
  73924. /** the trigger, with or without parameters, for the action */
  73925. triggerOptions: any;
  73926. /**
  73927. * Trigger for the action
  73928. */
  73929. trigger: number;
  73930. /**
  73931. * Internal only - manager for action
  73932. * @hidden
  73933. */
  73934. _actionManager: ActionManager;
  73935. private _nextActiveAction;
  73936. private _child;
  73937. private _condition?;
  73938. private _triggerParameter;
  73939. /**
  73940. * An event triggered prior to action being executed.
  73941. */
  73942. onBeforeExecuteObservable: Observable<Action>;
  73943. /**
  73944. * Creates a new Action
  73945. * @param triggerOptions the trigger, with or without parameters, for the action
  73946. * @param condition an optional determinant of action
  73947. */
  73948. constructor(
  73949. /** the trigger, with or without parameters, for the action */
  73950. triggerOptions: any, condition?: Condition);
  73951. /**
  73952. * Internal only
  73953. * @hidden
  73954. */
  73955. _prepare(): void;
  73956. /**
  73957. * Gets the trigger parameters
  73958. * @returns the trigger parameters
  73959. */
  73960. getTriggerParameter(): any;
  73961. /**
  73962. * Internal only - executes current action event
  73963. * @hidden
  73964. */
  73965. _executeCurrent(evt?: ActionEvent): void;
  73966. /**
  73967. * Execute placeholder for child classes
  73968. * @param evt optional action event
  73969. */
  73970. execute(evt?: ActionEvent): void;
  73971. /**
  73972. * Skips to next active action
  73973. */
  73974. skipToNextActiveAction(): void;
  73975. /**
  73976. * Adds action to chain of actions, may be a DoNothingAction
  73977. * @param action defines the next action to execute
  73978. * @returns The action passed in
  73979. * @see https://www.babylonjs-playground.com/#1T30HR#0
  73980. */
  73981. then(action: Action): Action;
  73982. /**
  73983. * Internal only
  73984. * @hidden
  73985. */
  73986. _getProperty(propertyPath: string): string;
  73987. /**
  73988. * Internal only
  73989. * @hidden
  73990. */
  73991. _getEffectiveTarget(target: any, propertyPath: string): any;
  73992. /**
  73993. * Serialize placeholder for child classes
  73994. * @param parent of child
  73995. * @returns the serialized object
  73996. */
  73997. serialize(parent: any): any;
  73998. /**
  73999. * Internal only called by serialize
  74000. * @hidden
  74001. */
  74002. protected _serialize(serializedAction: any, parent?: any): any;
  74003. /**
  74004. * Internal only
  74005. * @hidden
  74006. */
  74007. static _SerializeValueAsString: (value: any) => string;
  74008. /**
  74009. * Internal only
  74010. * @hidden
  74011. */
  74012. static _GetTargetProperty: (target: Node | Scene) => {
  74013. name: string;
  74014. targetType: string;
  74015. value: string;
  74016. };
  74017. }
  74018. }
  74019. declare module BABYLON {
  74020. /**
  74021. * A Condition applied to an Action
  74022. */
  74023. export class Condition {
  74024. /**
  74025. * Internal only - manager for action
  74026. * @hidden
  74027. */
  74028. _actionManager: ActionManager;
  74029. /**
  74030. * Internal only
  74031. * @hidden
  74032. */
  74033. _evaluationId: number;
  74034. /**
  74035. * Internal only
  74036. * @hidden
  74037. */
  74038. _currentResult: boolean;
  74039. /**
  74040. * Creates a new Condition
  74041. * @param actionManager the manager of the action the condition is applied to
  74042. */
  74043. constructor(actionManager: ActionManager);
  74044. /**
  74045. * Check if the current condition is valid
  74046. * @returns a boolean
  74047. */
  74048. isValid(): boolean;
  74049. /**
  74050. * Internal only
  74051. * @hidden
  74052. */
  74053. _getProperty(propertyPath: string): string;
  74054. /**
  74055. * Internal only
  74056. * @hidden
  74057. */
  74058. _getEffectiveTarget(target: any, propertyPath: string): any;
  74059. /**
  74060. * Serialize placeholder for child classes
  74061. * @returns the serialized object
  74062. */
  74063. serialize(): any;
  74064. /**
  74065. * Internal only
  74066. * @hidden
  74067. */
  74068. protected _serialize(serializedCondition: any): any;
  74069. }
  74070. /**
  74071. * Defines specific conditional operators as extensions of Condition
  74072. */
  74073. export class ValueCondition extends Condition {
  74074. /** path to specify the property of the target the conditional operator uses */
  74075. propertyPath: string;
  74076. /** the value compared by the conditional operator against the current value of the property */
  74077. value: any;
  74078. /** the conditional operator, default ValueCondition.IsEqual */
  74079. operator: number;
  74080. /**
  74081. * Internal only
  74082. * @hidden
  74083. */
  74084. private static _IsEqual;
  74085. /**
  74086. * Internal only
  74087. * @hidden
  74088. */
  74089. private static _IsDifferent;
  74090. /**
  74091. * Internal only
  74092. * @hidden
  74093. */
  74094. private static _IsGreater;
  74095. /**
  74096. * Internal only
  74097. * @hidden
  74098. */
  74099. private static _IsLesser;
  74100. /**
  74101. * returns the number for IsEqual
  74102. */
  74103. static readonly IsEqual: number;
  74104. /**
  74105. * Returns the number for IsDifferent
  74106. */
  74107. static readonly IsDifferent: number;
  74108. /**
  74109. * Returns the number for IsGreater
  74110. */
  74111. static readonly IsGreater: number;
  74112. /**
  74113. * Returns the number for IsLesser
  74114. */
  74115. static readonly IsLesser: number;
  74116. /**
  74117. * Internal only The action manager for the condition
  74118. * @hidden
  74119. */
  74120. _actionManager: ActionManager;
  74121. /**
  74122. * Internal only
  74123. * @hidden
  74124. */
  74125. private _target;
  74126. /**
  74127. * Internal only
  74128. * @hidden
  74129. */
  74130. private _effectiveTarget;
  74131. /**
  74132. * Internal only
  74133. * @hidden
  74134. */
  74135. private _property;
  74136. /**
  74137. * Creates a new ValueCondition
  74138. * @param actionManager manager for the action the condition applies to
  74139. * @param target for the action
  74140. * @param propertyPath path to specify the property of the target the conditional operator uses
  74141. * @param value the value compared by the conditional operator against the current value of the property
  74142. * @param operator the conditional operator, default ValueCondition.IsEqual
  74143. */
  74144. constructor(actionManager: ActionManager, target: any,
  74145. /** path to specify the property of the target the conditional operator uses */
  74146. propertyPath: string,
  74147. /** the value compared by the conditional operator against the current value of the property */
  74148. value: any,
  74149. /** the conditional operator, default ValueCondition.IsEqual */
  74150. operator?: number);
  74151. /**
  74152. * Compares the given value with the property value for the specified conditional operator
  74153. * @returns the result of the comparison
  74154. */
  74155. isValid(): boolean;
  74156. /**
  74157. * Serialize the ValueCondition into a JSON compatible object
  74158. * @returns serialization object
  74159. */
  74160. serialize(): any;
  74161. /**
  74162. * Gets the name of the conditional operator for the ValueCondition
  74163. * @param operator the conditional operator
  74164. * @returns the name
  74165. */
  74166. static GetOperatorName(operator: number): string;
  74167. }
  74168. /**
  74169. * Defines a predicate condition as an extension of Condition
  74170. */
  74171. export class PredicateCondition extends Condition {
  74172. /** defines the predicate function used to validate the condition */
  74173. predicate: () => boolean;
  74174. /**
  74175. * Internal only - manager for action
  74176. * @hidden
  74177. */
  74178. _actionManager: ActionManager;
  74179. /**
  74180. * Creates a new PredicateCondition
  74181. * @param actionManager manager for the action the condition applies to
  74182. * @param predicate defines the predicate function used to validate the condition
  74183. */
  74184. constructor(actionManager: ActionManager,
  74185. /** defines the predicate function used to validate the condition */
  74186. predicate: () => boolean);
  74187. /**
  74188. * @returns the validity of the predicate condition
  74189. */
  74190. isValid(): boolean;
  74191. }
  74192. /**
  74193. * Defines a state condition as an extension of Condition
  74194. */
  74195. export class StateCondition extends Condition {
  74196. /** Value to compare with target state */
  74197. value: string;
  74198. /**
  74199. * Internal only - manager for action
  74200. * @hidden
  74201. */
  74202. _actionManager: ActionManager;
  74203. /**
  74204. * Internal only
  74205. * @hidden
  74206. */
  74207. private _target;
  74208. /**
  74209. * Creates a new StateCondition
  74210. * @param actionManager manager for the action the condition applies to
  74211. * @param target of the condition
  74212. * @param value to compare with target state
  74213. */
  74214. constructor(actionManager: ActionManager, target: any,
  74215. /** Value to compare with target state */
  74216. value: string);
  74217. /**
  74218. * Gets a boolean indicating if the current condition is met
  74219. * @returns the validity of the state
  74220. */
  74221. isValid(): boolean;
  74222. /**
  74223. * Serialize the StateCondition into a JSON compatible object
  74224. * @returns serialization object
  74225. */
  74226. serialize(): any;
  74227. }
  74228. }
  74229. declare module BABYLON {
  74230. /**
  74231. * This defines an action responsible to toggle a boolean once triggered.
  74232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74233. */
  74234. export class SwitchBooleanAction extends Action {
  74235. /**
  74236. * The path to the boolean property in the target object
  74237. */
  74238. propertyPath: string;
  74239. private _target;
  74240. private _effectiveTarget;
  74241. private _property;
  74242. /**
  74243. * Instantiate the action
  74244. * @param triggerOptions defines the trigger options
  74245. * @param target defines the object containing the boolean
  74246. * @param propertyPath defines the path to the boolean property in the target object
  74247. * @param condition defines the trigger related conditions
  74248. */
  74249. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  74250. /** @hidden */
  74251. _prepare(): void;
  74252. /**
  74253. * Execute the action toggle the boolean value.
  74254. */
  74255. execute(): void;
  74256. /**
  74257. * Serializes the actions and its related information.
  74258. * @param parent defines the object to serialize in
  74259. * @returns the serialized object
  74260. */
  74261. serialize(parent: any): any;
  74262. }
  74263. /**
  74264. * This defines an action responsible to set a the state field of the target
  74265. * to a desired value once triggered.
  74266. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74267. */
  74268. export class SetStateAction extends Action {
  74269. /**
  74270. * The value to store in the state field.
  74271. */
  74272. value: string;
  74273. private _target;
  74274. /**
  74275. * Instantiate the action
  74276. * @param triggerOptions defines the trigger options
  74277. * @param target defines the object containing the state property
  74278. * @param value defines the value to store in the state field
  74279. * @param condition defines the trigger related conditions
  74280. */
  74281. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  74282. /**
  74283. * Execute the action and store the value on the target state property.
  74284. */
  74285. execute(): void;
  74286. /**
  74287. * Serializes the actions and its related information.
  74288. * @param parent defines the object to serialize in
  74289. * @returns the serialized object
  74290. */
  74291. serialize(parent: any): any;
  74292. }
  74293. /**
  74294. * This defines an action responsible to set a property of the target
  74295. * to a desired value once triggered.
  74296. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74297. */
  74298. export class SetValueAction extends Action {
  74299. /**
  74300. * The path of the property to set in the target.
  74301. */
  74302. propertyPath: string;
  74303. /**
  74304. * The value to set in the property
  74305. */
  74306. value: any;
  74307. private _target;
  74308. private _effectiveTarget;
  74309. private _property;
  74310. /**
  74311. * Instantiate the action
  74312. * @param triggerOptions defines the trigger options
  74313. * @param target defines the object containing the property
  74314. * @param propertyPath defines the path of the property to set in the target
  74315. * @param value defines the value to set in the property
  74316. * @param condition defines the trigger related conditions
  74317. */
  74318. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  74319. /** @hidden */
  74320. _prepare(): void;
  74321. /**
  74322. * Execute the action and set the targetted property to the desired value.
  74323. */
  74324. execute(): void;
  74325. /**
  74326. * Serializes the actions and its related information.
  74327. * @param parent defines the object to serialize in
  74328. * @returns the serialized object
  74329. */
  74330. serialize(parent: any): any;
  74331. }
  74332. /**
  74333. * This defines an action responsible to increment the target value
  74334. * to a desired value once triggered.
  74335. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74336. */
  74337. export class IncrementValueAction extends Action {
  74338. /**
  74339. * The path of the property to increment in the target.
  74340. */
  74341. propertyPath: string;
  74342. /**
  74343. * The value we should increment the property by.
  74344. */
  74345. value: any;
  74346. private _target;
  74347. private _effectiveTarget;
  74348. private _property;
  74349. /**
  74350. * Instantiate the action
  74351. * @param triggerOptions defines the trigger options
  74352. * @param target defines the object containing the property
  74353. * @param propertyPath defines the path of the property to increment in the target
  74354. * @param value defines the value value we should increment the property by
  74355. * @param condition defines the trigger related conditions
  74356. */
  74357. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  74358. /** @hidden */
  74359. _prepare(): void;
  74360. /**
  74361. * Execute the action and increment the target of the value amount.
  74362. */
  74363. execute(): void;
  74364. /**
  74365. * Serializes the actions and its related information.
  74366. * @param parent defines the object to serialize in
  74367. * @returns the serialized object
  74368. */
  74369. serialize(parent: any): any;
  74370. }
  74371. /**
  74372. * This defines an action responsible to start an animation once triggered.
  74373. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74374. */
  74375. export class PlayAnimationAction extends Action {
  74376. /**
  74377. * Where the animation should start (animation frame)
  74378. */
  74379. from: number;
  74380. /**
  74381. * Where the animation should stop (animation frame)
  74382. */
  74383. to: number;
  74384. /**
  74385. * Define if the animation should loop or stop after the first play.
  74386. */
  74387. loop?: boolean;
  74388. private _target;
  74389. /**
  74390. * Instantiate the action
  74391. * @param triggerOptions defines the trigger options
  74392. * @param target defines the target animation or animation name
  74393. * @param from defines from where the animation should start (animation frame)
  74394. * @param end defines where the animation should stop (animation frame)
  74395. * @param loop defines if the animation should loop or stop after the first play
  74396. * @param condition defines the trigger related conditions
  74397. */
  74398. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  74399. /** @hidden */
  74400. _prepare(): void;
  74401. /**
  74402. * Execute the action and play the animation.
  74403. */
  74404. execute(): void;
  74405. /**
  74406. * Serializes the actions and its related information.
  74407. * @param parent defines the object to serialize in
  74408. * @returns the serialized object
  74409. */
  74410. serialize(parent: any): any;
  74411. }
  74412. /**
  74413. * This defines an action responsible to stop an animation once triggered.
  74414. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74415. */
  74416. export class StopAnimationAction extends Action {
  74417. private _target;
  74418. /**
  74419. * Instantiate the action
  74420. * @param triggerOptions defines the trigger options
  74421. * @param target defines the target animation or animation name
  74422. * @param condition defines the trigger related conditions
  74423. */
  74424. constructor(triggerOptions: any, target: any, condition?: Condition);
  74425. /** @hidden */
  74426. _prepare(): void;
  74427. /**
  74428. * Execute the action and stop the animation.
  74429. */
  74430. execute(): void;
  74431. /**
  74432. * Serializes the actions and its related information.
  74433. * @param parent defines the object to serialize in
  74434. * @returns the serialized object
  74435. */
  74436. serialize(parent: any): any;
  74437. }
  74438. /**
  74439. * This defines an action responsible that does nothing once triggered.
  74440. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74441. */
  74442. export class DoNothingAction extends Action {
  74443. /**
  74444. * Instantiate the action
  74445. * @param triggerOptions defines the trigger options
  74446. * @param condition defines the trigger related conditions
  74447. */
  74448. constructor(triggerOptions?: any, condition?: Condition);
  74449. /**
  74450. * Execute the action and do nothing.
  74451. */
  74452. execute(): void;
  74453. /**
  74454. * Serializes the actions and its related information.
  74455. * @param parent defines the object to serialize in
  74456. * @returns the serialized object
  74457. */
  74458. serialize(parent: any): any;
  74459. }
  74460. /**
  74461. * This defines an action responsible to trigger several actions once triggered.
  74462. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74463. */
  74464. export class CombineAction extends Action {
  74465. /**
  74466. * The list of aggregated animations to run.
  74467. */
  74468. children: Action[];
  74469. /**
  74470. * Instantiate the action
  74471. * @param triggerOptions defines the trigger options
  74472. * @param children defines the list of aggregated animations to run
  74473. * @param condition defines the trigger related conditions
  74474. */
  74475. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  74476. /** @hidden */
  74477. _prepare(): void;
  74478. /**
  74479. * Execute the action and executes all the aggregated actions.
  74480. */
  74481. execute(evt: ActionEvent): void;
  74482. /**
  74483. * Serializes the actions and its related information.
  74484. * @param parent defines the object to serialize in
  74485. * @returns the serialized object
  74486. */
  74487. serialize(parent: any): any;
  74488. }
  74489. /**
  74490. * This defines an action responsible to run code (external event) once triggered.
  74491. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74492. */
  74493. export class ExecuteCodeAction extends Action {
  74494. /**
  74495. * The callback function to run.
  74496. */
  74497. func: (evt: ActionEvent) => void;
  74498. /**
  74499. * Instantiate the action
  74500. * @param triggerOptions defines the trigger options
  74501. * @param func defines the callback function to run
  74502. * @param condition defines the trigger related conditions
  74503. */
  74504. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  74505. /**
  74506. * Execute the action and run the attached code.
  74507. */
  74508. execute(evt: ActionEvent): void;
  74509. }
  74510. /**
  74511. * This defines an action responsible to set the parent property of the target once triggered.
  74512. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74513. */
  74514. export class SetParentAction extends Action {
  74515. private _parent;
  74516. private _target;
  74517. /**
  74518. * Instantiate the action
  74519. * @param triggerOptions defines the trigger options
  74520. * @param target defines the target containing the parent property
  74521. * @param parent defines from where the animation should start (animation frame)
  74522. * @param condition defines the trigger related conditions
  74523. */
  74524. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  74525. /** @hidden */
  74526. _prepare(): void;
  74527. /**
  74528. * Execute the action and set the parent property.
  74529. */
  74530. execute(): void;
  74531. /**
  74532. * Serializes the actions and its related information.
  74533. * @param parent defines the object to serialize in
  74534. * @returns the serialized object
  74535. */
  74536. serialize(parent: any): any;
  74537. }
  74538. }
  74539. declare module BABYLON {
  74540. /**
  74541. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  74542. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  74543. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74544. */
  74545. export class ActionManager extends AbstractActionManager {
  74546. /**
  74547. * Nothing
  74548. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74549. */
  74550. static readonly NothingTrigger: number;
  74551. /**
  74552. * On pick
  74553. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74554. */
  74555. static readonly OnPickTrigger: number;
  74556. /**
  74557. * On left pick
  74558. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74559. */
  74560. static readonly OnLeftPickTrigger: number;
  74561. /**
  74562. * On right pick
  74563. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74564. */
  74565. static readonly OnRightPickTrigger: number;
  74566. /**
  74567. * On center pick
  74568. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74569. */
  74570. static readonly OnCenterPickTrigger: number;
  74571. /**
  74572. * On pick down
  74573. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74574. */
  74575. static readonly OnPickDownTrigger: number;
  74576. /**
  74577. * On double pick
  74578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74579. */
  74580. static readonly OnDoublePickTrigger: number;
  74581. /**
  74582. * On pick up
  74583. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74584. */
  74585. static readonly OnPickUpTrigger: number;
  74586. /**
  74587. * On pick out.
  74588. * This trigger will only be raised if you also declared a OnPickDown
  74589. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74590. */
  74591. static readonly OnPickOutTrigger: number;
  74592. /**
  74593. * On long press
  74594. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74595. */
  74596. static readonly OnLongPressTrigger: number;
  74597. /**
  74598. * On pointer over
  74599. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74600. */
  74601. static readonly OnPointerOverTrigger: number;
  74602. /**
  74603. * On pointer out
  74604. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74605. */
  74606. static readonly OnPointerOutTrigger: number;
  74607. /**
  74608. * On every frame
  74609. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74610. */
  74611. static readonly OnEveryFrameTrigger: number;
  74612. /**
  74613. * On intersection enter
  74614. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74615. */
  74616. static readonly OnIntersectionEnterTrigger: number;
  74617. /**
  74618. * On intersection exit
  74619. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74620. */
  74621. static readonly OnIntersectionExitTrigger: number;
  74622. /**
  74623. * On key down
  74624. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74625. */
  74626. static readonly OnKeyDownTrigger: number;
  74627. /**
  74628. * On key up
  74629. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74630. */
  74631. static readonly OnKeyUpTrigger: number;
  74632. private _scene;
  74633. /**
  74634. * Creates a new action manager
  74635. * @param scene defines the hosting scene
  74636. */
  74637. constructor(scene: Scene);
  74638. /**
  74639. * Releases all associated resources
  74640. */
  74641. dispose(): void;
  74642. /**
  74643. * Gets hosting scene
  74644. * @returns the hosting scene
  74645. */
  74646. getScene(): Scene;
  74647. /**
  74648. * Does this action manager handles actions of any of the given triggers
  74649. * @param triggers defines the triggers to be tested
  74650. * @return a boolean indicating whether one (or more) of the triggers is handled
  74651. */
  74652. hasSpecificTriggers(triggers: number[]): boolean;
  74653. /**
  74654. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  74655. * speed.
  74656. * @param triggerA defines the trigger to be tested
  74657. * @param triggerB defines the trigger to be tested
  74658. * @return a boolean indicating whether one (or more) of the triggers is handled
  74659. */
  74660. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  74661. /**
  74662. * Does this action manager handles actions of a given trigger
  74663. * @param trigger defines the trigger to be tested
  74664. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  74665. * @return whether the trigger is handled
  74666. */
  74667. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  74668. /**
  74669. * Does this action manager has pointer triggers
  74670. */
  74671. readonly hasPointerTriggers: boolean;
  74672. /**
  74673. * Does this action manager has pick triggers
  74674. */
  74675. readonly hasPickTriggers: boolean;
  74676. /**
  74677. * Registers an action to this action manager
  74678. * @param action defines the action to be registered
  74679. * @return the action amended (prepared) after registration
  74680. */
  74681. registerAction(action: IAction): Nullable<IAction>;
  74682. /**
  74683. * Unregisters an action to this action manager
  74684. * @param action defines the action to be unregistered
  74685. * @return a boolean indicating whether the action has been unregistered
  74686. */
  74687. unregisterAction(action: IAction): Boolean;
  74688. /**
  74689. * Process a specific trigger
  74690. * @param trigger defines the trigger to process
  74691. * @param evt defines the event details to be processed
  74692. */
  74693. processTrigger(trigger: number, evt?: IActionEvent): void;
  74694. /** @hidden */
  74695. _getEffectiveTarget(target: any, propertyPath: string): any;
  74696. /** @hidden */
  74697. _getProperty(propertyPath: string): string;
  74698. /**
  74699. * Serialize this manager to a JSON object
  74700. * @param name defines the property name to store this manager
  74701. * @returns a JSON representation of this manager
  74702. */
  74703. serialize(name: string): any;
  74704. /**
  74705. * Creates a new ActionManager from a JSON data
  74706. * @param parsedActions defines the JSON data to read from
  74707. * @param object defines the hosting mesh
  74708. * @param scene defines the hosting scene
  74709. */
  74710. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  74711. /**
  74712. * Get a trigger name by index
  74713. * @param trigger defines the trigger index
  74714. * @returns a trigger name
  74715. */
  74716. static GetTriggerName(trigger: number): string;
  74717. }
  74718. }
  74719. declare module BABYLON {
  74720. /**
  74721. * Class representing a ray with position and direction
  74722. */
  74723. export class Ray {
  74724. /** origin point */
  74725. origin: Vector3;
  74726. /** direction */
  74727. direction: Vector3;
  74728. /** length of the ray */
  74729. length: number;
  74730. private static readonly TmpVector3;
  74731. private _tmpRay;
  74732. /**
  74733. * Creates a new ray
  74734. * @param origin origin point
  74735. * @param direction direction
  74736. * @param length length of the ray
  74737. */
  74738. constructor(
  74739. /** origin point */
  74740. origin: Vector3,
  74741. /** direction */
  74742. direction: Vector3,
  74743. /** length of the ray */
  74744. length?: number);
  74745. /**
  74746. * Checks if the ray intersects a box
  74747. * @param minimum bound of the box
  74748. * @param maximum bound of the box
  74749. * @param intersectionTreshold extra extend to be added to the box in all direction
  74750. * @returns if the box was hit
  74751. */
  74752. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  74753. /**
  74754. * Checks if the ray intersects a box
  74755. * @param box the bounding box to check
  74756. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  74757. * @returns if the box was hit
  74758. */
  74759. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  74760. /**
  74761. * If the ray hits a sphere
  74762. * @param sphere the bounding sphere to check
  74763. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  74764. * @returns true if it hits the sphere
  74765. */
  74766. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  74767. /**
  74768. * If the ray hits a triange
  74769. * @param vertex0 triangle vertex
  74770. * @param vertex1 triangle vertex
  74771. * @param vertex2 triangle vertex
  74772. * @returns intersection information if hit
  74773. */
  74774. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  74775. /**
  74776. * Checks if ray intersects a plane
  74777. * @param plane the plane to check
  74778. * @returns the distance away it was hit
  74779. */
  74780. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  74781. /**
  74782. * Calculate the intercept of a ray on a given axis
  74783. * @param axis to check 'x' | 'y' | 'z'
  74784. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  74785. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  74786. */
  74787. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  74788. /**
  74789. * Checks if ray intersects a mesh
  74790. * @param mesh the mesh to check
  74791. * @param fastCheck if only the bounding box should checked
  74792. * @returns picking info of the intersecton
  74793. */
  74794. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  74795. /**
  74796. * Checks if ray intersects a mesh
  74797. * @param meshes the meshes to check
  74798. * @param fastCheck if only the bounding box should checked
  74799. * @param results array to store result in
  74800. * @returns Array of picking infos
  74801. */
  74802. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  74803. private _comparePickingInfo;
  74804. private static smallnum;
  74805. private static rayl;
  74806. /**
  74807. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  74808. * @param sega the first point of the segment to test the intersection against
  74809. * @param segb the second point of the segment to test the intersection against
  74810. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  74811. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  74812. */
  74813. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  74814. /**
  74815. * Update the ray from viewport position
  74816. * @param x position
  74817. * @param y y position
  74818. * @param viewportWidth viewport width
  74819. * @param viewportHeight viewport height
  74820. * @param world world matrix
  74821. * @param view view matrix
  74822. * @param projection projection matrix
  74823. * @returns this ray updated
  74824. */
  74825. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  74826. /**
  74827. * Creates a ray with origin and direction of 0,0,0
  74828. * @returns the new ray
  74829. */
  74830. static Zero(): Ray;
  74831. /**
  74832. * Creates a new ray from screen space and viewport
  74833. * @param x position
  74834. * @param y y position
  74835. * @param viewportWidth viewport width
  74836. * @param viewportHeight viewport height
  74837. * @param world world matrix
  74838. * @param view view matrix
  74839. * @param projection projection matrix
  74840. * @returns new ray
  74841. */
  74842. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  74843. /**
  74844. * 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
  74845. * transformed to the given world matrix.
  74846. * @param origin The origin point
  74847. * @param end The end point
  74848. * @param world a matrix to transform the ray to. Default is the identity matrix.
  74849. * @returns the new ray
  74850. */
  74851. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  74852. /**
  74853. * Transforms a ray by a matrix
  74854. * @param ray ray to transform
  74855. * @param matrix matrix to apply
  74856. * @returns the resulting new ray
  74857. */
  74858. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  74859. /**
  74860. * Transforms a ray by a matrix
  74861. * @param ray ray to transform
  74862. * @param matrix matrix to apply
  74863. * @param result ray to store result in
  74864. */
  74865. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  74866. /**
  74867. * Unproject a ray from screen space to object space
  74868. * @param sourceX defines the screen space x coordinate to use
  74869. * @param sourceY defines the screen space y coordinate to use
  74870. * @param viewportWidth defines the current width of the viewport
  74871. * @param viewportHeight defines the current height of the viewport
  74872. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  74873. * @param view defines the view matrix to use
  74874. * @param projection defines the projection matrix to use
  74875. */
  74876. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  74877. }
  74878. /**
  74879. * Type used to define predicate used to select faces when a mesh intersection is detected
  74880. */
  74881. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  74882. interface Scene {
  74883. /** @hidden */
  74884. _tempPickingRay: Nullable<Ray>;
  74885. /** @hidden */
  74886. _cachedRayForTransform: Ray;
  74887. /** @hidden */
  74888. _pickWithRayInverseMatrix: Matrix;
  74889. /** @hidden */
  74890. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  74891. /** @hidden */
  74892. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  74893. }
  74894. }
  74895. declare module BABYLON {
  74896. /**
  74897. * Groups all the scene component constants in one place to ease maintenance.
  74898. * @hidden
  74899. */
  74900. export class SceneComponentConstants {
  74901. static readonly NAME_EFFECTLAYER: string;
  74902. static readonly NAME_LAYER: string;
  74903. static readonly NAME_LENSFLARESYSTEM: string;
  74904. static readonly NAME_BOUNDINGBOXRENDERER: string;
  74905. static readonly NAME_PARTICLESYSTEM: string;
  74906. static readonly NAME_GAMEPAD: string;
  74907. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  74908. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  74909. static readonly NAME_DEPTHRENDERER: string;
  74910. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  74911. static readonly NAME_SPRITE: string;
  74912. static readonly NAME_OUTLINERENDERER: string;
  74913. static readonly NAME_PROCEDURALTEXTURE: string;
  74914. static readonly NAME_SHADOWGENERATOR: string;
  74915. static readonly NAME_OCTREE: string;
  74916. static readonly NAME_PHYSICSENGINE: string;
  74917. static readonly NAME_AUDIO: string;
  74918. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  74919. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  74920. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  74921. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  74922. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  74923. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  74924. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  74925. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  74926. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  74927. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  74928. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  74929. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  74930. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  74931. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  74932. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  74933. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  74934. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  74935. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  74936. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  74937. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  74938. static readonly STEP_AFTERRENDER_AUDIO: number;
  74939. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  74940. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  74941. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  74942. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  74943. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  74944. static readonly STEP_POINTERMOVE_SPRITE: number;
  74945. static readonly STEP_POINTERDOWN_SPRITE: number;
  74946. static readonly STEP_POINTERUP_SPRITE: number;
  74947. }
  74948. /**
  74949. * This represents a scene component.
  74950. *
  74951. * This is used to decouple the dependency the scene is having on the different workloads like
  74952. * layers, post processes...
  74953. */
  74954. export interface ISceneComponent {
  74955. /**
  74956. * The name of the component. Each component must have a unique name.
  74957. */
  74958. name: string;
  74959. /**
  74960. * The scene the component belongs to.
  74961. */
  74962. scene: Scene;
  74963. /**
  74964. * Register the component to one instance of a scene.
  74965. */
  74966. register(): void;
  74967. /**
  74968. * Rebuilds the elements related to this component in case of
  74969. * context lost for instance.
  74970. */
  74971. rebuild(): void;
  74972. /**
  74973. * Disposes the component and the associated ressources.
  74974. */
  74975. dispose(): void;
  74976. }
  74977. /**
  74978. * This represents a SERIALIZABLE scene component.
  74979. *
  74980. * This extends Scene Component to add Serialization methods on top.
  74981. */
  74982. export interface ISceneSerializableComponent extends ISceneComponent {
  74983. /**
  74984. * Adds all the elements from the container to the scene
  74985. * @param container the container holding the elements
  74986. */
  74987. addFromContainer(container: AbstractScene): void;
  74988. /**
  74989. * Removes all the elements in the container from the scene
  74990. * @param container contains the elements to remove
  74991. * @param dispose if the removed element should be disposed (default: false)
  74992. */
  74993. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  74994. /**
  74995. * Serializes the component data to the specified json object
  74996. * @param serializationObject The object to serialize to
  74997. */
  74998. serialize(serializationObject: any): void;
  74999. }
  75000. /**
  75001. * Strong typing of a Mesh related stage step action
  75002. */
  75003. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  75004. /**
  75005. * Strong typing of a Evaluate Sub Mesh related stage step action
  75006. */
  75007. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  75008. /**
  75009. * Strong typing of a Active Mesh related stage step action
  75010. */
  75011. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  75012. /**
  75013. * Strong typing of a Camera related stage step action
  75014. */
  75015. export type CameraStageAction = (camera: Camera) => void;
  75016. /**
  75017. * Strong typing of a Camera Frame buffer related stage step action
  75018. */
  75019. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  75020. /**
  75021. * Strong typing of a Render Target related stage step action
  75022. */
  75023. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  75024. /**
  75025. * Strong typing of a RenderingGroup related stage step action
  75026. */
  75027. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  75028. /**
  75029. * Strong typing of a Mesh Render related stage step action
  75030. */
  75031. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  75032. /**
  75033. * Strong typing of a simple stage step action
  75034. */
  75035. export type SimpleStageAction = () => void;
  75036. /**
  75037. * Strong typing of a render target action.
  75038. */
  75039. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  75040. /**
  75041. * Strong typing of a pointer move action.
  75042. */
  75043. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  75044. /**
  75045. * Strong typing of a pointer up/down action.
  75046. */
  75047. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  75048. /**
  75049. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  75050. * @hidden
  75051. */
  75052. export class Stage<T extends Function> extends Array<{
  75053. index: number;
  75054. component: ISceneComponent;
  75055. action: T;
  75056. }> {
  75057. /**
  75058. * Hide ctor from the rest of the world.
  75059. * @param items The items to add.
  75060. */
  75061. private constructor();
  75062. /**
  75063. * Creates a new Stage.
  75064. * @returns A new instance of a Stage
  75065. */
  75066. static Create<T extends Function>(): Stage<T>;
  75067. /**
  75068. * Registers a step in an ordered way in the targeted stage.
  75069. * @param index Defines the position to register the step in
  75070. * @param component Defines the component attached to the step
  75071. * @param action Defines the action to launch during the step
  75072. */
  75073. registerStep(index: number, component: ISceneComponent, action: T): void;
  75074. /**
  75075. * Clears all the steps from the stage.
  75076. */
  75077. clear(): void;
  75078. }
  75079. }
  75080. declare module BABYLON {
  75081. interface Scene {
  75082. /** @hidden */
  75083. _pointerOverSprite: Nullable<Sprite>;
  75084. /** @hidden */
  75085. _pickedDownSprite: Nullable<Sprite>;
  75086. /** @hidden */
  75087. _tempSpritePickingRay: Nullable<Ray>;
  75088. /**
  75089. * All of the sprite managers added to this scene
  75090. * @see http://doc.babylonjs.com/babylon101/sprites
  75091. */
  75092. spriteManagers: Array<ISpriteManager>;
  75093. /**
  75094. * An event triggered when sprites rendering is about to start
  75095. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  75096. */
  75097. onBeforeSpritesRenderingObservable: Observable<Scene>;
  75098. /**
  75099. * An event triggered when sprites rendering is done
  75100. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  75101. */
  75102. onAfterSpritesRenderingObservable: Observable<Scene>;
  75103. /** @hidden */
  75104. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  75105. /** Launch a ray to try to pick a sprite in the scene
  75106. * @param x position on screen
  75107. * @param y position on screen
  75108. * @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
  75109. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  75110. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  75111. * @returns a PickingInfo
  75112. */
  75113. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  75114. /** Use the given ray to pick a sprite in the scene
  75115. * @param ray The ray (in world space) to use to pick meshes
  75116. * @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
  75117. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  75118. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  75119. * @returns a PickingInfo
  75120. */
  75121. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  75122. /**
  75123. * Force the sprite under the pointer
  75124. * @param sprite defines the sprite to use
  75125. */
  75126. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  75127. /**
  75128. * Gets the sprite under the pointer
  75129. * @returns a Sprite or null if no sprite is under the pointer
  75130. */
  75131. getPointerOverSprite(): Nullable<Sprite>;
  75132. }
  75133. /**
  75134. * Defines the sprite scene component responsible to manage sprites
  75135. * in a given scene.
  75136. */
  75137. export class SpriteSceneComponent implements ISceneComponent {
  75138. /**
  75139. * The component name helpfull to identify the component in the list of scene components.
  75140. */
  75141. readonly name: string;
  75142. /**
  75143. * The scene the component belongs to.
  75144. */
  75145. scene: Scene;
  75146. /** @hidden */
  75147. private _spritePredicate;
  75148. /**
  75149. * Creates a new instance of the component for the given scene
  75150. * @param scene Defines the scene to register the component in
  75151. */
  75152. constructor(scene: Scene);
  75153. /**
  75154. * Registers the component in a given scene
  75155. */
  75156. register(): void;
  75157. /**
  75158. * Rebuilds the elements related to this component in case of
  75159. * context lost for instance.
  75160. */
  75161. rebuild(): void;
  75162. /**
  75163. * Disposes the component and the associated ressources.
  75164. */
  75165. dispose(): void;
  75166. private _pickSpriteButKeepRay;
  75167. private _pointerMove;
  75168. private _pointerDown;
  75169. private _pointerUp;
  75170. }
  75171. }
  75172. declare module BABYLON {
  75173. /** @hidden */
  75174. export var fogFragmentDeclaration: {
  75175. name: string;
  75176. shader: string;
  75177. };
  75178. }
  75179. declare module BABYLON {
  75180. /** @hidden */
  75181. export var fogFragment: {
  75182. name: string;
  75183. shader: string;
  75184. };
  75185. }
  75186. declare module BABYLON {
  75187. /** @hidden */
  75188. export var spritesPixelShader: {
  75189. name: string;
  75190. shader: string;
  75191. };
  75192. }
  75193. declare module BABYLON {
  75194. /** @hidden */
  75195. export var fogVertexDeclaration: {
  75196. name: string;
  75197. shader: string;
  75198. };
  75199. }
  75200. declare module BABYLON {
  75201. /** @hidden */
  75202. export var spritesVertexShader: {
  75203. name: string;
  75204. shader: string;
  75205. };
  75206. }
  75207. declare module BABYLON {
  75208. /**
  75209. * Defines the minimum interface to fullfil in order to be a sprite manager.
  75210. */
  75211. export interface ISpriteManager extends IDisposable {
  75212. /**
  75213. * Restricts the camera to viewing objects with the same layerMask.
  75214. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  75215. */
  75216. layerMask: number;
  75217. /**
  75218. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  75219. */
  75220. isPickable: boolean;
  75221. /**
  75222. * Specifies the rendering group id for this mesh (0 by default)
  75223. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  75224. */
  75225. renderingGroupId: number;
  75226. /**
  75227. * Defines the list of sprites managed by the manager.
  75228. */
  75229. sprites: Array<Sprite>;
  75230. /**
  75231. * Tests the intersection of a sprite with a specific ray.
  75232. * @param ray The ray we are sending to test the collision
  75233. * @param camera The camera space we are sending rays in
  75234. * @param predicate A predicate allowing excluding sprites from the list of object to test
  75235. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  75236. * @returns picking info or null.
  75237. */
  75238. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  75239. /**
  75240. * Renders the list of sprites on screen.
  75241. */
  75242. render(): void;
  75243. }
  75244. /**
  75245. * Class used to manage multiple sprites on the same spritesheet
  75246. * @see http://doc.babylonjs.com/babylon101/sprites
  75247. */
  75248. export class SpriteManager implements ISpriteManager {
  75249. /** defines the manager's name */
  75250. name: string;
  75251. /** Gets the list of sprites */
  75252. sprites: Sprite[];
  75253. /** Gets or sets the rendering group id (0 by default) */
  75254. renderingGroupId: number;
  75255. /** Gets or sets camera layer mask */
  75256. layerMask: number;
  75257. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  75258. fogEnabled: boolean;
  75259. /** Gets or sets a boolean indicating if the sprites are pickable */
  75260. isPickable: boolean;
  75261. /** Defines the default width of a cell in the spritesheet */
  75262. cellWidth: number;
  75263. /** Defines the default height of a cell in the spritesheet */
  75264. cellHeight: number;
  75265. /**
  75266. * An event triggered when the manager is disposed.
  75267. */
  75268. onDisposeObservable: Observable<SpriteManager>;
  75269. private _onDisposeObserver;
  75270. /**
  75271. * Callback called when the manager is disposed
  75272. */
  75273. onDispose: () => void;
  75274. private _capacity;
  75275. private _spriteTexture;
  75276. private _epsilon;
  75277. private _scene;
  75278. private _vertexData;
  75279. private _buffer;
  75280. private _vertexBuffers;
  75281. private _indexBuffer;
  75282. private _effectBase;
  75283. private _effectFog;
  75284. /**
  75285. * Gets or sets the spritesheet texture
  75286. */
  75287. texture: Texture;
  75288. /**
  75289. * Creates a new sprite manager
  75290. * @param name defines the manager's name
  75291. * @param imgUrl defines the sprite sheet url
  75292. * @param capacity defines the maximum allowed number of sprites
  75293. * @param cellSize defines the size of a sprite cell
  75294. * @param scene defines the hosting scene
  75295. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  75296. * @param samplingMode defines the smapling mode to use with spritesheet
  75297. */
  75298. constructor(
  75299. /** defines the manager's name */
  75300. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  75301. private _appendSpriteVertex;
  75302. /**
  75303. * Intersects the sprites with a ray
  75304. * @param ray defines the ray to intersect with
  75305. * @param camera defines the current active camera
  75306. * @param predicate defines a predicate used to select candidate sprites
  75307. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  75308. * @returns null if no hit or a PickingInfo
  75309. */
  75310. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  75311. /**
  75312. * Render all child sprites
  75313. */
  75314. render(): void;
  75315. /**
  75316. * Release associated resources
  75317. */
  75318. dispose(): void;
  75319. }
  75320. }
  75321. declare module BABYLON {
  75322. /**
  75323. * Class used to represent a sprite
  75324. * @see http://doc.babylonjs.com/babylon101/sprites
  75325. */
  75326. export class Sprite {
  75327. /** defines the name */
  75328. name: string;
  75329. /** Gets or sets the current world position */
  75330. position: Vector3;
  75331. /** Gets or sets the main color */
  75332. color: Color4;
  75333. /** Gets or sets the width */
  75334. width: number;
  75335. /** Gets or sets the height */
  75336. height: number;
  75337. /** Gets or sets rotation angle */
  75338. angle: number;
  75339. /** Gets or sets the cell index in the sprite sheet */
  75340. cellIndex: number;
  75341. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  75342. invertU: number;
  75343. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  75344. invertV: number;
  75345. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  75346. disposeWhenFinishedAnimating: boolean;
  75347. /** Gets the list of attached animations */
  75348. animations: Animation[];
  75349. /** Gets or sets a boolean indicating if the sprite can be picked */
  75350. isPickable: boolean;
  75351. /**
  75352. * Gets or sets the associated action manager
  75353. */
  75354. actionManager: Nullable<ActionManager>;
  75355. private _animationStarted;
  75356. private _loopAnimation;
  75357. private _fromIndex;
  75358. private _toIndex;
  75359. private _delay;
  75360. private _direction;
  75361. private _manager;
  75362. private _time;
  75363. private _onAnimationEnd;
  75364. /**
  75365. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  75366. */
  75367. isVisible: boolean;
  75368. /**
  75369. * Gets or sets the sprite size
  75370. */
  75371. size: number;
  75372. /**
  75373. * Creates a new Sprite
  75374. * @param name defines the name
  75375. * @param manager defines the manager
  75376. */
  75377. constructor(
  75378. /** defines the name */
  75379. name: string, manager: ISpriteManager);
  75380. /**
  75381. * Starts an animation
  75382. * @param from defines the initial key
  75383. * @param to defines the end key
  75384. * @param loop defines if the animation must loop
  75385. * @param delay defines the start delay (in ms)
  75386. * @param onAnimationEnd defines a callback to call when animation ends
  75387. */
  75388. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  75389. /** Stops current animation (if any) */
  75390. stopAnimation(): void;
  75391. /** @hidden */
  75392. _animate(deltaTime: number): void;
  75393. /** Release associated resources */
  75394. dispose(): void;
  75395. }
  75396. }
  75397. declare module BABYLON {
  75398. /**
  75399. * Information about the result of picking within a scene
  75400. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  75401. */
  75402. export class PickingInfo {
  75403. /** @hidden */
  75404. _pickingUnavailable: boolean;
  75405. /**
  75406. * If the pick collided with an object
  75407. */
  75408. hit: boolean;
  75409. /**
  75410. * Distance away where the pick collided
  75411. */
  75412. distance: number;
  75413. /**
  75414. * The location of pick collision
  75415. */
  75416. pickedPoint: Nullable<Vector3>;
  75417. /**
  75418. * The mesh corresponding the the pick collision
  75419. */
  75420. pickedMesh: Nullable<AbstractMesh>;
  75421. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  75422. bu: number;
  75423. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  75424. bv: number;
  75425. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  75426. faceId: number;
  75427. /** Id of the the submesh that was picked */
  75428. subMeshId: number;
  75429. /** If a sprite was picked, this will be the sprite the pick collided with */
  75430. pickedSprite: Nullable<Sprite>;
  75431. /**
  75432. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  75433. */
  75434. originMesh: Nullable<AbstractMesh>;
  75435. /**
  75436. * The ray that was used to perform the picking.
  75437. */
  75438. ray: Nullable<Ray>;
  75439. /**
  75440. * Gets the normal correspodning to the face the pick collided with
  75441. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  75442. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  75443. * @returns The normal correspodning to the face the pick collided with
  75444. */
  75445. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  75446. /**
  75447. * Gets the texture coordinates of where the pick occured
  75448. * @returns the vector containing the coordnates of the texture
  75449. */
  75450. getTextureCoordinates(): Nullable<Vector2>;
  75451. }
  75452. }
  75453. declare module BABYLON {
  75454. /**
  75455. * Gather the list of pointer event types as constants.
  75456. */
  75457. export class PointerEventTypes {
  75458. /**
  75459. * 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.
  75460. */
  75461. static readonly POINTERDOWN: number;
  75462. /**
  75463. * The pointerup event is fired when a pointer is no longer active.
  75464. */
  75465. static readonly POINTERUP: number;
  75466. /**
  75467. * The pointermove event is fired when a pointer changes coordinates.
  75468. */
  75469. static readonly POINTERMOVE: number;
  75470. /**
  75471. * The pointerwheel event is fired when a mouse wheel has been rotated.
  75472. */
  75473. static readonly POINTERWHEEL: number;
  75474. /**
  75475. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  75476. */
  75477. static readonly POINTERPICK: number;
  75478. /**
  75479. * The pointertap event is fired when a the object has been touched and released without drag.
  75480. */
  75481. static readonly POINTERTAP: number;
  75482. /**
  75483. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  75484. */
  75485. static readonly POINTERDOUBLETAP: number;
  75486. }
  75487. /**
  75488. * Base class of pointer info types.
  75489. */
  75490. export class PointerInfoBase {
  75491. /**
  75492. * Defines the type of event (PointerEventTypes)
  75493. */
  75494. type: number;
  75495. /**
  75496. * Defines the related dom event
  75497. */
  75498. event: PointerEvent | MouseWheelEvent;
  75499. /**
  75500. * Instantiates the base class of pointers info.
  75501. * @param type Defines the type of event (PointerEventTypes)
  75502. * @param event Defines the related dom event
  75503. */
  75504. constructor(
  75505. /**
  75506. * Defines the type of event (PointerEventTypes)
  75507. */
  75508. type: number,
  75509. /**
  75510. * Defines the related dom event
  75511. */
  75512. event: PointerEvent | MouseWheelEvent);
  75513. }
  75514. /**
  75515. * This class is used to store pointer related info for the onPrePointerObservable event.
  75516. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  75517. */
  75518. export class PointerInfoPre extends PointerInfoBase {
  75519. /**
  75520. * Ray from a pointer if availible (eg. 6dof controller)
  75521. */
  75522. ray: Nullable<Ray>;
  75523. /**
  75524. * Defines the local position of the pointer on the canvas.
  75525. */
  75526. localPosition: Vector2;
  75527. /**
  75528. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  75529. */
  75530. skipOnPointerObservable: boolean;
  75531. /**
  75532. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  75533. * @param type Defines the type of event (PointerEventTypes)
  75534. * @param event Defines the related dom event
  75535. * @param localX Defines the local x coordinates of the pointer when the event occured
  75536. * @param localY Defines the local y coordinates of the pointer when the event occured
  75537. */
  75538. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  75539. }
  75540. /**
  75541. * This type contains all the data related to a pointer event in Babylon.js.
  75542. * 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.
  75543. */
  75544. export class PointerInfo extends PointerInfoBase {
  75545. /**
  75546. * Defines the picking info associated to the info (if any)\
  75547. */
  75548. pickInfo: Nullable<PickingInfo>;
  75549. /**
  75550. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  75551. * @param type Defines the type of event (PointerEventTypes)
  75552. * @param event Defines the related dom event
  75553. * @param pickInfo Defines the picking info associated to the info (if any)\
  75554. */
  75555. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  75556. /**
  75557. * Defines the picking info associated to the info (if any)\
  75558. */
  75559. pickInfo: Nullable<PickingInfo>);
  75560. }
  75561. /**
  75562. * Data relating to a touch event on the screen.
  75563. */
  75564. export interface PointerTouch {
  75565. /**
  75566. * X coordinate of touch.
  75567. */
  75568. x: number;
  75569. /**
  75570. * Y coordinate of touch.
  75571. */
  75572. y: number;
  75573. /**
  75574. * Id of touch. Unique for each finger.
  75575. */
  75576. pointerId: number;
  75577. /**
  75578. * Event type passed from DOM.
  75579. */
  75580. type: any;
  75581. }
  75582. }
  75583. declare module BABYLON {
  75584. /**
  75585. * Manage the mouse inputs to control the movement of a free camera.
  75586. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75587. */
  75588. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  75589. /**
  75590. * Define if touch is enabled in the mouse input
  75591. */
  75592. touchEnabled: boolean;
  75593. /**
  75594. * Defines the camera the input is attached to.
  75595. */
  75596. camera: FreeCamera;
  75597. /**
  75598. * Defines the buttons associated with the input to handle camera move.
  75599. */
  75600. buttons: number[];
  75601. /**
  75602. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  75603. */
  75604. angularSensibility: number;
  75605. private _pointerInput;
  75606. private _onMouseMove;
  75607. private _observer;
  75608. private previousPosition;
  75609. /**
  75610. * Observable for when a pointer move event occurs containing the move offset
  75611. */
  75612. onPointerMovedObservable: Observable<{
  75613. offsetX: number;
  75614. offsetY: number;
  75615. }>;
  75616. /**
  75617. * @hidden
  75618. * If the camera should be rotated automatically based on pointer movement
  75619. */
  75620. _allowCameraRotation: boolean;
  75621. /**
  75622. * Manage the mouse inputs to control the movement of a free camera.
  75623. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75624. * @param touchEnabled Defines if touch is enabled or not
  75625. */
  75626. constructor(
  75627. /**
  75628. * Define if touch is enabled in the mouse input
  75629. */
  75630. touchEnabled?: boolean);
  75631. /**
  75632. * Attach the input controls to a specific dom element to get the input from.
  75633. * @param element Defines the element the controls should be listened from
  75634. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75635. */
  75636. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75637. /**
  75638. * Called on JS contextmenu event.
  75639. * Override this method to provide functionality.
  75640. */
  75641. protected onContextMenu(evt: PointerEvent): void;
  75642. /**
  75643. * Detach the current controls from the specified dom element.
  75644. * @param element Defines the element to stop listening the inputs from
  75645. */
  75646. detachControl(element: Nullable<HTMLElement>): void;
  75647. /**
  75648. * Gets the class name of the current intput.
  75649. * @returns the class name
  75650. */
  75651. getClassName(): string;
  75652. /**
  75653. * Get the friendly name associated with the input class.
  75654. * @returns the input friendly name
  75655. */
  75656. getSimpleName(): string;
  75657. }
  75658. }
  75659. declare module BABYLON {
  75660. /**
  75661. * Manage the touch inputs to control the movement of a free camera.
  75662. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75663. */
  75664. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  75665. /**
  75666. * Defines the camera the input is attached to.
  75667. */
  75668. camera: FreeCamera;
  75669. /**
  75670. * Defines the touch sensibility for rotation.
  75671. * The higher the faster.
  75672. */
  75673. touchAngularSensibility: number;
  75674. /**
  75675. * Defines the touch sensibility for move.
  75676. * The higher the faster.
  75677. */
  75678. touchMoveSensibility: number;
  75679. private _offsetX;
  75680. private _offsetY;
  75681. private _pointerPressed;
  75682. private _pointerInput;
  75683. private _observer;
  75684. private _onLostFocus;
  75685. /**
  75686. * Attach the input controls to a specific dom element to get the input from.
  75687. * @param element Defines the element the controls should be listened from
  75688. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75689. */
  75690. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75691. /**
  75692. * Detach the current controls from the specified dom element.
  75693. * @param element Defines the element to stop listening the inputs from
  75694. */
  75695. detachControl(element: Nullable<HTMLElement>): void;
  75696. /**
  75697. * Update the current camera state depending on the inputs that have been used this frame.
  75698. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75699. */
  75700. checkInputs(): void;
  75701. /**
  75702. * Gets the class name of the current intput.
  75703. * @returns the class name
  75704. */
  75705. getClassName(): string;
  75706. /**
  75707. * Get the friendly name associated with the input class.
  75708. * @returns the input friendly name
  75709. */
  75710. getSimpleName(): string;
  75711. }
  75712. }
  75713. declare module BABYLON {
  75714. /**
  75715. * Default Inputs manager for the FreeCamera.
  75716. * It groups all the default supported inputs for ease of use.
  75717. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75718. */
  75719. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  75720. /**
  75721. * @hidden
  75722. */
  75723. _mouseInput: Nullable<FreeCameraMouseInput>;
  75724. /**
  75725. * Instantiates a new FreeCameraInputsManager.
  75726. * @param camera Defines the camera the inputs belong to
  75727. */
  75728. constructor(camera: FreeCamera);
  75729. /**
  75730. * Add keyboard input support to the input manager.
  75731. * @returns the current input manager
  75732. */
  75733. addKeyboard(): FreeCameraInputsManager;
  75734. /**
  75735. * Add mouse input support to the input manager.
  75736. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  75737. * @returns the current input manager
  75738. */
  75739. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  75740. /**
  75741. * Removes the mouse input support from the manager
  75742. * @returns the current input manager
  75743. */
  75744. removeMouse(): FreeCameraInputsManager;
  75745. /**
  75746. * Add touch input support to the input manager.
  75747. * @returns the current input manager
  75748. */
  75749. addTouch(): FreeCameraInputsManager;
  75750. /**
  75751. * Remove all attached input methods from a camera
  75752. */
  75753. clear(): void;
  75754. }
  75755. }
  75756. declare module BABYLON {
  75757. /**
  75758. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  75759. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  75760. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  75761. */
  75762. export class FreeCamera extends TargetCamera {
  75763. /**
  75764. * Define the collision ellipsoid of the camera.
  75765. * This is helpful to simulate a camera body like the player body around the camera
  75766. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  75767. */
  75768. ellipsoid: Vector3;
  75769. /**
  75770. * Define an offset for the position of the ellipsoid around the camera.
  75771. * This can be helpful to determine the center of the body near the gravity center of the body
  75772. * instead of its head.
  75773. */
  75774. ellipsoidOffset: Vector3;
  75775. /**
  75776. * Enable or disable collisions of the camera with the rest of the scene objects.
  75777. */
  75778. checkCollisions: boolean;
  75779. /**
  75780. * Enable or disable gravity on the camera.
  75781. */
  75782. applyGravity: boolean;
  75783. /**
  75784. * Define the input manager associated to the camera.
  75785. */
  75786. inputs: FreeCameraInputsManager;
  75787. /**
  75788. * Gets the input sensibility for a mouse input. (default is 2000.0)
  75789. * Higher values reduce sensitivity.
  75790. */
  75791. /**
  75792. * Sets the input sensibility for a mouse input. (default is 2000.0)
  75793. * Higher values reduce sensitivity.
  75794. */
  75795. angularSensibility: number;
  75796. /**
  75797. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  75798. */
  75799. keysUp: number[];
  75800. /**
  75801. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  75802. */
  75803. keysDown: number[];
  75804. /**
  75805. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  75806. */
  75807. keysLeft: number[];
  75808. /**
  75809. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  75810. */
  75811. keysRight: number[];
  75812. /**
  75813. * Event raised when the camera collide with a mesh in the scene.
  75814. */
  75815. onCollide: (collidedMesh: AbstractMesh) => void;
  75816. private _collider;
  75817. private _needMoveForGravity;
  75818. private _oldPosition;
  75819. private _diffPosition;
  75820. private _newPosition;
  75821. /** @hidden */
  75822. _localDirection: Vector3;
  75823. /** @hidden */
  75824. _transformedDirection: Vector3;
  75825. /**
  75826. * Instantiates a Free Camera.
  75827. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  75828. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  75829. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  75830. * @param name Define the name of the camera in the scene
  75831. * @param position Define the start position of the camera in the scene
  75832. * @param scene Define the scene the camera belongs to
  75833. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  75834. */
  75835. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  75836. /**
  75837. * Attached controls to the current camera.
  75838. * @param element Defines the element the controls should be listened from
  75839. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75840. */
  75841. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75842. /**
  75843. * Detach the current controls from the camera.
  75844. * The camera will stop reacting to inputs.
  75845. * @param element Defines the element to stop listening the inputs from
  75846. */
  75847. detachControl(element: HTMLElement): void;
  75848. private _collisionMask;
  75849. /**
  75850. * Define a collision mask to limit the list of object the camera can collide with
  75851. */
  75852. collisionMask: number;
  75853. /** @hidden */
  75854. _collideWithWorld(displacement: Vector3): void;
  75855. private _onCollisionPositionChange;
  75856. /** @hidden */
  75857. _checkInputs(): void;
  75858. /** @hidden */
  75859. _decideIfNeedsToMove(): boolean;
  75860. /** @hidden */
  75861. _updatePosition(): void;
  75862. /**
  75863. * Destroy the camera and release the current resources hold by it.
  75864. */
  75865. dispose(): void;
  75866. /**
  75867. * Gets the current object class name.
  75868. * @return the class name
  75869. */
  75870. getClassName(): string;
  75871. }
  75872. }
  75873. declare module BABYLON {
  75874. /**
  75875. * Represents a gamepad control stick position
  75876. */
  75877. export class StickValues {
  75878. /**
  75879. * The x component of the control stick
  75880. */
  75881. x: number;
  75882. /**
  75883. * The y component of the control stick
  75884. */
  75885. y: number;
  75886. /**
  75887. * Initializes the gamepad x and y control stick values
  75888. * @param x The x component of the gamepad control stick value
  75889. * @param y The y component of the gamepad control stick value
  75890. */
  75891. constructor(
  75892. /**
  75893. * The x component of the control stick
  75894. */
  75895. x: number,
  75896. /**
  75897. * The y component of the control stick
  75898. */
  75899. y: number);
  75900. }
  75901. /**
  75902. * An interface which manages callbacks for gamepad button changes
  75903. */
  75904. export interface GamepadButtonChanges {
  75905. /**
  75906. * Called when a gamepad has been changed
  75907. */
  75908. changed: boolean;
  75909. /**
  75910. * Called when a gamepad press event has been triggered
  75911. */
  75912. pressChanged: boolean;
  75913. /**
  75914. * Called when a touch event has been triggered
  75915. */
  75916. touchChanged: boolean;
  75917. /**
  75918. * Called when a value has changed
  75919. */
  75920. valueChanged: boolean;
  75921. }
  75922. /**
  75923. * Represents a gamepad
  75924. */
  75925. export class Gamepad {
  75926. /**
  75927. * The id of the gamepad
  75928. */
  75929. id: string;
  75930. /**
  75931. * The index of the gamepad
  75932. */
  75933. index: number;
  75934. /**
  75935. * The browser gamepad
  75936. */
  75937. browserGamepad: any;
  75938. /**
  75939. * Specifies what type of gamepad this represents
  75940. */
  75941. type: number;
  75942. private _leftStick;
  75943. private _rightStick;
  75944. /** @hidden */
  75945. _isConnected: boolean;
  75946. private _leftStickAxisX;
  75947. private _leftStickAxisY;
  75948. private _rightStickAxisX;
  75949. private _rightStickAxisY;
  75950. /**
  75951. * Triggered when the left control stick has been changed
  75952. */
  75953. private _onleftstickchanged;
  75954. /**
  75955. * Triggered when the right control stick has been changed
  75956. */
  75957. private _onrightstickchanged;
  75958. /**
  75959. * Represents a gamepad controller
  75960. */
  75961. static GAMEPAD: number;
  75962. /**
  75963. * Represents a generic controller
  75964. */
  75965. static GENERIC: number;
  75966. /**
  75967. * Represents an XBox controller
  75968. */
  75969. static XBOX: number;
  75970. /**
  75971. * Represents a pose-enabled controller
  75972. */
  75973. static POSE_ENABLED: number;
  75974. /**
  75975. * Specifies whether the left control stick should be Y-inverted
  75976. */
  75977. protected _invertLeftStickY: boolean;
  75978. /**
  75979. * Specifies if the gamepad has been connected
  75980. */
  75981. readonly isConnected: boolean;
  75982. /**
  75983. * Initializes the gamepad
  75984. * @param id The id of the gamepad
  75985. * @param index The index of the gamepad
  75986. * @param browserGamepad The browser gamepad
  75987. * @param leftStickX The x component of the left joystick
  75988. * @param leftStickY The y component of the left joystick
  75989. * @param rightStickX The x component of the right joystick
  75990. * @param rightStickY The y component of the right joystick
  75991. */
  75992. constructor(
  75993. /**
  75994. * The id of the gamepad
  75995. */
  75996. id: string,
  75997. /**
  75998. * The index of the gamepad
  75999. */
  76000. index: number,
  76001. /**
  76002. * The browser gamepad
  76003. */
  76004. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  76005. /**
  76006. * Callback triggered when the left joystick has changed
  76007. * @param callback
  76008. */
  76009. onleftstickchanged(callback: (values: StickValues) => void): void;
  76010. /**
  76011. * Callback triggered when the right joystick has changed
  76012. * @param callback
  76013. */
  76014. onrightstickchanged(callback: (values: StickValues) => void): void;
  76015. /**
  76016. * Gets the left joystick
  76017. */
  76018. /**
  76019. * Sets the left joystick values
  76020. */
  76021. leftStick: StickValues;
  76022. /**
  76023. * Gets the right joystick
  76024. */
  76025. /**
  76026. * Sets the right joystick value
  76027. */
  76028. rightStick: StickValues;
  76029. /**
  76030. * Updates the gamepad joystick positions
  76031. */
  76032. update(): void;
  76033. /**
  76034. * Disposes the gamepad
  76035. */
  76036. dispose(): void;
  76037. }
  76038. /**
  76039. * Represents a generic gamepad
  76040. */
  76041. export class GenericPad extends Gamepad {
  76042. private _buttons;
  76043. private _onbuttondown;
  76044. private _onbuttonup;
  76045. /**
  76046. * Observable triggered when a button has been pressed
  76047. */
  76048. onButtonDownObservable: Observable<number>;
  76049. /**
  76050. * Observable triggered when a button has been released
  76051. */
  76052. onButtonUpObservable: Observable<number>;
  76053. /**
  76054. * Callback triggered when a button has been pressed
  76055. * @param callback Called when a button has been pressed
  76056. */
  76057. onbuttondown(callback: (buttonPressed: number) => void): void;
  76058. /**
  76059. * Callback triggered when a button has been released
  76060. * @param callback Called when a button has been released
  76061. */
  76062. onbuttonup(callback: (buttonReleased: number) => void): void;
  76063. /**
  76064. * Initializes the generic gamepad
  76065. * @param id The id of the generic gamepad
  76066. * @param index The index of the generic gamepad
  76067. * @param browserGamepad The browser gamepad
  76068. */
  76069. constructor(id: string, index: number, browserGamepad: any);
  76070. private _setButtonValue;
  76071. /**
  76072. * Updates the generic gamepad
  76073. */
  76074. update(): void;
  76075. /**
  76076. * Disposes the generic gamepad
  76077. */
  76078. dispose(): void;
  76079. }
  76080. }
  76081. declare module BABYLON {
  76082. interface Engine {
  76083. /**
  76084. * Creates a raw texture
  76085. * @param data defines the data to store in the texture
  76086. * @param width defines the width of the texture
  76087. * @param height defines the height of the texture
  76088. * @param format defines the format of the data
  76089. * @param generateMipMaps defines if the engine should generate the mip levels
  76090. * @param invertY defines if data must be stored with Y axis inverted
  76091. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  76092. * @param compression defines the compression used (null by default)
  76093. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76094. * @returns the raw texture inside an InternalTexture
  76095. */
  76096. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  76097. /**
  76098. * Update a raw texture
  76099. * @param texture defines the texture to update
  76100. * @param data defines the data to store in the texture
  76101. * @param format defines the format of the data
  76102. * @param invertY defines if data must be stored with Y axis inverted
  76103. */
  76104. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  76105. /**
  76106. * Update a raw texture
  76107. * @param texture defines the texture to update
  76108. * @param data defines the data to store in the texture
  76109. * @param format defines the format of the data
  76110. * @param invertY defines if data must be stored with Y axis inverted
  76111. * @param compression defines the compression used (null by default)
  76112. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76113. */
  76114. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  76115. /**
  76116. * Creates a new raw cube texture
  76117. * @param data defines the array of data to use to create each face
  76118. * @param size defines the size of the textures
  76119. * @param format defines the format of the data
  76120. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  76121. * @param generateMipMaps defines if the engine should generate the mip levels
  76122. * @param invertY defines if data must be stored with Y axis inverted
  76123. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  76124. * @param compression defines the compression used (null by default)
  76125. * @returns the cube texture as an InternalTexture
  76126. */
  76127. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  76128. /**
  76129. * Update a raw cube texture
  76130. * @param texture defines the texture to udpdate
  76131. * @param data defines the data to store
  76132. * @param format defines the data format
  76133. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76134. * @param invertY defines if data must be stored with Y axis inverted
  76135. */
  76136. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  76137. /**
  76138. * Update a raw cube texture
  76139. * @param texture defines the texture to udpdate
  76140. * @param data defines the data to store
  76141. * @param format defines the data format
  76142. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76143. * @param invertY defines if data must be stored with Y axis inverted
  76144. * @param compression defines the compression used (null by default)
  76145. */
  76146. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  76147. /**
  76148. * Update a raw cube texture
  76149. * @param texture defines the texture to udpdate
  76150. * @param data defines the data to store
  76151. * @param format defines the data format
  76152. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76153. * @param invertY defines if data must be stored with Y axis inverted
  76154. * @param compression defines the compression used (null by default)
  76155. * @param level defines which level of the texture to update
  76156. */
  76157. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  76158. /**
  76159. * Creates a new raw cube texture from a specified url
  76160. * @param url defines the url where the data is located
  76161. * @param scene defines the current scene
  76162. * @param size defines the size of the textures
  76163. * @param format defines the format of the data
  76164. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  76165. * @param noMipmap defines if the engine should avoid generating the mip levels
  76166. * @param callback defines a callback used to extract texture data from loaded data
  76167. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  76168. * @param onLoad defines a callback called when texture is loaded
  76169. * @param onError defines a callback called if there is an error
  76170. * @returns the cube texture as an InternalTexture
  76171. */
  76172. 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;
  76173. /**
  76174. * Creates a new raw cube texture from a specified url
  76175. * @param url defines the url where the data is located
  76176. * @param scene defines the current scene
  76177. * @param size defines the size of the textures
  76178. * @param format defines the format of the data
  76179. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  76180. * @param noMipmap defines if the engine should avoid generating the mip levels
  76181. * @param callback defines a callback used to extract texture data from loaded data
  76182. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  76183. * @param onLoad defines a callback called when texture is loaded
  76184. * @param onError defines a callback called if there is an error
  76185. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  76186. * @param invertY defines if data must be stored with Y axis inverted
  76187. * @returns the cube texture as an InternalTexture
  76188. */
  76189. 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;
  76190. /**
  76191. * Creates a new raw 3D texture
  76192. * @param data defines the data used to create the texture
  76193. * @param width defines the width of the texture
  76194. * @param height defines the height of the texture
  76195. * @param depth defines the depth of the texture
  76196. * @param format defines the format of the texture
  76197. * @param generateMipMaps defines if the engine must generate mip levels
  76198. * @param invertY defines if data must be stored with Y axis inverted
  76199. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  76200. * @param compression defines the compressed used (can be null)
  76201. * @param textureType defines the compressed used (can be null)
  76202. * @returns a new raw 3D texture (stored in an InternalTexture)
  76203. */
  76204. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  76205. /**
  76206. * Update a raw 3D texture
  76207. * @param texture defines the texture to update
  76208. * @param data defines the data to store
  76209. * @param format defines the data format
  76210. * @param invertY defines if data must be stored with Y axis inverted
  76211. */
  76212. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  76213. /**
  76214. * Update a raw 3D texture
  76215. * @param texture defines the texture to update
  76216. * @param data defines the data to store
  76217. * @param format defines the data format
  76218. * @param invertY defines if data must be stored with Y axis inverted
  76219. * @param compression defines the used compression (can be null)
  76220. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  76221. */
  76222. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  76223. }
  76224. }
  76225. declare module BABYLON {
  76226. /**
  76227. * Raw texture can help creating a texture directly from an array of data.
  76228. * This can be super useful if you either get the data from an uncompressed source or
  76229. * if you wish to create your texture pixel by pixel.
  76230. */
  76231. export class RawTexture extends Texture {
  76232. /**
  76233. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76234. */
  76235. format: number;
  76236. private _engine;
  76237. /**
  76238. * Instantiates a new RawTexture.
  76239. * Raw texture can help creating a texture directly from an array of data.
  76240. * This can be super useful if you either get the data from an uncompressed source or
  76241. * if you wish to create your texture pixel by pixel.
  76242. * @param data define the array of data to use to create the texture
  76243. * @param width define the width of the texture
  76244. * @param height define the height of the texture
  76245. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76246. * @param scene define the scene the texture belongs to
  76247. * @param generateMipMaps define whether mip maps should be generated or not
  76248. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76249. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76250. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76251. */
  76252. constructor(data: ArrayBufferView, width: number, height: number,
  76253. /**
  76254. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76255. */
  76256. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  76257. /**
  76258. * Updates the texture underlying data.
  76259. * @param data Define the new data of the texture
  76260. */
  76261. update(data: ArrayBufferView): void;
  76262. /**
  76263. * Creates a luminance texture from some data.
  76264. * @param data Define the texture data
  76265. * @param width Define the width of the texture
  76266. * @param height Define the height of the texture
  76267. * @param scene Define the scene the texture belongs to
  76268. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76269. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76270. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76271. * @returns the luminance texture
  76272. */
  76273. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76274. /**
  76275. * Creates a luminance alpha texture from some data.
  76276. * @param data Define the texture data
  76277. * @param width Define the width of the texture
  76278. * @param height Define the height of the texture
  76279. * @param scene Define the scene the texture belongs to
  76280. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76281. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76282. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76283. * @returns the luminance alpha texture
  76284. */
  76285. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76286. /**
  76287. * Creates an alpha texture from some data.
  76288. * @param data Define the texture data
  76289. * @param width Define the width of the texture
  76290. * @param height Define the height of the texture
  76291. * @param scene Define the scene the texture belongs to
  76292. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76293. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76294. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76295. * @returns the alpha texture
  76296. */
  76297. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76298. /**
  76299. * Creates a RGB texture from some data.
  76300. * @param data Define the texture data
  76301. * @param width Define the width of the texture
  76302. * @param height Define the height of the texture
  76303. * @param scene Define the scene the texture belongs to
  76304. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76305. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76306. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76307. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76308. * @returns the RGB alpha texture
  76309. */
  76310. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76311. /**
  76312. * Creates a RGBA texture from some data.
  76313. * @param data Define the texture data
  76314. * @param width Define the width of the texture
  76315. * @param height Define the height of the texture
  76316. * @param scene Define the scene the texture belongs to
  76317. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76318. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76319. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76320. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76321. * @returns the RGBA texture
  76322. */
  76323. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76324. /**
  76325. * Creates a R texture from some data.
  76326. * @param data Define the texture data
  76327. * @param width Define the width of the texture
  76328. * @param height Define the height of the texture
  76329. * @param scene Define the scene the texture belongs to
  76330. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76331. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76332. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76333. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76334. * @returns the R texture
  76335. */
  76336. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76337. }
  76338. }
  76339. declare module BABYLON {
  76340. /**
  76341. * Interface for the size containing width and height
  76342. */
  76343. export interface ISize {
  76344. /**
  76345. * Width
  76346. */
  76347. width: number;
  76348. /**
  76349. * Heighht
  76350. */
  76351. height: number;
  76352. }
  76353. /**
  76354. * Size containing widht and height
  76355. */
  76356. export class Size implements ISize {
  76357. /**
  76358. * Width
  76359. */
  76360. width: number;
  76361. /**
  76362. * Height
  76363. */
  76364. height: number;
  76365. /**
  76366. * Creates a Size object from the given width and height (floats).
  76367. * @param width width of the new size
  76368. * @param height height of the new size
  76369. */
  76370. constructor(width: number, height: number);
  76371. /**
  76372. * Returns a string with the Size width and height
  76373. * @returns a string with the Size width and height
  76374. */
  76375. toString(): string;
  76376. /**
  76377. * "Size"
  76378. * @returns the string "Size"
  76379. */
  76380. getClassName(): string;
  76381. /**
  76382. * Returns the Size hash code.
  76383. * @returns a hash code for a unique width and height
  76384. */
  76385. getHashCode(): number;
  76386. /**
  76387. * Updates the current size from the given one.
  76388. * @param src the given size
  76389. */
  76390. copyFrom(src: Size): void;
  76391. /**
  76392. * Updates in place the current Size from the given floats.
  76393. * @param width width of the new size
  76394. * @param height height of the new size
  76395. * @returns the updated Size.
  76396. */
  76397. copyFromFloats(width: number, height: number): Size;
  76398. /**
  76399. * Updates in place the current Size from the given floats.
  76400. * @param width width to set
  76401. * @param height height to set
  76402. * @returns the updated Size.
  76403. */
  76404. set(width: number, height: number): Size;
  76405. /**
  76406. * Multiplies the width and height by numbers
  76407. * @param w factor to multiple the width by
  76408. * @param h factor to multiple the height by
  76409. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  76410. */
  76411. multiplyByFloats(w: number, h: number): Size;
  76412. /**
  76413. * Clones the size
  76414. * @returns a new Size copied from the given one.
  76415. */
  76416. clone(): Size;
  76417. /**
  76418. * True if the current Size and the given one width and height are strictly equal.
  76419. * @param other the other size to compare against
  76420. * @returns True if the current Size and the given one width and height are strictly equal.
  76421. */
  76422. equals(other: Size): boolean;
  76423. /**
  76424. * The surface of the Size : width * height (float).
  76425. */
  76426. readonly surface: number;
  76427. /**
  76428. * Create a new size of zero
  76429. * @returns a new Size set to (0.0, 0.0)
  76430. */
  76431. static Zero(): Size;
  76432. /**
  76433. * Sums the width and height of two sizes
  76434. * @param otherSize size to add to this size
  76435. * @returns a new Size set as the addition result of the current Size and the given one.
  76436. */
  76437. add(otherSize: Size): Size;
  76438. /**
  76439. * Subtracts the width and height of two
  76440. * @param otherSize size to subtract to this size
  76441. * @returns a new Size set as the subtraction result of the given one from the current Size.
  76442. */
  76443. subtract(otherSize: Size): Size;
  76444. /**
  76445. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  76446. * @param start starting size to lerp between
  76447. * @param end end size to lerp between
  76448. * @param amount amount to lerp between the start and end values
  76449. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  76450. */
  76451. static Lerp(start: Size, end: Size, amount: number): Size;
  76452. }
  76453. }
  76454. declare module BABYLON {
  76455. /**
  76456. * Defines a runtime animation
  76457. */
  76458. export class RuntimeAnimation {
  76459. private _events;
  76460. /**
  76461. * The current frame of the runtime animation
  76462. */
  76463. private _currentFrame;
  76464. /**
  76465. * The animation used by the runtime animation
  76466. */
  76467. private _animation;
  76468. /**
  76469. * The target of the runtime animation
  76470. */
  76471. private _target;
  76472. /**
  76473. * The initiating animatable
  76474. */
  76475. private _host;
  76476. /**
  76477. * The original value of the runtime animation
  76478. */
  76479. private _originalValue;
  76480. /**
  76481. * The original blend value of the runtime animation
  76482. */
  76483. private _originalBlendValue;
  76484. /**
  76485. * The offsets cache of the runtime animation
  76486. */
  76487. private _offsetsCache;
  76488. /**
  76489. * The high limits cache of the runtime animation
  76490. */
  76491. private _highLimitsCache;
  76492. /**
  76493. * Specifies if the runtime animation has been stopped
  76494. */
  76495. private _stopped;
  76496. /**
  76497. * The blending factor of the runtime animation
  76498. */
  76499. private _blendingFactor;
  76500. /**
  76501. * The BabylonJS scene
  76502. */
  76503. private _scene;
  76504. /**
  76505. * The current value of the runtime animation
  76506. */
  76507. private _currentValue;
  76508. /** @hidden */
  76509. _animationState: _IAnimationState;
  76510. /**
  76511. * The active target of the runtime animation
  76512. */
  76513. private _activeTargets;
  76514. private _currentActiveTarget;
  76515. private _directTarget;
  76516. /**
  76517. * The target path of the runtime animation
  76518. */
  76519. private _targetPath;
  76520. /**
  76521. * The weight of the runtime animation
  76522. */
  76523. private _weight;
  76524. /**
  76525. * The ratio offset of the runtime animation
  76526. */
  76527. private _ratioOffset;
  76528. /**
  76529. * The previous delay of the runtime animation
  76530. */
  76531. private _previousDelay;
  76532. /**
  76533. * The previous ratio of the runtime animation
  76534. */
  76535. private _previousRatio;
  76536. private _enableBlending;
  76537. private _keys;
  76538. private _minFrame;
  76539. private _maxFrame;
  76540. private _minValue;
  76541. private _maxValue;
  76542. private _targetIsArray;
  76543. /**
  76544. * Gets the current frame of the runtime animation
  76545. */
  76546. readonly currentFrame: number;
  76547. /**
  76548. * Gets the weight of the runtime animation
  76549. */
  76550. readonly weight: number;
  76551. /**
  76552. * Gets the current value of the runtime animation
  76553. */
  76554. readonly currentValue: any;
  76555. /**
  76556. * Gets the target path of the runtime animation
  76557. */
  76558. readonly targetPath: string;
  76559. /**
  76560. * Gets the actual target of the runtime animation
  76561. */
  76562. readonly target: any;
  76563. /** @hidden */
  76564. _onLoop: () => void;
  76565. /**
  76566. * Create a new RuntimeAnimation object
  76567. * @param target defines the target of the animation
  76568. * @param animation defines the source animation object
  76569. * @param scene defines the hosting scene
  76570. * @param host defines the initiating Animatable
  76571. */
  76572. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  76573. private _preparePath;
  76574. /**
  76575. * Gets the animation from the runtime animation
  76576. */
  76577. readonly animation: Animation;
  76578. /**
  76579. * Resets the runtime animation to the beginning
  76580. * @param restoreOriginal defines whether to restore the target property to the original value
  76581. */
  76582. reset(restoreOriginal?: boolean): void;
  76583. /**
  76584. * Specifies if the runtime animation is stopped
  76585. * @returns Boolean specifying if the runtime animation is stopped
  76586. */
  76587. isStopped(): boolean;
  76588. /**
  76589. * Disposes of the runtime animation
  76590. */
  76591. dispose(): void;
  76592. /**
  76593. * Apply the interpolated value to the target
  76594. * @param currentValue defines the value computed by the animation
  76595. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  76596. */
  76597. setValue(currentValue: any, weight: number): void;
  76598. private _getOriginalValues;
  76599. private _setValue;
  76600. /**
  76601. * Gets the loop pmode of the runtime animation
  76602. * @returns Loop Mode
  76603. */
  76604. private _getCorrectLoopMode;
  76605. /**
  76606. * Move the current animation to a given frame
  76607. * @param frame defines the frame to move to
  76608. */
  76609. goToFrame(frame: number): void;
  76610. /**
  76611. * @hidden Internal use only
  76612. */
  76613. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  76614. /**
  76615. * Execute the current animation
  76616. * @param delay defines the delay to add to the current frame
  76617. * @param from defines the lower bound of the animation range
  76618. * @param to defines the upper bound of the animation range
  76619. * @param loop defines if the current animation must loop
  76620. * @param speedRatio defines the current speed ratio
  76621. * @param weight defines the weight of the animation (default is -1 so no weight)
  76622. * @param onLoop optional callback called when animation loops
  76623. * @returns a boolean indicating if the animation is running
  76624. */
  76625. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  76626. }
  76627. }
  76628. declare module BABYLON {
  76629. /**
  76630. * Class used to store an actual running animation
  76631. */
  76632. export class Animatable {
  76633. /** defines the target object */
  76634. target: any;
  76635. /** defines the starting frame number (default is 0) */
  76636. fromFrame: number;
  76637. /** defines the ending frame number (default is 100) */
  76638. toFrame: number;
  76639. /** defines if the animation must loop (default is false) */
  76640. loopAnimation: boolean;
  76641. /** defines a callback to call when animation ends if it is not looping */
  76642. onAnimationEnd?: (() => void) | null | undefined;
  76643. /** defines a callback to call when animation loops */
  76644. onAnimationLoop?: (() => void) | null | undefined;
  76645. private _localDelayOffset;
  76646. private _pausedDelay;
  76647. private _runtimeAnimations;
  76648. private _paused;
  76649. private _scene;
  76650. private _speedRatio;
  76651. private _weight;
  76652. private _syncRoot;
  76653. /**
  76654. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  76655. * This will only apply for non looping animation (default is true)
  76656. */
  76657. disposeOnEnd: boolean;
  76658. /**
  76659. * Gets a boolean indicating if the animation has started
  76660. */
  76661. animationStarted: boolean;
  76662. /**
  76663. * Observer raised when the animation ends
  76664. */
  76665. onAnimationEndObservable: Observable<Animatable>;
  76666. /**
  76667. * Observer raised when the animation loops
  76668. */
  76669. onAnimationLoopObservable: Observable<Animatable>;
  76670. /**
  76671. * Gets the root Animatable used to synchronize and normalize animations
  76672. */
  76673. readonly syncRoot: Nullable<Animatable>;
  76674. /**
  76675. * Gets the current frame of the first RuntimeAnimation
  76676. * Used to synchronize Animatables
  76677. */
  76678. readonly masterFrame: number;
  76679. /**
  76680. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  76681. */
  76682. weight: number;
  76683. /**
  76684. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  76685. */
  76686. speedRatio: number;
  76687. /**
  76688. * Creates a new Animatable
  76689. * @param scene defines the hosting scene
  76690. * @param target defines the target object
  76691. * @param fromFrame defines the starting frame number (default is 0)
  76692. * @param toFrame defines the ending frame number (default is 100)
  76693. * @param loopAnimation defines if the animation must loop (default is false)
  76694. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  76695. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  76696. * @param animations defines a group of animation to add to the new Animatable
  76697. * @param onAnimationLoop defines a callback to call when animation loops
  76698. */
  76699. constructor(scene: Scene,
  76700. /** defines the target object */
  76701. target: any,
  76702. /** defines the starting frame number (default is 0) */
  76703. fromFrame?: number,
  76704. /** defines the ending frame number (default is 100) */
  76705. toFrame?: number,
  76706. /** defines if the animation must loop (default is false) */
  76707. loopAnimation?: boolean, speedRatio?: number,
  76708. /** defines a callback to call when animation ends if it is not looping */
  76709. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  76710. /** defines a callback to call when animation loops */
  76711. onAnimationLoop?: (() => void) | null | undefined);
  76712. /**
  76713. * Synchronize and normalize current Animatable with a source Animatable
  76714. * This is useful when using animation weights and when animations are not of the same length
  76715. * @param root defines the root Animatable to synchronize with
  76716. * @returns the current Animatable
  76717. */
  76718. syncWith(root: Animatable): Animatable;
  76719. /**
  76720. * Gets the list of runtime animations
  76721. * @returns an array of RuntimeAnimation
  76722. */
  76723. getAnimations(): RuntimeAnimation[];
  76724. /**
  76725. * Adds more animations to the current animatable
  76726. * @param target defines the target of the animations
  76727. * @param animations defines the new animations to add
  76728. */
  76729. appendAnimations(target: any, animations: Animation[]): void;
  76730. /**
  76731. * Gets the source animation for a specific property
  76732. * @param property defines the propertyu to look for
  76733. * @returns null or the source animation for the given property
  76734. */
  76735. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  76736. /**
  76737. * Gets the runtime animation for a specific property
  76738. * @param property defines the propertyu to look for
  76739. * @returns null or the runtime animation for the given property
  76740. */
  76741. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  76742. /**
  76743. * Resets the animatable to its original state
  76744. */
  76745. reset(): void;
  76746. /**
  76747. * Allows the animatable to blend with current running animations
  76748. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76749. * @param blendingSpeed defines the blending speed to use
  76750. */
  76751. enableBlending(blendingSpeed: number): void;
  76752. /**
  76753. * Disable animation blending
  76754. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76755. */
  76756. disableBlending(): void;
  76757. /**
  76758. * Jump directly to a given frame
  76759. * @param frame defines the frame to jump to
  76760. */
  76761. goToFrame(frame: number): void;
  76762. /**
  76763. * Pause the animation
  76764. */
  76765. pause(): void;
  76766. /**
  76767. * Restart the animation
  76768. */
  76769. restart(): void;
  76770. private _raiseOnAnimationEnd;
  76771. /**
  76772. * Stop and delete the current animation
  76773. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  76774. * @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)
  76775. */
  76776. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  76777. /**
  76778. * Wait asynchronously for the animation to end
  76779. * @returns a promise which will be fullfilled when the animation ends
  76780. */
  76781. waitAsync(): Promise<Animatable>;
  76782. /** @hidden */
  76783. _animate(delay: number): boolean;
  76784. }
  76785. interface Scene {
  76786. /** @hidden */
  76787. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  76788. /** @hidden */
  76789. _processLateAnimationBindingsForMatrices(holder: {
  76790. totalWeight: number;
  76791. animations: RuntimeAnimation[];
  76792. originalValue: Matrix;
  76793. }): any;
  76794. /** @hidden */
  76795. _processLateAnimationBindingsForQuaternions(holder: {
  76796. totalWeight: number;
  76797. animations: RuntimeAnimation[];
  76798. originalValue: Quaternion;
  76799. }, refQuaternion: Quaternion): Quaternion;
  76800. /** @hidden */
  76801. _processLateAnimationBindings(): void;
  76802. /**
  76803. * Will start the animation sequence of a given target
  76804. * @param target defines the target
  76805. * @param from defines from which frame should animation start
  76806. * @param to defines until which frame should animation run.
  76807. * @param weight defines the weight to apply to the animation (1.0 by default)
  76808. * @param loop defines if the animation loops
  76809. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76810. * @param onAnimationEnd defines the function to be executed when the animation ends
  76811. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76812. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76813. * @param onAnimationLoop defines the callback to call when an animation loops
  76814. * @returns the animatable object created for this animation
  76815. */
  76816. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76817. /**
  76818. * Will start the animation sequence of a given target
  76819. * @param target defines the target
  76820. * @param from defines from which frame should animation start
  76821. * @param to defines until which frame should animation run.
  76822. * @param loop defines if the animation loops
  76823. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76824. * @param onAnimationEnd defines the function to be executed when the animation ends
  76825. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76826. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76827. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  76828. * @param onAnimationLoop defines the callback to call when an animation loops
  76829. * @returns the animatable object created for this animation
  76830. */
  76831. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76832. /**
  76833. * Will start the animation sequence of a given target and its hierarchy
  76834. * @param target defines the target
  76835. * @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.
  76836. * @param from defines from which frame should animation start
  76837. * @param to defines until which frame should animation run.
  76838. * @param loop defines if the animation loops
  76839. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76840. * @param onAnimationEnd defines the function to be executed when the animation ends
  76841. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76842. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76843. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76844. * @param onAnimationLoop defines the callback to call when an animation loops
  76845. * @returns the list of created animatables
  76846. */
  76847. 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[];
  76848. /**
  76849. * Begin a new animation on a given node
  76850. * @param target defines the target where the animation will take place
  76851. * @param animations defines the list of animations to start
  76852. * @param from defines the initial value
  76853. * @param to defines the final value
  76854. * @param loop defines if you want animation to loop (off by default)
  76855. * @param speedRatio defines the speed ratio to apply to all animations
  76856. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76857. * @param onAnimationLoop defines the callback to call when an animation loops
  76858. * @returns the list of created animatables
  76859. */
  76860. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  76861. /**
  76862. * Begin a new animation on a given node and its hierarchy
  76863. * @param target defines the root node where the animation will take place
  76864. * @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.
  76865. * @param animations defines the list of animations to start
  76866. * @param from defines the initial value
  76867. * @param to defines the final value
  76868. * @param loop defines if you want animation to loop (off by default)
  76869. * @param speedRatio defines the speed ratio to apply to all animations
  76870. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76871. * @param onAnimationLoop defines the callback to call when an animation loops
  76872. * @returns the list of animatables created for all nodes
  76873. */
  76874. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  76875. /**
  76876. * Gets the animatable associated with a specific target
  76877. * @param target defines the target of the animatable
  76878. * @returns the required animatable if found
  76879. */
  76880. getAnimatableByTarget(target: any): Nullable<Animatable>;
  76881. /**
  76882. * Gets all animatables associated with a given target
  76883. * @param target defines the target to look animatables for
  76884. * @returns an array of Animatables
  76885. */
  76886. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  76887. /**
  76888. * Stops and removes all animations that have been applied to the scene
  76889. */
  76890. stopAllAnimations(): void;
  76891. }
  76892. interface Bone {
  76893. /**
  76894. * Copy an animation range from another bone
  76895. * @param source defines the source bone
  76896. * @param rangeName defines the range name to copy
  76897. * @param frameOffset defines the frame offset
  76898. * @param rescaleAsRequired defines if rescaling must be applied if required
  76899. * @param skelDimensionsRatio defines the scaling ratio
  76900. * @returns true if operation was successful
  76901. */
  76902. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  76903. }
  76904. }
  76905. declare module BABYLON {
  76906. /**
  76907. * Class used to override all child animations of a given target
  76908. */
  76909. export class AnimationPropertiesOverride {
  76910. /**
  76911. * Gets or sets a value indicating if animation blending must be used
  76912. */
  76913. enableBlending: boolean;
  76914. /**
  76915. * Gets or sets the blending speed to use when enableBlending is true
  76916. */
  76917. blendingSpeed: number;
  76918. /**
  76919. * Gets or sets the default loop mode to use
  76920. */
  76921. loopMode: number;
  76922. }
  76923. }
  76924. declare module BABYLON {
  76925. /**
  76926. * Class used to handle skinning animations
  76927. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  76928. */
  76929. export class Skeleton implements IAnimatable {
  76930. /** defines the skeleton name */
  76931. name: string;
  76932. /** defines the skeleton Id */
  76933. id: string;
  76934. /**
  76935. * Defines the list of child bones
  76936. */
  76937. bones: Bone[];
  76938. /**
  76939. * Defines an estimate of the dimension of the skeleton at rest
  76940. */
  76941. dimensionsAtRest: Vector3;
  76942. /**
  76943. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  76944. */
  76945. needInitialSkinMatrix: boolean;
  76946. /**
  76947. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  76948. */
  76949. overrideMesh: Nullable<AbstractMesh>;
  76950. /**
  76951. * Gets the list of animations attached to this skeleton
  76952. */
  76953. animations: Array<Animation>;
  76954. private _scene;
  76955. private _isDirty;
  76956. private _transformMatrices;
  76957. private _transformMatrixTexture;
  76958. private _meshesWithPoseMatrix;
  76959. private _animatables;
  76960. private _identity;
  76961. private _synchronizedWithMesh;
  76962. private _ranges;
  76963. private _lastAbsoluteTransformsUpdateId;
  76964. private _canUseTextureForBones;
  76965. private _uniqueId;
  76966. /** @hidden */
  76967. _numBonesWithLinkedTransformNode: number;
  76968. /** @hidden */
  76969. _hasWaitingData: Nullable<boolean>;
  76970. /**
  76971. * Specifies if the skeleton should be serialized
  76972. */
  76973. doNotSerialize: boolean;
  76974. private _useTextureToStoreBoneMatrices;
  76975. /**
  76976. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  76977. * Please note that this option is not available if the hardware does not support it
  76978. */
  76979. useTextureToStoreBoneMatrices: boolean;
  76980. private _animationPropertiesOverride;
  76981. /**
  76982. * Gets or sets the animation properties override
  76983. */
  76984. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  76985. /**
  76986. * List of inspectable custom properties (used by the Inspector)
  76987. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  76988. */
  76989. inspectableCustomProperties: IInspectable[];
  76990. /**
  76991. * An observable triggered before computing the skeleton's matrices
  76992. */
  76993. onBeforeComputeObservable: Observable<Skeleton>;
  76994. /**
  76995. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  76996. */
  76997. readonly isUsingTextureForMatrices: boolean;
  76998. /**
  76999. * Gets the unique ID of this skeleton
  77000. */
  77001. readonly uniqueId: number;
  77002. /**
  77003. * Creates a new skeleton
  77004. * @param name defines the skeleton name
  77005. * @param id defines the skeleton Id
  77006. * @param scene defines the hosting scene
  77007. */
  77008. constructor(
  77009. /** defines the skeleton name */
  77010. name: string,
  77011. /** defines the skeleton Id */
  77012. id: string, scene: Scene);
  77013. /**
  77014. * Gets the current object class name.
  77015. * @return the class name
  77016. */
  77017. getClassName(): string;
  77018. /**
  77019. * Returns an array containing the root bones
  77020. * @returns an array containing the root bones
  77021. */
  77022. getChildren(): Array<Bone>;
  77023. /**
  77024. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  77025. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  77026. * @returns a Float32Array containing matrices data
  77027. */
  77028. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  77029. /**
  77030. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  77031. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  77032. * @returns a raw texture containing the data
  77033. */
  77034. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  77035. /**
  77036. * Gets the current hosting scene
  77037. * @returns a scene object
  77038. */
  77039. getScene(): Scene;
  77040. /**
  77041. * Gets a string representing the current skeleton data
  77042. * @param fullDetails defines a boolean indicating if we want a verbose version
  77043. * @returns a string representing the current skeleton data
  77044. */
  77045. toString(fullDetails?: boolean): string;
  77046. /**
  77047. * Get bone's index searching by name
  77048. * @param name defines bone's name to search for
  77049. * @return the indice of the bone. Returns -1 if not found
  77050. */
  77051. getBoneIndexByName(name: string): number;
  77052. /**
  77053. * Creater a new animation range
  77054. * @param name defines the name of the range
  77055. * @param from defines the start key
  77056. * @param to defines the end key
  77057. */
  77058. createAnimationRange(name: string, from: number, to: number): void;
  77059. /**
  77060. * Delete a specific animation range
  77061. * @param name defines the name of the range
  77062. * @param deleteFrames defines if frames must be removed as well
  77063. */
  77064. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  77065. /**
  77066. * Gets a specific animation range
  77067. * @param name defines the name of the range to look for
  77068. * @returns the requested animation range or null if not found
  77069. */
  77070. getAnimationRange(name: string): Nullable<AnimationRange>;
  77071. /**
  77072. * Gets the list of all animation ranges defined on this skeleton
  77073. * @returns an array
  77074. */
  77075. getAnimationRanges(): Nullable<AnimationRange>[];
  77076. /**
  77077. * Copy animation range from a source skeleton.
  77078. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  77079. * @param source defines the source skeleton
  77080. * @param name defines the name of the range to copy
  77081. * @param rescaleAsRequired defines if rescaling must be applied if required
  77082. * @returns true if operation was successful
  77083. */
  77084. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  77085. /**
  77086. * Forces the skeleton to go to rest pose
  77087. */
  77088. returnToRest(): void;
  77089. private _getHighestAnimationFrame;
  77090. /**
  77091. * Begin a specific animation range
  77092. * @param name defines the name of the range to start
  77093. * @param loop defines if looping must be turned on (false by default)
  77094. * @param speedRatio defines the speed ratio to apply (1 by default)
  77095. * @param onAnimationEnd defines a callback which will be called when animation will end
  77096. * @returns a new animatable
  77097. */
  77098. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  77099. /** @hidden */
  77100. _markAsDirty(): void;
  77101. /** @hidden */
  77102. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77103. /** @hidden */
  77104. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77105. private _computeTransformMatrices;
  77106. /**
  77107. * Build all resources required to render a skeleton
  77108. */
  77109. prepare(): void;
  77110. /**
  77111. * Gets the list of animatables currently running for this skeleton
  77112. * @returns an array of animatables
  77113. */
  77114. getAnimatables(): IAnimatable[];
  77115. /**
  77116. * Clone the current skeleton
  77117. * @param name defines the name of the new skeleton
  77118. * @param id defines the id of the new skeleton
  77119. * @returns the new skeleton
  77120. */
  77121. clone(name: string, id: string): Skeleton;
  77122. /**
  77123. * Enable animation blending for this skeleton
  77124. * @param blendingSpeed defines the blending speed to apply
  77125. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77126. */
  77127. enableBlending(blendingSpeed?: number): void;
  77128. /**
  77129. * Releases all resources associated with the current skeleton
  77130. */
  77131. dispose(): void;
  77132. /**
  77133. * Serialize the skeleton in a JSON object
  77134. * @returns a JSON object
  77135. */
  77136. serialize(): any;
  77137. /**
  77138. * Creates a new skeleton from serialized data
  77139. * @param parsedSkeleton defines the serialized data
  77140. * @param scene defines the hosting scene
  77141. * @returns a new skeleton
  77142. */
  77143. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  77144. /**
  77145. * Compute all node absolute transforms
  77146. * @param forceUpdate defines if computation must be done even if cache is up to date
  77147. */
  77148. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  77149. /**
  77150. * Gets the root pose matrix
  77151. * @returns a matrix
  77152. */
  77153. getPoseMatrix(): Nullable<Matrix>;
  77154. /**
  77155. * Sorts bones per internal index
  77156. */
  77157. sortBones(): void;
  77158. private _sortBones;
  77159. }
  77160. }
  77161. declare module BABYLON {
  77162. /**
  77163. * Class used to store bone information
  77164. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77165. */
  77166. export class Bone extends Node {
  77167. /**
  77168. * defines the bone name
  77169. */
  77170. name: string;
  77171. private static _tmpVecs;
  77172. private static _tmpQuat;
  77173. private static _tmpMats;
  77174. /**
  77175. * Gets the list of child bones
  77176. */
  77177. children: Bone[];
  77178. /** Gets the animations associated with this bone */
  77179. animations: Animation[];
  77180. /**
  77181. * Gets or sets bone length
  77182. */
  77183. length: number;
  77184. /**
  77185. * @hidden Internal only
  77186. * Set this value to map this bone to a different index in the transform matrices
  77187. * Set this value to -1 to exclude the bone from the transform matrices
  77188. */
  77189. _index: Nullable<number>;
  77190. private _skeleton;
  77191. private _localMatrix;
  77192. private _restPose;
  77193. private _baseMatrix;
  77194. private _absoluteTransform;
  77195. private _invertedAbsoluteTransform;
  77196. private _parent;
  77197. private _scalingDeterminant;
  77198. private _worldTransform;
  77199. private _localScaling;
  77200. private _localRotation;
  77201. private _localPosition;
  77202. private _needToDecompose;
  77203. private _needToCompose;
  77204. /** @hidden */
  77205. _linkedTransformNode: Nullable<TransformNode>;
  77206. /** @hidden */
  77207. _waitingTransformNodeId: Nullable<string>;
  77208. /** @hidden */
  77209. /** @hidden */
  77210. _matrix: Matrix;
  77211. /**
  77212. * Create a new bone
  77213. * @param name defines the bone name
  77214. * @param skeleton defines the parent skeleton
  77215. * @param parentBone defines the parent (can be null if the bone is the root)
  77216. * @param localMatrix defines the local matrix
  77217. * @param restPose defines the rest pose matrix
  77218. * @param baseMatrix defines the base matrix
  77219. * @param index defines index of the bone in the hiearchy
  77220. */
  77221. constructor(
  77222. /**
  77223. * defines the bone name
  77224. */
  77225. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  77226. /**
  77227. * Gets the current object class name.
  77228. * @return the class name
  77229. */
  77230. getClassName(): string;
  77231. /**
  77232. * Gets the parent skeleton
  77233. * @returns a skeleton
  77234. */
  77235. getSkeleton(): Skeleton;
  77236. /**
  77237. * Gets parent bone
  77238. * @returns a bone or null if the bone is the root of the bone hierarchy
  77239. */
  77240. getParent(): Nullable<Bone>;
  77241. /**
  77242. * Returns an array containing the root bones
  77243. * @returns an array containing the root bones
  77244. */
  77245. getChildren(): Array<Bone>;
  77246. /**
  77247. * Sets the parent bone
  77248. * @param parent defines the parent (can be null if the bone is the root)
  77249. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  77250. */
  77251. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  77252. /**
  77253. * Gets the local matrix
  77254. * @returns a matrix
  77255. */
  77256. getLocalMatrix(): Matrix;
  77257. /**
  77258. * Gets the base matrix (initial matrix which remains unchanged)
  77259. * @returns a matrix
  77260. */
  77261. getBaseMatrix(): Matrix;
  77262. /**
  77263. * Gets the rest pose matrix
  77264. * @returns a matrix
  77265. */
  77266. getRestPose(): Matrix;
  77267. /**
  77268. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  77269. */
  77270. getWorldMatrix(): Matrix;
  77271. /**
  77272. * Sets the local matrix to rest pose matrix
  77273. */
  77274. returnToRest(): void;
  77275. /**
  77276. * Gets the inverse of the absolute transform matrix.
  77277. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  77278. * @returns a matrix
  77279. */
  77280. getInvertedAbsoluteTransform(): Matrix;
  77281. /**
  77282. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  77283. * @returns a matrix
  77284. */
  77285. getAbsoluteTransform(): Matrix;
  77286. /**
  77287. * Links with the given transform node.
  77288. * The local matrix of this bone is copied from the transform node every frame.
  77289. * @param transformNode defines the transform node to link to
  77290. */
  77291. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  77292. /**
  77293. * Gets the node used to drive the bone's transformation
  77294. * @returns a transform node or null
  77295. */
  77296. getTransformNode(): Nullable<TransformNode>;
  77297. /** Gets or sets current position (in local space) */
  77298. position: Vector3;
  77299. /** Gets or sets current rotation (in local space) */
  77300. rotation: Vector3;
  77301. /** Gets or sets current rotation quaternion (in local space) */
  77302. rotationQuaternion: Quaternion;
  77303. /** Gets or sets current scaling (in local space) */
  77304. scaling: Vector3;
  77305. /**
  77306. * Gets the animation properties override
  77307. */
  77308. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77309. private _decompose;
  77310. private _compose;
  77311. /**
  77312. * Update the base and local matrices
  77313. * @param matrix defines the new base or local matrix
  77314. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  77315. * @param updateLocalMatrix defines if the local matrix should be updated
  77316. */
  77317. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  77318. /** @hidden */
  77319. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  77320. /**
  77321. * Flag the bone as dirty (Forcing it to update everything)
  77322. */
  77323. markAsDirty(): void;
  77324. /** @hidden */
  77325. _markAsDirtyAndCompose(): void;
  77326. private _markAsDirtyAndDecompose;
  77327. /**
  77328. * Translate the bone in local or world space
  77329. * @param vec The amount to translate the bone
  77330. * @param space The space that the translation is in
  77331. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77332. */
  77333. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  77334. /**
  77335. * Set the postion of the bone in local or world space
  77336. * @param position The position to set the bone
  77337. * @param space The space that the position is in
  77338. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77339. */
  77340. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  77341. /**
  77342. * Set the absolute position of the bone (world space)
  77343. * @param position The position to set the bone
  77344. * @param mesh The mesh that this bone is attached to
  77345. */
  77346. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  77347. /**
  77348. * Scale the bone on the x, y and z axes (in local space)
  77349. * @param x The amount to scale the bone on the x axis
  77350. * @param y The amount to scale the bone on the y axis
  77351. * @param z The amount to scale the bone on the z axis
  77352. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  77353. */
  77354. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  77355. /**
  77356. * Set the bone scaling in local space
  77357. * @param scale defines the scaling vector
  77358. */
  77359. setScale(scale: Vector3): void;
  77360. /**
  77361. * Gets the current scaling in local space
  77362. * @returns the current scaling vector
  77363. */
  77364. getScale(): Vector3;
  77365. /**
  77366. * Gets the current scaling in local space and stores it in a target vector
  77367. * @param result defines the target vector
  77368. */
  77369. getScaleToRef(result: Vector3): void;
  77370. /**
  77371. * Set the yaw, pitch, and roll of the bone in local or world space
  77372. * @param yaw The rotation of the bone on the y axis
  77373. * @param pitch The rotation of the bone on the x axis
  77374. * @param roll The rotation of the bone on the z axis
  77375. * @param space The space that the axes of rotation are in
  77376. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77377. */
  77378. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  77379. /**
  77380. * Add a rotation to the bone on an axis in local or world space
  77381. * @param axis The axis to rotate the bone on
  77382. * @param amount The amount to rotate the bone
  77383. * @param space The space that the axis is in
  77384. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77385. */
  77386. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  77387. /**
  77388. * Set the rotation of the bone to a particular axis angle in local or world space
  77389. * @param axis The axis to rotate the bone on
  77390. * @param angle The angle that the bone should be rotated to
  77391. * @param space The space that the axis is in
  77392. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77393. */
  77394. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  77395. /**
  77396. * Set the euler rotation of the bone in local of world space
  77397. * @param rotation The euler rotation that the bone should be set to
  77398. * @param space The space that the rotation is in
  77399. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77400. */
  77401. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  77402. /**
  77403. * Set the quaternion rotation of the bone in local of world space
  77404. * @param quat The quaternion rotation that the bone should be set to
  77405. * @param space The space that the rotation is in
  77406. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77407. */
  77408. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  77409. /**
  77410. * Set the rotation matrix of the bone in local of world space
  77411. * @param rotMat The rotation matrix that the bone should be set to
  77412. * @param space The space that the rotation is in
  77413. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77414. */
  77415. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  77416. private _rotateWithMatrix;
  77417. private _getNegativeRotationToRef;
  77418. /**
  77419. * Get the position of the bone in local or world space
  77420. * @param space The space that the returned position is in
  77421. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77422. * @returns The position of the bone
  77423. */
  77424. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  77425. /**
  77426. * Copy the position of the bone to a vector3 in local or world space
  77427. * @param space The space that the returned position is in
  77428. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77429. * @param result The vector3 to copy the position to
  77430. */
  77431. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  77432. /**
  77433. * Get the absolute position of the bone (world space)
  77434. * @param mesh The mesh that this bone is attached to
  77435. * @returns The absolute position of the bone
  77436. */
  77437. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  77438. /**
  77439. * Copy the absolute position of the bone (world space) to the result param
  77440. * @param mesh The mesh that this bone is attached to
  77441. * @param result The vector3 to copy the absolute position to
  77442. */
  77443. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  77444. /**
  77445. * Compute the absolute transforms of this bone and its children
  77446. */
  77447. computeAbsoluteTransforms(): void;
  77448. /**
  77449. * Get the world direction from an axis that is in the local space of the bone
  77450. * @param localAxis The local direction that is used to compute the world direction
  77451. * @param mesh The mesh that this bone is attached to
  77452. * @returns The world direction
  77453. */
  77454. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  77455. /**
  77456. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  77457. * @param localAxis The local direction that is used to compute the world direction
  77458. * @param mesh The mesh that this bone is attached to
  77459. * @param result The vector3 that the world direction will be copied to
  77460. */
  77461. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77462. /**
  77463. * Get the euler rotation of the bone in local or world space
  77464. * @param space The space that the rotation should be in
  77465. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77466. * @returns The euler rotation
  77467. */
  77468. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  77469. /**
  77470. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  77471. * @param space The space that the rotation should be in
  77472. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77473. * @param result The vector3 that the rotation should be copied to
  77474. */
  77475. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77476. /**
  77477. * Get the quaternion rotation of the bone in either local or world space
  77478. * @param space The space that the rotation should be in
  77479. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77480. * @returns The quaternion rotation
  77481. */
  77482. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  77483. /**
  77484. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  77485. * @param space The space that the rotation should be in
  77486. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77487. * @param result The quaternion that the rotation should be copied to
  77488. */
  77489. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  77490. /**
  77491. * Get the rotation matrix of the bone in local or world space
  77492. * @param space The space that the rotation should be in
  77493. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77494. * @returns The rotation matrix
  77495. */
  77496. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  77497. /**
  77498. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  77499. * @param space The space that the rotation should be in
  77500. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77501. * @param result The quaternion that the rotation should be copied to
  77502. */
  77503. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  77504. /**
  77505. * Get the world position of a point that is in the local space of the bone
  77506. * @param position The local position
  77507. * @param mesh The mesh that this bone is attached to
  77508. * @returns The world position
  77509. */
  77510. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  77511. /**
  77512. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  77513. * @param position The local position
  77514. * @param mesh The mesh that this bone is attached to
  77515. * @param result The vector3 that the world position should be copied to
  77516. */
  77517. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77518. /**
  77519. * Get the local position of a point that is in world space
  77520. * @param position The world position
  77521. * @param mesh The mesh that this bone is attached to
  77522. * @returns The local position
  77523. */
  77524. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  77525. /**
  77526. * Get the local position of a point that is in world space and copy it to the result param
  77527. * @param position The world position
  77528. * @param mesh The mesh that this bone is attached to
  77529. * @param result The vector3 that the local position should be copied to
  77530. */
  77531. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77532. }
  77533. }
  77534. declare module BABYLON {
  77535. /**
  77536. * 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.
  77537. * @see https://doc.babylonjs.com/how_to/transformnode
  77538. */
  77539. export class TransformNode extends Node {
  77540. /**
  77541. * Object will not rotate to face the camera
  77542. */
  77543. static BILLBOARDMODE_NONE: number;
  77544. /**
  77545. * Object will rotate to face the camera but only on the x axis
  77546. */
  77547. static BILLBOARDMODE_X: number;
  77548. /**
  77549. * Object will rotate to face the camera but only on the y axis
  77550. */
  77551. static BILLBOARDMODE_Y: number;
  77552. /**
  77553. * Object will rotate to face the camera but only on the z axis
  77554. */
  77555. static BILLBOARDMODE_Z: number;
  77556. /**
  77557. * Object will rotate to face the camera
  77558. */
  77559. static BILLBOARDMODE_ALL: number;
  77560. private _forward;
  77561. private _forwardInverted;
  77562. private _up;
  77563. private _right;
  77564. private _rightInverted;
  77565. private _position;
  77566. private _rotation;
  77567. private _rotationQuaternion;
  77568. protected _scaling: Vector3;
  77569. protected _isDirty: boolean;
  77570. private _transformToBoneReferal;
  77571. private _isAbsoluteSynced;
  77572. private _billboardMode;
  77573. /**
  77574. * Gets or sets the billboard mode. Default is 0.
  77575. *
  77576. * | Value | Type | Description |
  77577. * | --- | --- | --- |
  77578. * | 0 | BILLBOARDMODE_NONE | |
  77579. * | 1 | BILLBOARDMODE_X | |
  77580. * | 2 | BILLBOARDMODE_Y | |
  77581. * | 4 | BILLBOARDMODE_Z | |
  77582. * | 7 | BILLBOARDMODE_ALL | |
  77583. *
  77584. */
  77585. billboardMode: number;
  77586. private _preserveParentRotationForBillboard;
  77587. /**
  77588. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  77589. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  77590. */
  77591. preserveParentRotationForBillboard: boolean;
  77592. /**
  77593. * 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
  77594. */
  77595. scalingDeterminant: number;
  77596. private _infiniteDistance;
  77597. /**
  77598. * Gets or sets the distance of the object to max, often used by skybox
  77599. */
  77600. infiniteDistance: boolean;
  77601. /**
  77602. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  77603. * By default the system will update normals to compensate
  77604. */
  77605. ignoreNonUniformScaling: boolean;
  77606. /**
  77607. * 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
  77608. */
  77609. reIntegrateRotationIntoRotationQuaternion: boolean;
  77610. /** @hidden */
  77611. _poseMatrix: Nullable<Matrix>;
  77612. /** @hidden */
  77613. _localMatrix: Matrix;
  77614. private _usePivotMatrix;
  77615. private _absolutePosition;
  77616. private _absoluteScaling;
  77617. private _absoluteRotationQuaternion;
  77618. private _pivotMatrix;
  77619. private _pivotMatrixInverse;
  77620. protected _postMultiplyPivotMatrix: boolean;
  77621. protected _isWorldMatrixFrozen: boolean;
  77622. /** @hidden */
  77623. _indexInSceneTransformNodesArray: number;
  77624. /**
  77625. * An event triggered after the world matrix is updated
  77626. */
  77627. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  77628. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  77629. /**
  77630. * Gets a string identifying the name of the class
  77631. * @returns "TransformNode" string
  77632. */
  77633. getClassName(): string;
  77634. /**
  77635. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  77636. */
  77637. position: Vector3;
  77638. /**
  77639. * 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)).
  77640. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  77641. */
  77642. rotation: Vector3;
  77643. /**
  77644. * 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)).
  77645. */
  77646. scaling: Vector3;
  77647. /**
  77648. * 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).
  77649. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  77650. */
  77651. rotationQuaternion: Nullable<Quaternion>;
  77652. /**
  77653. * The forward direction of that transform in world space.
  77654. */
  77655. readonly forward: Vector3;
  77656. /**
  77657. * The up direction of that transform in world space.
  77658. */
  77659. readonly up: Vector3;
  77660. /**
  77661. * The right direction of that transform in world space.
  77662. */
  77663. readonly right: Vector3;
  77664. /**
  77665. * Copies the parameter passed Matrix into the mesh Pose matrix.
  77666. * @param matrix the matrix to copy the pose from
  77667. * @returns this TransformNode.
  77668. */
  77669. updatePoseMatrix(matrix: Matrix): TransformNode;
  77670. /**
  77671. * Returns the mesh Pose matrix.
  77672. * @returns the pose matrix
  77673. */
  77674. getPoseMatrix(): Matrix;
  77675. /** @hidden */
  77676. _isSynchronized(): boolean;
  77677. /** @hidden */
  77678. _initCache(): void;
  77679. /**
  77680. * Flag the transform node as dirty (Forcing it to update everything)
  77681. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  77682. * @returns this transform node
  77683. */
  77684. markAsDirty(property: string): TransformNode;
  77685. /**
  77686. * Returns the current mesh absolute position.
  77687. * Returns a Vector3.
  77688. */
  77689. readonly absolutePosition: Vector3;
  77690. /**
  77691. * Returns the current mesh absolute scaling.
  77692. * Returns a Vector3.
  77693. */
  77694. readonly absoluteScaling: Vector3;
  77695. /**
  77696. * Returns the current mesh absolute rotation.
  77697. * Returns a Quaternion.
  77698. */
  77699. readonly absoluteRotationQuaternion: Quaternion;
  77700. /**
  77701. * Sets a new matrix to apply before all other transformation
  77702. * @param matrix defines the transform matrix
  77703. * @returns the current TransformNode
  77704. */
  77705. setPreTransformMatrix(matrix: Matrix): TransformNode;
  77706. /**
  77707. * Sets a new pivot matrix to the current node
  77708. * @param matrix defines the new pivot matrix to use
  77709. * @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
  77710. * @returns the current TransformNode
  77711. */
  77712. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  77713. /**
  77714. * Returns the mesh pivot matrix.
  77715. * Default : Identity.
  77716. * @returns the matrix
  77717. */
  77718. getPivotMatrix(): Matrix;
  77719. /**
  77720. * Prevents the World matrix to be computed any longer.
  77721. * @returns the TransformNode.
  77722. */
  77723. freezeWorldMatrix(): TransformNode;
  77724. /**
  77725. * Allows back the World matrix computation.
  77726. * @returns the TransformNode.
  77727. */
  77728. unfreezeWorldMatrix(): this;
  77729. /**
  77730. * True if the World matrix has been frozen.
  77731. */
  77732. readonly isWorldMatrixFrozen: boolean;
  77733. /**
  77734. * Retuns the mesh absolute position in the World.
  77735. * @returns a Vector3.
  77736. */
  77737. getAbsolutePosition(): Vector3;
  77738. /**
  77739. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  77740. * @param absolutePosition the absolute position to set
  77741. * @returns the TransformNode.
  77742. */
  77743. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  77744. /**
  77745. * Sets the mesh position in its local space.
  77746. * @param vector3 the position to set in localspace
  77747. * @returns the TransformNode.
  77748. */
  77749. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  77750. /**
  77751. * Returns the mesh position in the local space from the current World matrix values.
  77752. * @returns a new Vector3.
  77753. */
  77754. getPositionExpressedInLocalSpace(): Vector3;
  77755. /**
  77756. * Translates the mesh along the passed Vector3 in its local space.
  77757. * @param vector3 the distance to translate in localspace
  77758. * @returns the TransformNode.
  77759. */
  77760. locallyTranslate(vector3: Vector3): TransformNode;
  77761. private static _lookAtVectorCache;
  77762. /**
  77763. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  77764. * @param targetPoint the position (must be in same space as current mesh) to look at
  77765. * @param yawCor optional yaw (y-axis) correction in radians
  77766. * @param pitchCor optional pitch (x-axis) correction in radians
  77767. * @param rollCor optional roll (z-axis) correction in radians
  77768. * @param space the choosen space of the target
  77769. * @returns the TransformNode.
  77770. */
  77771. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  77772. /**
  77773. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  77774. * This Vector3 is expressed in the World space.
  77775. * @param localAxis axis to rotate
  77776. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  77777. */
  77778. getDirection(localAxis: Vector3): Vector3;
  77779. /**
  77780. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  77781. * localAxis is expressed in the mesh local space.
  77782. * result is computed in the Wordl space from the mesh World matrix.
  77783. * @param localAxis axis to rotate
  77784. * @param result the resulting transformnode
  77785. * @returns this TransformNode.
  77786. */
  77787. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  77788. /**
  77789. * Sets this transform node rotation to the given local axis.
  77790. * @param localAxis the axis in local space
  77791. * @param yawCor optional yaw (y-axis) correction in radians
  77792. * @param pitchCor optional pitch (x-axis) correction in radians
  77793. * @param rollCor optional roll (z-axis) correction in radians
  77794. * @returns this TransformNode
  77795. */
  77796. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  77797. /**
  77798. * Sets a new pivot point to the current node
  77799. * @param point defines the new pivot point to use
  77800. * @param space defines if the point is in world or local space (local by default)
  77801. * @returns the current TransformNode
  77802. */
  77803. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  77804. /**
  77805. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  77806. * @returns the pivot point
  77807. */
  77808. getPivotPoint(): Vector3;
  77809. /**
  77810. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  77811. * @param result the vector3 to store the result
  77812. * @returns this TransformNode.
  77813. */
  77814. getPivotPointToRef(result: Vector3): TransformNode;
  77815. /**
  77816. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  77817. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  77818. */
  77819. getAbsolutePivotPoint(): Vector3;
  77820. /**
  77821. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  77822. * @param result vector3 to store the result
  77823. * @returns this TransformNode.
  77824. */
  77825. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  77826. /**
  77827. * Defines the passed node as the parent of the current node.
  77828. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  77829. * @see https://doc.babylonjs.com/how_to/parenting
  77830. * @param node the node ot set as the parent
  77831. * @returns this TransformNode.
  77832. */
  77833. setParent(node: Nullable<Node>): TransformNode;
  77834. private _nonUniformScaling;
  77835. /**
  77836. * True if the scaling property of this object is non uniform eg. (1,2,1)
  77837. */
  77838. readonly nonUniformScaling: boolean;
  77839. /** @hidden */
  77840. _updateNonUniformScalingState(value: boolean): boolean;
  77841. /**
  77842. * Attach the current TransformNode to another TransformNode associated with a bone
  77843. * @param bone Bone affecting the TransformNode
  77844. * @param affectedTransformNode TransformNode associated with the bone
  77845. * @returns this object
  77846. */
  77847. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  77848. /**
  77849. * Detach the transform node if its associated with a bone
  77850. * @returns this object
  77851. */
  77852. detachFromBone(): TransformNode;
  77853. private static _rotationAxisCache;
  77854. /**
  77855. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  77856. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  77857. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  77858. * The passed axis is also normalized.
  77859. * @param axis the axis to rotate around
  77860. * @param amount the amount to rotate in radians
  77861. * @param space Space to rotate in (Default: local)
  77862. * @returns the TransformNode.
  77863. */
  77864. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  77865. /**
  77866. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  77867. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  77868. * The passed axis is also normalized. .
  77869. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  77870. * @param point the point to rotate around
  77871. * @param axis the axis to rotate around
  77872. * @param amount the amount to rotate in radians
  77873. * @returns the TransformNode
  77874. */
  77875. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  77876. /**
  77877. * Translates the mesh along the axis vector for the passed distance in the given space.
  77878. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  77879. * @param axis the axis to translate in
  77880. * @param distance the distance to translate
  77881. * @param space Space to rotate in (Default: local)
  77882. * @returns the TransformNode.
  77883. */
  77884. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  77885. /**
  77886. * Adds a rotation step to the mesh current rotation.
  77887. * x, y, z are Euler angles expressed in radians.
  77888. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  77889. * This means this rotation is made in the mesh local space only.
  77890. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  77891. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  77892. * ```javascript
  77893. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  77894. * ```
  77895. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  77896. * 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.
  77897. * @param x Rotation to add
  77898. * @param y Rotation to add
  77899. * @param z Rotation to add
  77900. * @returns the TransformNode.
  77901. */
  77902. addRotation(x: number, y: number, z: number): TransformNode;
  77903. /**
  77904. * @hidden
  77905. */
  77906. protected _getEffectiveParent(): Nullable<Node>;
  77907. /**
  77908. * Computes the world matrix of the node
  77909. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  77910. * @returns the world matrix
  77911. */
  77912. computeWorldMatrix(force?: boolean): Matrix;
  77913. protected _afterComputeWorldMatrix(): void;
  77914. /**
  77915. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  77916. * @param func callback function to add
  77917. *
  77918. * @returns the TransformNode.
  77919. */
  77920. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  77921. /**
  77922. * Removes a registered callback function.
  77923. * @param func callback function to remove
  77924. * @returns the TransformNode.
  77925. */
  77926. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  77927. /**
  77928. * Gets the position of the current mesh in camera space
  77929. * @param camera defines the camera to use
  77930. * @returns a position
  77931. */
  77932. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  77933. /**
  77934. * Returns the distance from the mesh to the active camera
  77935. * @param camera defines the camera to use
  77936. * @returns the distance
  77937. */
  77938. getDistanceToCamera(camera?: Nullable<Camera>): number;
  77939. /**
  77940. * Clone the current transform node
  77941. * @param name Name of the new clone
  77942. * @param newParent New parent for the clone
  77943. * @param doNotCloneChildren Do not clone children hierarchy
  77944. * @returns the new transform node
  77945. */
  77946. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  77947. /**
  77948. * Serializes the objects information.
  77949. * @param currentSerializationObject defines the object to serialize in
  77950. * @returns the serialized object
  77951. */
  77952. serialize(currentSerializationObject?: any): any;
  77953. /**
  77954. * Returns a new TransformNode object parsed from the source provided.
  77955. * @param parsedTransformNode is the source.
  77956. * @param scene the scne the object belongs to
  77957. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  77958. * @returns a new TransformNode object parsed from the source provided.
  77959. */
  77960. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  77961. /**
  77962. * Get all child-transformNodes of this node
  77963. * @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
  77964. * @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
  77965. * @returns an array of TransformNode
  77966. */
  77967. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  77968. /**
  77969. * Releases resources associated with this transform node.
  77970. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77971. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77972. */
  77973. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77974. /**
  77975. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  77976. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  77977. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  77978. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  77979. * @returns the current mesh
  77980. */
  77981. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  77982. private _syncAbsoluteScalingAndRotation;
  77983. }
  77984. }
  77985. declare module BABYLON {
  77986. /**
  77987. * Defines the types of pose enabled controllers that are supported
  77988. */
  77989. export enum PoseEnabledControllerType {
  77990. /**
  77991. * HTC Vive
  77992. */
  77993. VIVE = 0,
  77994. /**
  77995. * Oculus Rift
  77996. */
  77997. OCULUS = 1,
  77998. /**
  77999. * Windows mixed reality
  78000. */
  78001. WINDOWS = 2,
  78002. /**
  78003. * Samsung gear VR
  78004. */
  78005. GEAR_VR = 3,
  78006. /**
  78007. * Google Daydream
  78008. */
  78009. DAYDREAM = 4,
  78010. /**
  78011. * Generic
  78012. */
  78013. GENERIC = 5
  78014. }
  78015. /**
  78016. * Defines the MutableGamepadButton interface for the state of a gamepad button
  78017. */
  78018. export interface MutableGamepadButton {
  78019. /**
  78020. * Value of the button/trigger
  78021. */
  78022. value: number;
  78023. /**
  78024. * If the button/trigger is currently touched
  78025. */
  78026. touched: boolean;
  78027. /**
  78028. * If the button/trigger is currently pressed
  78029. */
  78030. pressed: boolean;
  78031. }
  78032. /**
  78033. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  78034. * @hidden
  78035. */
  78036. export interface ExtendedGamepadButton extends GamepadButton {
  78037. /**
  78038. * If the button/trigger is currently pressed
  78039. */
  78040. readonly pressed: boolean;
  78041. /**
  78042. * If the button/trigger is currently touched
  78043. */
  78044. readonly touched: boolean;
  78045. /**
  78046. * Value of the button/trigger
  78047. */
  78048. readonly value: number;
  78049. }
  78050. /** @hidden */
  78051. export interface _GamePadFactory {
  78052. /**
  78053. * Returns wether or not the current gamepad can be created for this type of controller.
  78054. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  78055. * @returns true if it can be created, otherwise false
  78056. */
  78057. canCreate(gamepadInfo: any): boolean;
  78058. /**
  78059. * Creates a new instance of the Gamepad.
  78060. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  78061. * @returns the new gamepad instance
  78062. */
  78063. create(gamepadInfo: any): Gamepad;
  78064. }
  78065. /**
  78066. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  78067. */
  78068. export class PoseEnabledControllerHelper {
  78069. /** @hidden */
  78070. static _ControllerFactories: _GamePadFactory[];
  78071. /** @hidden */
  78072. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  78073. /**
  78074. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  78075. * @param vrGamepad the gamepad to initialized
  78076. * @returns a vr controller of the type the gamepad identified as
  78077. */
  78078. static InitiateController(vrGamepad: any): Gamepad;
  78079. }
  78080. /**
  78081. * Defines the PoseEnabledController object that contains state of a vr capable controller
  78082. */
  78083. export class PoseEnabledController extends Gamepad implements PoseControlled {
  78084. /**
  78085. * If the controller is used in a webXR session
  78086. */
  78087. isXR: boolean;
  78088. private _deviceRoomPosition;
  78089. private _deviceRoomRotationQuaternion;
  78090. /**
  78091. * The device position in babylon space
  78092. */
  78093. devicePosition: Vector3;
  78094. /**
  78095. * The device rotation in babylon space
  78096. */
  78097. deviceRotationQuaternion: Quaternion;
  78098. /**
  78099. * The scale factor of the device in babylon space
  78100. */
  78101. deviceScaleFactor: number;
  78102. /**
  78103. * (Likely devicePosition should be used instead) The device position in its room space
  78104. */
  78105. position: Vector3;
  78106. /**
  78107. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  78108. */
  78109. rotationQuaternion: Quaternion;
  78110. /**
  78111. * The type of controller (Eg. Windows mixed reality)
  78112. */
  78113. controllerType: PoseEnabledControllerType;
  78114. protected _calculatedPosition: Vector3;
  78115. private _calculatedRotation;
  78116. /**
  78117. * The raw pose from the device
  78118. */
  78119. rawPose: DevicePose;
  78120. private _trackPosition;
  78121. private _maxRotationDistFromHeadset;
  78122. private _draggedRoomRotation;
  78123. /**
  78124. * @hidden
  78125. */
  78126. _disableTrackPosition(fixedPosition: Vector3): void;
  78127. /**
  78128. * Internal, the mesh attached to the controller
  78129. * @hidden
  78130. */
  78131. _mesh: Nullable<AbstractMesh>;
  78132. private _poseControlledCamera;
  78133. private _leftHandSystemQuaternion;
  78134. /**
  78135. * Internal, matrix used to convert room space to babylon space
  78136. * @hidden
  78137. */
  78138. _deviceToWorld: Matrix;
  78139. /**
  78140. * Node to be used when casting a ray from the controller
  78141. * @hidden
  78142. */
  78143. _pointingPoseNode: Nullable<TransformNode>;
  78144. /**
  78145. * Name of the child mesh that can be used to cast a ray from the controller
  78146. */
  78147. static readonly POINTING_POSE: string;
  78148. /**
  78149. * Creates a new PoseEnabledController from a gamepad
  78150. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  78151. */
  78152. constructor(browserGamepad: any);
  78153. private _workingMatrix;
  78154. /**
  78155. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  78156. */
  78157. update(): void;
  78158. /**
  78159. * Updates only the pose device and mesh without doing any button event checking
  78160. */
  78161. protected _updatePoseAndMesh(): void;
  78162. /**
  78163. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  78164. * @param poseData raw pose fromthe device
  78165. */
  78166. updateFromDevice(poseData: DevicePose): void;
  78167. /**
  78168. * @hidden
  78169. */
  78170. _meshAttachedObservable: Observable<AbstractMesh>;
  78171. /**
  78172. * Attaches a mesh to the controller
  78173. * @param mesh the mesh to be attached
  78174. */
  78175. attachToMesh(mesh: AbstractMesh): void;
  78176. /**
  78177. * Attaches the controllers mesh to a camera
  78178. * @param camera the camera the mesh should be attached to
  78179. */
  78180. attachToPoseControlledCamera(camera: TargetCamera): void;
  78181. /**
  78182. * Disposes of the controller
  78183. */
  78184. dispose(): void;
  78185. /**
  78186. * The mesh that is attached to the controller
  78187. */
  78188. readonly mesh: Nullable<AbstractMesh>;
  78189. /**
  78190. * Gets the ray of the controller in the direction the controller is pointing
  78191. * @param length the length the resulting ray should be
  78192. * @returns a ray in the direction the controller is pointing
  78193. */
  78194. getForwardRay(length?: number): Ray;
  78195. }
  78196. }
  78197. declare module BABYLON {
  78198. /**
  78199. * Defines the WebVRController object that represents controllers tracked in 3D space
  78200. */
  78201. export abstract class WebVRController extends PoseEnabledController {
  78202. /**
  78203. * Internal, the default controller model for the controller
  78204. */
  78205. protected _defaultModel: AbstractMesh;
  78206. /**
  78207. * Fired when the trigger state has changed
  78208. */
  78209. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  78210. /**
  78211. * Fired when the main button state has changed
  78212. */
  78213. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  78214. /**
  78215. * Fired when the secondary button state has changed
  78216. */
  78217. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  78218. /**
  78219. * Fired when the pad state has changed
  78220. */
  78221. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  78222. /**
  78223. * Fired when controllers stick values have changed
  78224. */
  78225. onPadValuesChangedObservable: Observable<StickValues>;
  78226. /**
  78227. * Array of button availible on the controller
  78228. */
  78229. protected _buttons: Array<MutableGamepadButton>;
  78230. private _onButtonStateChange;
  78231. /**
  78232. * Fired when a controller button's state has changed
  78233. * @param callback the callback containing the button that was modified
  78234. */
  78235. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  78236. /**
  78237. * X and Y axis corresponding to the controllers joystick
  78238. */
  78239. pad: StickValues;
  78240. /**
  78241. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  78242. */
  78243. hand: string;
  78244. /**
  78245. * The default controller model for the controller
  78246. */
  78247. readonly defaultModel: AbstractMesh;
  78248. /**
  78249. * Creates a new WebVRController from a gamepad
  78250. * @param vrGamepad the gamepad that the WebVRController should be created from
  78251. */
  78252. constructor(vrGamepad: any);
  78253. /**
  78254. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  78255. */
  78256. update(): void;
  78257. /**
  78258. * Function to be called when a button is modified
  78259. */
  78260. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  78261. /**
  78262. * Loads a mesh and attaches it to the controller
  78263. * @param scene the scene the mesh should be added to
  78264. * @param meshLoaded callback for when the mesh has been loaded
  78265. */
  78266. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  78267. private _setButtonValue;
  78268. private _changes;
  78269. private _checkChanges;
  78270. /**
  78271. * Disposes of th webVRCOntroller
  78272. */
  78273. dispose(): void;
  78274. }
  78275. }
  78276. declare module BABYLON {
  78277. /**
  78278. * The HemisphericLight simulates the ambient environment light,
  78279. * so the passed direction is the light reflection direction, not the incoming direction.
  78280. */
  78281. export class HemisphericLight extends Light {
  78282. /**
  78283. * The groundColor is the light in the opposite direction to the one specified during creation.
  78284. * 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.
  78285. */
  78286. groundColor: Color3;
  78287. /**
  78288. * The light reflection direction, not the incoming direction.
  78289. */
  78290. direction: Vector3;
  78291. /**
  78292. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  78293. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  78294. * The HemisphericLight can't cast shadows.
  78295. * Documentation : https://doc.babylonjs.com/babylon101/lights
  78296. * @param name The friendly name of the light
  78297. * @param direction The direction of the light reflection
  78298. * @param scene The scene the light belongs to
  78299. */
  78300. constructor(name: string, direction: Vector3, scene: Scene);
  78301. protected _buildUniformLayout(): void;
  78302. /**
  78303. * Returns the string "HemisphericLight".
  78304. * @return The class name
  78305. */
  78306. getClassName(): string;
  78307. /**
  78308. * Sets the HemisphericLight direction towards the passed target (Vector3).
  78309. * Returns the updated direction.
  78310. * @param target The target the direction should point to
  78311. * @return The computed direction
  78312. */
  78313. setDirectionToTarget(target: Vector3): Vector3;
  78314. /**
  78315. * Returns the shadow generator associated to the light.
  78316. * @returns Always null for hemispheric lights because it does not support shadows.
  78317. */
  78318. getShadowGenerator(): Nullable<IShadowGenerator>;
  78319. /**
  78320. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  78321. * @param effect The effect to update
  78322. * @param lightIndex The index of the light in the effect to update
  78323. * @returns The hemispheric light
  78324. */
  78325. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  78326. /**
  78327. * Computes the world matrix of the node
  78328. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  78329. * @param useWasUpdatedFlag defines a reserved property
  78330. * @returns the world matrix
  78331. */
  78332. computeWorldMatrix(): Matrix;
  78333. /**
  78334. * Returns the integer 3.
  78335. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  78336. */
  78337. getTypeID(): number;
  78338. /**
  78339. * Prepares the list of defines specific to the light type.
  78340. * @param defines the list of defines
  78341. * @param lightIndex defines the index of the light for the effect
  78342. */
  78343. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  78344. }
  78345. }
  78346. declare module BABYLON {
  78347. /** @hidden */
  78348. export var vrMultiviewToSingleviewPixelShader: {
  78349. name: string;
  78350. shader: string;
  78351. };
  78352. }
  78353. declare module BABYLON {
  78354. /**
  78355. * Renders to multiple views with a single draw call
  78356. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  78357. */
  78358. export class MultiviewRenderTarget extends RenderTargetTexture {
  78359. /**
  78360. * Creates a multiview render target
  78361. * @param scene scene used with the render target
  78362. * @param size the size of the render target (used for each view)
  78363. */
  78364. constructor(scene: Scene, size?: number | {
  78365. width: number;
  78366. height: number;
  78367. } | {
  78368. ratio: number;
  78369. });
  78370. /**
  78371. * @hidden
  78372. * @param faceIndex the face index, if its a cube texture
  78373. */
  78374. _bindFrameBuffer(faceIndex?: number): void;
  78375. /**
  78376. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  78377. * @returns the view count
  78378. */
  78379. getViewCount(): number;
  78380. }
  78381. }
  78382. declare module BABYLON {
  78383. /**
  78384. * Reprasents a camera frustum
  78385. */
  78386. export class Frustum {
  78387. /**
  78388. * Gets the planes representing the frustum
  78389. * @param transform matrix to be applied to the returned planes
  78390. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  78391. */
  78392. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  78393. /**
  78394. * Gets the near frustum plane transformed by the transform matrix
  78395. * @param transform transformation matrix to be applied to the resulting frustum plane
  78396. * @param frustumPlane the resuling frustum plane
  78397. */
  78398. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78399. /**
  78400. * Gets the far frustum plane transformed by the transform matrix
  78401. * @param transform transformation matrix to be applied to the resulting frustum plane
  78402. * @param frustumPlane the resuling frustum plane
  78403. */
  78404. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78405. /**
  78406. * Gets the left frustum plane transformed by the transform matrix
  78407. * @param transform transformation matrix to be applied to the resulting frustum plane
  78408. * @param frustumPlane the resuling frustum plane
  78409. */
  78410. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78411. /**
  78412. * Gets the right frustum plane transformed by the transform matrix
  78413. * @param transform transformation matrix to be applied to the resulting frustum plane
  78414. * @param frustumPlane the resuling frustum plane
  78415. */
  78416. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78417. /**
  78418. * Gets the top frustum plane transformed by the transform matrix
  78419. * @param transform transformation matrix to be applied to the resulting frustum plane
  78420. * @param frustumPlane the resuling frustum plane
  78421. */
  78422. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78423. /**
  78424. * Gets the bottom frustum plane transformed by the transform matrix
  78425. * @param transform transformation matrix to be applied to the resulting frustum plane
  78426. * @param frustumPlane the resuling frustum plane
  78427. */
  78428. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78429. /**
  78430. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  78431. * @param transform transformation matrix to be applied to the resulting frustum planes
  78432. * @param frustumPlanes the resuling frustum planes
  78433. */
  78434. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  78435. }
  78436. }
  78437. declare module BABYLON {
  78438. interface Engine {
  78439. /**
  78440. * Creates a new multiview render target
  78441. * @param width defines the width of the texture
  78442. * @param height defines the height of the texture
  78443. * @returns the created multiview texture
  78444. */
  78445. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  78446. /**
  78447. * Binds a multiview framebuffer to be drawn to
  78448. * @param multiviewTexture texture to bind
  78449. */
  78450. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  78451. }
  78452. interface Camera {
  78453. /**
  78454. * @hidden
  78455. * 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)
  78456. */
  78457. _useMultiviewToSingleView: boolean;
  78458. /**
  78459. * @hidden
  78460. * 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)
  78461. */
  78462. _multiviewTexture: Nullable<RenderTargetTexture>;
  78463. /**
  78464. * @hidden
  78465. * ensures the multiview texture of the camera exists and has the specified width/height
  78466. * @param width height to set on the multiview texture
  78467. * @param height width to set on the multiview texture
  78468. */
  78469. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  78470. }
  78471. interface Scene {
  78472. /** @hidden */
  78473. _transformMatrixR: Matrix;
  78474. /** @hidden */
  78475. _multiviewSceneUbo: Nullable<UniformBuffer>;
  78476. /** @hidden */
  78477. _createMultiviewUbo(): void;
  78478. /** @hidden */
  78479. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  78480. /** @hidden */
  78481. _renderMultiviewToSingleView(camera: Camera): void;
  78482. }
  78483. }
  78484. declare module BABYLON {
  78485. /**
  78486. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  78487. * This will not be used for webXR as it supports displaying texture arrays directly
  78488. */
  78489. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  78490. /**
  78491. * Initializes a VRMultiviewToSingleview
  78492. * @param name name of the post process
  78493. * @param camera camera to be applied to
  78494. * @param scaleFactor scaling factor to the size of the output texture
  78495. */
  78496. constructor(name: string, camera: Camera, scaleFactor: number);
  78497. }
  78498. }
  78499. declare module BABYLON {
  78500. interface Engine {
  78501. /** @hidden */
  78502. _vrDisplay: any;
  78503. /** @hidden */
  78504. _vrSupported: boolean;
  78505. /** @hidden */
  78506. _oldSize: Size;
  78507. /** @hidden */
  78508. _oldHardwareScaleFactor: number;
  78509. /** @hidden */
  78510. _vrExclusivePointerMode: boolean;
  78511. /** @hidden */
  78512. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  78513. /** @hidden */
  78514. _onVRDisplayPointerRestricted: () => void;
  78515. /** @hidden */
  78516. _onVRDisplayPointerUnrestricted: () => void;
  78517. /** @hidden */
  78518. _onVrDisplayConnect: Nullable<(display: any) => void>;
  78519. /** @hidden */
  78520. _onVrDisplayDisconnect: Nullable<() => void>;
  78521. /** @hidden */
  78522. _onVrDisplayPresentChange: Nullable<() => void>;
  78523. /**
  78524. * Observable signaled when VR display mode changes
  78525. */
  78526. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  78527. /**
  78528. * Observable signaled when VR request present is complete
  78529. */
  78530. onVRRequestPresentComplete: Observable<boolean>;
  78531. /**
  78532. * Observable signaled when VR request present starts
  78533. */
  78534. onVRRequestPresentStart: Observable<Engine>;
  78535. /**
  78536. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  78537. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  78538. */
  78539. isInVRExclusivePointerMode: boolean;
  78540. /**
  78541. * Gets a boolean indicating if a webVR device was detected
  78542. * @returns true if a webVR device was detected
  78543. */
  78544. isVRDevicePresent(): boolean;
  78545. /**
  78546. * Gets the current webVR device
  78547. * @returns the current webVR device (or null)
  78548. */
  78549. getVRDevice(): any;
  78550. /**
  78551. * Initializes a webVR display and starts listening to display change events
  78552. * The onVRDisplayChangedObservable will be notified upon these changes
  78553. * @returns A promise containing a VRDisplay and if vr is supported
  78554. */
  78555. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  78556. /** @hidden */
  78557. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  78558. /**
  78559. * Call this function to switch to webVR mode
  78560. * Will do nothing if webVR is not supported or if there is no webVR device
  78561. * @see http://doc.babylonjs.com/how_to/webvr_camera
  78562. */
  78563. enableVR(): void;
  78564. /** @hidden */
  78565. _onVRFullScreenTriggered(): void;
  78566. }
  78567. }
  78568. declare module BABYLON {
  78569. /**
  78570. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  78571. * IMPORTANT!! The data is right-hand data.
  78572. * @export
  78573. * @interface DevicePose
  78574. */
  78575. export interface DevicePose {
  78576. /**
  78577. * The position of the device, values in array are [x,y,z].
  78578. */
  78579. readonly position: Nullable<Float32Array>;
  78580. /**
  78581. * The linearVelocity of the device, values in array are [x,y,z].
  78582. */
  78583. readonly linearVelocity: Nullable<Float32Array>;
  78584. /**
  78585. * The linearAcceleration of the device, values in array are [x,y,z].
  78586. */
  78587. readonly linearAcceleration: Nullable<Float32Array>;
  78588. /**
  78589. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  78590. */
  78591. readonly orientation: Nullable<Float32Array>;
  78592. /**
  78593. * The angularVelocity of the device, values in array are [x,y,z].
  78594. */
  78595. readonly angularVelocity: Nullable<Float32Array>;
  78596. /**
  78597. * The angularAcceleration of the device, values in array are [x,y,z].
  78598. */
  78599. readonly angularAcceleration: Nullable<Float32Array>;
  78600. }
  78601. /**
  78602. * Interface representing a pose controlled object in Babylon.
  78603. * A pose controlled object has both regular pose values as well as pose values
  78604. * from an external device such as a VR head mounted display
  78605. */
  78606. export interface PoseControlled {
  78607. /**
  78608. * The position of the object in babylon space.
  78609. */
  78610. position: Vector3;
  78611. /**
  78612. * The rotation quaternion of the object in babylon space.
  78613. */
  78614. rotationQuaternion: Quaternion;
  78615. /**
  78616. * The position of the device in babylon space.
  78617. */
  78618. devicePosition?: Vector3;
  78619. /**
  78620. * The rotation quaternion of the device in babylon space.
  78621. */
  78622. deviceRotationQuaternion: Quaternion;
  78623. /**
  78624. * The raw pose coming from the device.
  78625. */
  78626. rawPose: Nullable<DevicePose>;
  78627. /**
  78628. * The scale of the device to be used when translating from device space to babylon space.
  78629. */
  78630. deviceScaleFactor: number;
  78631. /**
  78632. * Updates the poseControlled values based on the input device pose.
  78633. * @param poseData the pose data to update the object with
  78634. */
  78635. updateFromDevice(poseData: DevicePose): void;
  78636. }
  78637. /**
  78638. * Set of options to customize the webVRCamera
  78639. */
  78640. export interface WebVROptions {
  78641. /**
  78642. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  78643. */
  78644. trackPosition?: boolean;
  78645. /**
  78646. * Sets the scale of the vrDevice in babylon space. (default: 1)
  78647. */
  78648. positionScale?: number;
  78649. /**
  78650. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  78651. */
  78652. displayName?: string;
  78653. /**
  78654. * Should the native controller meshes be initialized. (default: true)
  78655. */
  78656. controllerMeshes?: boolean;
  78657. /**
  78658. * Creating a default HemiLight only on controllers. (default: true)
  78659. */
  78660. defaultLightingOnControllers?: boolean;
  78661. /**
  78662. * If you don't want to use the default VR button of the helper. (default: false)
  78663. */
  78664. useCustomVRButton?: boolean;
  78665. /**
  78666. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  78667. */
  78668. customVRButton?: HTMLButtonElement;
  78669. /**
  78670. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  78671. */
  78672. rayLength?: number;
  78673. /**
  78674. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  78675. */
  78676. defaultHeight?: number;
  78677. /**
  78678. * If multiview should be used if availible (default: false)
  78679. */
  78680. useMultiview?: boolean;
  78681. }
  78682. /**
  78683. * This represents a WebVR camera.
  78684. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  78685. * @example http://doc.babylonjs.com/how_to/webvr_camera
  78686. */
  78687. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  78688. private webVROptions;
  78689. /**
  78690. * @hidden
  78691. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  78692. */
  78693. _vrDevice: any;
  78694. /**
  78695. * The rawPose of the vrDevice.
  78696. */
  78697. rawPose: Nullable<DevicePose>;
  78698. private _onVREnabled;
  78699. private _specsVersion;
  78700. private _attached;
  78701. private _frameData;
  78702. protected _descendants: Array<Node>;
  78703. private _deviceRoomPosition;
  78704. /** @hidden */
  78705. _deviceRoomRotationQuaternion: Quaternion;
  78706. private _standingMatrix;
  78707. /**
  78708. * Represents device position in babylon space.
  78709. */
  78710. devicePosition: Vector3;
  78711. /**
  78712. * Represents device rotation in babylon space.
  78713. */
  78714. deviceRotationQuaternion: Quaternion;
  78715. /**
  78716. * The scale of the device to be used when translating from device space to babylon space.
  78717. */
  78718. deviceScaleFactor: number;
  78719. private _deviceToWorld;
  78720. private _worldToDevice;
  78721. /**
  78722. * References to the webVR controllers for the vrDevice.
  78723. */
  78724. controllers: Array<WebVRController>;
  78725. /**
  78726. * Emits an event when a controller is attached.
  78727. */
  78728. onControllersAttachedObservable: Observable<WebVRController[]>;
  78729. /**
  78730. * Emits an event when a controller's mesh has been loaded;
  78731. */
  78732. onControllerMeshLoadedObservable: Observable<WebVRController>;
  78733. /**
  78734. * Emits an event when the HMD's pose has been updated.
  78735. */
  78736. onPoseUpdatedFromDeviceObservable: Observable<any>;
  78737. private _poseSet;
  78738. /**
  78739. * If the rig cameras be used as parent instead of this camera.
  78740. */
  78741. rigParenting: boolean;
  78742. private _lightOnControllers;
  78743. private _defaultHeight?;
  78744. /**
  78745. * Instantiates a WebVRFreeCamera.
  78746. * @param name The name of the WebVRFreeCamera
  78747. * @param position The starting anchor position for the camera
  78748. * @param scene The scene the camera belongs to
  78749. * @param webVROptions a set of customizable options for the webVRCamera
  78750. */
  78751. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  78752. /**
  78753. * Gets the device distance from the ground in meters.
  78754. * @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.
  78755. */
  78756. deviceDistanceToRoomGround(): number;
  78757. /**
  78758. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  78759. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  78760. */
  78761. useStandingMatrix(callback?: (bool: boolean) => void): void;
  78762. /**
  78763. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  78764. * @returns A promise with a boolean set to if the standing matrix is supported.
  78765. */
  78766. useStandingMatrixAsync(): Promise<boolean>;
  78767. /**
  78768. * Disposes the camera
  78769. */
  78770. dispose(): void;
  78771. /**
  78772. * Gets a vrController by name.
  78773. * @param name The name of the controller to retreive
  78774. * @returns the controller matching the name specified or null if not found
  78775. */
  78776. getControllerByName(name: string): Nullable<WebVRController>;
  78777. private _leftController;
  78778. /**
  78779. * The controller corresponding to the users left hand.
  78780. */
  78781. readonly leftController: Nullable<WebVRController>;
  78782. private _rightController;
  78783. /**
  78784. * The controller corresponding to the users right hand.
  78785. */
  78786. readonly rightController: Nullable<WebVRController>;
  78787. /**
  78788. * Casts a ray forward from the vrCamera's gaze.
  78789. * @param length Length of the ray (default: 100)
  78790. * @returns the ray corresponding to the gaze
  78791. */
  78792. getForwardRay(length?: number): Ray;
  78793. /**
  78794. * @hidden
  78795. * Updates the camera based on device's frame data
  78796. */
  78797. _checkInputs(): void;
  78798. /**
  78799. * Updates the poseControlled values based on the input device pose.
  78800. * @param poseData Pose coming from the device
  78801. */
  78802. updateFromDevice(poseData: DevicePose): void;
  78803. private _htmlElementAttached;
  78804. private _detachIfAttached;
  78805. /**
  78806. * WebVR's attach control will start broadcasting frames to the device.
  78807. * Note that in certain browsers (chrome for example) this function must be called
  78808. * within a user-interaction callback. Example:
  78809. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  78810. *
  78811. * @param element html element to attach the vrDevice to
  78812. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  78813. */
  78814. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78815. /**
  78816. * Detaches the camera from the html element and disables VR
  78817. *
  78818. * @param element html element to detach from
  78819. */
  78820. detachControl(element: HTMLElement): void;
  78821. /**
  78822. * @returns the name of this class
  78823. */
  78824. getClassName(): string;
  78825. /**
  78826. * Calls resetPose on the vrDisplay
  78827. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  78828. */
  78829. resetToCurrentRotation(): void;
  78830. /**
  78831. * @hidden
  78832. * Updates the rig cameras (left and right eye)
  78833. */
  78834. _updateRigCameras(): void;
  78835. private _workingVector;
  78836. private _oneVector;
  78837. private _workingMatrix;
  78838. private updateCacheCalled;
  78839. private _correctPositionIfNotTrackPosition;
  78840. /**
  78841. * @hidden
  78842. * Updates the cached values of the camera
  78843. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  78844. */
  78845. _updateCache(ignoreParentClass?: boolean): void;
  78846. /**
  78847. * @hidden
  78848. * Get current device position in babylon world
  78849. */
  78850. _computeDevicePosition(): void;
  78851. /**
  78852. * Updates the current device position and rotation in the babylon world
  78853. */
  78854. update(): void;
  78855. /**
  78856. * @hidden
  78857. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  78858. * @returns an identity matrix
  78859. */
  78860. _getViewMatrix(): Matrix;
  78861. private _tmpMatrix;
  78862. /**
  78863. * This function is called by the two RIG cameras.
  78864. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  78865. * @hidden
  78866. */
  78867. _getWebVRViewMatrix(): Matrix;
  78868. /** @hidden */
  78869. _getWebVRProjectionMatrix(): Matrix;
  78870. private _onGamepadConnectedObserver;
  78871. private _onGamepadDisconnectedObserver;
  78872. private _updateCacheWhenTrackingDisabledObserver;
  78873. /**
  78874. * Initializes the controllers and their meshes
  78875. */
  78876. initControllers(): void;
  78877. }
  78878. }
  78879. declare module BABYLON {
  78880. /**
  78881. * Size options for a post process
  78882. */
  78883. export type PostProcessOptions = {
  78884. width: number;
  78885. height: number;
  78886. };
  78887. /**
  78888. * PostProcess can be used to apply a shader to a texture after it has been rendered
  78889. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  78890. */
  78891. export class PostProcess {
  78892. /** Name of the PostProcess. */
  78893. name: string;
  78894. /**
  78895. * Gets or sets the unique id of the post process
  78896. */
  78897. uniqueId: number;
  78898. /**
  78899. * Width of the texture to apply the post process on
  78900. */
  78901. width: number;
  78902. /**
  78903. * Height of the texture to apply the post process on
  78904. */
  78905. height: number;
  78906. /**
  78907. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  78908. * @hidden
  78909. */
  78910. _outputTexture: Nullable<InternalTexture>;
  78911. /**
  78912. * Sampling mode used by the shader
  78913. * See https://doc.babylonjs.com/classes/3.1/texture
  78914. */
  78915. renderTargetSamplingMode: number;
  78916. /**
  78917. * Clear color to use when screen clearing
  78918. */
  78919. clearColor: Color4;
  78920. /**
  78921. * If the buffer needs to be cleared before applying the post process. (default: true)
  78922. * Should be set to false if shader will overwrite all previous pixels.
  78923. */
  78924. autoClear: boolean;
  78925. /**
  78926. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  78927. */
  78928. alphaMode: number;
  78929. /**
  78930. * Sets the setAlphaBlendConstants of the babylon engine
  78931. */
  78932. alphaConstants: Color4;
  78933. /**
  78934. * Animations to be used for the post processing
  78935. */
  78936. animations: Animation[];
  78937. /**
  78938. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  78939. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  78940. */
  78941. enablePixelPerfectMode: boolean;
  78942. /**
  78943. * Force the postprocess to be applied without taking in account viewport
  78944. */
  78945. forceFullscreenViewport: boolean;
  78946. /**
  78947. * List of inspectable custom properties (used by the Inspector)
  78948. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78949. */
  78950. inspectableCustomProperties: IInspectable[];
  78951. /**
  78952. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  78953. *
  78954. * | Value | Type | Description |
  78955. * | ----- | ----------------------------------- | ----------- |
  78956. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  78957. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  78958. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  78959. *
  78960. */
  78961. scaleMode: number;
  78962. /**
  78963. * Force textures to be a power of two (default: false)
  78964. */
  78965. alwaysForcePOT: boolean;
  78966. private _samples;
  78967. /**
  78968. * Number of sample textures (default: 1)
  78969. */
  78970. samples: number;
  78971. /**
  78972. * Modify the scale of the post process to be the same as the viewport (default: false)
  78973. */
  78974. adaptScaleToCurrentViewport: boolean;
  78975. private _camera;
  78976. private _scene;
  78977. private _engine;
  78978. private _options;
  78979. private _reusable;
  78980. private _textureType;
  78981. /**
  78982. * Smart array of input and output textures for the post process.
  78983. * @hidden
  78984. */
  78985. _textures: SmartArray<InternalTexture>;
  78986. /**
  78987. * The index in _textures that corresponds to the output texture.
  78988. * @hidden
  78989. */
  78990. _currentRenderTextureInd: number;
  78991. private _effect;
  78992. private _samplers;
  78993. private _fragmentUrl;
  78994. private _vertexUrl;
  78995. private _parameters;
  78996. private _scaleRatio;
  78997. protected _indexParameters: any;
  78998. private _shareOutputWithPostProcess;
  78999. private _texelSize;
  79000. private _forcedOutputTexture;
  79001. /**
  79002. * Returns the fragment url or shader name used in the post process.
  79003. * @returns the fragment url or name in the shader store.
  79004. */
  79005. getEffectName(): string;
  79006. /**
  79007. * An event triggered when the postprocess is activated.
  79008. */
  79009. onActivateObservable: Observable<Camera>;
  79010. private _onActivateObserver;
  79011. /**
  79012. * A function that is added to the onActivateObservable
  79013. */
  79014. onActivate: Nullable<(camera: Camera) => void>;
  79015. /**
  79016. * An event triggered when the postprocess changes its size.
  79017. */
  79018. onSizeChangedObservable: Observable<PostProcess>;
  79019. private _onSizeChangedObserver;
  79020. /**
  79021. * A function that is added to the onSizeChangedObservable
  79022. */
  79023. onSizeChanged: (postProcess: PostProcess) => void;
  79024. /**
  79025. * An event triggered when the postprocess applies its effect.
  79026. */
  79027. onApplyObservable: Observable<Effect>;
  79028. private _onApplyObserver;
  79029. /**
  79030. * A function that is added to the onApplyObservable
  79031. */
  79032. onApply: (effect: Effect) => void;
  79033. /**
  79034. * An event triggered before rendering the postprocess
  79035. */
  79036. onBeforeRenderObservable: Observable<Effect>;
  79037. private _onBeforeRenderObserver;
  79038. /**
  79039. * A function that is added to the onBeforeRenderObservable
  79040. */
  79041. onBeforeRender: (effect: Effect) => void;
  79042. /**
  79043. * An event triggered after rendering the postprocess
  79044. */
  79045. onAfterRenderObservable: Observable<Effect>;
  79046. private _onAfterRenderObserver;
  79047. /**
  79048. * A function that is added to the onAfterRenderObservable
  79049. */
  79050. onAfterRender: (efect: Effect) => void;
  79051. /**
  79052. * 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
  79053. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  79054. */
  79055. inputTexture: InternalTexture;
  79056. /**
  79057. * Gets the camera which post process is applied to.
  79058. * @returns The camera the post process is applied to.
  79059. */
  79060. getCamera(): Camera;
  79061. /**
  79062. * Gets the texel size of the postprocess.
  79063. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  79064. */
  79065. readonly texelSize: Vector2;
  79066. /**
  79067. * Creates a new instance PostProcess
  79068. * @param name The name of the PostProcess.
  79069. * @param fragmentUrl The url of the fragment shader to be used.
  79070. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  79071. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  79072. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  79073. * @param camera The camera to apply the render pass to.
  79074. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  79075. * @param engine The engine which the post process will be applied. (default: current engine)
  79076. * @param reusable If the post process can be reused on the same frame. (default: false)
  79077. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  79078. * @param textureType Type of textures used when performing the post process. (default: 0)
  79079. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  79080. * @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
  79081. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  79082. */
  79083. constructor(
  79084. /** Name of the PostProcess. */
  79085. 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);
  79086. /**
  79087. * Gets a string idenfifying the name of the class
  79088. * @returns "PostProcess" string
  79089. */
  79090. getClassName(): string;
  79091. /**
  79092. * Gets the engine which this post process belongs to.
  79093. * @returns The engine the post process was enabled with.
  79094. */
  79095. getEngine(): Engine;
  79096. /**
  79097. * The effect that is created when initializing the post process.
  79098. * @returns The created effect corresponding the the postprocess.
  79099. */
  79100. getEffect(): Effect;
  79101. /**
  79102. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  79103. * @param postProcess The post process to share the output with.
  79104. * @returns This post process.
  79105. */
  79106. shareOutputWith(postProcess: PostProcess): PostProcess;
  79107. /**
  79108. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  79109. * This should be called if the post process that shares output with this post process is disabled/disposed.
  79110. */
  79111. useOwnOutput(): void;
  79112. /**
  79113. * Updates the effect with the current post process compile time values and recompiles the shader.
  79114. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  79115. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  79116. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  79117. * @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
  79118. * @param onCompiled Called when the shader has been compiled.
  79119. * @param onError Called if there is an error when compiling a shader.
  79120. */
  79121. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  79122. /**
  79123. * The post process is reusable if it can be used multiple times within one frame.
  79124. * @returns If the post process is reusable
  79125. */
  79126. isReusable(): boolean;
  79127. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  79128. markTextureDirty(): void;
  79129. /**
  79130. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  79131. * 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.
  79132. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  79133. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  79134. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  79135. * @returns The target texture that was bound to be written to.
  79136. */
  79137. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  79138. /**
  79139. * If the post process is supported.
  79140. */
  79141. readonly isSupported: boolean;
  79142. /**
  79143. * The aspect ratio of the output texture.
  79144. */
  79145. readonly aspectRatio: number;
  79146. /**
  79147. * Get a value indicating if the post-process is ready to be used
  79148. * @returns true if the post-process is ready (shader is compiled)
  79149. */
  79150. isReady(): boolean;
  79151. /**
  79152. * Binds all textures and uniforms to the shader, this will be run on every pass.
  79153. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  79154. */
  79155. apply(): Nullable<Effect>;
  79156. private _disposeTextures;
  79157. /**
  79158. * Disposes the post process.
  79159. * @param camera The camera to dispose the post process on.
  79160. */
  79161. dispose(camera?: Camera): void;
  79162. }
  79163. }
  79164. declare module BABYLON {
  79165. /** @hidden */
  79166. export var kernelBlurVaryingDeclaration: {
  79167. name: string;
  79168. shader: string;
  79169. };
  79170. }
  79171. declare module BABYLON {
  79172. /** @hidden */
  79173. export var kernelBlurFragment: {
  79174. name: string;
  79175. shader: string;
  79176. };
  79177. }
  79178. declare module BABYLON {
  79179. /** @hidden */
  79180. export var kernelBlurFragment2: {
  79181. name: string;
  79182. shader: string;
  79183. };
  79184. }
  79185. declare module BABYLON {
  79186. /** @hidden */
  79187. export var kernelBlurPixelShader: {
  79188. name: string;
  79189. shader: string;
  79190. };
  79191. }
  79192. declare module BABYLON {
  79193. /** @hidden */
  79194. export var kernelBlurVertex: {
  79195. name: string;
  79196. shader: string;
  79197. };
  79198. }
  79199. declare module BABYLON {
  79200. /** @hidden */
  79201. export var kernelBlurVertexShader: {
  79202. name: string;
  79203. shader: string;
  79204. };
  79205. }
  79206. declare module BABYLON {
  79207. /**
  79208. * The Blur Post Process which blurs an image based on a kernel and direction.
  79209. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  79210. */
  79211. export class BlurPostProcess extends PostProcess {
  79212. /** The direction in which to blur the image. */
  79213. direction: Vector2;
  79214. private blockCompilation;
  79215. protected _kernel: number;
  79216. protected _idealKernel: number;
  79217. protected _packedFloat: boolean;
  79218. private _staticDefines;
  79219. /**
  79220. * Sets the length in pixels of the blur sample region
  79221. */
  79222. /**
  79223. * Gets the length in pixels of the blur sample region
  79224. */
  79225. kernel: number;
  79226. /**
  79227. * Sets wether or not the blur needs to unpack/repack floats
  79228. */
  79229. /**
  79230. * Gets wether or not the blur is unpacking/repacking floats
  79231. */
  79232. packedFloat: boolean;
  79233. /**
  79234. * Creates a new instance BlurPostProcess
  79235. * @param name The name of the effect.
  79236. * @param direction The direction in which to blur the image.
  79237. * @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.
  79238. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  79239. * @param camera The camera to apply the render pass to.
  79240. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  79241. * @param engine The engine which the post process will be applied. (default: current engine)
  79242. * @param reusable If the post process can be reused on the same frame. (default: false)
  79243. * @param textureType Type of textures used when performing the post process. (default: 0)
  79244. * @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)
  79245. */
  79246. constructor(name: string,
  79247. /** The direction in which to blur the image. */
  79248. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  79249. /**
  79250. * Updates the effect with the current post process compile time values and recompiles the shader.
  79251. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  79252. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  79253. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  79254. * @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
  79255. * @param onCompiled Called when the shader has been compiled.
  79256. * @param onError Called if there is an error when compiling a shader.
  79257. */
  79258. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  79259. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  79260. /**
  79261. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  79262. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  79263. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  79264. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  79265. * The gaps between physical kernels are compensated for in the weighting of the samples
  79266. * @param idealKernel Ideal blur kernel.
  79267. * @return Nearest best kernel.
  79268. */
  79269. protected _nearestBestKernel(idealKernel: number): number;
  79270. /**
  79271. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  79272. * @param x The point on the Gaussian distribution to sample.
  79273. * @return the value of the Gaussian function at x.
  79274. */
  79275. protected _gaussianWeight(x: number): number;
  79276. /**
  79277. * Generates a string that can be used as a floating point number in GLSL.
  79278. * @param x Value to print.
  79279. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  79280. * @return GLSL float string.
  79281. */
  79282. protected _glslFloat(x: number, decimalFigures?: number): string;
  79283. }
  79284. }
  79285. declare module BABYLON {
  79286. /**
  79287. * Mirror texture can be used to simulate the view from a mirror in a scene.
  79288. * It will dynamically be rendered every frame to adapt to the camera point of view.
  79289. * You can then easily use it as a reflectionTexture on a flat surface.
  79290. * In case the surface is not a plane, please consider relying on reflection probes.
  79291. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79292. */
  79293. export class MirrorTexture extends RenderTargetTexture {
  79294. private scene;
  79295. /**
  79296. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  79297. * 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.
  79298. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79299. */
  79300. mirrorPlane: Plane;
  79301. /**
  79302. * Define the blur ratio used to blur the reflection if needed.
  79303. */
  79304. blurRatio: number;
  79305. /**
  79306. * Define the adaptive blur kernel used to blur the reflection if needed.
  79307. * This will autocompute the closest best match for the `blurKernel`
  79308. */
  79309. adaptiveBlurKernel: number;
  79310. /**
  79311. * Define the blur kernel used to blur the reflection if needed.
  79312. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79313. */
  79314. blurKernel: number;
  79315. /**
  79316. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  79317. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79318. */
  79319. blurKernelX: number;
  79320. /**
  79321. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  79322. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79323. */
  79324. blurKernelY: number;
  79325. private _autoComputeBlurKernel;
  79326. protected _onRatioRescale(): void;
  79327. private _updateGammaSpace;
  79328. private _imageProcessingConfigChangeObserver;
  79329. private _transformMatrix;
  79330. private _mirrorMatrix;
  79331. private _savedViewMatrix;
  79332. private _blurX;
  79333. private _blurY;
  79334. private _adaptiveBlurKernel;
  79335. private _blurKernelX;
  79336. private _blurKernelY;
  79337. private _blurRatio;
  79338. /**
  79339. * Instantiates a Mirror Texture.
  79340. * Mirror texture can be used to simulate the view from a mirror in a scene.
  79341. * It will dynamically be rendered every frame to adapt to the camera point of view.
  79342. * You can then easily use it as a reflectionTexture on a flat surface.
  79343. * In case the surface is not a plane, please consider relying on reflection probes.
  79344. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79345. * @param name
  79346. * @param size
  79347. * @param scene
  79348. * @param generateMipMaps
  79349. * @param type
  79350. * @param samplingMode
  79351. * @param generateDepthBuffer
  79352. */
  79353. constructor(name: string, size: number | {
  79354. width: number;
  79355. height: number;
  79356. } | {
  79357. ratio: number;
  79358. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  79359. private _preparePostProcesses;
  79360. /**
  79361. * Clone the mirror texture.
  79362. * @returns the cloned texture
  79363. */
  79364. clone(): MirrorTexture;
  79365. /**
  79366. * Serialize the texture to a JSON representation you could use in Parse later on
  79367. * @returns the serialized JSON representation
  79368. */
  79369. serialize(): any;
  79370. /**
  79371. * Dispose the texture and release its associated resources.
  79372. */
  79373. dispose(): void;
  79374. }
  79375. }
  79376. declare module BABYLON {
  79377. /**
  79378. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  79379. * @see http://doc.babylonjs.com/babylon101/materials#texture
  79380. */
  79381. export class Texture extends BaseTexture {
  79382. /** @hidden */
  79383. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  79384. /** @hidden */
  79385. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  79386. /** @hidden */
  79387. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  79388. /** nearest is mag = nearest and min = nearest and mip = linear */
  79389. static readonly NEAREST_SAMPLINGMODE: number;
  79390. /** nearest is mag = nearest and min = nearest and mip = linear */
  79391. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  79392. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79393. static readonly BILINEAR_SAMPLINGMODE: number;
  79394. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79395. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  79396. /** Trilinear is mag = linear and min = linear and mip = linear */
  79397. static readonly TRILINEAR_SAMPLINGMODE: number;
  79398. /** Trilinear is mag = linear and min = linear and mip = linear */
  79399. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  79400. /** mag = nearest and min = nearest and mip = nearest */
  79401. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  79402. /** mag = nearest and min = linear and mip = nearest */
  79403. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  79404. /** mag = nearest and min = linear and mip = linear */
  79405. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  79406. /** mag = nearest and min = linear and mip = none */
  79407. static readonly NEAREST_LINEAR: number;
  79408. /** mag = nearest and min = nearest and mip = none */
  79409. static readonly NEAREST_NEAREST: number;
  79410. /** mag = linear and min = nearest and mip = nearest */
  79411. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  79412. /** mag = linear and min = nearest and mip = linear */
  79413. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  79414. /** mag = linear and min = linear and mip = none */
  79415. static readonly LINEAR_LINEAR: number;
  79416. /** mag = linear and min = nearest and mip = none */
  79417. static readonly LINEAR_NEAREST: number;
  79418. /** Explicit coordinates mode */
  79419. static readonly EXPLICIT_MODE: number;
  79420. /** Spherical coordinates mode */
  79421. static readonly SPHERICAL_MODE: number;
  79422. /** Planar coordinates mode */
  79423. static readonly PLANAR_MODE: number;
  79424. /** Cubic coordinates mode */
  79425. static readonly CUBIC_MODE: number;
  79426. /** Projection coordinates mode */
  79427. static readonly PROJECTION_MODE: number;
  79428. /** Inverse Cubic coordinates mode */
  79429. static readonly SKYBOX_MODE: number;
  79430. /** Inverse Cubic coordinates mode */
  79431. static readonly INVCUBIC_MODE: number;
  79432. /** Equirectangular coordinates mode */
  79433. static readonly EQUIRECTANGULAR_MODE: number;
  79434. /** Equirectangular Fixed coordinates mode */
  79435. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  79436. /** Equirectangular Fixed Mirrored coordinates mode */
  79437. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  79438. /** Texture is not repeating outside of 0..1 UVs */
  79439. static readonly CLAMP_ADDRESSMODE: number;
  79440. /** Texture is repeating outside of 0..1 UVs */
  79441. static readonly WRAP_ADDRESSMODE: number;
  79442. /** Texture is repeating and mirrored */
  79443. static readonly MIRROR_ADDRESSMODE: number;
  79444. /**
  79445. * 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
  79446. */
  79447. static UseSerializedUrlIfAny: boolean;
  79448. /**
  79449. * Define the url of the texture.
  79450. */
  79451. url: Nullable<string>;
  79452. /**
  79453. * Define an offset on the texture to offset the u coordinates of the UVs
  79454. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  79455. */
  79456. uOffset: number;
  79457. /**
  79458. * Define an offset on the texture to offset the v coordinates of the UVs
  79459. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  79460. */
  79461. vOffset: number;
  79462. /**
  79463. * Define an offset on the texture to scale the u coordinates of the UVs
  79464. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  79465. */
  79466. uScale: number;
  79467. /**
  79468. * Define an offset on the texture to scale the v coordinates of the UVs
  79469. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  79470. */
  79471. vScale: number;
  79472. /**
  79473. * Define an offset on the texture to rotate around the u coordinates of the UVs
  79474. * @see http://doc.babylonjs.com/how_to/more_materials
  79475. */
  79476. uAng: number;
  79477. /**
  79478. * Define an offset on the texture to rotate around the v coordinates of the UVs
  79479. * @see http://doc.babylonjs.com/how_to/more_materials
  79480. */
  79481. vAng: number;
  79482. /**
  79483. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  79484. * @see http://doc.babylonjs.com/how_to/more_materials
  79485. */
  79486. wAng: number;
  79487. /**
  79488. * Defines the center of rotation (U)
  79489. */
  79490. uRotationCenter: number;
  79491. /**
  79492. * Defines the center of rotation (V)
  79493. */
  79494. vRotationCenter: number;
  79495. /**
  79496. * Defines the center of rotation (W)
  79497. */
  79498. wRotationCenter: number;
  79499. /**
  79500. * Are mip maps generated for this texture or not.
  79501. */
  79502. readonly noMipmap: boolean;
  79503. /**
  79504. * List of inspectable custom properties (used by the Inspector)
  79505. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79506. */
  79507. inspectableCustomProperties: Nullable<IInspectable[]>;
  79508. private _noMipmap;
  79509. /** @hidden */
  79510. _invertY: boolean;
  79511. private _rowGenerationMatrix;
  79512. private _cachedTextureMatrix;
  79513. private _projectionModeMatrix;
  79514. private _t0;
  79515. private _t1;
  79516. private _t2;
  79517. private _cachedUOffset;
  79518. private _cachedVOffset;
  79519. private _cachedUScale;
  79520. private _cachedVScale;
  79521. private _cachedUAng;
  79522. private _cachedVAng;
  79523. private _cachedWAng;
  79524. private _cachedProjectionMatrixId;
  79525. private _cachedCoordinatesMode;
  79526. /** @hidden */
  79527. protected _initialSamplingMode: number;
  79528. /** @hidden */
  79529. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  79530. private _deleteBuffer;
  79531. protected _format: Nullable<number>;
  79532. private _delayedOnLoad;
  79533. private _delayedOnError;
  79534. /**
  79535. * Observable triggered once the texture has been loaded.
  79536. */
  79537. onLoadObservable: Observable<Texture>;
  79538. protected _isBlocking: boolean;
  79539. /**
  79540. * Is the texture preventing material to render while loading.
  79541. * If false, a default texture will be used instead of the loading one during the preparation step.
  79542. */
  79543. isBlocking: boolean;
  79544. /**
  79545. * Get the current sampling mode associated with the texture.
  79546. */
  79547. readonly samplingMode: number;
  79548. /**
  79549. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  79550. */
  79551. readonly invertY: boolean;
  79552. /**
  79553. * Instantiates a new texture.
  79554. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  79555. * @see http://doc.babylonjs.com/babylon101/materials#texture
  79556. * @param url define the url of the picture to load as a texture
  79557. * @param scene define the scene or engine the texture will belong to
  79558. * @param noMipmap define if the texture will require mip maps or not
  79559. * @param invertY define if the texture needs to be inverted on the y axis during loading
  79560. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  79561. * @param onLoad define a callback triggered when the texture has been loaded
  79562. * @param onError define a callback triggered when an error occurred during the loading session
  79563. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  79564. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  79565. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  79566. */
  79567. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  79568. /**
  79569. * Update the url (and optional buffer) of this texture if url was null during construction.
  79570. * @param url the url of the texture
  79571. * @param buffer the buffer of the texture (defaults to null)
  79572. * @param onLoad callback called when the texture is loaded (defaults to null)
  79573. */
  79574. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  79575. /**
  79576. * Finish the loading sequence of a texture flagged as delayed load.
  79577. * @hidden
  79578. */
  79579. delayLoad(): void;
  79580. private _prepareRowForTextureGeneration;
  79581. /**
  79582. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  79583. * @returns the transform matrix of the texture.
  79584. */
  79585. getTextureMatrix(): Matrix;
  79586. /**
  79587. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  79588. * @returns The reflection texture transform
  79589. */
  79590. getReflectionTextureMatrix(): Matrix;
  79591. /**
  79592. * Clones the texture.
  79593. * @returns the cloned texture
  79594. */
  79595. clone(): Texture;
  79596. /**
  79597. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  79598. * @returns The JSON representation of the texture
  79599. */
  79600. serialize(): any;
  79601. /**
  79602. * Get the current class name of the texture useful for serialization or dynamic coding.
  79603. * @returns "Texture"
  79604. */
  79605. getClassName(): string;
  79606. /**
  79607. * Dispose the texture and release its associated resources.
  79608. */
  79609. dispose(): void;
  79610. /**
  79611. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  79612. * @param parsedTexture Define the JSON representation of the texture
  79613. * @param scene Define the scene the parsed texture should be instantiated in
  79614. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  79615. * @returns The parsed texture if successful
  79616. */
  79617. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  79618. /**
  79619. * Creates a texture from its base 64 representation.
  79620. * @param data Define the base64 payload without the data: prefix
  79621. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  79622. * @param scene Define the scene the texture should belong to
  79623. * @param noMipmap Forces the texture to not create mip map information if true
  79624. * @param invertY define if the texture needs to be inverted on the y axis during loading
  79625. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  79626. * @param onLoad define a callback triggered when the texture has been loaded
  79627. * @param onError define a callback triggered when an error occurred during the loading session
  79628. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  79629. * @returns the created texture
  79630. */
  79631. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  79632. /**
  79633. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  79634. * @param data Define the base64 payload without the data: prefix
  79635. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  79636. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  79637. * @param scene Define the scene the texture should belong to
  79638. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  79639. * @param noMipmap Forces the texture to not create mip map information if true
  79640. * @param invertY define if the texture needs to be inverted on the y axis during loading
  79641. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  79642. * @param onLoad define a callback triggered when the texture has been loaded
  79643. * @param onError define a callback triggered when an error occurred during the loading session
  79644. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  79645. * @returns the created texture
  79646. */
  79647. 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;
  79648. }
  79649. }
  79650. declare module BABYLON {
  79651. /**
  79652. * PostProcessManager is used to manage one or more post processes or post process pipelines
  79653. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  79654. */
  79655. export class PostProcessManager {
  79656. private _scene;
  79657. private _indexBuffer;
  79658. private _vertexBuffers;
  79659. /**
  79660. * Creates a new instance PostProcess
  79661. * @param scene The scene that the post process is associated with.
  79662. */
  79663. constructor(scene: Scene);
  79664. private _prepareBuffers;
  79665. private _buildIndexBuffer;
  79666. /**
  79667. * Rebuilds the vertex buffers of the manager.
  79668. * @hidden
  79669. */
  79670. _rebuild(): void;
  79671. /**
  79672. * Prepares a frame to be run through a post process.
  79673. * @param sourceTexture The input texture to the post procesess. (default: null)
  79674. * @param postProcesses An array of post processes to be run. (default: null)
  79675. * @returns True if the post processes were able to be run.
  79676. * @hidden
  79677. */
  79678. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  79679. /**
  79680. * Manually render a set of post processes to a texture.
  79681. * @param postProcesses An array of post processes to be run.
  79682. * @param targetTexture The target texture to render to.
  79683. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  79684. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  79685. * @param lodLevel defines which lod of the texture to render to
  79686. */
  79687. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  79688. /**
  79689. * Finalize the result of the output of the postprocesses.
  79690. * @param doNotPresent If true the result will not be displayed to the screen.
  79691. * @param targetTexture The target texture to render to.
  79692. * @param faceIndex The index of the face to bind the target texture to.
  79693. * @param postProcesses The array of post processes to render.
  79694. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  79695. * @hidden
  79696. */
  79697. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  79698. /**
  79699. * Disposes of the post process manager.
  79700. */
  79701. dispose(): void;
  79702. }
  79703. }
  79704. declare module BABYLON {
  79705. /** Interface used by value gradients (color, factor, ...) */
  79706. export interface IValueGradient {
  79707. /**
  79708. * Gets or sets the gradient value (between 0 and 1)
  79709. */
  79710. gradient: number;
  79711. }
  79712. /** Class used to store color4 gradient */
  79713. export class ColorGradient implements IValueGradient {
  79714. /**
  79715. * Gets or sets the gradient value (between 0 and 1)
  79716. */
  79717. gradient: number;
  79718. /**
  79719. * Gets or sets first associated color
  79720. */
  79721. color1: Color4;
  79722. /**
  79723. * Gets or sets second associated color
  79724. */
  79725. color2?: Color4;
  79726. /**
  79727. * Will get a color picked randomly between color1 and color2.
  79728. * If color2 is undefined then color1 will be used
  79729. * @param result defines the target Color4 to store the result in
  79730. */
  79731. getColorToRef(result: Color4): void;
  79732. }
  79733. /** Class used to store color 3 gradient */
  79734. export class Color3Gradient implements IValueGradient {
  79735. /**
  79736. * Gets or sets the gradient value (between 0 and 1)
  79737. */
  79738. gradient: number;
  79739. /**
  79740. * Gets or sets the associated color
  79741. */
  79742. color: Color3;
  79743. }
  79744. /** Class used to store factor gradient */
  79745. export class FactorGradient implements IValueGradient {
  79746. /**
  79747. * Gets or sets the gradient value (between 0 and 1)
  79748. */
  79749. gradient: number;
  79750. /**
  79751. * Gets or sets first associated factor
  79752. */
  79753. factor1: number;
  79754. /**
  79755. * Gets or sets second associated factor
  79756. */
  79757. factor2?: number;
  79758. /**
  79759. * Will get a number picked randomly between factor1 and factor2.
  79760. * If factor2 is undefined then factor1 will be used
  79761. * @returns the picked number
  79762. */
  79763. getFactor(): number;
  79764. }
  79765. /**
  79766. * Helper used to simplify some generic gradient tasks
  79767. */
  79768. export class GradientHelper {
  79769. /**
  79770. * Gets the current gradient from an array of IValueGradient
  79771. * @param ratio defines the current ratio to get
  79772. * @param gradients defines the array of IValueGradient
  79773. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  79774. */
  79775. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  79776. }
  79777. }
  79778. declare module BABYLON {
  79779. interface AbstractScene {
  79780. /**
  79781. * The list of procedural textures added to the scene
  79782. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  79783. */
  79784. proceduralTextures: Array<ProceduralTexture>;
  79785. }
  79786. /**
  79787. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  79788. * in a given scene.
  79789. */
  79790. export class ProceduralTextureSceneComponent implements ISceneComponent {
  79791. /**
  79792. * The component name helpfull to identify the component in the list of scene components.
  79793. */
  79794. readonly name: string;
  79795. /**
  79796. * The scene the component belongs to.
  79797. */
  79798. scene: Scene;
  79799. /**
  79800. * Creates a new instance of the component for the given scene
  79801. * @param scene Defines the scene to register the component in
  79802. */
  79803. constructor(scene: Scene);
  79804. /**
  79805. * Registers the component in a given scene
  79806. */
  79807. register(): void;
  79808. /**
  79809. * Rebuilds the elements related to this component in case of
  79810. * context lost for instance.
  79811. */
  79812. rebuild(): void;
  79813. /**
  79814. * Disposes the component and the associated ressources.
  79815. */
  79816. dispose(): void;
  79817. private _beforeClear;
  79818. }
  79819. }
  79820. declare module BABYLON {
  79821. interface Engine {
  79822. /**
  79823. * Creates a new render target cube texture
  79824. * @param size defines the size of the texture
  79825. * @param options defines the options used to create the texture
  79826. * @returns a new render target cube texture stored in an InternalTexture
  79827. */
  79828. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  79829. }
  79830. }
  79831. declare module BABYLON {
  79832. /** @hidden */
  79833. export var proceduralVertexShader: {
  79834. name: string;
  79835. shader: string;
  79836. };
  79837. }
  79838. declare module BABYLON {
  79839. /**
  79840. * 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.
  79841. * This is the base class of any Procedural texture and contains most of the shareable code.
  79842. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  79843. */
  79844. export class ProceduralTexture extends Texture {
  79845. isCube: boolean;
  79846. /**
  79847. * Define if the texture is enabled or not (disabled texture will not render)
  79848. */
  79849. isEnabled: boolean;
  79850. /**
  79851. * Define if the texture must be cleared before rendering (default is true)
  79852. */
  79853. autoClear: boolean;
  79854. /**
  79855. * Callback called when the texture is generated
  79856. */
  79857. onGenerated: () => void;
  79858. /**
  79859. * Event raised when the texture is generated
  79860. */
  79861. onGeneratedObservable: Observable<ProceduralTexture>;
  79862. /** @hidden */
  79863. _generateMipMaps: boolean;
  79864. /** @hidden **/
  79865. _effect: Effect;
  79866. /** @hidden */
  79867. _textures: {
  79868. [key: string]: Texture;
  79869. };
  79870. private _size;
  79871. private _currentRefreshId;
  79872. private _refreshRate;
  79873. private _vertexBuffers;
  79874. private _indexBuffer;
  79875. private _uniforms;
  79876. private _samplers;
  79877. private _fragment;
  79878. private _floats;
  79879. private _ints;
  79880. private _floatsArrays;
  79881. private _colors3;
  79882. private _colors4;
  79883. private _vectors2;
  79884. private _vectors3;
  79885. private _matrices;
  79886. private _fallbackTexture;
  79887. private _fallbackTextureUsed;
  79888. private _engine;
  79889. private _cachedDefines;
  79890. private _contentUpdateId;
  79891. private _contentData;
  79892. /**
  79893. * Instantiates a new procedural texture.
  79894. * 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.
  79895. * This is the base class of any Procedural texture and contains most of the shareable code.
  79896. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  79897. * @param name Define the name of the texture
  79898. * @param size Define the size of the texture to create
  79899. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  79900. * @param scene Define the scene the texture belongs to
  79901. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  79902. * @param generateMipMaps Define if the texture should creates mip maps or not
  79903. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  79904. */
  79905. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  79906. /**
  79907. * The effect that is created when initializing the post process.
  79908. * @returns The created effect corresponding the the postprocess.
  79909. */
  79910. getEffect(): Effect;
  79911. /**
  79912. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  79913. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  79914. */
  79915. getContent(): Nullable<ArrayBufferView>;
  79916. private _createIndexBuffer;
  79917. /** @hidden */
  79918. _rebuild(): void;
  79919. /**
  79920. * Resets the texture in order to recreate its associated resources.
  79921. * This can be called in case of context loss
  79922. */
  79923. reset(): void;
  79924. protected _getDefines(): string;
  79925. /**
  79926. * Is the texture ready to be used ? (rendered at least once)
  79927. * @returns true if ready, otherwise, false.
  79928. */
  79929. isReady(): boolean;
  79930. /**
  79931. * Resets the refresh counter of the texture and start bak from scratch.
  79932. * Could be useful to regenerate the texture if it is setup to render only once.
  79933. */
  79934. resetRefreshCounter(): void;
  79935. /**
  79936. * Set the fragment shader to use in order to render the texture.
  79937. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  79938. */
  79939. setFragment(fragment: any): void;
  79940. /**
  79941. * Define the refresh rate of the texture or the rendering frequency.
  79942. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  79943. */
  79944. refreshRate: number;
  79945. /** @hidden */
  79946. _shouldRender(): boolean;
  79947. /**
  79948. * Get the size the texture is rendering at.
  79949. * @returns the size (texture is always squared)
  79950. */
  79951. getRenderSize(): number;
  79952. /**
  79953. * Resize the texture to new value.
  79954. * @param size Define the new size the texture should have
  79955. * @param generateMipMaps Define whether the new texture should create mip maps
  79956. */
  79957. resize(size: number, generateMipMaps: boolean): void;
  79958. private _checkUniform;
  79959. /**
  79960. * Set a texture in the shader program used to render.
  79961. * @param name Define the name of the uniform samplers as defined in the shader
  79962. * @param texture Define the texture to bind to this sampler
  79963. * @return the texture itself allowing "fluent" like uniform updates
  79964. */
  79965. setTexture(name: string, texture: Texture): ProceduralTexture;
  79966. /**
  79967. * Set a float in the shader.
  79968. * @param name Define the name of the uniform as defined in the shader
  79969. * @param value Define the value to give to the uniform
  79970. * @return the texture itself allowing "fluent" like uniform updates
  79971. */
  79972. setFloat(name: string, value: number): ProceduralTexture;
  79973. /**
  79974. * Set a int in the shader.
  79975. * @param name Define the name of the uniform as defined in the shader
  79976. * @param value Define the value to give to the uniform
  79977. * @return the texture itself allowing "fluent" like uniform updates
  79978. */
  79979. setInt(name: string, value: number): ProceduralTexture;
  79980. /**
  79981. * Set an array of floats in the shader.
  79982. * @param name Define the name of the uniform as defined in the shader
  79983. * @param value Define the value to give to the uniform
  79984. * @return the texture itself allowing "fluent" like uniform updates
  79985. */
  79986. setFloats(name: string, value: number[]): ProceduralTexture;
  79987. /**
  79988. * Set a vec3 in the shader from a Color3.
  79989. * @param name Define the name of the uniform as defined in the shader
  79990. * @param value Define the value to give to the uniform
  79991. * @return the texture itself allowing "fluent" like uniform updates
  79992. */
  79993. setColor3(name: string, value: Color3): ProceduralTexture;
  79994. /**
  79995. * Set a vec4 in the shader from a Color4.
  79996. * @param name Define the name of the uniform as defined in the shader
  79997. * @param value Define the value to give to the uniform
  79998. * @return the texture itself allowing "fluent" like uniform updates
  79999. */
  80000. setColor4(name: string, value: Color4): ProceduralTexture;
  80001. /**
  80002. * Set a vec2 in the shader from a Vector2.
  80003. * @param name Define the name of the uniform as defined in the shader
  80004. * @param value Define the value to give to the uniform
  80005. * @return the texture itself allowing "fluent" like uniform updates
  80006. */
  80007. setVector2(name: string, value: Vector2): ProceduralTexture;
  80008. /**
  80009. * Set a vec3 in the shader from a Vector3.
  80010. * @param name Define the name of the uniform as defined in the shader
  80011. * @param value Define the value to give to the uniform
  80012. * @return the texture itself allowing "fluent" like uniform updates
  80013. */
  80014. setVector3(name: string, value: Vector3): ProceduralTexture;
  80015. /**
  80016. * Set a mat4 in the shader from a MAtrix.
  80017. * @param name Define the name of the uniform as defined in the shader
  80018. * @param value Define the value to give to the uniform
  80019. * @return the texture itself allowing "fluent" like uniform updates
  80020. */
  80021. setMatrix(name: string, value: Matrix): ProceduralTexture;
  80022. /**
  80023. * Render the texture to its associated render target.
  80024. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  80025. */
  80026. render(useCameraPostProcess?: boolean): void;
  80027. /**
  80028. * Clone the texture.
  80029. * @returns the cloned texture
  80030. */
  80031. clone(): ProceduralTexture;
  80032. /**
  80033. * Dispose the texture and release its asoociated resources.
  80034. */
  80035. dispose(): void;
  80036. }
  80037. }
  80038. declare module BABYLON {
  80039. /**
  80040. * This represents the base class for particle system in Babylon.
  80041. * 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.
  80042. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  80043. * @example https://doc.babylonjs.com/babylon101/particles
  80044. */
  80045. export class BaseParticleSystem {
  80046. /**
  80047. * Source color is added to the destination color without alpha affecting the result
  80048. */
  80049. static BLENDMODE_ONEONE: number;
  80050. /**
  80051. * Blend current color and particle color using particle’s alpha
  80052. */
  80053. static BLENDMODE_STANDARD: number;
  80054. /**
  80055. * Add current color and particle color multiplied by particle’s alpha
  80056. */
  80057. static BLENDMODE_ADD: number;
  80058. /**
  80059. * Multiply current color with particle color
  80060. */
  80061. static BLENDMODE_MULTIPLY: number;
  80062. /**
  80063. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  80064. */
  80065. static BLENDMODE_MULTIPLYADD: number;
  80066. /**
  80067. * List of animations used by the particle system.
  80068. */
  80069. animations: Animation[];
  80070. /**
  80071. * The id of the Particle system.
  80072. */
  80073. id: string;
  80074. /**
  80075. * The friendly name of the Particle system.
  80076. */
  80077. name: string;
  80078. /**
  80079. * The rendering group used by the Particle system to chose when to render.
  80080. */
  80081. renderingGroupId: number;
  80082. /**
  80083. * The emitter represents the Mesh or position we are attaching the particle system to.
  80084. */
  80085. emitter: Nullable<AbstractMesh | Vector3>;
  80086. /**
  80087. * The maximum number of particles to emit per frame
  80088. */
  80089. emitRate: number;
  80090. /**
  80091. * If you want to launch only a few particles at once, that can be done, as well.
  80092. */
  80093. manualEmitCount: number;
  80094. /**
  80095. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  80096. */
  80097. updateSpeed: number;
  80098. /**
  80099. * The amount of time the particle system is running (depends of the overall update speed).
  80100. */
  80101. targetStopDuration: number;
  80102. /**
  80103. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  80104. */
  80105. disposeOnStop: boolean;
  80106. /**
  80107. * Minimum power of emitting particles.
  80108. */
  80109. minEmitPower: number;
  80110. /**
  80111. * Maximum power of emitting particles.
  80112. */
  80113. maxEmitPower: number;
  80114. /**
  80115. * Minimum life time of emitting particles.
  80116. */
  80117. minLifeTime: number;
  80118. /**
  80119. * Maximum life time of emitting particles.
  80120. */
  80121. maxLifeTime: number;
  80122. /**
  80123. * Minimum Size of emitting particles.
  80124. */
  80125. minSize: number;
  80126. /**
  80127. * Maximum Size of emitting particles.
  80128. */
  80129. maxSize: number;
  80130. /**
  80131. * Minimum scale of emitting particles on X axis.
  80132. */
  80133. minScaleX: number;
  80134. /**
  80135. * Maximum scale of emitting particles on X axis.
  80136. */
  80137. maxScaleX: number;
  80138. /**
  80139. * Minimum scale of emitting particles on Y axis.
  80140. */
  80141. minScaleY: number;
  80142. /**
  80143. * Maximum scale of emitting particles on Y axis.
  80144. */
  80145. maxScaleY: number;
  80146. /**
  80147. * Gets or sets the minimal initial rotation in radians.
  80148. */
  80149. minInitialRotation: number;
  80150. /**
  80151. * Gets or sets the maximal initial rotation in radians.
  80152. */
  80153. maxInitialRotation: number;
  80154. /**
  80155. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  80156. */
  80157. minAngularSpeed: number;
  80158. /**
  80159. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  80160. */
  80161. maxAngularSpeed: number;
  80162. /**
  80163. * The texture used to render each particle. (this can be a spritesheet)
  80164. */
  80165. particleTexture: Nullable<Texture>;
  80166. /**
  80167. * The layer mask we are rendering the particles through.
  80168. */
  80169. layerMask: number;
  80170. /**
  80171. * This can help using your own shader to render the particle system.
  80172. * The according effect will be created
  80173. */
  80174. customShader: any;
  80175. /**
  80176. * By default particle system starts as soon as they are created. This prevents the
  80177. * automatic start to happen and let you decide when to start emitting particles.
  80178. */
  80179. preventAutoStart: boolean;
  80180. private _noiseTexture;
  80181. /**
  80182. * Gets or sets a texture used to add random noise to particle positions
  80183. */
  80184. noiseTexture: Nullable<ProceduralTexture>;
  80185. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  80186. noiseStrength: Vector3;
  80187. /**
  80188. * Callback triggered when the particle animation is ending.
  80189. */
  80190. onAnimationEnd: Nullable<() => void>;
  80191. /**
  80192. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  80193. */
  80194. blendMode: number;
  80195. /**
  80196. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  80197. * to override the particles.
  80198. */
  80199. forceDepthWrite: boolean;
  80200. /** 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 */
  80201. preWarmCycles: number;
  80202. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  80203. preWarmStepOffset: number;
  80204. /**
  80205. * 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)
  80206. */
  80207. spriteCellChangeSpeed: number;
  80208. /**
  80209. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  80210. */
  80211. startSpriteCellID: number;
  80212. /**
  80213. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  80214. */
  80215. endSpriteCellID: number;
  80216. /**
  80217. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  80218. */
  80219. spriteCellWidth: number;
  80220. /**
  80221. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  80222. */
  80223. spriteCellHeight: number;
  80224. /**
  80225. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  80226. */
  80227. spriteRandomStartCell: boolean;
  80228. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  80229. translationPivot: Vector2;
  80230. /** @hidden */
  80231. protected _isAnimationSheetEnabled: boolean;
  80232. /**
  80233. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  80234. */
  80235. beginAnimationOnStart: boolean;
  80236. /**
  80237. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  80238. */
  80239. beginAnimationFrom: number;
  80240. /**
  80241. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  80242. */
  80243. beginAnimationTo: number;
  80244. /**
  80245. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  80246. */
  80247. beginAnimationLoop: boolean;
  80248. /**
  80249. * Gets or sets a world offset applied to all particles
  80250. */
  80251. worldOffset: Vector3;
  80252. /**
  80253. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  80254. */
  80255. isAnimationSheetEnabled: boolean;
  80256. /**
  80257. * Get hosting scene
  80258. * @returns the scene
  80259. */
  80260. getScene(): Scene;
  80261. /**
  80262. * You can use gravity if you want to give an orientation to your particles.
  80263. */
  80264. gravity: Vector3;
  80265. protected _colorGradients: Nullable<Array<ColorGradient>>;
  80266. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  80267. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  80268. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  80269. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  80270. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  80271. protected _dragGradients: Nullable<Array<FactorGradient>>;
  80272. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  80273. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  80274. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  80275. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  80276. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  80277. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  80278. /**
  80279. * Defines the delay in milliseconds before starting the system (0 by default)
  80280. */
  80281. startDelay: number;
  80282. /**
  80283. * Gets the current list of drag gradients.
  80284. * You must use addDragGradient and removeDragGradient to udpate this list
  80285. * @returns the list of drag gradients
  80286. */
  80287. getDragGradients(): Nullable<Array<FactorGradient>>;
  80288. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  80289. limitVelocityDamping: number;
  80290. /**
  80291. * Gets the current list of limit velocity gradients.
  80292. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  80293. * @returns the list of limit velocity gradients
  80294. */
  80295. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  80296. /**
  80297. * Gets the current list of color gradients.
  80298. * You must use addColorGradient and removeColorGradient to udpate this list
  80299. * @returns the list of color gradients
  80300. */
  80301. getColorGradients(): Nullable<Array<ColorGradient>>;
  80302. /**
  80303. * Gets the current list of size gradients.
  80304. * You must use addSizeGradient and removeSizeGradient to udpate this list
  80305. * @returns the list of size gradients
  80306. */
  80307. getSizeGradients(): Nullable<Array<FactorGradient>>;
  80308. /**
  80309. * Gets the current list of color remap gradients.
  80310. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  80311. * @returns the list of color remap gradients
  80312. */
  80313. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  80314. /**
  80315. * Gets the current list of alpha remap gradients.
  80316. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  80317. * @returns the list of alpha remap gradients
  80318. */
  80319. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  80320. /**
  80321. * Gets the current list of life time gradients.
  80322. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  80323. * @returns the list of life time gradients
  80324. */
  80325. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  80326. /**
  80327. * Gets the current list of angular speed gradients.
  80328. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  80329. * @returns the list of angular speed gradients
  80330. */
  80331. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  80332. /**
  80333. * Gets the current list of velocity gradients.
  80334. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  80335. * @returns the list of velocity gradients
  80336. */
  80337. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  80338. /**
  80339. * Gets the current list of start size gradients.
  80340. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  80341. * @returns the list of start size gradients
  80342. */
  80343. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  80344. /**
  80345. * Gets the current list of emit rate gradients.
  80346. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  80347. * @returns the list of emit rate gradients
  80348. */
  80349. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  80350. /**
  80351. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  80352. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80353. */
  80354. direction1: Vector3;
  80355. /**
  80356. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  80357. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80358. */
  80359. direction2: Vector3;
  80360. /**
  80361. * 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.
  80362. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80363. */
  80364. minEmitBox: Vector3;
  80365. /**
  80366. * 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.
  80367. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80368. */
  80369. maxEmitBox: Vector3;
  80370. /**
  80371. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  80372. */
  80373. color1: Color4;
  80374. /**
  80375. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  80376. */
  80377. color2: Color4;
  80378. /**
  80379. * Color the particle will have at the end of its lifetime
  80380. */
  80381. colorDead: Color4;
  80382. /**
  80383. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  80384. */
  80385. textureMask: Color4;
  80386. /**
  80387. * The particle emitter type defines the emitter used by the particle system.
  80388. * It can be for example box, sphere, or cone...
  80389. */
  80390. particleEmitterType: IParticleEmitterType;
  80391. /** @hidden */
  80392. _isSubEmitter: boolean;
  80393. /**
  80394. * Gets or sets the billboard mode to use when isBillboardBased = true.
  80395. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  80396. */
  80397. billboardMode: number;
  80398. protected _isBillboardBased: boolean;
  80399. /**
  80400. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  80401. */
  80402. isBillboardBased: boolean;
  80403. /**
  80404. * The scene the particle system belongs to.
  80405. */
  80406. protected _scene: Scene;
  80407. /**
  80408. * Local cache of defines for image processing.
  80409. */
  80410. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  80411. /**
  80412. * Default configuration related to image processing available in the standard Material.
  80413. */
  80414. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  80415. /**
  80416. * Gets the image processing configuration used either in this material.
  80417. */
  80418. /**
  80419. * Sets the Default image processing configuration used either in the this material.
  80420. *
  80421. * If sets to null, the scene one is in use.
  80422. */
  80423. imageProcessingConfiguration: ImageProcessingConfiguration;
  80424. /**
  80425. * Attaches a new image processing configuration to the Standard Material.
  80426. * @param configuration
  80427. */
  80428. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  80429. /** @hidden */
  80430. protected _reset(): void;
  80431. /** @hidden */
  80432. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  80433. /**
  80434. * Instantiates a particle system.
  80435. * 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.
  80436. * @param name The name of the particle system
  80437. */
  80438. constructor(name: string);
  80439. /**
  80440. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  80441. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  80442. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  80443. * @returns the emitter
  80444. */
  80445. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  80446. /**
  80447. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  80448. * @param radius The radius of the hemisphere to emit from
  80449. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  80450. * @returns the emitter
  80451. */
  80452. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  80453. /**
  80454. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  80455. * @param radius The radius of the sphere to emit from
  80456. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  80457. * @returns the emitter
  80458. */
  80459. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  80460. /**
  80461. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  80462. * @param radius The radius of the sphere to emit from
  80463. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  80464. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  80465. * @returns the emitter
  80466. */
  80467. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  80468. /**
  80469. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  80470. * @param radius The radius of the emission cylinder
  80471. * @param height The height of the emission cylinder
  80472. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  80473. * @param directionRandomizer How much to randomize the particle direction [0-1]
  80474. * @returns the emitter
  80475. */
  80476. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  80477. /**
  80478. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  80479. * @param radius The radius of the cylinder to emit from
  80480. * @param height The height of the emission cylinder
  80481. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  80482. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  80483. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  80484. * @returns the emitter
  80485. */
  80486. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  80487. /**
  80488. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  80489. * @param radius The radius of the cone to emit from
  80490. * @param angle The base angle of the cone
  80491. * @returns the emitter
  80492. */
  80493. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  80494. /**
  80495. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  80496. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  80497. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  80498. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  80499. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  80500. * @returns the emitter
  80501. */
  80502. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  80503. }
  80504. }
  80505. declare module BABYLON {
  80506. /**
  80507. * Type of sub emitter
  80508. */
  80509. export enum SubEmitterType {
  80510. /**
  80511. * Attached to the particle over it's lifetime
  80512. */
  80513. ATTACHED = 0,
  80514. /**
  80515. * Created when the particle dies
  80516. */
  80517. END = 1
  80518. }
  80519. /**
  80520. * Sub emitter class used to emit particles from an existing particle
  80521. */
  80522. export class SubEmitter {
  80523. /**
  80524. * the particle system to be used by the sub emitter
  80525. */
  80526. particleSystem: ParticleSystem;
  80527. /**
  80528. * Type of the submitter (Default: END)
  80529. */
  80530. type: SubEmitterType;
  80531. /**
  80532. * 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)
  80533. * Note: This only is supported when using an emitter of type Mesh
  80534. */
  80535. inheritDirection: boolean;
  80536. /**
  80537. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  80538. */
  80539. inheritedVelocityAmount: number;
  80540. /**
  80541. * Creates a sub emitter
  80542. * @param particleSystem the particle system to be used by the sub emitter
  80543. */
  80544. constructor(
  80545. /**
  80546. * the particle system to be used by the sub emitter
  80547. */
  80548. particleSystem: ParticleSystem);
  80549. /**
  80550. * Clones the sub emitter
  80551. * @returns the cloned sub emitter
  80552. */
  80553. clone(): SubEmitter;
  80554. /**
  80555. * Serialize current object to a JSON object
  80556. * @returns the serialized object
  80557. */
  80558. serialize(): any;
  80559. /** @hidden */
  80560. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  80561. /**
  80562. * Creates a new SubEmitter from a serialized JSON version
  80563. * @param serializationObject defines the JSON object to read from
  80564. * @param scene defines the hosting scene
  80565. * @param rootUrl defines the rootUrl for data loading
  80566. * @returns a new SubEmitter
  80567. */
  80568. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  80569. /** Release associated resources */
  80570. dispose(): void;
  80571. }
  80572. }
  80573. declare module BABYLON {
  80574. /** @hidden */
  80575. export var clipPlaneFragmentDeclaration: {
  80576. name: string;
  80577. shader: string;
  80578. };
  80579. }
  80580. declare module BABYLON {
  80581. /** @hidden */
  80582. export var imageProcessingDeclaration: {
  80583. name: string;
  80584. shader: string;
  80585. };
  80586. }
  80587. declare module BABYLON {
  80588. /** @hidden */
  80589. export var imageProcessingFunctions: {
  80590. name: string;
  80591. shader: string;
  80592. };
  80593. }
  80594. declare module BABYLON {
  80595. /** @hidden */
  80596. export var clipPlaneFragment: {
  80597. name: string;
  80598. shader: string;
  80599. };
  80600. }
  80601. declare module BABYLON {
  80602. /** @hidden */
  80603. export var particlesPixelShader: {
  80604. name: string;
  80605. shader: string;
  80606. };
  80607. }
  80608. declare module BABYLON {
  80609. /** @hidden */
  80610. export var clipPlaneVertexDeclaration: {
  80611. name: string;
  80612. shader: string;
  80613. };
  80614. }
  80615. declare module BABYLON {
  80616. /** @hidden */
  80617. export var clipPlaneVertex: {
  80618. name: string;
  80619. shader: string;
  80620. };
  80621. }
  80622. declare module BABYLON {
  80623. /** @hidden */
  80624. export var particlesVertexShader: {
  80625. name: string;
  80626. shader: string;
  80627. };
  80628. }
  80629. declare module BABYLON {
  80630. /**
  80631. * This represents a particle system in Babylon.
  80632. * 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.
  80633. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  80634. * @example https://doc.babylonjs.com/babylon101/particles
  80635. */
  80636. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  80637. /**
  80638. * Billboard mode will only apply to Y axis
  80639. */
  80640. static readonly BILLBOARDMODE_Y: number;
  80641. /**
  80642. * Billboard mode will apply to all axes
  80643. */
  80644. static readonly BILLBOARDMODE_ALL: number;
  80645. /**
  80646. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  80647. */
  80648. static readonly BILLBOARDMODE_STRETCHED: number;
  80649. /**
  80650. * This function can be defined to provide custom update for active particles.
  80651. * This function will be called instead of regular update (age, position, color, etc.).
  80652. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  80653. */
  80654. updateFunction: (particles: Particle[]) => void;
  80655. private _emitterWorldMatrix;
  80656. /**
  80657. * This function can be defined to specify initial direction for every new particle.
  80658. * It by default use the emitterType defined function
  80659. */
  80660. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  80661. /**
  80662. * This function can be defined to specify initial position for every new particle.
  80663. * It by default use the emitterType defined function
  80664. */
  80665. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  80666. /**
  80667. * @hidden
  80668. */
  80669. _inheritedVelocityOffset: Vector3;
  80670. /**
  80671. * An event triggered when the system is disposed
  80672. */
  80673. onDisposeObservable: Observable<ParticleSystem>;
  80674. private _onDisposeObserver;
  80675. /**
  80676. * Sets a callback that will be triggered when the system is disposed
  80677. */
  80678. onDispose: () => void;
  80679. private _particles;
  80680. private _epsilon;
  80681. private _capacity;
  80682. private _stockParticles;
  80683. private _newPartsExcess;
  80684. private _vertexData;
  80685. private _vertexBuffer;
  80686. private _vertexBuffers;
  80687. private _spriteBuffer;
  80688. private _indexBuffer;
  80689. private _effect;
  80690. private _customEffect;
  80691. private _cachedDefines;
  80692. private _scaledColorStep;
  80693. private _colorDiff;
  80694. private _scaledDirection;
  80695. private _scaledGravity;
  80696. private _currentRenderId;
  80697. private _alive;
  80698. private _useInstancing;
  80699. private _started;
  80700. private _stopped;
  80701. private _actualFrame;
  80702. private _scaledUpdateSpeed;
  80703. private _vertexBufferSize;
  80704. /** @hidden */
  80705. _currentEmitRateGradient: Nullable<FactorGradient>;
  80706. /** @hidden */
  80707. _currentEmitRate1: number;
  80708. /** @hidden */
  80709. _currentEmitRate2: number;
  80710. /** @hidden */
  80711. _currentStartSizeGradient: Nullable<FactorGradient>;
  80712. /** @hidden */
  80713. _currentStartSize1: number;
  80714. /** @hidden */
  80715. _currentStartSize2: number;
  80716. private readonly _rawTextureWidth;
  80717. private _rampGradientsTexture;
  80718. private _useRampGradients;
  80719. /** Gets or sets a boolean indicating that ramp gradients must be used
  80720. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  80721. */
  80722. useRampGradients: boolean;
  80723. /**
  80724. * 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.
  80725. * 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: [])
  80726. */
  80727. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  80728. private _subEmitters;
  80729. /**
  80730. * @hidden
  80731. * If the particle systems emitter should be disposed when the particle system is disposed
  80732. */
  80733. _disposeEmitterOnDispose: boolean;
  80734. /**
  80735. * The current active Sub-systems, this property is used by the root particle system only.
  80736. */
  80737. activeSubSystems: Array<ParticleSystem>;
  80738. private _rootParticleSystem;
  80739. /**
  80740. * Gets the current list of active particles
  80741. */
  80742. readonly particles: Particle[];
  80743. /**
  80744. * Returns the string "ParticleSystem"
  80745. * @returns a string containing the class name
  80746. */
  80747. getClassName(): string;
  80748. /**
  80749. * Instantiates a particle system.
  80750. * 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.
  80751. * @param name The name of the particle system
  80752. * @param capacity The max number of particles alive at the same time
  80753. * @param scene The scene the particle system belongs to
  80754. * @param customEffect a custom effect used to change the way particles are rendered by default
  80755. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  80756. * @param epsilon Offset used to render the particles
  80757. */
  80758. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  80759. private _addFactorGradient;
  80760. private _removeFactorGradient;
  80761. /**
  80762. * Adds a new life time gradient
  80763. * @param gradient defines the gradient to use (between 0 and 1)
  80764. * @param factor defines the life time factor to affect to the specified gradient
  80765. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80766. * @returns the current particle system
  80767. */
  80768. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80769. /**
  80770. * Remove a specific life time gradient
  80771. * @param gradient defines the gradient to remove
  80772. * @returns the current particle system
  80773. */
  80774. removeLifeTimeGradient(gradient: number): IParticleSystem;
  80775. /**
  80776. * Adds a new size gradient
  80777. * @param gradient defines the gradient to use (between 0 and 1)
  80778. * @param factor defines the size factor to affect to the specified gradient
  80779. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80780. * @returns the current particle system
  80781. */
  80782. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80783. /**
  80784. * Remove a specific size gradient
  80785. * @param gradient defines the gradient to remove
  80786. * @returns the current particle system
  80787. */
  80788. removeSizeGradient(gradient: number): IParticleSystem;
  80789. /**
  80790. * Adds a new color remap gradient
  80791. * @param gradient defines the gradient to use (between 0 and 1)
  80792. * @param min defines the color remap minimal range
  80793. * @param max defines the color remap maximal range
  80794. * @returns the current particle system
  80795. */
  80796. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  80797. /**
  80798. * Remove a specific color remap gradient
  80799. * @param gradient defines the gradient to remove
  80800. * @returns the current particle system
  80801. */
  80802. removeColorRemapGradient(gradient: number): IParticleSystem;
  80803. /**
  80804. * Adds a new alpha remap gradient
  80805. * @param gradient defines the gradient to use (between 0 and 1)
  80806. * @param min defines the alpha remap minimal range
  80807. * @param max defines the alpha remap maximal range
  80808. * @returns the current particle system
  80809. */
  80810. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  80811. /**
  80812. * Remove a specific alpha remap gradient
  80813. * @param gradient defines the gradient to remove
  80814. * @returns the current particle system
  80815. */
  80816. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  80817. /**
  80818. * Adds a new angular speed gradient
  80819. * @param gradient defines the gradient to use (between 0 and 1)
  80820. * @param factor defines the angular speed to affect to the specified gradient
  80821. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80822. * @returns the current particle system
  80823. */
  80824. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80825. /**
  80826. * Remove a specific angular speed gradient
  80827. * @param gradient defines the gradient to remove
  80828. * @returns the current particle system
  80829. */
  80830. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  80831. /**
  80832. * Adds a new velocity gradient
  80833. * @param gradient defines the gradient to use (between 0 and 1)
  80834. * @param factor defines the velocity to affect to the specified gradient
  80835. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80836. * @returns the current particle system
  80837. */
  80838. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80839. /**
  80840. * Remove a specific velocity gradient
  80841. * @param gradient defines the gradient to remove
  80842. * @returns the current particle system
  80843. */
  80844. removeVelocityGradient(gradient: number): IParticleSystem;
  80845. /**
  80846. * Adds a new limit velocity gradient
  80847. * @param gradient defines the gradient to use (between 0 and 1)
  80848. * @param factor defines the limit velocity value to affect to the specified gradient
  80849. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80850. * @returns the current particle system
  80851. */
  80852. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80853. /**
  80854. * Remove a specific limit velocity gradient
  80855. * @param gradient defines the gradient to remove
  80856. * @returns the current particle system
  80857. */
  80858. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  80859. /**
  80860. * Adds a new drag gradient
  80861. * @param gradient defines the gradient to use (between 0 and 1)
  80862. * @param factor defines the drag value to affect to the specified gradient
  80863. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80864. * @returns the current particle system
  80865. */
  80866. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80867. /**
  80868. * Remove a specific drag gradient
  80869. * @param gradient defines the gradient to remove
  80870. * @returns the current particle system
  80871. */
  80872. removeDragGradient(gradient: number): IParticleSystem;
  80873. /**
  80874. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  80875. * @param gradient defines the gradient to use (between 0 and 1)
  80876. * @param factor defines the emit rate value to affect to the specified gradient
  80877. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80878. * @returns the current particle system
  80879. */
  80880. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80881. /**
  80882. * Remove a specific emit rate gradient
  80883. * @param gradient defines the gradient to remove
  80884. * @returns the current particle system
  80885. */
  80886. removeEmitRateGradient(gradient: number): IParticleSystem;
  80887. /**
  80888. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  80889. * @param gradient defines the gradient to use (between 0 and 1)
  80890. * @param factor defines the start size value to affect to the specified gradient
  80891. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80892. * @returns the current particle system
  80893. */
  80894. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80895. /**
  80896. * Remove a specific start size gradient
  80897. * @param gradient defines the gradient to remove
  80898. * @returns the current particle system
  80899. */
  80900. removeStartSizeGradient(gradient: number): IParticleSystem;
  80901. private _createRampGradientTexture;
  80902. /**
  80903. * Gets the current list of ramp gradients.
  80904. * You must use addRampGradient and removeRampGradient to udpate this list
  80905. * @returns the list of ramp gradients
  80906. */
  80907. getRampGradients(): Nullable<Array<Color3Gradient>>;
  80908. /**
  80909. * Adds a new ramp gradient used to remap particle colors
  80910. * @param gradient defines the gradient to use (between 0 and 1)
  80911. * @param color defines the color to affect to the specified gradient
  80912. * @returns the current particle system
  80913. */
  80914. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  80915. /**
  80916. * Remove a specific ramp gradient
  80917. * @param gradient defines the gradient to remove
  80918. * @returns the current particle system
  80919. */
  80920. removeRampGradient(gradient: number): ParticleSystem;
  80921. /**
  80922. * Adds a new color gradient
  80923. * @param gradient defines the gradient to use (between 0 and 1)
  80924. * @param color1 defines the color to affect to the specified gradient
  80925. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  80926. * @returns this particle system
  80927. */
  80928. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  80929. /**
  80930. * Remove a specific color gradient
  80931. * @param gradient defines the gradient to remove
  80932. * @returns this particle system
  80933. */
  80934. removeColorGradient(gradient: number): IParticleSystem;
  80935. private _fetchR;
  80936. protected _reset(): void;
  80937. private _resetEffect;
  80938. private _createVertexBuffers;
  80939. private _createIndexBuffer;
  80940. /**
  80941. * Gets the maximum number of particles active at the same time.
  80942. * @returns The max number of active particles.
  80943. */
  80944. getCapacity(): number;
  80945. /**
  80946. * Gets whether there are still active particles in the system.
  80947. * @returns True if it is alive, otherwise false.
  80948. */
  80949. isAlive(): boolean;
  80950. /**
  80951. * Gets if the system has been started. (Note: this will still be true after stop is called)
  80952. * @returns True if it has been started, otherwise false.
  80953. */
  80954. isStarted(): boolean;
  80955. private _prepareSubEmitterInternalArray;
  80956. /**
  80957. * Starts the particle system and begins to emit
  80958. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  80959. */
  80960. start(delay?: number): void;
  80961. /**
  80962. * Stops the particle system.
  80963. * @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.
  80964. */
  80965. stop(stopSubEmitters?: boolean): void;
  80966. /**
  80967. * Remove all active particles
  80968. */
  80969. reset(): void;
  80970. /**
  80971. * @hidden (for internal use only)
  80972. */
  80973. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  80974. /**
  80975. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  80976. * Its lifetime will start back at 0.
  80977. */
  80978. recycleParticle: (particle: Particle) => void;
  80979. private _stopSubEmitters;
  80980. private _createParticle;
  80981. private _removeFromRoot;
  80982. private _emitFromParticle;
  80983. private _update;
  80984. /** @hidden */
  80985. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  80986. /** @hidden */
  80987. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  80988. /** @hidden */
  80989. private _getEffect;
  80990. /**
  80991. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  80992. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  80993. */
  80994. animate(preWarmOnly?: boolean): void;
  80995. private _appendParticleVertices;
  80996. /**
  80997. * Rebuilds the particle system.
  80998. */
  80999. rebuild(): void;
  81000. /**
  81001. * Is this system ready to be used/rendered
  81002. * @return true if the system is ready
  81003. */
  81004. isReady(): boolean;
  81005. private _render;
  81006. /**
  81007. * Renders the particle system in its current state.
  81008. * @returns the current number of particles
  81009. */
  81010. render(): number;
  81011. /**
  81012. * Disposes the particle system and free the associated resources
  81013. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  81014. */
  81015. dispose(disposeTexture?: boolean): void;
  81016. /**
  81017. * Clones the particle system.
  81018. * @param name The name of the cloned object
  81019. * @param newEmitter The new emitter to use
  81020. * @returns the cloned particle system
  81021. */
  81022. clone(name: string, newEmitter: any): ParticleSystem;
  81023. /**
  81024. * Serializes the particle system to a JSON object.
  81025. * @returns the JSON object
  81026. */
  81027. serialize(): any;
  81028. /** @hidden */
  81029. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  81030. /** @hidden */
  81031. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  81032. /**
  81033. * Parses a JSON object to create a particle system.
  81034. * @param parsedParticleSystem The JSON object to parse
  81035. * @param scene The scene to create the particle system in
  81036. * @param rootUrl The root url to use to load external dependencies like texture
  81037. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  81038. * @returns the Parsed particle system
  81039. */
  81040. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  81041. }
  81042. }
  81043. declare module BABYLON {
  81044. /**
  81045. * A particle represents one of the element emitted by a particle system.
  81046. * This is mainly define by its coordinates, direction, velocity and age.
  81047. */
  81048. export class Particle {
  81049. /**
  81050. * The particle system the particle belongs to.
  81051. */
  81052. particleSystem: ParticleSystem;
  81053. private static _Count;
  81054. /**
  81055. * Unique ID of the particle
  81056. */
  81057. id: number;
  81058. /**
  81059. * The world position of the particle in the scene.
  81060. */
  81061. position: Vector3;
  81062. /**
  81063. * The world direction of the particle in the scene.
  81064. */
  81065. direction: Vector3;
  81066. /**
  81067. * The color of the particle.
  81068. */
  81069. color: Color4;
  81070. /**
  81071. * The color change of the particle per step.
  81072. */
  81073. colorStep: Color4;
  81074. /**
  81075. * Defines how long will the life of the particle be.
  81076. */
  81077. lifeTime: number;
  81078. /**
  81079. * The current age of the particle.
  81080. */
  81081. age: number;
  81082. /**
  81083. * The current size of the particle.
  81084. */
  81085. size: number;
  81086. /**
  81087. * The current scale of the particle.
  81088. */
  81089. scale: Vector2;
  81090. /**
  81091. * The current angle of the particle.
  81092. */
  81093. angle: number;
  81094. /**
  81095. * Defines how fast is the angle changing.
  81096. */
  81097. angularSpeed: number;
  81098. /**
  81099. * Defines the cell index used by the particle to be rendered from a sprite.
  81100. */
  81101. cellIndex: number;
  81102. /**
  81103. * The information required to support color remapping
  81104. */
  81105. remapData: Vector4;
  81106. /** @hidden */
  81107. _randomCellOffset?: number;
  81108. /** @hidden */
  81109. _initialDirection: Nullable<Vector3>;
  81110. /** @hidden */
  81111. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  81112. /** @hidden */
  81113. _initialStartSpriteCellID: number;
  81114. /** @hidden */
  81115. _initialEndSpriteCellID: number;
  81116. /** @hidden */
  81117. _currentColorGradient: Nullable<ColorGradient>;
  81118. /** @hidden */
  81119. _currentColor1: Color4;
  81120. /** @hidden */
  81121. _currentColor2: Color4;
  81122. /** @hidden */
  81123. _currentSizeGradient: Nullable<FactorGradient>;
  81124. /** @hidden */
  81125. _currentSize1: number;
  81126. /** @hidden */
  81127. _currentSize2: number;
  81128. /** @hidden */
  81129. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  81130. /** @hidden */
  81131. _currentAngularSpeed1: number;
  81132. /** @hidden */
  81133. _currentAngularSpeed2: number;
  81134. /** @hidden */
  81135. _currentVelocityGradient: Nullable<FactorGradient>;
  81136. /** @hidden */
  81137. _currentVelocity1: number;
  81138. /** @hidden */
  81139. _currentVelocity2: number;
  81140. /** @hidden */
  81141. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  81142. /** @hidden */
  81143. _currentLimitVelocity1: number;
  81144. /** @hidden */
  81145. _currentLimitVelocity2: number;
  81146. /** @hidden */
  81147. _currentDragGradient: Nullable<FactorGradient>;
  81148. /** @hidden */
  81149. _currentDrag1: number;
  81150. /** @hidden */
  81151. _currentDrag2: number;
  81152. /** @hidden */
  81153. _randomNoiseCoordinates1: Vector3;
  81154. /** @hidden */
  81155. _randomNoiseCoordinates2: Vector3;
  81156. /**
  81157. * Creates a new instance Particle
  81158. * @param particleSystem the particle system the particle belongs to
  81159. */
  81160. constructor(
  81161. /**
  81162. * The particle system the particle belongs to.
  81163. */
  81164. particleSystem: ParticleSystem);
  81165. private updateCellInfoFromSystem;
  81166. /**
  81167. * Defines how the sprite cell index is updated for the particle
  81168. */
  81169. updateCellIndex(): void;
  81170. /** @hidden */
  81171. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  81172. /** @hidden */
  81173. _inheritParticleInfoToSubEmitters(): void;
  81174. /** @hidden */
  81175. _reset(): void;
  81176. /**
  81177. * Copy the properties of particle to another one.
  81178. * @param other the particle to copy the information to.
  81179. */
  81180. copyTo(other: Particle): void;
  81181. }
  81182. }
  81183. declare module BABYLON {
  81184. /**
  81185. * Particle emitter represents a volume emitting particles.
  81186. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  81187. */
  81188. export interface IParticleEmitterType {
  81189. /**
  81190. * Called by the particle System when the direction is computed for the created particle.
  81191. * @param worldMatrix is the world matrix of the particle system
  81192. * @param directionToUpdate is the direction vector to update with the result
  81193. * @param particle is the particle we are computed the direction for
  81194. */
  81195. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81196. /**
  81197. * Called by the particle System when the position is computed for the created particle.
  81198. * @param worldMatrix is the world matrix of the particle system
  81199. * @param positionToUpdate is the position vector to update with the result
  81200. * @param particle is the particle we are computed the position for
  81201. */
  81202. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81203. /**
  81204. * Clones the current emitter and returns a copy of it
  81205. * @returns the new emitter
  81206. */
  81207. clone(): IParticleEmitterType;
  81208. /**
  81209. * Called by the GPUParticleSystem to setup the update shader
  81210. * @param effect defines the update shader
  81211. */
  81212. applyToShader(effect: Effect): void;
  81213. /**
  81214. * Returns a string to use to update the GPU particles update shader
  81215. * @returns the effect defines string
  81216. */
  81217. getEffectDefines(): string;
  81218. /**
  81219. * Returns a string representing the class name
  81220. * @returns a string containing the class name
  81221. */
  81222. getClassName(): string;
  81223. /**
  81224. * Serializes the particle system to a JSON object.
  81225. * @returns the JSON object
  81226. */
  81227. serialize(): any;
  81228. /**
  81229. * Parse properties from a JSON object
  81230. * @param serializationObject defines the JSON object
  81231. */
  81232. parse(serializationObject: any): void;
  81233. }
  81234. }
  81235. declare module BABYLON {
  81236. /**
  81237. * Particle emitter emitting particles from the inside of a box.
  81238. * It emits the particles randomly between 2 given directions.
  81239. */
  81240. export class BoxParticleEmitter implements IParticleEmitterType {
  81241. /**
  81242. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81243. */
  81244. direction1: Vector3;
  81245. /**
  81246. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81247. */
  81248. direction2: Vector3;
  81249. /**
  81250. * 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.
  81251. */
  81252. minEmitBox: Vector3;
  81253. /**
  81254. * 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.
  81255. */
  81256. maxEmitBox: Vector3;
  81257. /**
  81258. * Creates a new instance BoxParticleEmitter
  81259. */
  81260. constructor();
  81261. /**
  81262. * Called by the particle System when the direction is computed for the created particle.
  81263. * @param worldMatrix is the world matrix of the particle system
  81264. * @param directionToUpdate is the direction vector to update with the result
  81265. * @param particle is the particle we are computed the direction for
  81266. */
  81267. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81268. /**
  81269. * Called by the particle System when the position is computed for the created particle.
  81270. * @param worldMatrix is the world matrix of the particle system
  81271. * @param positionToUpdate is the position vector to update with the result
  81272. * @param particle is the particle we are computed the position for
  81273. */
  81274. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81275. /**
  81276. * Clones the current emitter and returns a copy of it
  81277. * @returns the new emitter
  81278. */
  81279. clone(): BoxParticleEmitter;
  81280. /**
  81281. * Called by the GPUParticleSystem to setup the update shader
  81282. * @param effect defines the update shader
  81283. */
  81284. applyToShader(effect: Effect): void;
  81285. /**
  81286. * Returns a string to use to update the GPU particles update shader
  81287. * @returns a string containng the defines string
  81288. */
  81289. getEffectDefines(): string;
  81290. /**
  81291. * Returns the string "BoxParticleEmitter"
  81292. * @returns a string containing the class name
  81293. */
  81294. getClassName(): string;
  81295. /**
  81296. * Serializes the particle system to a JSON object.
  81297. * @returns the JSON object
  81298. */
  81299. serialize(): any;
  81300. /**
  81301. * Parse properties from a JSON object
  81302. * @param serializationObject defines the JSON object
  81303. */
  81304. parse(serializationObject: any): void;
  81305. }
  81306. }
  81307. declare module BABYLON {
  81308. /**
  81309. * Particle emitter emitting particles from the inside of a cone.
  81310. * It emits the particles alongside the cone volume from the base to the particle.
  81311. * The emission direction might be randomized.
  81312. */
  81313. export class ConeParticleEmitter implements IParticleEmitterType {
  81314. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  81315. directionRandomizer: number;
  81316. private _radius;
  81317. private _angle;
  81318. private _height;
  81319. /**
  81320. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  81321. */
  81322. radiusRange: number;
  81323. /**
  81324. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  81325. */
  81326. heightRange: number;
  81327. /**
  81328. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  81329. */
  81330. emitFromSpawnPointOnly: boolean;
  81331. /**
  81332. * Gets or sets the radius of the emission cone
  81333. */
  81334. radius: number;
  81335. /**
  81336. * Gets or sets the angle of the emission cone
  81337. */
  81338. angle: number;
  81339. private _buildHeight;
  81340. /**
  81341. * Creates a new instance ConeParticleEmitter
  81342. * @param radius the radius of the emission cone (1 by default)
  81343. * @param angle the cone base angle (PI by default)
  81344. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  81345. */
  81346. constructor(radius?: number, angle?: number,
  81347. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  81348. directionRandomizer?: number);
  81349. /**
  81350. * Called by the particle System when the direction is computed for the created particle.
  81351. * @param worldMatrix is the world matrix of the particle system
  81352. * @param directionToUpdate is the direction vector to update with the result
  81353. * @param particle is the particle we are computed the direction for
  81354. */
  81355. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81356. /**
  81357. * Called by the particle System when the position is computed for the created particle.
  81358. * @param worldMatrix is the world matrix of the particle system
  81359. * @param positionToUpdate is the position vector to update with the result
  81360. * @param particle is the particle we are computed the position for
  81361. */
  81362. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81363. /**
  81364. * Clones the current emitter and returns a copy of it
  81365. * @returns the new emitter
  81366. */
  81367. clone(): ConeParticleEmitter;
  81368. /**
  81369. * Called by the GPUParticleSystem to setup the update shader
  81370. * @param effect defines the update shader
  81371. */
  81372. applyToShader(effect: Effect): void;
  81373. /**
  81374. * Returns a string to use to update the GPU particles update shader
  81375. * @returns a string containng the defines string
  81376. */
  81377. getEffectDefines(): string;
  81378. /**
  81379. * Returns the string "ConeParticleEmitter"
  81380. * @returns a string containing the class name
  81381. */
  81382. getClassName(): string;
  81383. /**
  81384. * Serializes the particle system to a JSON object.
  81385. * @returns the JSON object
  81386. */
  81387. serialize(): any;
  81388. /**
  81389. * Parse properties from a JSON object
  81390. * @param serializationObject defines the JSON object
  81391. */
  81392. parse(serializationObject: any): void;
  81393. }
  81394. }
  81395. declare module BABYLON {
  81396. /**
  81397. * Particle emitter emitting particles from the inside of a cylinder.
  81398. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  81399. */
  81400. export class CylinderParticleEmitter implements IParticleEmitterType {
  81401. /**
  81402. * The radius of the emission cylinder.
  81403. */
  81404. radius: number;
  81405. /**
  81406. * The height of the emission cylinder.
  81407. */
  81408. height: number;
  81409. /**
  81410. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81411. */
  81412. radiusRange: number;
  81413. /**
  81414. * How much to randomize the particle direction [0-1].
  81415. */
  81416. directionRandomizer: number;
  81417. /**
  81418. * Creates a new instance CylinderParticleEmitter
  81419. * @param radius the radius of the emission cylinder (1 by default)
  81420. * @param height the height of the emission cylinder (1 by default)
  81421. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81422. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  81423. */
  81424. constructor(
  81425. /**
  81426. * The radius of the emission cylinder.
  81427. */
  81428. radius?: number,
  81429. /**
  81430. * The height of the emission cylinder.
  81431. */
  81432. height?: number,
  81433. /**
  81434. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81435. */
  81436. radiusRange?: number,
  81437. /**
  81438. * How much to randomize the particle direction [0-1].
  81439. */
  81440. directionRandomizer?: number);
  81441. /**
  81442. * Called by the particle System when the direction is computed for the created particle.
  81443. * @param worldMatrix is the world matrix of the particle system
  81444. * @param directionToUpdate is the direction vector to update with the result
  81445. * @param particle is the particle we are computed the direction for
  81446. */
  81447. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81448. /**
  81449. * Called by the particle System when the position is computed for the created particle.
  81450. * @param worldMatrix is the world matrix of the particle system
  81451. * @param positionToUpdate is the position vector to update with the result
  81452. * @param particle is the particle we are computed the position for
  81453. */
  81454. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81455. /**
  81456. * Clones the current emitter and returns a copy of it
  81457. * @returns the new emitter
  81458. */
  81459. clone(): CylinderParticleEmitter;
  81460. /**
  81461. * Called by the GPUParticleSystem to setup the update shader
  81462. * @param effect defines the update shader
  81463. */
  81464. applyToShader(effect: Effect): void;
  81465. /**
  81466. * Returns a string to use to update the GPU particles update shader
  81467. * @returns a string containng the defines string
  81468. */
  81469. getEffectDefines(): string;
  81470. /**
  81471. * Returns the string "CylinderParticleEmitter"
  81472. * @returns a string containing the class name
  81473. */
  81474. getClassName(): string;
  81475. /**
  81476. * Serializes the particle system to a JSON object.
  81477. * @returns the JSON object
  81478. */
  81479. serialize(): any;
  81480. /**
  81481. * Parse properties from a JSON object
  81482. * @param serializationObject defines the JSON object
  81483. */
  81484. parse(serializationObject: any): void;
  81485. }
  81486. /**
  81487. * Particle emitter emitting particles from the inside of a cylinder.
  81488. * It emits the particles randomly between two vectors.
  81489. */
  81490. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  81491. /**
  81492. * The min limit of the emission direction.
  81493. */
  81494. direction1: Vector3;
  81495. /**
  81496. * The max limit of the emission direction.
  81497. */
  81498. direction2: Vector3;
  81499. /**
  81500. * Creates a new instance CylinderDirectedParticleEmitter
  81501. * @param radius the radius of the emission cylinder (1 by default)
  81502. * @param height the height of the emission cylinder (1 by default)
  81503. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81504. * @param direction1 the min limit of the emission direction (up vector by default)
  81505. * @param direction2 the max limit of the emission direction (up vector by default)
  81506. */
  81507. constructor(radius?: number, height?: number, radiusRange?: number,
  81508. /**
  81509. * The min limit of the emission direction.
  81510. */
  81511. direction1?: Vector3,
  81512. /**
  81513. * The max limit of the emission direction.
  81514. */
  81515. direction2?: Vector3);
  81516. /**
  81517. * Called by the particle System when the direction is computed for the created particle.
  81518. * @param worldMatrix is the world matrix of the particle system
  81519. * @param directionToUpdate is the direction vector to update with the result
  81520. * @param particle is the particle we are computed the direction for
  81521. */
  81522. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81523. /**
  81524. * Clones the current emitter and returns a copy of it
  81525. * @returns the new emitter
  81526. */
  81527. clone(): CylinderDirectedParticleEmitter;
  81528. /**
  81529. * Called by the GPUParticleSystem to setup the update shader
  81530. * @param effect defines the update shader
  81531. */
  81532. applyToShader(effect: Effect): void;
  81533. /**
  81534. * Returns a string to use to update the GPU particles update shader
  81535. * @returns a string containng the defines string
  81536. */
  81537. getEffectDefines(): string;
  81538. /**
  81539. * Returns the string "CylinderDirectedParticleEmitter"
  81540. * @returns a string containing the class name
  81541. */
  81542. getClassName(): string;
  81543. /**
  81544. * Serializes the particle system to a JSON object.
  81545. * @returns the JSON object
  81546. */
  81547. serialize(): any;
  81548. /**
  81549. * Parse properties from a JSON object
  81550. * @param serializationObject defines the JSON object
  81551. */
  81552. parse(serializationObject: any): void;
  81553. }
  81554. }
  81555. declare module BABYLON {
  81556. /**
  81557. * Particle emitter emitting particles from the inside of a hemisphere.
  81558. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  81559. */
  81560. export class HemisphericParticleEmitter implements IParticleEmitterType {
  81561. /**
  81562. * The radius of the emission hemisphere.
  81563. */
  81564. radius: number;
  81565. /**
  81566. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81567. */
  81568. radiusRange: number;
  81569. /**
  81570. * How much to randomize the particle direction [0-1].
  81571. */
  81572. directionRandomizer: number;
  81573. /**
  81574. * Creates a new instance HemisphericParticleEmitter
  81575. * @param radius the radius of the emission hemisphere (1 by default)
  81576. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81577. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  81578. */
  81579. constructor(
  81580. /**
  81581. * The radius of the emission hemisphere.
  81582. */
  81583. radius?: number,
  81584. /**
  81585. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81586. */
  81587. radiusRange?: number,
  81588. /**
  81589. * How much to randomize the particle direction [0-1].
  81590. */
  81591. directionRandomizer?: number);
  81592. /**
  81593. * Called by the particle System when the direction is computed for the created particle.
  81594. * @param worldMatrix is the world matrix of the particle system
  81595. * @param directionToUpdate is the direction vector to update with the result
  81596. * @param particle is the particle we are computed the direction for
  81597. */
  81598. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81599. /**
  81600. * Called by the particle System when the position is computed for the created particle.
  81601. * @param worldMatrix is the world matrix of the particle system
  81602. * @param positionToUpdate is the position vector to update with the result
  81603. * @param particle is the particle we are computed the position for
  81604. */
  81605. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81606. /**
  81607. * Clones the current emitter and returns a copy of it
  81608. * @returns the new emitter
  81609. */
  81610. clone(): HemisphericParticleEmitter;
  81611. /**
  81612. * Called by the GPUParticleSystem to setup the update shader
  81613. * @param effect defines the update shader
  81614. */
  81615. applyToShader(effect: Effect): void;
  81616. /**
  81617. * Returns a string to use to update the GPU particles update shader
  81618. * @returns a string containng the defines string
  81619. */
  81620. getEffectDefines(): string;
  81621. /**
  81622. * Returns the string "HemisphericParticleEmitter"
  81623. * @returns a string containing the class name
  81624. */
  81625. getClassName(): string;
  81626. /**
  81627. * Serializes the particle system to a JSON object.
  81628. * @returns the JSON object
  81629. */
  81630. serialize(): any;
  81631. /**
  81632. * Parse properties from a JSON object
  81633. * @param serializationObject defines the JSON object
  81634. */
  81635. parse(serializationObject: any): void;
  81636. }
  81637. }
  81638. declare module BABYLON {
  81639. /**
  81640. * Particle emitter emitting particles from a point.
  81641. * It emits the particles randomly between 2 given directions.
  81642. */
  81643. export class PointParticleEmitter implements IParticleEmitterType {
  81644. /**
  81645. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81646. */
  81647. direction1: Vector3;
  81648. /**
  81649. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81650. */
  81651. direction2: Vector3;
  81652. /**
  81653. * Creates a new instance PointParticleEmitter
  81654. */
  81655. constructor();
  81656. /**
  81657. * Called by the particle System when the direction is computed for the created particle.
  81658. * @param worldMatrix is the world matrix of the particle system
  81659. * @param directionToUpdate is the direction vector to update with the result
  81660. * @param particle is the particle we are computed the direction for
  81661. */
  81662. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81663. /**
  81664. * Called by the particle System when the position is computed for the created particle.
  81665. * @param worldMatrix is the world matrix of the particle system
  81666. * @param positionToUpdate is the position vector to update with the result
  81667. * @param particle is the particle we are computed the position for
  81668. */
  81669. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81670. /**
  81671. * Clones the current emitter and returns a copy of it
  81672. * @returns the new emitter
  81673. */
  81674. clone(): PointParticleEmitter;
  81675. /**
  81676. * Called by the GPUParticleSystem to setup the update shader
  81677. * @param effect defines the update shader
  81678. */
  81679. applyToShader(effect: Effect): void;
  81680. /**
  81681. * Returns a string to use to update the GPU particles update shader
  81682. * @returns a string containng the defines string
  81683. */
  81684. getEffectDefines(): string;
  81685. /**
  81686. * Returns the string "PointParticleEmitter"
  81687. * @returns a string containing the class name
  81688. */
  81689. getClassName(): string;
  81690. /**
  81691. * Serializes the particle system to a JSON object.
  81692. * @returns the JSON object
  81693. */
  81694. serialize(): any;
  81695. /**
  81696. * Parse properties from a JSON object
  81697. * @param serializationObject defines the JSON object
  81698. */
  81699. parse(serializationObject: any): void;
  81700. }
  81701. }
  81702. declare module BABYLON {
  81703. /**
  81704. * Particle emitter emitting particles from the inside of a sphere.
  81705. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  81706. */
  81707. export class SphereParticleEmitter implements IParticleEmitterType {
  81708. /**
  81709. * The radius of the emission sphere.
  81710. */
  81711. radius: number;
  81712. /**
  81713. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81714. */
  81715. radiusRange: number;
  81716. /**
  81717. * How much to randomize the particle direction [0-1].
  81718. */
  81719. directionRandomizer: number;
  81720. /**
  81721. * Creates a new instance SphereParticleEmitter
  81722. * @param radius the radius of the emission sphere (1 by default)
  81723. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81724. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  81725. */
  81726. constructor(
  81727. /**
  81728. * The radius of the emission sphere.
  81729. */
  81730. radius?: number,
  81731. /**
  81732. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81733. */
  81734. radiusRange?: number,
  81735. /**
  81736. * How much to randomize the particle direction [0-1].
  81737. */
  81738. directionRandomizer?: number);
  81739. /**
  81740. * Called by the particle System when the direction is computed for the created particle.
  81741. * @param worldMatrix is the world matrix of the particle system
  81742. * @param directionToUpdate is the direction vector to update with the result
  81743. * @param particle is the particle we are computed the direction for
  81744. */
  81745. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81746. /**
  81747. * Called by the particle System when the position is computed for the created particle.
  81748. * @param worldMatrix is the world matrix of the particle system
  81749. * @param positionToUpdate is the position vector to update with the result
  81750. * @param particle is the particle we are computed the position for
  81751. */
  81752. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81753. /**
  81754. * Clones the current emitter and returns a copy of it
  81755. * @returns the new emitter
  81756. */
  81757. clone(): SphereParticleEmitter;
  81758. /**
  81759. * Called by the GPUParticleSystem to setup the update shader
  81760. * @param effect defines the update shader
  81761. */
  81762. applyToShader(effect: Effect): void;
  81763. /**
  81764. * Returns a string to use to update the GPU particles update shader
  81765. * @returns a string containng the defines string
  81766. */
  81767. getEffectDefines(): string;
  81768. /**
  81769. * Returns the string "SphereParticleEmitter"
  81770. * @returns a string containing the class name
  81771. */
  81772. getClassName(): string;
  81773. /**
  81774. * Serializes the particle system to a JSON object.
  81775. * @returns the JSON object
  81776. */
  81777. serialize(): any;
  81778. /**
  81779. * Parse properties from a JSON object
  81780. * @param serializationObject defines the JSON object
  81781. */
  81782. parse(serializationObject: any): void;
  81783. }
  81784. /**
  81785. * Particle emitter emitting particles from the inside of a sphere.
  81786. * It emits the particles randomly between two vectors.
  81787. */
  81788. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  81789. /**
  81790. * The min limit of the emission direction.
  81791. */
  81792. direction1: Vector3;
  81793. /**
  81794. * The max limit of the emission direction.
  81795. */
  81796. direction2: Vector3;
  81797. /**
  81798. * Creates a new instance SphereDirectedParticleEmitter
  81799. * @param radius the radius of the emission sphere (1 by default)
  81800. * @param direction1 the min limit of the emission direction (up vector by default)
  81801. * @param direction2 the max limit of the emission direction (up vector by default)
  81802. */
  81803. constructor(radius?: number,
  81804. /**
  81805. * The min limit of the emission direction.
  81806. */
  81807. direction1?: Vector3,
  81808. /**
  81809. * The max limit of the emission direction.
  81810. */
  81811. direction2?: Vector3);
  81812. /**
  81813. * Called by the particle System when the direction is computed for the created particle.
  81814. * @param worldMatrix is the world matrix of the particle system
  81815. * @param directionToUpdate is the direction vector to update with the result
  81816. * @param particle is the particle we are computed the direction for
  81817. */
  81818. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81819. /**
  81820. * Clones the current emitter and returns a copy of it
  81821. * @returns the new emitter
  81822. */
  81823. clone(): SphereDirectedParticleEmitter;
  81824. /**
  81825. * Called by the GPUParticleSystem to setup the update shader
  81826. * @param effect defines the update shader
  81827. */
  81828. applyToShader(effect: Effect): void;
  81829. /**
  81830. * Returns a string to use to update the GPU particles update shader
  81831. * @returns a string containng the defines string
  81832. */
  81833. getEffectDefines(): string;
  81834. /**
  81835. * Returns the string "SphereDirectedParticleEmitter"
  81836. * @returns a string containing the class name
  81837. */
  81838. getClassName(): string;
  81839. /**
  81840. * Serializes the particle system to a JSON object.
  81841. * @returns the JSON object
  81842. */
  81843. serialize(): any;
  81844. /**
  81845. * Parse properties from a JSON object
  81846. * @param serializationObject defines the JSON object
  81847. */
  81848. parse(serializationObject: any): void;
  81849. }
  81850. }
  81851. declare module BABYLON {
  81852. /**
  81853. * Interface representing a particle system in Babylon.js.
  81854. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  81855. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  81856. */
  81857. export interface IParticleSystem {
  81858. /**
  81859. * List of animations used by the particle system.
  81860. */
  81861. animations: Animation[];
  81862. /**
  81863. * The id of the Particle system.
  81864. */
  81865. id: string;
  81866. /**
  81867. * The name of the Particle system.
  81868. */
  81869. name: string;
  81870. /**
  81871. * The emitter represents the Mesh or position we are attaching the particle system to.
  81872. */
  81873. emitter: Nullable<AbstractMesh | Vector3>;
  81874. /**
  81875. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  81876. */
  81877. isBillboardBased: boolean;
  81878. /**
  81879. * The rendering group used by the Particle system to chose when to render.
  81880. */
  81881. renderingGroupId: number;
  81882. /**
  81883. * The layer mask we are rendering the particles through.
  81884. */
  81885. layerMask: number;
  81886. /**
  81887. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  81888. */
  81889. updateSpeed: number;
  81890. /**
  81891. * The amount of time the particle system is running (depends of the overall update speed).
  81892. */
  81893. targetStopDuration: number;
  81894. /**
  81895. * The texture used to render each particle. (this can be a spritesheet)
  81896. */
  81897. particleTexture: Nullable<Texture>;
  81898. /**
  81899. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  81900. */
  81901. blendMode: number;
  81902. /**
  81903. * Minimum life time of emitting particles.
  81904. */
  81905. minLifeTime: number;
  81906. /**
  81907. * Maximum life time of emitting particles.
  81908. */
  81909. maxLifeTime: number;
  81910. /**
  81911. * Minimum Size of emitting particles.
  81912. */
  81913. minSize: number;
  81914. /**
  81915. * Maximum Size of emitting particles.
  81916. */
  81917. maxSize: number;
  81918. /**
  81919. * Minimum scale of emitting particles on X axis.
  81920. */
  81921. minScaleX: number;
  81922. /**
  81923. * Maximum scale of emitting particles on X axis.
  81924. */
  81925. maxScaleX: number;
  81926. /**
  81927. * Minimum scale of emitting particles on Y axis.
  81928. */
  81929. minScaleY: number;
  81930. /**
  81931. * Maximum scale of emitting particles on Y axis.
  81932. */
  81933. maxScaleY: number;
  81934. /**
  81935. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  81936. */
  81937. color1: Color4;
  81938. /**
  81939. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  81940. */
  81941. color2: Color4;
  81942. /**
  81943. * Color the particle will have at the end of its lifetime.
  81944. */
  81945. colorDead: Color4;
  81946. /**
  81947. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  81948. */
  81949. emitRate: number;
  81950. /**
  81951. * You can use gravity if you want to give an orientation to your particles.
  81952. */
  81953. gravity: Vector3;
  81954. /**
  81955. * Minimum power of emitting particles.
  81956. */
  81957. minEmitPower: number;
  81958. /**
  81959. * Maximum power of emitting particles.
  81960. */
  81961. maxEmitPower: number;
  81962. /**
  81963. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  81964. */
  81965. minAngularSpeed: number;
  81966. /**
  81967. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  81968. */
  81969. maxAngularSpeed: number;
  81970. /**
  81971. * Gets or sets the minimal initial rotation in radians.
  81972. */
  81973. minInitialRotation: number;
  81974. /**
  81975. * Gets or sets the maximal initial rotation in radians.
  81976. */
  81977. maxInitialRotation: number;
  81978. /**
  81979. * The particle emitter type defines the emitter used by the particle system.
  81980. * It can be for example box, sphere, or cone...
  81981. */
  81982. particleEmitterType: Nullable<IParticleEmitterType>;
  81983. /**
  81984. * Defines the delay in milliseconds before starting the system (0 by default)
  81985. */
  81986. startDelay: number;
  81987. /**
  81988. * 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
  81989. */
  81990. preWarmCycles: number;
  81991. /**
  81992. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  81993. */
  81994. preWarmStepOffset: number;
  81995. /**
  81996. * 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)
  81997. */
  81998. spriteCellChangeSpeed: number;
  81999. /**
  82000. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  82001. */
  82002. startSpriteCellID: number;
  82003. /**
  82004. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  82005. */
  82006. endSpriteCellID: number;
  82007. /**
  82008. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  82009. */
  82010. spriteCellWidth: number;
  82011. /**
  82012. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  82013. */
  82014. spriteCellHeight: number;
  82015. /**
  82016. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  82017. */
  82018. spriteRandomStartCell: boolean;
  82019. /**
  82020. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  82021. */
  82022. isAnimationSheetEnabled: boolean;
  82023. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  82024. translationPivot: Vector2;
  82025. /**
  82026. * Gets or sets a texture used to add random noise to particle positions
  82027. */
  82028. noiseTexture: Nullable<BaseTexture>;
  82029. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  82030. noiseStrength: Vector3;
  82031. /**
  82032. * Gets or sets the billboard mode to use when isBillboardBased = true.
  82033. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  82034. */
  82035. billboardMode: number;
  82036. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  82037. limitVelocityDamping: number;
  82038. /**
  82039. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  82040. */
  82041. beginAnimationOnStart: boolean;
  82042. /**
  82043. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  82044. */
  82045. beginAnimationFrom: number;
  82046. /**
  82047. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  82048. */
  82049. beginAnimationTo: number;
  82050. /**
  82051. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  82052. */
  82053. beginAnimationLoop: boolean;
  82054. /**
  82055. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  82056. */
  82057. disposeOnStop: boolean;
  82058. /**
  82059. * Gets the maximum number of particles active at the same time.
  82060. * @returns The max number of active particles.
  82061. */
  82062. getCapacity(): number;
  82063. /**
  82064. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82065. * @returns True if it has been started, otherwise false.
  82066. */
  82067. isStarted(): boolean;
  82068. /**
  82069. * Animates the particle system for this frame.
  82070. */
  82071. animate(): void;
  82072. /**
  82073. * Renders the particle system in its current state.
  82074. * @returns the current number of particles
  82075. */
  82076. render(): number;
  82077. /**
  82078. * Dispose the particle system and frees its associated resources.
  82079. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82080. */
  82081. dispose(disposeTexture?: boolean): void;
  82082. /**
  82083. * Clones the particle system.
  82084. * @param name The name of the cloned object
  82085. * @param newEmitter The new emitter to use
  82086. * @returns the cloned particle system
  82087. */
  82088. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  82089. /**
  82090. * Serializes the particle system to a JSON object.
  82091. * @returns the JSON object
  82092. */
  82093. serialize(): any;
  82094. /**
  82095. * Rebuild the particle system
  82096. */
  82097. rebuild(): void;
  82098. /**
  82099. * Starts the particle system and begins to emit
  82100. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  82101. */
  82102. start(delay?: number): void;
  82103. /**
  82104. * Stops the particle system.
  82105. */
  82106. stop(): void;
  82107. /**
  82108. * Remove all active particles
  82109. */
  82110. reset(): void;
  82111. /**
  82112. * Is this system ready to be used/rendered
  82113. * @return true if the system is ready
  82114. */
  82115. isReady(): boolean;
  82116. /**
  82117. * Adds a new color gradient
  82118. * @param gradient defines the gradient to use (between 0 and 1)
  82119. * @param color1 defines the color to affect to the specified gradient
  82120. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82121. * @returns the current particle system
  82122. */
  82123. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82124. /**
  82125. * Remove a specific color gradient
  82126. * @param gradient defines the gradient to remove
  82127. * @returns the current particle system
  82128. */
  82129. removeColorGradient(gradient: number): IParticleSystem;
  82130. /**
  82131. * Adds a new size gradient
  82132. * @param gradient defines the gradient to use (between 0 and 1)
  82133. * @param factor defines the size factor to affect to the specified gradient
  82134. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82135. * @returns the current particle system
  82136. */
  82137. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82138. /**
  82139. * Remove a specific size gradient
  82140. * @param gradient defines the gradient to remove
  82141. * @returns the current particle system
  82142. */
  82143. removeSizeGradient(gradient: number): IParticleSystem;
  82144. /**
  82145. * Gets the current list of color gradients.
  82146. * You must use addColorGradient and removeColorGradient to udpate this list
  82147. * @returns the list of color gradients
  82148. */
  82149. getColorGradients(): Nullable<Array<ColorGradient>>;
  82150. /**
  82151. * Gets the current list of size gradients.
  82152. * You must use addSizeGradient and removeSizeGradient to udpate this list
  82153. * @returns the list of size gradients
  82154. */
  82155. getSizeGradients(): Nullable<Array<FactorGradient>>;
  82156. /**
  82157. * Gets the current list of angular speed gradients.
  82158. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  82159. * @returns the list of angular speed gradients
  82160. */
  82161. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  82162. /**
  82163. * Adds a new angular speed gradient
  82164. * @param gradient defines the gradient to use (between 0 and 1)
  82165. * @param factor defines the angular speed to affect to the specified gradient
  82166. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82167. * @returns the current particle system
  82168. */
  82169. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82170. /**
  82171. * Remove a specific angular speed gradient
  82172. * @param gradient defines the gradient to remove
  82173. * @returns the current particle system
  82174. */
  82175. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82176. /**
  82177. * Gets the current list of velocity gradients.
  82178. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  82179. * @returns the list of velocity gradients
  82180. */
  82181. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  82182. /**
  82183. * Adds a new velocity gradient
  82184. * @param gradient defines the gradient to use (between 0 and 1)
  82185. * @param factor defines the velocity to affect to the specified gradient
  82186. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82187. * @returns the current particle system
  82188. */
  82189. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82190. /**
  82191. * Remove a specific velocity gradient
  82192. * @param gradient defines the gradient to remove
  82193. * @returns the current particle system
  82194. */
  82195. removeVelocityGradient(gradient: number): IParticleSystem;
  82196. /**
  82197. * Gets the current list of limit velocity gradients.
  82198. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  82199. * @returns the list of limit velocity gradients
  82200. */
  82201. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  82202. /**
  82203. * Adds a new limit velocity gradient
  82204. * @param gradient defines the gradient to use (between 0 and 1)
  82205. * @param factor defines the limit velocity to affect to the specified gradient
  82206. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82207. * @returns the current particle system
  82208. */
  82209. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82210. /**
  82211. * Remove a specific limit velocity gradient
  82212. * @param gradient defines the gradient to remove
  82213. * @returns the current particle system
  82214. */
  82215. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82216. /**
  82217. * Adds a new drag gradient
  82218. * @param gradient defines the gradient to use (between 0 and 1)
  82219. * @param factor defines the drag to affect to the specified gradient
  82220. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82221. * @returns the current particle system
  82222. */
  82223. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82224. /**
  82225. * Remove a specific drag gradient
  82226. * @param gradient defines the gradient to remove
  82227. * @returns the current particle system
  82228. */
  82229. removeDragGradient(gradient: number): IParticleSystem;
  82230. /**
  82231. * Gets the current list of drag gradients.
  82232. * You must use addDragGradient and removeDragGradient to udpate this list
  82233. * @returns the list of drag gradients
  82234. */
  82235. getDragGradients(): Nullable<Array<FactorGradient>>;
  82236. /**
  82237. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82238. * @param gradient defines the gradient to use (between 0 and 1)
  82239. * @param factor defines the emit rate to affect to the specified gradient
  82240. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82241. * @returns the current particle system
  82242. */
  82243. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82244. /**
  82245. * Remove a specific emit rate gradient
  82246. * @param gradient defines the gradient to remove
  82247. * @returns the current particle system
  82248. */
  82249. removeEmitRateGradient(gradient: number): IParticleSystem;
  82250. /**
  82251. * Gets the current list of emit rate gradients.
  82252. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  82253. * @returns the list of emit rate gradients
  82254. */
  82255. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  82256. /**
  82257. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82258. * @param gradient defines the gradient to use (between 0 and 1)
  82259. * @param factor defines the start size to affect to the specified gradient
  82260. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82261. * @returns the current particle system
  82262. */
  82263. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82264. /**
  82265. * Remove a specific start size gradient
  82266. * @param gradient defines the gradient to remove
  82267. * @returns the current particle system
  82268. */
  82269. removeStartSizeGradient(gradient: number): IParticleSystem;
  82270. /**
  82271. * Gets the current list of start size gradients.
  82272. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  82273. * @returns the list of start size gradients
  82274. */
  82275. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  82276. /**
  82277. * Adds a new life time gradient
  82278. * @param gradient defines the gradient to use (between 0 and 1)
  82279. * @param factor defines the life time factor to affect to the specified gradient
  82280. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82281. * @returns the current particle system
  82282. */
  82283. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82284. /**
  82285. * Remove a specific life time gradient
  82286. * @param gradient defines the gradient to remove
  82287. * @returns the current particle system
  82288. */
  82289. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82290. /**
  82291. * Gets the current list of life time gradients.
  82292. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  82293. * @returns the list of life time gradients
  82294. */
  82295. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  82296. /**
  82297. * Gets the current list of color gradients.
  82298. * You must use addColorGradient and removeColorGradient to udpate this list
  82299. * @returns the list of color gradients
  82300. */
  82301. getColorGradients(): Nullable<Array<ColorGradient>>;
  82302. /**
  82303. * Adds a new ramp gradient used to remap particle colors
  82304. * @param gradient defines the gradient to use (between 0 and 1)
  82305. * @param color defines the color to affect to the specified gradient
  82306. * @returns the current particle system
  82307. */
  82308. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  82309. /**
  82310. * Gets the current list of ramp gradients.
  82311. * You must use addRampGradient and removeRampGradient to udpate this list
  82312. * @returns the list of ramp gradients
  82313. */
  82314. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82315. /** Gets or sets a boolean indicating that ramp gradients must be used
  82316. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82317. */
  82318. useRampGradients: boolean;
  82319. /**
  82320. * Adds a new color remap gradient
  82321. * @param gradient defines the gradient to use (between 0 and 1)
  82322. * @param min defines the color remap minimal range
  82323. * @param max defines the color remap maximal range
  82324. * @returns the current particle system
  82325. */
  82326. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82327. /**
  82328. * Gets the current list of color remap gradients.
  82329. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  82330. * @returns the list of color remap gradients
  82331. */
  82332. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  82333. /**
  82334. * Adds a new alpha remap gradient
  82335. * @param gradient defines the gradient to use (between 0 and 1)
  82336. * @param min defines the alpha remap minimal range
  82337. * @param max defines the alpha remap maximal range
  82338. * @returns the current particle system
  82339. */
  82340. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82341. /**
  82342. * Gets the current list of alpha remap gradients.
  82343. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  82344. * @returns the list of alpha remap gradients
  82345. */
  82346. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  82347. /**
  82348. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82349. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82350. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82351. * @returns the emitter
  82352. */
  82353. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82354. /**
  82355. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82356. * @param radius The radius of the hemisphere to emit from
  82357. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82358. * @returns the emitter
  82359. */
  82360. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  82361. /**
  82362. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82363. * @param radius The radius of the sphere to emit from
  82364. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82365. * @returns the emitter
  82366. */
  82367. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  82368. /**
  82369. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82370. * @param radius The radius of the sphere to emit from
  82371. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82372. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82373. * @returns the emitter
  82374. */
  82375. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  82376. /**
  82377. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82378. * @param radius The radius of the emission cylinder
  82379. * @param height The height of the emission cylinder
  82380. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82381. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82382. * @returns the emitter
  82383. */
  82384. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  82385. /**
  82386. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82387. * @param radius The radius of the cylinder to emit from
  82388. * @param height The height of the emission cylinder
  82389. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82390. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82391. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82392. * @returns the emitter
  82393. */
  82394. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  82395. /**
  82396. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82397. * @param radius The radius of the cone to emit from
  82398. * @param angle The base angle of the cone
  82399. * @returns the emitter
  82400. */
  82401. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  82402. /**
  82403. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82404. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82405. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82406. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82407. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82408. * @returns the emitter
  82409. */
  82410. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82411. /**
  82412. * Get hosting scene
  82413. * @returns the scene
  82414. */
  82415. getScene(): Scene;
  82416. }
  82417. }
  82418. declare module BABYLON {
  82419. /**
  82420. * Creates an instance based on a source mesh.
  82421. */
  82422. export class InstancedMesh extends AbstractMesh {
  82423. private _sourceMesh;
  82424. private _currentLOD;
  82425. /** @hidden */
  82426. _indexInSourceMeshInstanceArray: number;
  82427. constructor(name: string, source: Mesh);
  82428. /**
  82429. * Returns the string "InstancedMesh".
  82430. */
  82431. getClassName(): string;
  82432. /** Gets the list of lights affecting that mesh */
  82433. readonly lightSources: Light[];
  82434. _resyncLightSources(): void;
  82435. _resyncLighSource(light: Light): void;
  82436. _removeLightSource(light: Light): void;
  82437. /**
  82438. * If the source mesh receives shadows
  82439. */
  82440. readonly receiveShadows: boolean;
  82441. /**
  82442. * The material of the source mesh
  82443. */
  82444. readonly material: Nullable<Material>;
  82445. /**
  82446. * Visibility of the source mesh
  82447. */
  82448. readonly visibility: number;
  82449. /**
  82450. * Skeleton of the source mesh
  82451. */
  82452. readonly skeleton: Nullable<Skeleton>;
  82453. /**
  82454. * Rendering ground id of the source mesh
  82455. */
  82456. renderingGroupId: number;
  82457. /**
  82458. * Returns the total number of vertices (integer).
  82459. */
  82460. getTotalVertices(): number;
  82461. /**
  82462. * Returns a positive integer : the total number of indices in this mesh geometry.
  82463. * @returns the numner of indices or zero if the mesh has no geometry.
  82464. */
  82465. getTotalIndices(): number;
  82466. /**
  82467. * The source mesh of the instance
  82468. */
  82469. readonly sourceMesh: Mesh;
  82470. /**
  82471. * Is this node ready to be used/rendered
  82472. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  82473. * @return {boolean} is it ready
  82474. */
  82475. isReady(completeCheck?: boolean): boolean;
  82476. /**
  82477. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  82478. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  82479. * @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.
  82480. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  82481. */
  82482. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  82483. /**
  82484. * Sets the vertex data of the mesh geometry for the requested `kind`.
  82485. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  82486. * The `data` are either a numeric array either a Float32Array.
  82487. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  82488. * 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).
  82489. * Note that a new underlying VertexBuffer object is created each call.
  82490. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  82491. *
  82492. * Possible `kind` values :
  82493. * - VertexBuffer.PositionKind
  82494. * - VertexBuffer.UVKind
  82495. * - VertexBuffer.UV2Kind
  82496. * - VertexBuffer.UV3Kind
  82497. * - VertexBuffer.UV4Kind
  82498. * - VertexBuffer.UV5Kind
  82499. * - VertexBuffer.UV6Kind
  82500. * - VertexBuffer.ColorKind
  82501. * - VertexBuffer.MatricesIndicesKind
  82502. * - VertexBuffer.MatricesIndicesExtraKind
  82503. * - VertexBuffer.MatricesWeightsKind
  82504. * - VertexBuffer.MatricesWeightsExtraKind
  82505. *
  82506. * Returns the Mesh.
  82507. */
  82508. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  82509. /**
  82510. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  82511. * If the mesh has no geometry, it is simply returned as it is.
  82512. * The `data` are either a numeric array either a Float32Array.
  82513. * No new underlying VertexBuffer object is created.
  82514. * 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.
  82515. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  82516. *
  82517. * Possible `kind` values :
  82518. * - VertexBuffer.PositionKind
  82519. * - VertexBuffer.UVKind
  82520. * - VertexBuffer.UV2Kind
  82521. * - VertexBuffer.UV3Kind
  82522. * - VertexBuffer.UV4Kind
  82523. * - VertexBuffer.UV5Kind
  82524. * - VertexBuffer.UV6Kind
  82525. * - VertexBuffer.ColorKind
  82526. * - VertexBuffer.MatricesIndicesKind
  82527. * - VertexBuffer.MatricesIndicesExtraKind
  82528. * - VertexBuffer.MatricesWeightsKind
  82529. * - VertexBuffer.MatricesWeightsExtraKind
  82530. *
  82531. * Returns the Mesh.
  82532. */
  82533. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  82534. /**
  82535. * Sets the mesh indices.
  82536. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  82537. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  82538. * This method creates a new index buffer each call.
  82539. * Returns the Mesh.
  82540. */
  82541. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  82542. /**
  82543. * Boolean : True if the mesh owns the requested kind of data.
  82544. */
  82545. isVerticesDataPresent(kind: string): boolean;
  82546. /**
  82547. * Returns an array of indices (IndicesArray).
  82548. */
  82549. getIndices(): Nullable<IndicesArray>;
  82550. readonly _positions: Nullable<Vector3[]>;
  82551. /**
  82552. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  82553. * This means the mesh underlying bounding box and sphere are recomputed.
  82554. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  82555. * @returns the current mesh
  82556. */
  82557. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  82558. /** @hidden */
  82559. _preActivate(): InstancedMesh;
  82560. /** @hidden */
  82561. _activate(renderId: number, intermediateRendering: boolean): boolean;
  82562. /** @hidden */
  82563. _postActivate(): void;
  82564. getWorldMatrix(): Matrix;
  82565. readonly isAnInstance: boolean;
  82566. /**
  82567. * Returns the current associated LOD AbstractMesh.
  82568. */
  82569. getLOD(camera: Camera): AbstractMesh;
  82570. /** @hidden */
  82571. _syncSubMeshes(): InstancedMesh;
  82572. /** @hidden */
  82573. _generatePointsArray(): boolean;
  82574. /**
  82575. * Creates a new InstancedMesh from the current mesh.
  82576. * - name (string) : the cloned mesh name
  82577. * - newParent (optional Node) : the optional Node to parent the clone to.
  82578. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  82579. *
  82580. * Returns the clone.
  82581. */
  82582. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  82583. /**
  82584. * Disposes the InstancedMesh.
  82585. * Returns nothing.
  82586. */
  82587. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82588. }
  82589. }
  82590. declare module BABYLON {
  82591. /**
  82592. * Defines the options associated with the creation of a shader material.
  82593. */
  82594. export interface IShaderMaterialOptions {
  82595. /**
  82596. * Does the material work in alpha blend mode
  82597. */
  82598. needAlphaBlending: boolean;
  82599. /**
  82600. * Does the material work in alpha test mode
  82601. */
  82602. needAlphaTesting: boolean;
  82603. /**
  82604. * The list of attribute names used in the shader
  82605. */
  82606. attributes: string[];
  82607. /**
  82608. * The list of unifrom names used in the shader
  82609. */
  82610. uniforms: string[];
  82611. /**
  82612. * The list of UBO names used in the shader
  82613. */
  82614. uniformBuffers: string[];
  82615. /**
  82616. * The list of sampler names used in the shader
  82617. */
  82618. samplers: string[];
  82619. /**
  82620. * The list of defines used in the shader
  82621. */
  82622. defines: string[];
  82623. }
  82624. /**
  82625. * 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.
  82626. *
  82627. * This returned material effects how the mesh will look based on the code in the shaders.
  82628. *
  82629. * @see http://doc.babylonjs.com/how_to/shader_material
  82630. */
  82631. export class ShaderMaterial extends Material {
  82632. private _shaderPath;
  82633. private _options;
  82634. private _textures;
  82635. private _textureArrays;
  82636. private _floats;
  82637. private _ints;
  82638. private _floatsArrays;
  82639. private _colors3;
  82640. private _colors3Arrays;
  82641. private _colors4;
  82642. private _colors4Arrays;
  82643. private _vectors2;
  82644. private _vectors3;
  82645. private _vectors4;
  82646. private _matrices;
  82647. private _matrices3x3;
  82648. private _matrices2x2;
  82649. private _vectors2Arrays;
  82650. private _vectors3Arrays;
  82651. private _vectors4Arrays;
  82652. private _cachedWorldViewMatrix;
  82653. private _cachedWorldViewProjectionMatrix;
  82654. private _renderId;
  82655. /**
  82656. * Instantiate a new shader material.
  82657. * 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.
  82658. * This returned material effects how the mesh will look based on the code in the shaders.
  82659. * @see http://doc.babylonjs.com/how_to/shader_material
  82660. * @param name Define the name of the material in the scene
  82661. * @param scene Define the scene the material belongs to
  82662. * @param shaderPath Defines the route to the shader code in one of three ways:
  82663. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  82664. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  82665. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  82666. * @param options Define the options used to create the shader
  82667. */
  82668. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  82669. /**
  82670. * Gets the options used to compile the shader.
  82671. * They can be modified to trigger a new compilation
  82672. */
  82673. readonly options: IShaderMaterialOptions;
  82674. /**
  82675. * Gets the current class name of the material e.g. "ShaderMaterial"
  82676. * Mainly use in serialization.
  82677. * @returns the class name
  82678. */
  82679. getClassName(): string;
  82680. /**
  82681. * Specifies if the material will require alpha blending
  82682. * @returns a boolean specifying if alpha blending is needed
  82683. */
  82684. needAlphaBlending(): boolean;
  82685. /**
  82686. * Specifies if this material should be rendered in alpha test mode
  82687. * @returns a boolean specifying if an alpha test is needed.
  82688. */
  82689. needAlphaTesting(): boolean;
  82690. private _checkUniform;
  82691. /**
  82692. * Set a texture in the shader.
  82693. * @param name Define the name of the uniform samplers as defined in the shader
  82694. * @param texture Define the texture to bind to this sampler
  82695. * @return the material itself allowing "fluent" like uniform updates
  82696. */
  82697. setTexture(name: string, texture: Texture): ShaderMaterial;
  82698. /**
  82699. * Set a texture array in the shader.
  82700. * @param name Define the name of the uniform sampler array as defined in the shader
  82701. * @param textures Define the list of textures to bind to this sampler
  82702. * @return the material itself allowing "fluent" like uniform updates
  82703. */
  82704. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  82705. /**
  82706. * Set a float in the shader.
  82707. * @param name Define the name of the uniform as defined in the shader
  82708. * @param value Define the value to give to the uniform
  82709. * @return the material itself allowing "fluent" like uniform updates
  82710. */
  82711. setFloat(name: string, value: number): ShaderMaterial;
  82712. /**
  82713. * Set a int in the shader.
  82714. * @param name Define the name of the uniform as defined in the shader
  82715. * @param value Define the value to give to the uniform
  82716. * @return the material itself allowing "fluent" like uniform updates
  82717. */
  82718. setInt(name: string, value: number): ShaderMaterial;
  82719. /**
  82720. * Set an array of floats in the shader.
  82721. * @param name Define the name of the uniform as defined in the shader
  82722. * @param value Define the value to give to the uniform
  82723. * @return the material itself allowing "fluent" like uniform updates
  82724. */
  82725. setFloats(name: string, value: number[]): ShaderMaterial;
  82726. /**
  82727. * Set a vec3 in the shader from a Color3.
  82728. * @param name Define the name of the uniform as defined in the shader
  82729. * @param value Define the value to give to the uniform
  82730. * @return the material itself allowing "fluent" like uniform updates
  82731. */
  82732. setColor3(name: string, value: Color3): ShaderMaterial;
  82733. /**
  82734. * Set a vec3 array in the shader from a Color3 array.
  82735. * @param name Define the name of the uniform as defined in the shader
  82736. * @param value Define the value to give to the uniform
  82737. * @return the material itself allowing "fluent" like uniform updates
  82738. */
  82739. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  82740. /**
  82741. * Set a vec4 in the shader from a Color4.
  82742. * @param name Define the name of the uniform as defined in the shader
  82743. * @param value Define the value to give to the uniform
  82744. * @return the material itself allowing "fluent" like uniform updates
  82745. */
  82746. setColor4(name: string, value: Color4): ShaderMaterial;
  82747. /**
  82748. * Set a vec4 array in the shader from a Color4 array.
  82749. * @param name Define the name of the uniform as defined in the shader
  82750. * @param value Define the value to give to the uniform
  82751. * @return the material itself allowing "fluent" like uniform updates
  82752. */
  82753. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  82754. /**
  82755. * Set a vec2 in the shader from a Vector2.
  82756. * @param name Define the name of the uniform as defined in the shader
  82757. * @param value Define the value to give to the uniform
  82758. * @return the material itself allowing "fluent" like uniform updates
  82759. */
  82760. setVector2(name: string, value: Vector2): ShaderMaterial;
  82761. /**
  82762. * Set a vec3 in the shader from a Vector3.
  82763. * @param name Define the name of the uniform as defined in the shader
  82764. * @param value Define the value to give to the uniform
  82765. * @return the material itself allowing "fluent" like uniform updates
  82766. */
  82767. setVector3(name: string, value: Vector3): ShaderMaterial;
  82768. /**
  82769. * Set a vec4 in the shader from a Vector4.
  82770. * @param name Define the name of the uniform as defined in the shader
  82771. * @param value Define the value to give to the uniform
  82772. * @return the material itself allowing "fluent" like uniform updates
  82773. */
  82774. setVector4(name: string, value: Vector4): ShaderMaterial;
  82775. /**
  82776. * Set a mat4 in the shader from a Matrix.
  82777. * @param name Define the name of the uniform as defined in the shader
  82778. * @param value Define the value to give to the uniform
  82779. * @return the material itself allowing "fluent" like uniform updates
  82780. */
  82781. setMatrix(name: string, value: Matrix): ShaderMaterial;
  82782. /**
  82783. * Set a mat3 in the shader from a Float32Array.
  82784. * @param name Define the name of the uniform as defined in the shader
  82785. * @param value Define the value to give to the uniform
  82786. * @return the material itself allowing "fluent" like uniform updates
  82787. */
  82788. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  82789. /**
  82790. * Set a mat2 in the shader from a Float32Array.
  82791. * @param name Define the name of the uniform as defined in the shader
  82792. * @param value Define the value to give to the uniform
  82793. * @return the material itself allowing "fluent" like uniform updates
  82794. */
  82795. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  82796. /**
  82797. * Set a vec2 array in the shader from a number array.
  82798. * @param name Define the name of the uniform as defined in the shader
  82799. * @param value Define the value to give to the uniform
  82800. * @return the material itself allowing "fluent" like uniform updates
  82801. */
  82802. setArray2(name: string, value: number[]): ShaderMaterial;
  82803. /**
  82804. * Set a vec3 array in the shader from a number array.
  82805. * @param name Define the name of the uniform as defined in the shader
  82806. * @param value Define the value to give to the uniform
  82807. * @return the material itself allowing "fluent" like uniform updates
  82808. */
  82809. setArray3(name: string, value: number[]): ShaderMaterial;
  82810. /**
  82811. * Set a vec4 array in the shader from a number array.
  82812. * @param name Define the name of the uniform as defined in the shader
  82813. * @param value Define the value to give to the uniform
  82814. * @return the material itself allowing "fluent" like uniform updates
  82815. */
  82816. setArray4(name: string, value: number[]): ShaderMaterial;
  82817. private _checkCache;
  82818. /**
  82819. * Specifies that the submesh is ready to be used
  82820. * @param mesh defines the mesh to check
  82821. * @param subMesh defines which submesh to check
  82822. * @param useInstances specifies that instances should be used
  82823. * @returns a boolean indicating that the submesh is ready or not
  82824. */
  82825. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  82826. /**
  82827. * Checks if the material is ready to render the requested mesh
  82828. * @param mesh Define the mesh to render
  82829. * @param useInstances Define whether or not the material is used with instances
  82830. * @returns true if ready, otherwise false
  82831. */
  82832. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  82833. /**
  82834. * Binds the world matrix to the material
  82835. * @param world defines the world transformation matrix
  82836. */
  82837. bindOnlyWorldMatrix(world: Matrix): void;
  82838. /**
  82839. * Binds the material to the mesh
  82840. * @param world defines the world transformation matrix
  82841. * @param mesh defines the mesh to bind the material to
  82842. */
  82843. bind(world: Matrix, mesh?: Mesh): void;
  82844. /**
  82845. * Gets the active textures from the material
  82846. * @returns an array of textures
  82847. */
  82848. getActiveTextures(): BaseTexture[];
  82849. /**
  82850. * Specifies if the material uses a texture
  82851. * @param texture defines the texture to check against the material
  82852. * @returns a boolean specifying if the material uses the texture
  82853. */
  82854. hasTexture(texture: BaseTexture): boolean;
  82855. /**
  82856. * Makes a duplicate of the material, and gives it a new name
  82857. * @param name defines the new name for the duplicated material
  82858. * @returns the cloned material
  82859. */
  82860. clone(name: string): ShaderMaterial;
  82861. /**
  82862. * Disposes the material
  82863. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  82864. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  82865. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  82866. */
  82867. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  82868. /**
  82869. * Serializes this material in a JSON representation
  82870. * @returns the serialized material object
  82871. */
  82872. serialize(): any;
  82873. /**
  82874. * Creates a shader material from parsed shader material data
  82875. * @param source defines the JSON represnetation of the material
  82876. * @param scene defines the hosting scene
  82877. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  82878. * @returns a new material
  82879. */
  82880. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  82881. }
  82882. }
  82883. declare module BABYLON {
  82884. /** @hidden */
  82885. export var colorPixelShader: {
  82886. name: string;
  82887. shader: string;
  82888. };
  82889. }
  82890. declare module BABYLON {
  82891. /** @hidden */
  82892. export var colorVertexShader: {
  82893. name: string;
  82894. shader: string;
  82895. };
  82896. }
  82897. declare module BABYLON {
  82898. /**
  82899. * Line mesh
  82900. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  82901. */
  82902. export class LinesMesh extends Mesh {
  82903. /**
  82904. * If vertex color should be applied to the mesh
  82905. */
  82906. readonly useVertexColor?: boolean | undefined;
  82907. /**
  82908. * If vertex alpha should be applied to the mesh
  82909. */
  82910. readonly useVertexAlpha?: boolean | undefined;
  82911. /**
  82912. * Color of the line (Default: White)
  82913. */
  82914. color: Color3;
  82915. /**
  82916. * Alpha of the line (Default: 1)
  82917. */
  82918. alpha: number;
  82919. /**
  82920. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  82921. * This margin is expressed in world space coordinates, so its value may vary.
  82922. * Default value is 0.1
  82923. */
  82924. intersectionThreshold: number;
  82925. private _colorShader;
  82926. private color4;
  82927. /**
  82928. * Creates a new LinesMesh
  82929. * @param name defines the name
  82930. * @param scene defines the hosting scene
  82931. * @param parent defines the parent mesh if any
  82932. * @param source defines the optional source LinesMesh used to clone data from
  82933. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  82934. * When false, achieved by calling a clone(), also passing False.
  82935. * This will make creation of children, recursive.
  82936. * @param useVertexColor defines if this LinesMesh supports vertex color
  82937. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  82938. */
  82939. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  82940. /**
  82941. * If vertex color should be applied to the mesh
  82942. */
  82943. useVertexColor?: boolean | undefined,
  82944. /**
  82945. * If vertex alpha should be applied to the mesh
  82946. */
  82947. useVertexAlpha?: boolean | undefined);
  82948. private _addClipPlaneDefine;
  82949. private _removeClipPlaneDefine;
  82950. isReady(): boolean;
  82951. /**
  82952. * Returns the string "LineMesh"
  82953. */
  82954. getClassName(): string;
  82955. /**
  82956. * @hidden
  82957. */
  82958. /**
  82959. * @hidden
  82960. */
  82961. material: Material;
  82962. /**
  82963. * @hidden
  82964. */
  82965. readonly checkCollisions: boolean;
  82966. /** @hidden */
  82967. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  82968. /** @hidden */
  82969. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  82970. /**
  82971. * Disposes of the line mesh
  82972. * @param doNotRecurse If children should be disposed
  82973. */
  82974. dispose(doNotRecurse?: boolean): void;
  82975. /**
  82976. * Returns a new LineMesh object cloned from the current one.
  82977. */
  82978. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  82979. /**
  82980. * Creates a new InstancedLinesMesh object from the mesh model.
  82981. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  82982. * @param name defines the name of the new instance
  82983. * @returns a new InstancedLinesMesh
  82984. */
  82985. createInstance(name: string): InstancedLinesMesh;
  82986. }
  82987. /**
  82988. * Creates an instance based on a source LinesMesh
  82989. */
  82990. export class InstancedLinesMesh extends InstancedMesh {
  82991. /**
  82992. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  82993. * This margin is expressed in world space coordinates, so its value may vary.
  82994. * Initilized with the intersectionThreshold value of the source LinesMesh
  82995. */
  82996. intersectionThreshold: number;
  82997. constructor(name: string, source: LinesMesh);
  82998. /**
  82999. * Returns the string "InstancedLinesMesh".
  83000. */
  83001. getClassName(): string;
  83002. }
  83003. }
  83004. declare module BABYLON {
  83005. /** @hidden */
  83006. export var linePixelShader: {
  83007. name: string;
  83008. shader: string;
  83009. };
  83010. }
  83011. declare module BABYLON {
  83012. /** @hidden */
  83013. export var lineVertexShader: {
  83014. name: string;
  83015. shader: string;
  83016. };
  83017. }
  83018. declare module BABYLON {
  83019. interface AbstractMesh {
  83020. /**
  83021. * Gets the edgesRenderer associated with the mesh
  83022. */
  83023. edgesRenderer: Nullable<EdgesRenderer>;
  83024. }
  83025. interface LinesMesh {
  83026. /**
  83027. * Enables the edge rendering mode on the mesh.
  83028. * This mode makes the mesh edges visible
  83029. * @param epsilon defines the maximal distance between two angles to detect a face
  83030. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  83031. * @returns the currentAbstractMesh
  83032. * @see https://www.babylonjs-playground.com/#19O9TU#0
  83033. */
  83034. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  83035. }
  83036. interface InstancedLinesMesh {
  83037. /**
  83038. * Enables the edge rendering mode on the mesh.
  83039. * This mode makes the mesh edges visible
  83040. * @param epsilon defines the maximal distance between two angles to detect a face
  83041. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  83042. * @returns the current InstancedLinesMesh
  83043. * @see https://www.babylonjs-playground.com/#19O9TU#0
  83044. */
  83045. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  83046. }
  83047. /**
  83048. * Defines the minimum contract an Edges renderer should follow.
  83049. */
  83050. export interface IEdgesRenderer extends IDisposable {
  83051. /**
  83052. * Gets or sets a boolean indicating if the edgesRenderer is active
  83053. */
  83054. isEnabled: boolean;
  83055. /**
  83056. * Renders the edges of the attached mesh,
  83057. */
  83058. render(): void;
  83059. /**
  83060. * Checks wether or not the edges renderer is ready to render.
  83061. * @return true if ready, otherwise false.
  83062. */
  83063. isReady(): boolean;
  83064. }
  83065. /**
  83066. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  83067. */
  83068. export class EdgesRenderer implements IEdgesRenderer {
  83069. /**
  83070. * Define the size of the edges with an orthographic camera
  83071. */
  83072. edgesWidthScalerForOrthographic: number;
  83073. /**
  83074. * Define the size of the edges with a perspective camera
  83075. */
  83076. edgesWidthScalerForPerspective: number;
  83077. protected _source: AbstractMesh;
  83078. protected _linesPositions: number[];
  83079. protected _linesNormals: number[];
  83080. protected _linesIndices: number[];
  83081. protected _epsilon: number;
  83082. protected _indicesCount: number;
  83083. protected _lineShader: ShaderMaterial;
  83084. protected _ib: DataBuffer;
  83085. protected _buffers: {
  83086. [key: string]: Nullable<VertexBuffer>;
  83087. };
  83088. protected _checkVerticesInsteadOfIndices: boolean;
  83089. private _meshRebuildObserver;
  83090. private _meshDisposeObserver;
  83091. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  83092. isEnabled: boolean;
  83093. /**
  83094. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  83095. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  83096. * @param source Mesh used to create edges
  83097. * @param epsilon sum of angles in adjacency to check for edge
  83098. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  83099. * @param generateEdgesLines - should generate Lines or only prepare resources.
  83100. */
  83101. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  83102. protected _prepareRessources(): void;
  83103. /** @hidden */
  83104. _rebuild(): void;
  83105. /**
  83106. * Releases the required resources for the edges renderer
  83107. */
  83108. dispose(): void;
  83109. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  83110. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  83111. /**
  83112. * Checks if the pair of p0 and p1 is en edge
  83113. * @param faceIndex
  83114. * @param edge
  83115. * @param faceNormals
  83116. * @param p0
  83117. * @param p1
  83118. * @private
  83119. */
  83120. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  83121. /**
  83122. * push line into the position, normal and index buffer
  83123. * @protected
  83124. */
  83125. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  83126. /**
  83127. * Generates lines edges from adjacencjes
  83128. * @private
  83129. */
  83130. _generateEdgesLines(): void;
  83131. /**
  83132. * Checks wether or not the edges renderer is ready to render.
  83133. * @return true if ready, otherwise false.
  83134. */
  83135. isReady(): boolean;
  83136. /**
  83137. * Renders the edges of the attached mesh,
  83138. */
  83139. render(): void;
  83140. }
  83141. /**
  83142. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  83143. */
  83144. export class LineEdgesRenderer extends EdgesRenderer {
  83145. /**
  83146. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  83147. * @param source LineMesh used to generate edges
  83148. * @param epsilon not important (specified angle for edge detection)
  83149. * @param checkVerticesInsteadOfIndices not important for LineMesh
  83150. */
  83151. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  83152. /**
  83153. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  83154. */
  83155. _generateEdgesLines(): void;
  83156. }
  83157. }
  83158. declare module BABYLON {
  83159. /**
  83160. * This represents the object necessary to create a rendering group.
  83161. * This is exclusively used and created by the rendering manager.
  83162. * To modify the behavior, you use the available helpers in your scene or meshes.
  83163. * @hidden
  83164. */
  83165. export class RenderingGroup {
  83166. index: number;
  83167. private static _zeroVector;
  83168. private _scene;
  83169. private _opaqueSubMeshes;
  83170. private _transparentSubMeshes;
  83171. private _alphaTestSubMeshes;
  83172. private _depthOnlySubMeshes;
  83173. private _particleSystems;
  83174. private _spriteManagers;
  83175. private _opaqueSortCompareFn;
  83176. private _alphaTestSortCompareFn;
  83177. private _transparentSortCompareFn;
  83178. private _renderOpaque;
  83179. private _renderAlphaTest;
  83180. private _renderTransparent;
  83181. /** @hidden */
  83182. _edgesRenderers: SmartArray<IEdgesRenderer>;
  83183. onBeforeTransparentRendering: () => void;
  83184. /**
  83185. * Set the opaque sort comparison function.
  83186. * If null the sub meshes will be render in the order they were created
  83187. */
  83188. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83189. /**
  83190. * Set the alpha test sort comparison function.
  83191. * If null the sub meshes will be render in the order they were created
  83192. */
  83193. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83194. /**
  83195. * Set the transparent sort comparison function.
  83196. * If null the sub meshes will be render in the order they were created
  83197. */
  83198. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83199. /**
  83200. * Creates a new rendering group.
  83201. * @param index The rendering group index
  83202. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  83203. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  83204. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  83205. */
  83206. 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>);
  83207. /**
  83208. * Render all the sub meshes contained in the group.
  83209. * @param customRenderFunction Used to override the default render behaviour of the group.
  83210. * @returns true if rendered some submeshes.
  83211. */
  83212. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  83213. /**
  83214. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  83215. * @param subMeshes The submeshes to render
  83216. */
  83217. private renderOpaqueSorted;
  83218. /**
  83219. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  83220. * @param subMeshes The submeshes to render
  83221. */
  83222. private renderAlphaTestSorted;
  83223. /**
  83224. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  83225. * @param subMeshes The submeshes to render
  83226. */
  83227. private renderTransparentSorted;
  83228. /**
  83229. * Renders the submeshes in a specified order.
  83230. * @param subMeshes The submeshes to sort before render
  83231. * @param sortCompareFn The comparison function use to sort
  83232. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  83233. * @param transparent Specifies to activate blending if true
  83234. */
  83235. private static renderSorted;
  83236. /**
  83237. * Renders the submeshes in the order they were dispatched (no sort applied).
  83238. * @param subMeshes The submeshes to render
  83239. */
  83240. private static renderUnsorted;
  83241. /**
  83242. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  83243. * are rendered back to front if in the same alpha index.
  83244. *
  83245. * @param a The first submesh
  83246. * @param b The second submesh
  83247. * @returns The result of the comparison
  83248. */
  83249. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  83250. /**
  83251. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  83252. * are rendered back to front.
  83253. *
  83254. * @param a The first submesh
  83255. * @param b The second submesh
  83256. * @returns The result of the comparison
  83257. */
  83258. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  83259. /**
  83260. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  83261. * are rendered front to back (prevent overdraw).
  83262. *
  83263. * @param a The first submesh
  83264. * @param b The second submesh
  83265. * @returns The result of the comparison
  83266. */
  83267. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  83268. /**
  83269. * Resets the different lists of submeshes to prepare a new frame.
  83270. */
  83271. prepare(): void;
  83272. dispose(): void;
  83273. /**
  83274. * Inserts the submesh in its correct queue depending on its material.
  83275. * @param subMesh The submesh to dispatch
  83276. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  83277. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  83278. */
  83279. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  83280. dispatchSprites(spriteManager: ISpriteManager): void;
  83281. dispatchParticles(particleSystem: IParticleSystem): void;
  83282. private _renderParticles;
  83283. private _renderSprites;
  83284. }
  83285. }
  83286. declare module BABYLON {
  83287. /**
  83288. * Interface describing the different options available in the rendering manager
  83289. * regarding Auto Clear between groups.
  83290. */
  83291. export interface IRenderingManagerAutoClearSetup {
  83292. /**
  83293. * Defines whether or not autoclear is enable.
  83294. */
  83295. autoClear: boolean;
  83296. /**
  83297. * Defines whether or not to autoclear the depth buffer.
  83298. */
  83299. depth: boolean;
  83300. /**
  83301. * Defines whether or not to autoclear the stencil buffer.
  83302. */
  83303. stencil: boolean;
  83304. }
  83305. /**
  83306. * This class is used by the onRenderingGroupObservable
  83307. */
  83308. export class RenderingGroupInfo {
  83309. /**
  83310. * The Scene that being rendered
  83311. */
  83312. scene: Scene;
  83313. /**
  83314. * The camera currently used for the rendering pass
  83315. */
  83316. camera: Nullable<Camera>;
  83317. /**
  83318. * The ID of the renderingGroup being processed
  83319. */
  83320. renderingGroupId: number;
  83321. }
  83322. /**
  83323. * This is the manager responsible of all the rendering for meshes sprites and particles.
  83324. * It is enable to manage the different groups as well as the different necessary sort functions.
  83325. * This should not be used directly aside of the few static configurations
  83326. */
  83327. export class RenderingManager {
  83328. /**
  83329. * The max id used for rendering groups (not included)
  83330. */
  83331. static MAX_RENDERINGGROUPS: number;
  83332. /**
  83333. * The min id used for rendering groups (included)
  83334. */
  83335. static MIN_RENDERINGGROUPS: number;
  83336. /**
  83337. * Used to globally prevent autoclearing scenes.
  83338. */
  83339. static AUTOCLEAR: boolean;
  83340. /**
  83341. * @hidden
  83342. */
  83343. _useSceneAutoClearSetup: boolean;
  83344. private _scene;
  83345. private _renderingGroups;
  83346. private _depthStencilBufferAlreadyCleaned;
  83347. private _autoClearDepthStencil;
  83348. private _customOpaqueSortCompareFn;
  83349. private _customAlphaTestSortCompareFn;
  83350. private _customTransparentSortCompareFn;
  83351. private _renderingGroupInfo;
  83352. /**
  83353. * Instantiates a new rendering group for a particular scene
  83354. * @param scene Defines the scene the groups belongs to
  83355. */
  83356. constructor(scene: Scene);
  83357. private _clearDepthStencilBuffer;
  83358. /**
  83359. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  83360. * @hidden
  83361. */
  83362. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  83363. /**
  83364. * Resets the different information of the group to prepare a new frame
  83365. * @hidden
  83366. */
  83367. reset(): void;
  83368. /**
  83369. * Dispose and release the group and its associated resources.
  83370. * @hidden
  83371. */
  83372. dispose(): void;
  83373. /**
  83374. * Clear the info related to rendering groups preventing retention points during dispose.
  83375. */
  83376. freeRenderingGroups(): void;
  83377. private _prepareRenderingGroup;
  83378. /**
  83379. * Add a sprite manager to the rendering manager in order to render it this frame.
  83380. * @param spriteManager Define the sprite manager to render
  83381. */
  83382. dispatchSprites(spriteManager: ISpriteManager): void;
  83383. /**
  83384. * Add a particle system to the rendering manager in order to render it this frame.
  83385. * @param particleSystem Define the particle system to render
  83386. */
  83387. dispatchParticles(particleSystem: IParticleSystem): void;
  83388. /**
  83389. * Add a submesh to the manager in order to render it this frame
  83390. * @param subMesh The submesh to dispatch
  83391. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  83392. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  83393. */
  83394. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  83395. /**
  83396. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  83397. * This allowed control for front to back rendering or reversly depending of the special needs.
  83398. *
  83399. * @param renderingGroupId The rendering group id corresponding to its index
  83400. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  83401. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  83402. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  83403. */
  83404. 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;
  83405. /**
  83406. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  83407. *
  83408. * @param renderingGroupId The rendering group id corresponding to its index
  83409. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  83410. * @param depth Automatically clears depth between groups if true and autoClear is true.
  83411. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  83412. */
  83413. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  83414. /**
  83415. * Gets the current auto clear configuration for one rendering group of the rendering
  83416. * manager.
  83417. * @param index the rendering group index to get the information for
  83418. * @returns The auto clear setup for the requested rendering group
  83419. */
  83420. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  83421. }
  83422. }
  83423. declare module BABYLON {
  83424. /**
  83425. * This Helps creating a texture that will be created from a camera in your scene.
  83426. * It is basically a dynamic texture that could be used to create special effects for instance.
  83427. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  83428. */
  83429. export class RenderTargetTexture extends Texture {
  83430. isCube: boolean;
  83431. /**
  83432. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  83433. */
  83434. static readonly REFRESHRATE_RENDER_ONCE: number;
  83435. /**
  83436. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  83437. */
  83438. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  83439. /**
  83440. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  83441. * the central point of your effect and can save a lot of performances.
  83442. */
  83443. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  83444. /**
  83445. * Use this predicate to dynamically define the list of mesh you want to render.
  83446. * If set, the renderList property will be overwritten.
  83447. */
  83448. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  83449. private _renderList;
  83450. /**
  83451. * Use this list to define the list of mesh you want to render.
  83452. */
  83453. renderList: Nullable<Array<AbstractMesh>>;
  83454. private _hookArray;
  83455. /**
  83456. * Define if particles should be rendered in your texture.
  83457. */
  83458. renderParticles: boolean;
  83459. /**
  83460. * Define if sprites should be rendered in your texture.
  83461. */
  83462. renderSprites: boolean;
  83463. /**
  83464. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  83465. */
  83466. coordinatesMode: number;
  83467. /**
  83468. * Define the camera used to render the texture.
  83469. */
  83470. activeCamera: Nullable<Camera>;
  83471. /**
  83472. * Override the render function of the texture with your own one.
  83473. */
  83474. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  83475. /**
  83476. * Define if camera post processes should be use while rendering the texture.
  83477. */
  83478. useCameraPostProcesses: boolean;
  83479. /**
  83480. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  83481. */
  83482. ignoreCameraViewport: boolean;
  83483. private _postProcessManager;
  83484. private _postProcesses;
  83485. private _resizeObserver;
  83486. /**
  83487. * An event triggered when the texture is unbind.
  83488. */
  83489. onBeforeBindObservable: Observable<RenderTargetTexture>;
  83490. /**
  83491. * An event triggered when the texture is unbind.
  83492. */
  83493. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  83494. private _onAfterUnbindObserver;
  83495. /**
  83496. * Set a after unbind callback in the texture.
  83497. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  83498. */
  83499. onAfterUnbind: () => void;
  83500. /**
  83501. * An event triggered before rendering the texture
  83502. */
  83503. onBeforeRenderObservable: Observable<number>;
  83504. private _onBeforeRenderObserver;
  83505. /**
  83506. * Set a before render callback in the texture.
  83507. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  83508. */
  83509. onBeforeRender: (faceIndex: number) => void;
  83510. /**
  83511. * An event triggered after rendering the texture
  83512. */
  83513. onAfterRenderObservable: Observable<number>;
  83514. private _onAfterRenderObserver;
  83515. /**
  83516. * Set a after render callback in the texture.
  83517. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  83518. */
  83519. onAfterRender: (faceIndex: number) => void;
  83520. /**
  83521. * An event triggered after the texture clear
  83522. */
  83523. onClearObservable: Observable<Engine>;
  83524. private _onClearObserver;
  83525. /**
  83526. * Set a clear callback in the texture.
  83527. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  83528. */
  83529. onClear: (Engine: Engine) => void;
  83530. /**
  83531. * Define the clear color of the Render Target if it should be different from the scene.
  83532. */
  83533. clearColor: Color4;
  83534. protected _size: number | {
  83535. width: number;
  83536. height: number;
  83537. };
  83538. protected _initialSizeParameter: number | {
  83539. width: number;
  83540. height: number;
  83541. } | {
  83542. ratio: number;
  83543. };
  83544. protected _sizeRatio: Nullable<number>;
  83545. /** @hidden */
  83546. _generateMipMaps: boolean;
  83547. protected _renderingManager: RenderingManager;
  83548. /** @hidden */
  83549. _waitingRenderList: string[];
  83550. protected _doNotChangeAspectRatio: boolean;
  83551. protected _currentRefreshId: number;
  83552. protected _refreshRate: number;
  83553. protected _textureMatrix: Matrix;
  83554. protected _samples: number;
  83555. protected _renderTargetOptions: RenderTargetCreationOptions;
  83556. /**
  83557. * Gets render target creation options that were used.
  83558. */
  83559. readonly renderTargetOptions: RenderTargetCreationOptions;
  83560. protected _engine: Engine;
  83561. protected _onRatioRescale(): void;
  83562. /**
  83563. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  83564. * It must define where the camera used to render the texture is set
  83565. */
  83566. boundingBoxPosition: Vector3;
  83567. private _boundingBoxSize;
  83568. /**
  83569. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  83570. * When defined, the cubemap will switch to local mode
  83571. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  83572. * @example https://www.babylonjs-playground.com/#RNASML
  83573. */
  83574. boundingBoxSize: Vector3;
  83575. /**
  83576. * In case the RTT has been created with a depth texture, get the associated
  83577. * depth texture.
  83578. * Otherwise, return null.
  83579. */
  83580. depthStencilTexture: Nullable<InternalTexture>;
  83581. /**
  83582. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  83583. * or used a shadow, depth texture...
  83584. * @param name The friendly name of the texture
  83585. * @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)
  83586. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  83587. * @param generateMipMaps True if mip maps need to be generated after render.
  83588. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  83589. * @param type The type of the buffer in the RTT (int, half float, float...)
  83590. * @param isCube True if a cube texture needs to be created
  83591. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  83592. * @param generateDepthBuffer True to generate a depth buffer
  83593. * @param generateStencilBuffer True to generate a stencil buffer
  83594. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  83595. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  83596. * @param delayAllocation if the texture allocation should be delayed (default: false)
  83597. */
  83598. constructor(name: string, size: number | {
  83599. width: number;
  83600. height: number;
  83601. } | {
  83602. ratio: number;
  83603. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  83604. /**
  83605. * Creates a depth stencil texture.
  83606. * This is only available in WebGL 2 or with the depth texture extension available.
  83607. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  83608. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  83609. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  83610. */
  83611. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  83612. private _processSizeParameter;
  83613. /**
  83614. * Define the number of samples to use in case of MSAA.
  83615. * It defaults to one meaning no MSAA has been enabled.
  83616. */
  83617. samples: number;
  83618. /**
  83619. * Resets the refresh counter of the texture and start bak from scratch.
  83620. * Could be useful to regenerate the texture if it is setup to render only once.
  83621. */
  83622. resetRefreshCounter(): void;
  83623. /**
  83624. * Define the refresh rate of the texture or the rendering frequency.
  83625. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  83626. */
  83627. refreshRate: number;
  83628. /**
  83629. * Adds a post process to the render target rendering passes.
  83630. * @param postProcess define the post process to add
  83631. */
  83632. addPostProcess(postProcess: PostProcess): void;
  83633. /**
  83634. * Clear all the post processes attached to the render target
  83635. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  83636. */
  83637. clearPostProcesses(dispose?: boolean): void;
  83638. /**
  83639. * Remove one of the post process from the list of attached post processes to the texture
  83640. * @param postProcess define the post process to remove from the list
  83641. */
  83642. removePostProcess(postProcess: PostProcess): void;
  83643. /** @hidden */
  83644. _shouldRender(): boolean;
  83645. /**
  83646. * Gets the actual render size of the texture.
  83647. * @returns the width of the render size
  83648. */
  83649. getRenderSize(): number;
  83650. /**
  83651. * Gets the actual render width of the texture.
  83652. * @returns the width of the render size
  83653. */
  83654. getRenderWidth(): number;
  83655. /**
  83656. * Gets the actual render height of the texture.
  83657. * @returns the height of the render size
  83658. */
  83659. getRenderHeight(): number;
  83660. /**
  83661. * Get if the texture can be rescaled or not.
  83662. */
  83663. readonly canRescale: boolean;
  83664. /**
  83665. * Resize the texture using a ratio.
  83666. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  83667. */
  83668. scale(ratio: number): void;
  83669. /**
  83670. * Get the texture reflection matrix used to rotate/transform the reflection.
  83671. * @returns the reflection matrix
  83672. */
  83673. getReflectionTextureMatrix(): Matrix;
  83674. /**
  83675. * Resize the texture to a new desired size.
  83676. * Be carrefull as it will recreate all the data in the new texture.
  83677. * @param size Define the new size. It can be:
  83678. * - a number for squared texture,
  83679. * - an object containing { width: number, height: number }
  83680. * - or an object containing a ratio { ratio: number }
  83681. */
  83682. resize(size: number | {
  83683. width: number;
  83684. height: number;
  83685. } | {
  83686. ratio: number;
  83687. }): void;
  83688. /**
  83689. * Renders all the objects from the render list into the texture.
  83690. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  83691. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  83692. */
  83693. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  83694. private _bestReflectionRenderTargetDimension;
  83695. /**
  83696. * @hidden
  83697. * @param faceIndex face index to bind to if this is a cubetexture
  83698. */
  83699. _bindFrameBuffer(faceIndex?: number): void;
  83700. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  83701. private renderToTarget;
  83702. /**
  83703. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  83704. * This allowed control for front to back rendering or reversly depending of the special needs.
  83705. *
  83706. * @param renderingGroupId The rendering group id corresponding to its index
  83707. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  83708. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  83709. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  83710. */
  83711. 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;
  83712. /**
  83713. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  83714. *
  83715. * @param renderingGroupId The rendering group id corresponding to its index
  83716. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  83717. */
  83718. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  83719. /**
  83720. * Clones the texture.
  83721. * @returns the cloned texture
  83722. */
  83723. clone(): RenderTargetTexture;
  83724. /**
  83725. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  83726. * @returns The JSON representation of the texture
  83727. */
  83728. serialize(): any;
  83729. /**
  83730. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  83731. */
  83732. disposeFramebufferObjects(): void;
  83733. /**
  83734. * Dispose the texture and release its associated resources.
  83735. */
  83736. dispose(): void;
  83737. /** @hidden */
  83738. _rebuild(): void;
  83739. /**
  83740. * Clear the info related to rendering groups preventing retention point in material dispose.
  83741. */
  83742. freeRenderingGroups(): void;
  83743. /**
  83744. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  83745. * @returns the view count
  83746. */
  83747. getViewCount(): number;
  83748. }
  83749. }
  83750. declare module BABYLON {
  83751. /**
  83752. * Base class for the main features of a material in Babylon.js
  83753. */
  83754. export class Material implements IAnimatable {
  83755. /**
  83756. * Returns the triangle fill mode
  83757. */
  83758. static readonly TriangleFillMode: number;
  83759. /**
  83760. * Returns the wireframe mode
  83761. */
  83762. static readonly WireFrameFillMode: number;
  83763. /**
  83764. * Returns the point fill mode
  83765. */
  83766. static readonly PointFillMode: number;
  83767. /**
  83768. * Returns the point list draw mode
  83769. */
  83770. static readonly PointListDrawMode: number;
  83771. /**
  83772. * Returns the line list draw mode
  83773. */
  83774. static readonly LineListDrawMode: number;
  83775. /**
  83776. * Returns the line loop draw mode
  83777. */
  83778. static readonly LineLoopDrawMode: number;
  83779. /**
  83780. * Returns the line strip draw mode
  83781. */
  83782. static readonly LineStripDrawMode: number;
  83783. /**
  83784. * Returns the triangle strip draw mode
  83785. */
  83786. static readonly TriangleStripDrawMode: number;
  83787. /**
  83788. * Returns the triangle fan draw mode
  83789. */
  83790. static readonly TriangleFanDrawMode: number;
  83791. /**
  83792. * Stores the clock-wise side orientation
  83793. */
  83794. static readonly ClockWiseSideOrientation: number;
  83795. /**
  83796. * Stores the counter clock-wise side orientation
  83797. */
  83798. static readonly CounterClockWiseSideOrientation: number;
  83799. /**
  83800. * The dirty texture flag value
  83801. */
  83802. static readonly TextureDirtyFlag: number;
  83803. /**
  83804. * The dirty light flag value
  83805. */
  83806. static readonly LightDirtyFlag: number;
  83807. /**
  83808. * The dirty fresnel flag value
  83809. */
  83810. static readonly FresnelDirtyFlag: number;
  83811. /**
  83812. * The dirty attribute flag value
  83813. */
  83814. static readonly AttributesDirtyFlag: number;
  83815. /**
  83816. * The dirty misc flag value
  83817. */
  83818. static readonly MiscDirtyFlag: number;
  83819. /**
  83820. * The all dirty flag value
  83821. */
  83822. static readonly AllDirtyFlag: number;
  83823. /**
  83824. * The ID of the material
  83825. */
  83826. id: string;
  83827. /**
  83828. * Gets or sets the unique id of the material
  83829. */
  83830. uniqueId: number;
  83831. /**
  83832. * The name of the material
  83833. */
  83834. name: string;
  83835. /**
  83836. * Gets or sets user defined metadata
  83837. */
  83838. metadata: any;
  83839. /**
  83840. * For internal use only. Please do not use.
  83841. */
  83842. reservedDataStore: any;
  83843. /**
  83844. * Specifies if the ready state should be checked on each call
  83845. */
  83846. checkReadyOnEveryCall: boolean;
  83847. /**
  83848. * Specifies if the ready state should be checked once
  83849. */
  83850. checkReadyOnlyOnce: boolean;
  83851. /**
  83852. * The state of the material
  83853. */
  83854. state: string;
  83855. /**
  83856. * The alpha value of the material
  83857. */
  83858. protected _alpha: number;
  83859. /**
  83860. * List of inspectable custom properties (used by the Inspector)
  83861. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83862. */
  83863. inspectableCustomProperties: IInspectable[];
  83864. /**
  83865. * Sets the alpha value of the material
  83866. */
  83867. /**
  83868. * Gets the alpha value of the material
  83869. */
  83870. alpha: number;
  83871. /**
  83872. * Specifies if back face culling is enabled
  83873. */
  83874. protected _backFaceCulling: boolean;
  83875. /**
  83876. * Sets the back-face culling state
  83877. */
  83878. /**
  83879. * Gets the back-face culling state
  83880. */
  83881. backFaceCulling: boolean;
  83882. /**
  83883. * Stores the value for side orientation
  83884. */
  83885. sideOrientation: number;
  83886. /**
  83887. * Callback triggered when the material is compiled
  83888. */
  83889. onCompiled: Nullable<(effect: Effect) => void>;
  83890. /**
  83891. * Callback triggered when an error occurs
  83892. */
  83893. onError: Nullable<(effect: Effect, errors: string) => void>;
  83894. /**
  83895. * Callback triggered to get the render target textures
  83896. */
  83897. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  83898. /**
  83899. * Gets a boolean indicating that current material needs to register RTT
  83900. */
  83901. readonly hasRenderTargetTextures: boolean;
  83902. /**
  83903. * Specifies if the material should be serialized
  83904. */
  83905. doNotSerialize: boolean;
  83906. /**
  83907. * @hidden
  83908. */
  83909. _storeEffectOnSubMeshes: boolean;
  83910. /**
  83911. * Stores the animations for the material
  83912. */
  83913. animations: Nullable<Array<Animation>>;
  83914. /**
  83915. * An event triggered when the material is disposed
  83916. */
  83917. onDisposeObservable: Observable<Material>;
  83918. /**
  83919. * An observer which watches for dispose events
  83920. */
  83921. private _onDisposeObserver;
  83922. private _onUnBindObservable;
  83923. /**
  83924. * Called during a dispose event
  83925. */
  83926. onDispose: () => void;
  83927. private _onBindObservable;
  83928. /**
  83929. * An event triggered when the material is bound
  83930. */
  83931. readonly onBindObservable: Observable<AbstractMesh>;
  83932. /**
  83933. * An observer which watches for bind events
  83934. */
  83935. private _onBindObserver;
  83936. /**
  83937. * Called during a bind event
  83938. */
  83939. onBind: (Mesh: AbstractMesh) => void;
  83940. /**
  83941. * An event triggered when the material is unbound
  83942. */
  83943. readonly onUnBindObservable: Observable<Material>;
  83944. /**
  83945. * Stores the value of the alpha mode
  83946. */
  83947. private _alphaMode;
  83948. /**
  83949. * Sets the value of the alpha mode.
  83950. *
  83951. * | Value | Type | Description |
  83952. * | --- | --- | --- |
  83953. * | 0 | ALPHA_DISABLE | |
  83954. * | 1 | ALPHA_ADD | |
  83955. * | 2 | ALPHA_COMBINE | |
  83956. * | 3 | ALPHA_SUBTRACT | |
  83957. * | 4 | ALPHA_MULTIPLY | |
  83958. * | 5 | ALPHA_MAXIMIZED | |
  83959. * | 6 | ALPHA_ONEONE | |
  83960. * | 7 | ALPHA_PREMULTIPLIED | |
  83961. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  83962. * | 9 | ALPHA_INTERPOLATE | |
  83963. * | 10 | ALPHA_SCREENMODE | |
  83964. *
  83965. */
  83966. /**
  83967. * Gets the value of the alpha mode
  83968. */
  83969. alphaMode: number;
  83970. /**
  83971. * Stores the state of the need depth pre-pass value
  83972. */
  83973. private _needDepthPrePass;
  83974. /**
  83975. * Sets the need depth pre-pass value
  83976. */
  83977. /**
  83978. * Gets the depth pre-pass value
  83979. */
  83980. needDepthPrePass: boolean;
  83981. /**
  83982. * Specifies if depth writing should be disabled
  83983. */
  83984. disableDepthWrite: boolean;
  83985. /**
  83986. * Specifies if depth writing should be forced
  83987. */
  83988. forceDepthWrite: boolean;
  83989. /**
  83990. * Specifies if there should be a separate pass for culling
  83991. */
  83992. separateCullingPass: boolean;
  83993. /**
  83994. * Stores the state specifing if fog should be enabled
  83995. */
  83996. private _fogEnabled;
  83997. /**
  83998. * Sets the state for enabling fog
  83999. */
  84000. /**
  84001. * Gets the value of the fog enabled state
  84002. */
  84003. fogEnabled: boolean;
  84004. /**
  84005. * Stores the size of points
  84006. */
  84007. pointSize: number;
  84008. /**
  84009. * Stores the z offset value
  84010. */
  84011. zOffset: number;
  84012. /**
  84013. * Gets a value specifying if wireframe mode is enabled
  84014. */
  84015. /**
  84016. * Sets the state of wireframe mode
  84017. */
  84018. wireframe: boolean;
  84019. /**
  84020. * Gets the value specifying if point clouds are enabled
  84021. */
  84022. /**
  84023. * Sets the state of point cloud mode
  84024. */
  84025. pointsCloud: boolean;
  84026. /**
  84027. * Gets the material fill mode
  84028. */
  84029. /**
  84030. * Sets the material fill mode
  84031. */
  84032. fillMode: number;
  84033. /**
  84034. * @hidden
  84035. * Stores the effects for the material
  84036. */
  84037. _effect: Nullable<Effect>;
  84038. /**
  84039. * @hidden
  84040. * Specifies if the material was previously ready
  84041. */
  84042. _wasPreviouslyReady: boolean;
  84043. /**
  84044. * Specifies if uniform buffers should be used
  84045. */
  84046. private _useUBO;
  84047. /**
  84048. * Stores a reference to the scene
  84049. */
  84050. private _scene;
  84051. /**
  84052. * Stores the fill mode state
  84053. */
  84054. private _fillMode;
  84055. /**
  84056. * Specifies if the depth write state should be cached
  84057. */
  84058. private _cachedDepthWriteState;
  84059. /**
  84060. * Stores the uniform buffer
  84061. */
  84062. protected _uniformBuffer: UniformBuffer;
  84063. /** @hidden */
  84064. _indexInSceneMaterialArray: number;
  84065. /** @hidden */
  84066. meshMap: Nullable<{
  84067. [id: string]: AbstractMesh | undefined;
  84068. }>;
  84069. /**
  84070. * Creates a material instance
  84071. * @param name defines the name of the material
  84072. * @param scene defines the scene to reference
  84073. * @param doNotAdd specifies if the material should be added to the scene
  84074. */
  84075. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  84076. /**
  84077. * Returns a string representation of the current material
  84078. * @param fullDetails defines a boolean indicating which levels of logging is desired
  84079. * @returns a string with material information
  84080. */
  84081. toString(fullDetails?: boolean): string;
  84082. /**
  84083. * Gets the class name of the material
  84084. * @returns a string with the class name of the material
  84085. */
  84086. getClassName(): string;
  84087. /**
  84088. * Specifies if updates for the material been locked
  84089. */
  84090. readonly isFrozen: boolean;
  84091. /**
  84092. * Locks updates for the material
  84093. */
  84094. freeze(): void;
  84095. /**
  84096. * Unlocks updates for the material
  84097. */
  84098. unfreeze(): void;
  84099. /**
  84100. * Specifies if the material is ready to be used
  84101. * @param mesh defines the mesh to check
  84102. * @param useInstances specifies if instances should be used
  84103. * @returns a boolean indicating if the material is ready to be used
  84104. */
  84105. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  84106. /**
  84107. * Specifies that the submesh is ready to be used
  84108. * @param mesh defines the mesh to check
  84109. * @param subMesh defines which submesh to check
  84110. * @param useInstances specifies that instances should be used
  84111. * @returns a boolean indicating that the submesh is ready or not
  84112. */
  84113. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84114. /**
  84115. * Returns the material effect
  84116. * @returns the effect associated with the material
  84117. */
  84118. getEffect(): Nullable<Effect>;
  84119. /**
  84120. * Returns the current scene
  84121. * @returns a Scene
  84122. */
  84123. getScene(): Scene;
  84124. /**
  84125. * Specifies if the material will require alpha blending
  84126. * @returns a boolean specifying if alpha blending is needed
  84127. */
  84128. needAlphaBlending(): boolean;
  84129. /**
  84130. * Specifies if the mesh will require alpha blending
  84131. * @param mesh defines the mesh to check
  84132. * @returns a boolean specifying if alpha blending is needed for the mesh
  84133. */
  84134. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  84135. /**
  84136. * Specifies if this material should be rendered in alpha test mode
  84137. * @returns a boolean specifying if an alpha test is needed.
  84138. */
  84139. needAlphaTesting(): boolean;
  84140. /**
  84141. * Gets the texture used for the alpha test
  84142. * @returns the texture to use for alpha testing
  84143. */
  84144. getAlphaTestTexture(): Nullable<BaseTexture>;
  84145. /**
  84146. * Marks the material to indicate that it needs to be re-calculated
  84147. */
  84148. markDirty(): void;
  84149. /** @hidden */
  84150. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  84151. /**
  84152. * Binds the material to the mesh
  84153. * @param world defines the world transformation matrix
  84154. * @param mesh defines the mesh to bind the material to
  84155. */
  84156. bind(world: Matrix, mesh?: Mesh): void;
  84157. /**
  84158. * Binds the submesh to the material
  84159. * @param world defines the world transformation matrix
  84160. * @param mesh defines the mesh containing the submesh
  84161. * @param subMesh defines the submesh to bind the material to
  84162. */
  84163. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  84164. /**
  84165. * Binds the world matrix to the material
  84166. * @param world defines the world transformation matrix
  84167. */
  84168. bindOnlyWorldMatrix(world: Matrix): void;
  84169. /**
  84170. * Binds the scene's uniform buffer to the effect.
  84171. * @param effect defines the effect to bind to the scene uniform buffer
  84172. * @param sceneUbo defines the uniform buffer storing scene data
  84173. */
  84174. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  84175. /**
  84176. * Binds the view matrix to the effect
  84177. * @param effect defines the effect to bind the view matrix to
  84178. */
  84179. bindView(effect: Effect): void;
  84180. /**
  84181. * Binds the view projection matrix to the effect
  84182. * @param effect defines the effect to bind the view projection matrix to
  84183. */
  84184. bindViewProjection(effect: Effect): void;
  84185. /**
  84186. * Specifies if material alpha testing should be turned on for the mesh
  84187. * @param mesh defines the mesh to check
  84188. */
  84189. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  84190. /**
  84191. * Processes to execute after binding the material to a mesh
  84192. * @param mesh defines the rendered mesh
  84193. */
  84194. protected _afterBind(mesh?: Mesh): void;
  84195. /**
  84196. * Unbinds the material from the mesh
  84197. */
  84198. unbind(): void;
  84199. /**
  84200. * Gets the active textures from the material
  84201. * @returns an array of textures
  84202. */
  84203. getActiveTextures(): BaseTexture[];
  84204. /**
  84205. * Specifies if the material uses a texture
  84206. * @param texture defines the texture to check against the material
  84207. * @returns a boolean specifying if the material uses the texture
  84208. */
  84209. hasTexture(texture: BaseTexture): boolean;
  84210. /**
  84211. * Makes a duplicate of the material, and gives it a new name
  84212. * @param name defines the new name for the duplicated material
  84213. * @returns the cloned material
  84214. */
  84215. clone(name: string): Nullable<Material>;
  84216. /**
  84217. * Gets the meshes bound to the material
  84218. * @returns an array of meshes bound to the material
  84219. */
  84220. getBindedMeshes(): AbstractMesh[];
  84221. /**
  84222. * Force shader compilation
  84223. * @param mesh defines the mesh associated with this material
  84224. * @param onCompiled defines a function to execute once the material is compiled
  84225. * @param options defines the options to configure the compilation
  84226. */
  84227. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  84228. clipPlane: boolean;
  84229. }>): void;
  84230. /**
  84231. * Force shader compilation
  84232. * @param mesh defines the mesh that will use this material
  84233. * @param options defines additional options for compiling the shaders
  84234. * @returns a promise that resolves when the compilation completes
  84235. */
  84236. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  84237. clipPlane: boolean;
  84238. }>): Promise<void>;
  84239. private static readonly _AllDirtyCallBack;
  84240. private static readonly _ImageProcessingDirtyCallBack;
  84241. private static readonly _TextureDirtyCallBack;
  84242. private static readonly _FresnelDirtyCallBack;
  84243. private static readonly _MiscDirtyCallBack;
  84244. private static readonly _LightsDirtyCallBack;
  84245. private static readonly _AttributeDirtyCallBack;
  84246. private static _FresnelAndMiscDirtyCallBack;
  84247. private static _TextureAndMiscDirtyCallBack;
  84248. private static readonly _DirtyCallbackArray;
  84249. private static readonly _RunDirtyCallBacks;
  84250. /**
  84251. * Marks a define in the material to indicate that it needs to be re-computed
  84252. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  84253. */
  84254. markAsDirty(flag: number): void;
  84255. /**
  84256. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  84257. * @param func defines a function which checks material defines against the submeshes
  84258. */
  84259. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  84260. /**
  84261. * Indicates that we need to re-calculated for all submeshes
  84262. */
  84263. protected _markAllSubMeshesAsAllDirty(): void;
  84264. /**
  84265. * Indicates that image processing needs to be re-calculated for all submeshes
  84266. */
  84267. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  84268. /**
  84269. * Indicates that textures need to be re-calculated for all submeshes
  84270. */
  84271. protected _markAllSubMeshesAsTexturesDirty(): void;
  84272. /**
  84273. * Indicates that fresnel needs to be re-calculated for all submeshes
  84274. */
  84275. protected _markAllSubMeshesAsFresnelDirty(): void;
  84276. /**
  84277. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  84278. */
  84279. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  84280. /**
  84281. * Indicates that lights need to be re-calculated for all submeshes
  84282. */
  84283. protected _markAllSubMeshesAsLightsDirty(): void;
  84284. /**
  84285. * Indicates that attributes need to be re-calculated for all submeshes
  84286. */
  84287. protected _markAllSubMeshesAsAttributesDirty(): void;
  84288. /**
  84289. * Indicates that misc needs to be re-calculated for all submeshes
  84290. */
  84291. protected _markAllSubMeshesAsMiscDirty(): void;
  84292. /**
  84293. * Indicates that textures and misc need to be re-calculated for all submeshes
  84294. */
  84295. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  84296. /**
  84297. * Disposes the material
  84298. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84299. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  84300. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  84301. */
  84302. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  84303. /** @hidden */
  84304. private releaseVertexArrayObject;
  84305. /**
  84306. * Serializes this material
  84307. * @returns the serialized material object
  84308. */
  84309. serialize(): any;
  84310. /**
  84311. * Creates a material from parsed material data
  84312. * @param parsedMaterial defines parsed material data
  84313. * @param scene defines the hosting scene
  84314. * @param rootUrl defines the root URL to use to load textures
  84315. * @returns a new material
  84316. */
  84317. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  84318. }
  84319. }
  84320. declare module BABYLON {
  84321. /**
  84322. * A multi-material is used to apply different materials to different parts of the same object without the need of
  84323. * separate meshes. This can be use to improve performances.
  84324. * @see http://doc.babylonjs.com/how_to/multi_materials
  84325. */
  84326. export class MultiMaterial extends Material {
  84327. private _subMaterials;
  84328. /**
  84329. * Gets or Sets the list of Materials used within the multi material.
  84330. * They need to be ordered according to the submeshes order in the associated mesh
  84331. */
  84332. subMaterials: Nullable<Material>[];
  84333. /**
  84334. * Function used to align with Node.getChildren()
  84335. * @returns the list of Materials used within the multi material
  84336. */
  84337. getChildren(): Nullable<Material>[];
  84338. /**
  84339. * Instantiates a new Multi Material
  84340. * A multi-material is used to apply different materials to different parts of the same object without the need of
  84341. * separate meshes. This can be use to improve performances.
  84342. * @see http://doc.babylonjs.com/how_to/multi_materials
  84343. * @param name Define the name in the scene
  84344. * @param scene Define the scene the material belongs to
  84345. */
  84346. constructor(name: string, scene: Scene);
  84347. private _hookArray;
  84348. /**
  84349. * Get one of the submaterial by its index in the submaterials array
  84350. * @param index The index to look the sub material at
  84351. * @returns The Material if the index has been defined
  84352. */
  84353. getSubMaterial(index: number): Nullable<Material>;
  84354. /**
  84355. * Get the list of active textures for the whole sub materials list.
  84356. * @returns All the textures that will be used during the rendering
  84357. */
  84358. getActiveTextures(): BaseTexture[];
  84359. /**
  84360. * Gets the current class name of the material e.g. "MultiMaterial"
  84361. * Mainly use in serialization.
  84362. * @returns the class name
  84363. */
  84364. getClassName(): string;
  84365. /**
  84366. * Checks if the material is ready to render the requested sub mesh
  84367. * @param mesh Define the mesh the submesh belongs to
  84368. * @param subMesh Define the sub mesh to look readyness for
  84369. * @param useInstances Define whether or not the material is used with instances
  84370. * @returns true if ready, otherwise false
  84371. */
  84372. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84373. /**
  84374. * Clones the current material and its related sub materials
  84375. * @param name Define the name of the newly cloned material
  84376. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  84377. * @returns the cloned material
  84378. */
  84379. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  84380. /**
  84381. * Serializes the materials into a JSON representation.
  84382. * @returns the JSON representation
  84383. */
  84384. serialize(): any;
  84385. /**
  84386. * Dispose the material and release its associated resources
  84387. * @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)
  84388. * @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)
  84389. * @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)
  84390. */
  84391. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  84392. /**
  84393. * Creates a MultiMaterial from parsed MultiMaterial data.
  84394. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  84395. * @param scene defines the hosting scene
  84396. * @returns a new MultiMaterial
  84397. */
  84398. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  84399. }
  84400. }
  84401. declare module BABYLON {
  84402. /**
  84403. * Base class for submeshes
  84404. */
  84405. export class BaseSubMesh {
  84406. /** @hidden */
  84407. _materialDefines: Nullable<MaterialDefines>;
  84408. /** @hidden */
  84409. _materialEffect: Nullable<Effect>;
  84410. /**
  84411. * Gets associated effect
  84412. */
  84413. readonly effect: Nullable<Effect>;
  84414. /**
  84415. * Sets associated effect (effect used to render this submesh)
  84416. * @param effect defines the effect to associate with
  84417. * @param defines defines the set of defines used to compile this effect
  84418. */
  84419. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  84420. }
  84421. /**
  84422. * Defines a subdivision inside a mesh
  84423. */
  84424. export class SubMesh extends BaseSubMesh implements ICullable {
  84425. /** the material index to use */
  84426. materialIndex: number;
  84427. /** vertex index start */
  84428. verticesStart: number;
  84429. /** vertices count */
  84430. verticesCount: number;
  84431. /** index start */
  84432. indexStart: number;
  84433. /** indices count */
  84434. indexCount: number;
  84435. /** @hidden */
  84436. _linesIndexCount: number;
  84437. private _mesh;
  84438. private _renderingMesh;
  84439. private _boundingInfo;
  84440. private _linesIndexBuffer;
  84441. /** @hidden */
  84442. _lastColliderWorldVertices: Nullable<Vector3[]>;
  84443. /** @hidden */
  84444. _trianglePlanes: Plane[];
  84445. /** @hidden */
  84446. _lastColliderTransformMatrix: Nullable<Matrix>;
  84447. /** @hidden */
  84448. _renderId: number;
  84449. /** @hidden */
  84450. _alphaIndex: number;
  84451. /** @hidden */
  84452. _distanceToCamera: number;
  84453. /** @hidden */
  84454. _id: number;
  84455. private _currentMaterial;
  84456. /**
  84457. * Add a new submesh to a mesh
  84458. * @param materialIndex defines the material index to use
  84459. * @param verticesStart defines vertex index start
  84460. * @param verticesCount defines vertices count
  84461. * @param indexStart defines index start
  84462. * @param indexCount defines indices count
  84463. * @param mesh defines the parent mesh
  84464. * @param renderingMesh defines an optional rendering mesh
  84465. * @param createBoundingBox defines if bounding box should be created for this submesh
  84466. * @returns the new submesh
  84467. */
  84468. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  84469. /**
  84470. * Creates a new submesh
  84471. * @param materialIndex defines the material index to use
  84472. * @param verticesStart defines vertex index start
  84473. * @param verticesCount defines vertices count
  84474. * @param indexStart defines index start
  84475. * @param indexCount defines indices count
  84476. * @param mesh defines the parent mesh
  84477. * @param renderingMesh defines an optional rendering mesh
  84478. * @param createBoundingBox defines if bounding box should be created for this submesh
  84479. */
  84480. constructor(
  84481. /** the material index to use */
  84482. materialIndex: number,
  84483. /** vertex index start */
  84484. verticesStart: number,
  84485. /** vertices count */
  84486. verticesCount: number,
  84487. /** index start */
  84488. indexStart: number,
  84489. /** indices count */
  84490. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  84491. /**
  84492. * Returns true if this submesh covers the entire parent mesh
  84493. * @ignorenaming
  84494. */
  84495. readonly IsGlobal: boolean;
  84496. /**
  84497. * Returns the submesh BoudingInfo object
  84498. * @returns current bounding info (or mesh's one if the submesh is global)
  84499. */
  84500. getBoundingInfo(): BoundingInfo;
  84501. /**
  84502. * Sets the submesh BoundingInfo
  84503. * @param boundingInfo defines the new bounding info to use
  84504. * @returns the SubMesh
  84505. */
  84506. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  84507. /**
  84508. * Returns the mesh of the current submesh
  84509. * @return the parent mesh
  84510. */
  84511. getMesh(): AbstractMesh;
  84512. /**
  84513. * Returns the rendering mesh of the submesh
  84514. * @returns the rendering mesh (could be different from parent mesh)
  84515. */
  84516. getRenderingMesh(): Mesh;
  84517. /**
  84518. * Returns the submesh material
  84519. * @returns null or the current material
  84520. */
  84521. getMaterial(): Nullable<Material>;
  84522. /**
  84523. * Sets a new updated BoundingInfo object to the submesh
  84524. * @param data defines an optional position array to use to determine the bounding info
  84525. * @returns the SubMesh
  84526. */
  84527. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  84528. /** @hidden */
  84529. _checkCollision(collider: Collider): boolean;
  84530. /**
  84531. * Updates the submesh BoundingInfo
  84532. * @param world defines the world matrix to use to update the bounding info
  84533. * @returns the submesh
  84534. */
  84535. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  84536. /**
  84537. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  84538. * @param frustumPlanes defines the frustum planes
  84539. * @returns true if the submesh is intersecting with the frustum
  84540. */
  84541. isInFrustum(frustumPlanes: Plane[]): boolean;
  84542. /**
  84543. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  84544. * @param frustumPlanes defines the frustum planes
  84545. * @returns true if the submesh is inside the frustum
  84546. */
  84547. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84548. /**
  84549. * Renders the submesh
  84550. * @param enableAlphaMode defines if alpha needs to be used
  84551. * @returns the submesh
  84552. */
  84553. render(enableAlphaMode: boolean): SubMesh;
  84554. /**
  84555. * @hidden
  84556. */
  84557. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  84558. /**
  84559. * Checks if the submesh intersects with a ray
  84560. * @param ray defines the ray to test
  84561. * @returns true is the passed ray intersects the submesh bounding box
  84562. */
  84563. canIntersects(ray: Ray): boolean;
  84564. /**
  84565. * Intersects current submesh with a ray
  84566. * @param ray defines the ray to test
  84567. * @param positions defines mesh's positions array
  84568. * @param indices defines mesh's indices array
  84569. * @param fastCheck defines if only bounding info should be used
  84570. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  84571. * @returns intersection info or null if no intersection
  84572. */
  84573. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  84574. /** @hidden */
  84575. private _intersectLines;
  84576. /** @hidden */
  84577. private _intersectUnIndexedLines;
  84578. /** @hidden */
  84579. private _intersectTriangles;
  84580. /** @hidden */
  84581. private _intersectUnIndexedTriangles;
  84582. /** @hidden */
  84583. _rebuild(): void;
  84584. /**
  84585. * Creates a new submesh from the passed mesh
  84586. * @param newMesh defines the new hosting mesh
  84587. * @param newRenderingMesh defines an optional rendering mesh
  84588. * @returns the new submesh
  84589. */
  84590. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  84591. /**
  84592. * Release associated resources
  84593. */
  84594. dispose(): void;
  84595. /**
  84596. * Gets the class name
  84597. * @returns the string "SubMesh".
  84598. */
  84599. getClassName(): string;
  84600. /**
  84601. * Creates a new submesh from indices data
  84602. * @param materialIndex the index of the main mesh material
  84603. * @param startIndex the index where to start the copy in the mesh indices array
  84604. * @param indexCount the number of indices to copy then from the startIndex
  84605. * @param mesh the main mesh to create the submesh from
  84606. * @param renderingMesh the optional rendering mesh
  84607. * @returns a new submesh
  84608. */
  84609. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  84610. }
  84611. }
  84612. declare module BABYLON {
  84613. /**
  84614. * Class used to represent data loading progression
  84615. */
  84616. export class SceneLoaderFlags {
  84617. private static _ForceFullSceneLoadingForIncremental;
  84618. private static _ShowLoadingScreen;
  84619. private static _CleanBoneMatrixWeights;
  84620. private static _loggingLevel;
  84621. /**
  84622. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  84623. */
  84624. static ForceFullSceneLoadingForIncremental: boolean;
  84625. /**
  84626. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  84627. */
  84628. static ShowLoadingScreen: boolean;
  84629. /**
  84630. * Defines the current logging level (while loading the scene)
  84631. * @ignorenaming
  84632. */
  84633. static loggingLevel: number;
  84634. /**
  84635. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  84636. */
  84637. static CleanBoneMatrixWeights: boolean;
  84638. }
  84639. }
  84640. declare module BABYLON {
  84641. /**
  84642. * Class used to store geometry data (vertex buffers + index buffer)
  84643. */
  84644. export class Geometry implements IGetSetVerticesData {
  84645. /**
  84646. * Gets or sets the ID of the geometry
  84647. */
  84648. id: string;
  84649. /**
  84650. * Gets or sets the unique ID of the geometry
  84651. */
  84652. uniqueId: number;
  84653. /**
  84654. * Gets the delay loading state of the geometry (none by default which means not delayed)
  84655. */
  84656. delayLoadState: number;
  84657. /**
  84658. * Gets the file containing the data to load when running in delay load state
  84659. */
  84660. delayLoadingFile: Nullable<string>;
  84661. /**
  84662. * Callback called when the geometry is updated
  84663. */
  84664. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  84665. private _scene;
  84666. private _engine;
  84667. private _meshes;
  84668. private _totalVertices;
  84669. /** @hidden */
  84670. _indices: IndicesArray;
  84671. /** @hidden */
  84672. _vertexBuffers: {
  84673. [key: string]: VertexBuffer;
  84674. };
  84675. private _isDisposed;
  84676. private _extend;
  84677. private _boundingBias;
  84678. /** @hidden */
  84679. _delayInfo: Array<string>;
  84680. private _indexBuffer;
  84681. private _indexBufferIsUpdatable;
  84682. /** @hidden */
  84683. _boundingInfo: Nullable<BoundingInfo>;
  84684. /** @hidden */
  84685. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  84686. /** @hidden */
  84687. _softwareSkinningFrameId: number;
  84688. private _vertexArrayObjects;
  84689. private _updatable;
  84690. /** @hidden */
  84691. _positions: Nullable<Vector3[]>;
  84692. /**
  84693. * 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
  84694. */
  84695. /**
  84696. * 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
  84697. */
  84698. boundingBias: Vector2;
  84699. /**
  84700. * Static function used to attach a new empty geometry to a mesh
  84701. * @param mesh defines the mesh to attach the geometry to
  84702. * @returns the new Geometry
  84703. */
  84704. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  84705. /**
  84706. * Creates a new geometry
  84707. * @param id defines the unique ID
  84708. * @param scene defines the hosting scene
  84709. * @param vertexData defines the VertexData used to get geometry data
  84710. * @param updatable defines if geometry must be updatable (false by default)
  84711. * @param mesh defines the mesh that will be associated with the geometry
  84712. */
  84713. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  84714. /**
  84715. * Gets the current extend of the geometry
  84716. */
  84717. readonly extend: {
  84718. minimum: Vector3;
  84719. maximum: Vector3;
  84720. };
  84721. /**
  84722. * Gets the hosting scene
  84723. * @returns the hosting Scene
  84724. */
  84725. getScene(): Scene;
  84726. /**
  84727. * Gets the hosting engine
  84728. * @returns the hosting Engine
  84729. */
  84730. getEngine(): Engine;
  84731. /**
  84732. * Defines if the geometry is ready to use
  84733. * @returns true if the geometry is ready to be used
  84734. */
  84735. isReady(): boolean;
  84736. /**
  84737. * Gets a value indicating that the geometry should not be serialized
  84738. */
  84739. readonly doNotSerialize: boolean;
  84740. /** @hidden */
  84741. _rebuild(): void;
  84742. /**
  84743. * Affects all geometry data in one call
  84744. * @param vertexData defines the geometry data
  84745. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  84746. */
  84747. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  84748. /**
  84749. * Set specific vertex data
  84750. * @param kind defines the data kind (Position, normal, etc...)
  84751. * @param data defines the vertex data to use
  84752. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  84753. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  84754. */
  84755. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  84756. /**
  84757. * Removes a specific vertex data
  84758. * @param kind defines the data kind (Position, normal, etc...)
  84759. */
  84760. removeVerticesData(kind: string): void;
  84761. /**
  84762. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  84763. * @param buffer defines the vertex buffer to use
  84764. * @param totalVertices defines the total number of vertices for position kind (could be null)
  84765. */
  84766. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  84767. /**
  84768. * Update a specific vertex buffer
  84769. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  84770. * It will do nothing if the buffer is not updatable
  84771. * @param kind defines the data kind (Position, normal, etc...)
  84772. * @param data defines the data to use
  84773. * @param offset defines the offset in the target buffer where to store the data
  84774. * @param useBytes set to true if the offset is in bytes
  84775. */
  84776. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  84777. /**
  84778. * Update a specific vertex buffer
  84779. * This function will create a new buffer if the current one is not updatable
  84780. * @param kind defines the data kind (Position, normal, etc...)
  84781. * @param data defines the data to use
  84782. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  84783. */
  84784. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  84785. private _updateBoundingInfo;
  84786. /** @hidden */
  84787. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  84788. /**
  84789. * Gets total number of vertices
  84790. * @returns the total number of vertices
  84791. */
  84792. getTotalVertices(): number;
  84793. /**
  84794. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  84795. * @param kind defines the data kind (Position, normal, etc...)
  84796. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  84797. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84798. * @returns a float array containing vertex data
  84799. */
  84800. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  84801. /**
  84802. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  84803. * @param kind defines the data kind (Position, normal, etc...)
  84804. * @returns true if the vertex buffer with the specified kind is updatable
  84805. */
  84806. isVertexBufferUpdatable(kind: string): boolean;
  84807. /**
  84808. * Gets a specific vertex buffer
  84809. * @param kind defines the data kind (Position, normal, etc...)
  84810. * @returns a VertexBuffer
  84811. */
  84812. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  84813. /**
  84814. * Returns all vertex buffers
  84815. * @return an object holding all vertex buffers indexed by kind
  84816. */
  84817. getVertexBuffers(): Nullable<{
  84818. [key: string]: VertexBuffer;
  84819. }>;
  84820. /**
  84821. * Gets a boolean indicating if specific vertex buffer is present
  84822. * @param kind defines the data kind (Position, normal, etc...)
  84823. * @returns true if data is present
  84824. */
  84825. isVerticesDataPresent(kind: string): boolean;
  84826. /**
  84827. * Gets a list of all attached data kinds (Position, normal, etc...)
  84828. * @returns a list of string containing all kinds
  84829. */
  84830. getVerticesDataKinds(): string[];
  84831. /**
  84832. * Update index buffer
  84833. * @param indices defines the indices to store in the index buffer
  84834. * @param offset defines the offset in the target buffer where to store the data
  84835. * @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)
  84836. */
  84837. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  84838. /**
  84839. * Creates a new index buffer
  84840. * @param indices defines the indices to store in the index buffer
  84841. * @param totalVertices defines the total number of vertices (could be null)
  84842. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  84843. */
  84844. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  84845. /**
  84846. * Return the total number of indices
  84847. * @returns the total number of indices
  84848. */
  84849. getTotalIndices(): number;
  84850. /**
  84851. * Gets the index buffer array
  84852. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  84853. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84854. * @returns the index buffer array
  84855. */
  84856. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  84857. /**
  84858. * Gets the index buffer
  84859. * @return the index buffer
  84860. */
  84861. getIndexBuffer(): Nullable<DataBuffer>;
  84862. /** @hidden */
  84863. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  84864. /**
  84865. * Release the associated resources for a specific mesh
  84866. * @param mesh defines the source mesh
  84867. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  84868. */
  84869. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  84870. /**
  84871. * Apply current geometry to a given mesh
  84872. * @param mesh defines the mesh to apply geometry to
  84873. */
  84874. applyToMesh(mesh: Mesh): void;
  84875. private _updateExtend;
  84876. private _applyToMesh;
  84877. private notifyUpdate;
  84878. /**
  84879. * Load the geometry if it was flagged as delay loaded
  84880. * @param scene defines the hosting scene
  84881. * @param onLoaded defines a callback called when the geometry is loaded
  84882. */
  84883. load(scene: Scene, onLoaded?: () => void): void;
  84884. private _queueLoad;
  84885. /**
  84886. * Invert the geometry to move from a right handed system to a left handed one.
  84887. */
  84888. toLeftHanded(): void;
  84889. /** @hidden */
  84890. _resetPointsArrayCache(): void;
  84891. /** @hidden */
  84892. _generatePointsArray(): boolean;
  84893. /**
  84894. * Gets a value indicating if the geometry is disposed
  84895. * @returns true if the geometry was disposed
  84896. */
  84897. isDisposed(): boolean;
  84898. private _disposeVertexArrayObjects;
  84899. /**
  84900. * Free all associated resources
  84901. */
  84902. dispose(): void;
  84903. /**
  84904. * Clone the current geometry into a new geometry
  84905. * @param id defines the unique ID of the new geometry
  84906. * @returns a new geometry object
  84907. */
  84908. copy(id: string): Geometry;
  84909. /**
  84910. * Serialize the current geometry info (and not the vertices data) into a JSON object
  84911. * @return a JSON representation of the current geometry data (without the vertices data)
  84912. */
  84913. serialize(): any;
  84914. private toNumberArray;
  84915. /**
  84916. * Serialize all vertices data into a JSON oject
  84917. * @returns a JSON representation of the current geometry data
  84918. */
  84919. serializeVerticeData(): any;
  84920. /**
  84921. * Extracts a clone of a mesh geometry
  84922. * @param mesh defines the source mesh
  84923. * @param id defines the unique ID of the new geometry object
  84924. * @returns the new geometry object
  84925. */
  84926. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  84927. /**
  84928. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  84929. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  84930. * Be aware Math.random() could cause collisions, but:
  84931. * "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"
  84932. * @returns a string containing a new GUID
  84933. */
  84934. static RandomId(): string;
  84935. /** @hidden */
  84936. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  84937. private static _CleanMatricesWeights;
  84938. /**
  84939. * Create a new geometry from persisted data (Using .babylon file format)
  84940. * @param parsedVertexData defines the persisted data
  84941. * @param scene defines the hosting scene
  84942. * @param rootUrl defines the root url to use to load assets (like delayed data)
  84943. * @returns the new geometry object
  84944. */
  84945. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  84946. }
  84947. }
  84948. declare module BABYLON {
  84949. /**
  84950. * Define an interface for all classes that will get and set the data on vertices
  84951. */
  84952. export interface IGetSetVerticesData {
  84953. /**
  84954. * Gets a boolean indicating if specific vertex data is present
  84955. * @param kind defines the vertex data kind to use
  84956. * @returns true is data kind is present
  84957. */
  84958. isVerticesDataPresent(kind: string): boolean;
  84959. /**
  84960. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  84961. * @param kind defines the data kind (Position, normal, etc...)
  84962. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  84963. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84964. * @returns a float array containing vertex data
  84965. */
  84966. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  84967. /**
  84968. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  84969. * @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.
  84970. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84971. * @returns the indices array or an empty array if the mesh has no geometry
  84972. */
  84973. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  84974. /**
  84975. * Set specific vertex data
  84976. * @param kind defines the data kind (Position, normal, etc...)
  84977. * @param data defines the vertex data to use
  84978. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  84979. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  84980. */
  84981. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  84982. /**
  84983. * Update a specific associated vertex buffer
  84984. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  84985. * - VertexBuffer.PositionKind
  84986. * - VertexBuffer.UVKind
  84987. * - VertexBuffer.UV2Kind
  84988. * - VertexBuffer.UV3Kind
  84989. * - VertexBuffer.UV4Kind
  84990. * - VertexBuffer.UV5Kind
  84991. * - VertexBuffer.UV6Kind
  84992. * - VertexBuffer.ColorKind
  84993. * - VertexBuffer.MatricesIndicesKind
  84994. * - VertexBuffer.MatricesIndicesExtraKind
  84995. * - VertexBuffer.MatricesWeightsKind
  84996. * - VertexBuffer.MatricesWeightsExtraKind
  84997. * @param data defines the data source
  84998. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  84999. * @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)
  85000. */
  85001. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  85002. /**
  85003. * Creates a new index buffer
  85004. * @param indices defines the indices to store in the index buffer
  85005. * @param totalVertices defines the total number of vertices (could be null)
  85006. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85007. */
  85008. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  85009. }
  85010. /**
  85011. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  85012. */
  85013. export class VertexData {
  85014. /**
  85015. * Mesh side orientation : usually the external or front surface
  85016. */
  85017. static readonly FRONTSIDE: number;
  85018. /**
  85019. * Mesh side orientation : usually the internal or back surface
  85020. */
  85021. static readonly BACKSIDE: number;
  85022. /**
  85023. * Mesh side orientation : both internal and external or front and back surfaces
  85024. */
  85025. static readonly DOUBLESIDE: number;
  85026. /**
  85027. * Mesh side orientation : by default, `FRONTSIDE`
  85028. */
  85029. static readonly DEFAULTSIDE: number;
  85030. /**
  85031. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  85032. */
  85033. positions: Nullable<FloatArray>;
  85034. /**
  85035. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  85036. */
  85037. normals: Nullable<FloatArray>;
  85038. /**
  85039. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  85040. */
  85041. tangents: Nullable<FloatArray>;
  85042. /**
  85043. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85044. */
  85045. uvs: Nullable<FloatArray>;
  85046. /**
  85047. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85048. */
  85049. uvs2: Nullable<FloatArray>;
  85050. /**
  85051. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85052. */
  85053. uvs3: Nullable<FloatArray>;
  85054. /**
  85055. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85056. */
  85057. uvs4: Nullable<FloatArray>;
  85058. /**
  85059. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85060. */
  85061. uvs5: Nullable<FloatArray>;
  85062. /**
  85063. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85064. */
  85065. uvs6: Nullable<FloatArray>;
  85066. /**
  85067. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  85068. */
  85069. colors: Nullable<FloatArray>;
  85070. /**
  85071. * 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).
  85072. */
  85073. matricesIndices: Nullable<FloatArray>;
  85074. /**
  85075. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  85076. */
  85077. matricesWeights: Nullable<FloatArray>;
  85078. /**
  85079. * An array extending the number of possible indices
  85080. */
  85081. matricesIndicesExtra: Nullable<FloatArray>;
  85082. /**
  85083. * An array extending the number of possible weights when the number of indices is extended
  85084. */
  85085. matricesWeightsExtra: Nullable<FloatArray>;
  85086. /**
  85087. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  85088. */
  85089. indices: Nullable<IndicesArray>;
  85090. /**
  85091. * Uses the passed data array to set the set the values for the specified kind of data
  85092. * @param data a linear array of floating numbers
  85093. * @param kind the type of data that is being set, eg positions, colors etc
  85094. */
  85095. set(data: FloatArray, kind: string): void;
  85096. /**
  85097. * Associates the vertexData to the passed Mesh.
  85098. * Sets it as updatable or not (default `false`)
  85099. * @param mesh the mesh the vertexData is applied to
  85100. * @param updatable when used and having the value true allows new data to update the vertexData
  85101. * @returns the VertexData
  85102. */
  85103. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  85104. /**
  85105. * Associates the vertexData to the passed Geometry.
  85106. * Sets it as updatable or not (default `false`)
  85107. * @param geometry the geometry the vertexData is applied to
  85108. * @param updatable when used and having the value true allows new data to update the vertexData
  85109. * @returns VertexData
  85110. */
  85111. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  85112. /**
  85113. * Updates the associated mesh
  85114. * @param mesh the mesh to be updated
  85115. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85116. * @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
  85117. * @returns VertexData
  85118. */
  85119. updateMesh(mesh: Mesh): VertexData;
  85120. /**
  85121. * Updates the associated geometry
  85122. * @param geometry the geometry to be updated
  85123. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85124. * @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
  85125. * @returns VertexData.
  85126. */
  85127. updateGeometry(geometry: Geometry): VertexData;
  85128. private _applyTo;
  85129. private _update;
  85130. /**
  85131. * Transforms each position and each normal of the vertexData according to the passed Matrix
  85132. * @param matrix the transforming matrix
  85133. * @returns the VertexData
  85134. */
  85135. transform(matrix: Matrix): VertexData;
  85136. /**
  85137. * Merges the passed VertexData into the current one
  85138. * @param other the VertexData to be merged into the current one
  85139. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  85140. * @returns the modified VertexData
  85141. */
  85142. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  85143. private _mergeElement;
  85144. private _validate;
  85145. /**
  85146. * Serializes the VertexData
  85147. * @returns a serialized object
  85148. */
  85149. serialize(): any;
  85150. /**
  85151. * Extracts the vertexData from a mesh
  85152. * @param mesh the mesh from which to extract the VertexData
  85153. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  85154. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85155. * @returns the object VertexData associated to the passed mesh
  85156. */
  85157. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85158. /**
  85159. * Extracts the vertexData from the geometry
  85160. * @param geometry the geometry from which to extract the VertexData
  85161. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  85162. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85163. * @returns the object VertexData associated to the passed mesh
  85164. */
  85165. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85166. private static _ExtractFrom;
  85167. /**
  85168. * Creates the VertexData for a Ribbon
  85169. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  85170. * * pathArray array of paths, each of which an array of successive Vector3
  85171. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  85172. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  85173. * * 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
  85174. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85175. * * 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)
  85176. * * 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)
  85177. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  85178. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  85179. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  85180. * @returns the VertexData of the ribbon
  85181. */
  85182. static CreateRibbon(options: {
  85183. pathArray: Vector3[][];
  85184. closeArray?: boolean;
  85185. closePath?: boolean;
  85186. offset?: number;
  85187. sideOrientation?: number;
  85188. frontUVs?: Vector4;
  85189. backUVs?: Vector4;
  85190. invertUV?: boolean;
  85191. uvs?: Vector2[];
  85192. colors?: Color4[];
  85193. }): VertexData;
  85194. /**
  85195. * Creates the VertexData for a box
  85196. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85197. * * size sets the width, height and depth of the box to the value of size, optional default 1
  85198. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  85199. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  85200. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  85201. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85202. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85203. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85204. * * 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)
  85205. * * 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)
  85206. * @returns the VertexData of the box
  85207. */
  85208. static CreateBox(options: {
  85209. size?: number;
  85210. width?: number;
  85211. height?: number;
  85212. depth?: number;
  85213. faceUV?: Vector4[];
  85214. faceColors?: Color4[];
  85215. sideOrientation?: number;
  85216. frontUVs?: Vector4;
  85217. backUVs?: Vector4;
  85218. }): VertexData;
  85219. /**
  85220. * Creates the VertexData for a tiled box
  85221. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85222. * * faceTiles sets the pattern, tile size and number of tiles for a face
  85223. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85224. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85225. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85226. * @returns the VertexData of the box
  85227. */
  85228. static CreateTiledBox(options: {
  85229. pattern?: number;
  85230. width?: number;
  85231. height?: number;
  85232. depth?: number;
  85233. tileSize?: number;
  85234. tileWidth?: number;
  85235. tileHeight?: number;
  85236. alignHorizontal?: number;
  85237. alignVertical?: number;
  85238. faceUV?: Vector4[];
  85239. faceColors?: Color4[];
  85240. sideOrientation?: number;
  85241. }): VertexData;
  85242. /**
  85243. * Creates the VertexData for a tiled plane
  85244. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85245. * * pattern a limited pattern arrangement depending on the number
  85246. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  85247. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  85248. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  85249. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85250. * * 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)
  85251. * * 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)
  85252. * @returns the VertexData of the tiled plane
  85253. */
  85254. static CreateTiledPlane(options: {
  85255. pattern?: number;
  85256. tileSize?: number;
  85257. tileWidth?: number;
  85258. tileHeight?: number;
  85259. size?: number;
  85260. width?: number;
  85261. height?: number;
  85262. alignHorizontal?: number;
  85263. alignVertical?: number;
  85264. sideOrientation?: number;
  85265. frontUVs?: Vector4;
  85266. backUVs?: Vector4;
  85267. }): VertexData;
  85268. /**
  85269. * Creates the VertexData for an ellipsoid, defaults to a sphere
  85270. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85271. * * segments sets the number of horizontal strips optional, default 32
  85272. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  85273. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  85274. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  85275. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  85276. * * 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
  85277. * * 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
  85278. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85279. * * 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)
  85280. * * 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)
  85281. * @returns the VertexData of the ellipsoid
  85282. */
  85283. static CreateSphere(options: {
  85284. segments?: number;
  85285. diameter?: number;
  85286. diameterX?: number;
  85287. diameterY?: number;
  85288. diameterZ?: number;
  85289. arc?: number;
  85290. slice?: number;
  85291. sideOrientation?: number;
  85292. frontUVs?: Vector4;
  85293. backUVs?: Vector4;
  85294. }): VertexData;
  85295. /**
  85296. * Creates the VertexData for a cylinder, cone or prism
  85297. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85298. * * height sets the height (y direction) of the cylinder, optional, default 2
  85299. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  85300. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  85301. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  85302. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85303. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  85304. * * 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
  85305. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85306. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85307. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  85308. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  85309. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85310. * * 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)
  85311. * * 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)
  85312. * @returns the VertexData of the cylinder, cone or prism
  85313. */
  85314. static CreateCylinder(options: {
  85315. height?: number;
  85316. diameterTop?: number;
  85317. diameterBottom?: number;
  85318. diameter?: number;
  85319. tessellation?: number;
  85320. subdivisions?: number;
  85321. arc?: number;
  85322. faceColors?: Color4[];
  85323. faceUV?: Vector4[];
  85324. hasRings?: boolean;
  85325. enclose?: boolean;
  85326. sideOrientation?: number;
  85327. frontUVs?: Vector4;
  85328. backUVs?: Vector4;
  85329. }): VertexData;
  85330. /**
  85331. * Creates the VertexData for a torus
  85332. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85333. * * diameter the diameter of the torus, optional default 1
  85334. * * thickness the diameter of the tube forming the torus, optional default 0.5
  85335. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85336. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85337. * * 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)
  85338. * * 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)
  85339. * @returns the VertexData of the torus
  85340. */
  85341. static CreateTorus(options: {
  85342. diameter?: number;
  85343. thickness?: number;
  85344. tessellation?: number;
  85345. sideOrientation?: number;
  85346. frontUVs?: Vector4;
  85347. backUVs?: Vector4;
  85348. }): VertexData;
  85349. /**
  85350. * Creates the VertexData of the LineSystem
  85351. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  85352. * - lines an array of lines, each line being an array of successive Vector3
  85353. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  85354. * @returns the VertexData of the LineSystem
  85355. */
  85356. static CreateLineSystem(options: {
  85357. lines: Vector3[][];
  85358. colors?: Nullable<Color4[][]>;
  85359. }): VertexData;
  85360. /**
  85361. * Create the VertexData for a DashedLines
  85362. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  85363. * - points an array successive Vector3
  85364. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  85365. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  85366. * - dashNb the intended total number of dashes, optional, default 200
  85367. * @returns the VertexData for the DashedLines
  85368. */
  85369. static CreateDashedLines(options: {
  85370. points: Vector3[];
  85371. dashSize?: number;
  85372. gapSize?: number;
  85373. dashNb?: number;
  85374. }): VertexData;
  85375. /**
  85376. * Creates the VertexData for a Ground
  85377. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  85378. * - width the width (x direction) of the ground, optional, default 1
  85379. * - height the height (z direction) of the ground, optional, default 1
  85380. * - subdivisions the number of subdivisions per side, optional, default 1
  85381. * @returns the VertexData of the Ground
  85382. */
  85383. static CreateGround(options: {
  85384. width?: number;
  85385. height?: number;
  85386. subdivisions?: number;
  85387. subdivisionsX?: number;
  85388. subdivisionsY?: number;
  85389. }): VertexData;
  85390. /**
  85391. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  85392. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  85393. * * xmin the ground minimum X coordinate, optional, default -1
  85394. * * zmin the ground minimum Z coordinate, optional, default -1
  85395. * * xmax the ground maximum X coordinate, optional, default 1
  85396. * * zmax the ground maximum Z coordinate, optional, default 1
  85397. * * 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}
  85398. * * 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}
  85399. * @returns the VertexData of the TiledGround
  85400. */
  85401. static CreateTiledGround(options: {
  85402. xmin: number;
  85403. zmin: number;
  85404. xmax: number;
  85405. zmax: number;
  85406. subdivisions?: {
  85407. w: number;
  85408. h: number;
  85409. };
  85410. precision?: {
  85411. w: number;
  85412. h: number;
  85413. };
  85414. }): VertexData;
  85415. /**
  85416. * Creates the VertexData of the Ground designed from a heightmap
  85417. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  85418. * * width the width (x direction) of the ground
  85419. * * height the height (z direction) of the ground
  85420. * * subdivisions the number of subdivisions per side
  85421. * * minHeight the minimum altitude on the ground, optional, default 0
  85422. * * maxHeight the maximum altitude on the ground, optional default 1
  85423. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  85424. * * buffer the array holding the image color data
  85425. * * bufferWidth the width of image
  85426. * * bufferHeight the height of image
  85427. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  85428. * @returns the VertexData of the Ground designed from a heightmap
  85429. */
  85430. static CreateGroundFromHeightMap(options: {
  85431. width: number;
  85432. height: number;
  85433. subdivisions: number;
  85434. minHeight: number;
  85435. maxHeight: number;
  85436. colorFilter: Color3;
  85437. buffer: Uint8Array;
  85438. bufferWidth: number;
  85439. bufferHeight: number;
  85440. alphaFilter: number;
  85441. }): VertexData;
  85442. /**
  85443. * Creates the VertexData for a Plane
  85444. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  85445. * * size sets the width and height of the plane to the value of size, optional default 1
  85446. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  85447. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  85448. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85449. * * 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)
  85450. * * 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)
  85451. * @returns the VertexData of the box
  85452. */
  85453. static CreatePlane(options: {
  85454. size?: number;
  85455. width?: number;
  85456. height?: number;
  85457. sideOrientation?: number;
  85458. frontUVs?: Vector4;
  85459. backUVs?: Vector4;
  85460. }): VertexData;
  85461. /**
  85462. * Creates the VertexData of the Disc or regular Polygon
  85463. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  85464. * * radius the radius of the disc, optional default 0.5
  85465. * * tessellation the number of polygon sides, optional, default 64
  85466. * * 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
  85467. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85468. * * 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)
  85469. * * 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)
  85470. * @returns the VertexData of the box
  85471. */
  85472. static CreateDisc(options: {
  85473. radius?: number;
  85474. tessellation?: number;
  85475. arc?: number;
  85476. sideOrientation?: number;
  85477. frontUVs?: Vector4;
  85478. backUVs?: Vector4;
  85479. }): VertexData;
  85480. /**
  85481. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  85482. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  85483. * @param polygon a mesh built from polygonTriangulation.build()
  85484. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85485. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85486. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85487. * @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)
  85488. * @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)
  85489. * @returns the VertexData of the Polygon
  85490. */
  85491. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  85492. /**
  85493. * Creates the VertexData of the IcoSphere
  85494. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  85495. * * radius the radius of the IcoSphere, optional default 1
  85496. * * radiusX allows stretching in the x direction, optional, default radius
  85497. * * radiusY allows stretching in the y direction, optional, default radius
  85498. * * radiusZ allows stretching in the z direction, optional, default radius
  85499. * * flat when true creates a flat shaded mesh, optional, default true
  85500. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  85501. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85502. * * 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)
  85503. * * 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)
  85504. * @returns the VertexData of the IcoSphere
  85505. */
  85506. static CreateIcoSphere(options: {
  85507. radius?: number;
  85508. radiusX?: number;
  85509. radiusY?: number;
  85510. radiusZ?: number;
  85511. flat?: boolean;
  85512. subdivisions?: number;
  85513. sideOrientation?: number;
  85514. frontUVs?: Vector4;
  85515. backUVs?: Vector4;
  85516. }): VertexData;
  85517. /**
  85518. * Creates the VertexData for a Polyhedron
  85519. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  85520. * * type provided types are:
  85521. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  85522. * * 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)
  85523. * * size the size of the IcoSphere, optional default 1
  85524. * * sizeX allows stretching in the x direction, optional, default size
  85525. * * sizeY allows stretching in the y direction, optional, default size
  85526. * * sizeZ allows stretching in the z direction, optional, default size
  85527. * * 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
  85528. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85529. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85530. * * flat when true creates a flat shaded mesh, optional, default true
  85531. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  85532. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85533. * * 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)
  85534. * * 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)
  85535. * @returns the VertexData of the Polyhedron
  85536. */
  85537. static CreatePolyhedron(options: {
  85538. type?: number;
  85539. size?: number;
  85540. sizeX?: number;
  85541. sizeY?: number;
  85542. sizeZ?: number;
  85543. custom?: any;
  85544. faceUV?: Vector4[];
  85545. faceColors?: Color4[];
  85546. flat?: boolean;
  85547. sideOrientation?: number;
  85548. frontUVs?: Vector4;
  85549. backUVs?: Vector4;
  85550. }): VertexData;
  85551. /**
  85552. * Creates the VertexData for a TorusKnot
  85553. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  85554. * * radius the radius of the torus knot, optional, default 2
  85555. * * tube the thickness of the tube, optional, default 0.5
  85556. * * radialSegments the number of sides on each tube segments, optional, default 32
  85557. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  85558. * * p the number of windings around the z axis, optional, default 2
  85559. * * q the number of windings around the x axis, optional, default 3
  85560. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85561. * * 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)
  85562. * * 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)
  85563. * @returns the VertexData of the Torus Knot
  85564. */
  85565. static CreateTorusKnot(options: {
  85566. radius?: number;
  85567. tube?: number;
  85568. radialSegments?: number;
  85569. tubularSegments?: number;
  85570. p?: number;
  85571. q?: number;
  85572. sideOrientation?: number;
  85573. frontUVs?: Vector4;
  85574. backUVs?: Vector4;
  85575. }): VertexData;
  85576. /**
  85577. * Compute normals for given positions and indices
  85578. * @param positions an array of vertex positions, [...., x, y, z, ......]
  85579. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  85580. * @param normals an array of vertex normals, [...., x, y, z, ......]
  85581. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  85582. * * facetNormals : optional array of facet normals (vector3)
  85583. * * facetPositions : optional array of facet positions (vector3)
  85584. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  85585. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  85586. * * bInfo : optional bounding info, required for facetPartitioning computation
  85587. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  85588. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  85589. * * useRightHandedSystem: optional boolean to for right handed system computation
  85590. * * depthSort : optional boolean to enable the facet depth sort computation
  85591. * * distanceTo : optional Vector3 to compute the facet depth from this location
  85592. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  85593. */
  85594. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  85595. facetNormals?: any;
  85596. facetPositions?: any;
  85597. facetPartitioning?: any;
  85598. ratio?: number;
  85599. bInfo?: any;
  85600. bbSize?: Vector3;
  85601. subDiv?: any;
  85602. useRightHandedSystem?: boolean;
  85603. depthSort?: boolean;
  85604. distanceTo?: Vector3;
  85605. depthSortedFacets?: any;
  85606. }): void;
  85607. /** @hidden */
  85608. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  85609. /**
  85610. * Applies VertexData created from the imported parameters to the geometry
  85611. * @param parsedVertexData the parsed data from an imported file
  85612. * @param geometry the geometry to apply the VertexData to
  85613. */
  85614. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  85615. }
  85616. }
  85617. declare module BABYLON {
  85618. /**
  85619. * Defines a target to use with MorphTargetManager
  85620. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  85621. */
  85622. export class MorphTarget implements IAnimatable {
  85623. /** defines the name of the target */
  85624. name: string;
  85625. /**
  85626. * Gets or sets the list of animations
  85627. */
  85628. animations: Animation[];
  85629. private _scene;
  85630. private _positions;
  85631. private _normals;
  85632. private _tangents;
  85633. private _uvs;
  85634. private _influence;
  85635. /**
  85636. * Observable raised when the influence changes
  85637. */
  85638. onInfluenceChanged: Observable<boolean>;
  85639. /** @hidden */
  85640. _onDataLayoutChanged: Observable<void>;
  85641. /**
  85642. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  85643. */
  85644. influence: number;
  85645. /**
  85646. * Gets or sets the id of the morph Target
  85647. */
  85648. id: string;
  85649. private _animationPropertiesOverride;
  85650. /**
  85651. * Gets or sets the animation properties override
  85652. */
  85653. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  85654. /**
  85655. * Creates a new MorphTarget
  85656. * @param name defines the name of the target
  85657. * @param influence defines the influence to use
  85658. * @param scene defines the scene the morphtarget belongs to
  85659. */
  85660. constructor(
  85661. /** defines the name of the target */
  85662. name: string, influence?: number, scene?: Nullable<Scene>);
  85663. /**
  85664. * Gets a boolean defining if the target contains position data
  85665. */
  85666. readonly hasPositions: boolean;
  85667. /**
  85668. * Gets a boolean defining if the target contains normal data
  85669. */
  85670. readonly hasNormals: boolean;
  85671. /**
  85672. * Gets a boolean defining if the target contains tangent data
  85673. */
  85674. readonly hasTangents: boolean;
  85675. /**
  85676. * Gets a boolean defining if the target contains texture coordinates data
  85677. */
  85678. readonly hasUVs: boolean;
  85679. /**
  85680. * Affects position data to this target
  85681. * @param data defines the position data to use
  85682. */
  85683. setPositions(data: Nullable<FloatArray>): void;
  85684. /**
  85685. * Gets the position data stored in this target
  85686. * @returns a FloatArray containing the position data (or null if not present)
  85687. */
  85688. getPositions(): Nullable<FloatArray>;
  85689. /**
  85690. * Affects normal data to this target
  85691. * @param data defines the normal data to use
  85692. */
  85693. setNormals(data: Nullable<FloatArray>): void;
  85694. /**
  85695. * Gets the normal data stored in this target
  85696. * @returns a FloatArray containing the normal data (or null if not present)
  85697. */
  85698. getNormals(): Nullable<FloatArray>;
  85699. /**
  85700. * Affects tangent data to this target
  85701. * @param data defines the tangent data to use
  85702. */
  85703. setTangents(data: Nullable<FloatArray>): void;
  85704. /**
  85705. * Gets the tangent data stored in this target
  85706. * @returns a FloatArray containing the tangent data (or null if not present)
  85707. */
  85708. getTangents(): Nullable<FloatArray>;
  85709. /**
  85710. * Affects texture coordinates data to this target
  85711. * @param data defines the texture coordinates data to use
  85712. */
  85713. setUVs(data: Nullable<FloatArray>): void;
  85714. /**
  85715. * Gets the texture coordinates data stored in this target
  85716. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  85717. */
  85718. getUVs(): Nullable<FloatArray>;
  85719. /**
  85720. * Serializes the current target into a Serialization object
  85721. * @returns the serialized object
  85722. */
  85723. serialize(): any;
  85724. /**
  85725. * Returns the string "MorphTarget"
  85726. * @returns "MorphTarget"
  85727. */
  85728. getClassName(): string;
  85729. /**
  85730. * Creates a new target from serialized data
  85731. * @param serializationObject defines the serialized data to use
  85732. * @returns a new MorphTarget
  85733. */
  85734. static Parse(serializationObject: any): MorphTarget;
  85735. /**
  85736. * Creates a MorphTarget from mesh data
  85737. * @param mesh defines the source mesh
  85738. * @param name defines the name to use for the new target
  85739. * @param influence defines the influence to attach to the target
  85740. * @returns a new MorphTarget
  85741. */
  85742. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  85743. }
  85744. }
  85745. declare module BABYLON {
  85746. /**
  85747. * This class is used to deform meshes using morphing between different targets
  85748. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  85749. */
  85750. export class MorphTargetManager {
  85751. private _targets;
  85752. private _targetInfluenceChangedObservers;
  85753. private _targetDataLayoutChangedObservers;
  85754. private _activeTargets;
  85755. private _scene;
  85756. private _influences;
  85757. private _supportsNormals;
  85758. private _supportsTangents;
  85759. private _supportsUVs;
  85760. private _vertexCount;
  85761. private _uniqueId;
  85762. private _tempInfluences;
  85763. /**
  85764. * Gets or sets a boolean indicating if normals must be morphed
  85765. */
  85766. enableNormalMorphing: boolean;
  85767. /**
  85768. * Gets or sets a boolean indicating if tangents must be morphed
  85769. */
  85770. enableTangentMorphing: boolean;
  85771. /**
  85772. * Gets or sets a boolean indicating if UV must be morphed
  85773. */
  85774. enableUVMorphing: boolean;
  85775. /**
  85776. * Creates a new MorphTargetManager
  85777. * @param scene defines the current scene
  85778. */
  85779. constructor(scene?: Nullable<Scene>);
  85780. /**
  85781. * Gets the unique ID of this manager
  85782. */
  85783. readonly uniqueId: number;
  85784. /**
  85785. * Gets the number of vertices handled by this manager
  85786. */
  85787. readonly vertexCount: number;
  85788. /**
  85789. * Gets a boolean indicating if this manager supports morphing of normals
  85790. */
  85791. readonly supportsNormals: boolean;
  85792. /**
  85793. * Gets a boolean indicating if this manager supports morphing of tangents
  85794. */
  85795. readonly supportsTangents: boolean;
  85796. /**
  85797. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  85798. */
  85799. readonly supportsUVs: boolean;
  85800. /**
  85801. * Gets the number of targets stored in this manager
  85802. */
  85803. readonly numTargets: number;
  85804. /**
  85805. * Gets the number of influencers (ie. the number of targets with influences > 0)
  85806. */
  85807. readonly numInfluencers: number;
  85808. /**
  85809. * Gets the list of influences (one per target)
  85810. */
  85811. readonly influences: Float32Array;
  85812. /**
  85813. * Gets the active target at specified index. An active target is a target with an influence > 0
  85814. * @param index defines the index to check
  85815. * @returns the requested target
  85816. */
  85817. getActiveTarget(index: number): MorphTarget;
  85818. /**
  85819. * Gets the target at specified index
  85820. * @param index defines the index to check
  85821. * @returns the requested target
  85822. */
  85823. getTarget(index: number): MorphTarget;
  85824. /**
  85825. * Add a new target to this manager
  85826. * @param target defines the target to add
  85827. */
  85828. addTarget(target: MorphTarget): void;
  85829. /**
  85830. * Removes a target from the manager
  85831. * @param target defines the target to remove
  85832. */
  85833. removeTarget(target: MorphTarget): void;
  85834. /**
  85835. * Serializes the current manager into a Serialization object
  85836. * @returns the serialized object
  85837. */
  85838. serialize(): any;
  85839. private _syncActiveTargets;
  85840. /**
  85841. * Syncrhonize the targets with all the meshes using this morph target manager
  85842. */
  85843. synchronize(): void;
  85844. /**
  85845. * Creates a new MorphTargetManager from serialized data
  85846. * @param serializationObject defines the serialized data
  85847. * @param scene defines the hosting scene
  85848. * @returns the new MorphTargetManager
  85849. */
  85850. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  85851. }
  85852. }
  85853. declare module BABYLON {
  85854. /**
  85855. * Class used to represent a specific level of detail of a mesh
  85856. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  85857. */
  85858. export class MeshLODLevel {
  85859. /** Defines the distance where this level should star being displayed */
  85860. distance: number;
  85861. /** Defines the mesh to use to render this level */
  85862. mesh: Nullable<Mesh>;
  85863. /**
  85864. * Creates a new LOD level
  85865. * @param distance defines the distance where this level should star being displayed
  85866. * @param mesh defines the mesh to use to render this level
  85867. */
  85868. constructor(
  85869. /** Defines the distance where this level should star being displayed */
  85870. distance: number,
  85871. /** Defines the mesh to use to render this level */
  85872. mesh: Nullable<Mesh>);
  85873. }
  85874. }
  85875. declare module BABYLON {
  85876. /**
  85877. * Mesh representing the gorund
  85878. */
  85879. export class GroundMesh extends Mesh {
  85880. /** If octree should be generated */
  85881. generateOctree: boolean;
  85882. private _heightQuads;
  85883. /** @hidden */
  85884. _subdivisionsX: number;
  85885. /** @hidden */
  85886. _subdivisionsY: number;
  85887. /** @hidden */
  85888. _width: number;
  85889. /** @hidden */
  85890. _height: number;
  85891. /** @hidden */
  85892. _minX: number;
  85893. /** @hidden */
  85894. _maxX: number;
  85895. /** @hidden */
  85896. _minZ: number;
  85897. /** @hidden */
  85898. _maxZ: number;
  85899. constructor(name: string, scene: Scene);
  85900. /**
  85901. * "GroundMesh"
  85902. * @returns "GroundMesh"
  85903. */
  85904. getClassName(): string;
  85905. /**
  85906. * The minimum of x and y subdivisions
  85907. */
  85908. readonly subdivisions: number;
  85909. /**
  85910. * X subdivisions
  85911. */
  85912. readonly subdivisionsX: number;
  85913. /**
  85914. * Y subdivisions
  85915. */
  85916. readonly subdivisionsY: number;
  85917. /**
  85918. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  85919. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  85920. * @param chunksCount the number of subdivisions for x and y
  85921. * @param octreeBlocksSize (Default: 32)
  85922. */
  85923. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  85924. /**
  85925. * Returns a height (y) value in the Worl system :
  85926. * the ground altitude at the coordinates (x, z) expressed in the World system.
  85927. * @param x x coordinate
  85928. * @param z z coordinate
  85929. * @returns the ground y position if (x, z) are outside the ground surface.
  85930. */
  85931. getHeightAtCoordinates(x: number, z: number): number;
  85932. /**
  85933. * Returns a normalized vector (Vector3) orthogonal to the ground
  85934. * at the ground coordinates (x, z) expressed in the World system.
  85935. * @param x x coordinate
  85936. * @param z z coordinate
  85937. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  85938. */
  85939. getNormalAtCoordinates(x: number, z: number): Vector3;
  85940. /**
  85941. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  85942. * at the ground coordinates (x, z) expressed in the World system.
  85943. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  85944. * @param x x coordinate
  85945. * @param z z coordinate
  85946. * @param ref vector to store the result
  85947. * @returns the GroundMesh.
  85948. */
  85949. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  85950. /**
  85951. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  85952. * if the ground has been updated.
  85953. * This can be used in the render loop.
  85954. * @returns the GroundMesh.
  85955. */
  85956. updateCoordinateHeights(): GroundMesh;
  85957. private _getFacetAt;
  85958. private _initHeightQuads;
  85959. private _computeHeightQuads;
  85960. /**
  85961. * Serializes this ground mesh
  85962. * @param serializationObject object to write serialization to
  85963. */
  85964. serialize(serializationObject: any): void;
  85965. /**
  85966. * Parses a serialized ground mesh
  85967. * @param parsedMesh the serialized mesh
  85968. * @param scene the scene to create the ground mesh in
  85969. * @returns the created ground mesh
  85970. */
  85971. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  85972. }
  85973. }
  85974. declare module BABYLON {
  85975. /**
  85976. * Interface for Physics-Joint data
  85977. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85978. */
  85979. export interface PhysicsJointData {
  85980. /**
  85981. * The main pivot of the joint
  85982. */
  85983. mainPivot?: Vector3;
  85984. /**
  85985. * The connected pivot of the joint
  85986. */
  85987. connectedPivot?: Vector3;
  85988. /**
  85989. * The main axis of the joint
  85990. */
  85991. mainAxis?: Vector3;
  85992. /**
  85993. * The connected axis of the joint
  85994. */
  85995. connectedAxis?: Vector3;
  85996. /**
  85997. * The collision of the joint
  85998. */
  85999. collision?: boolean;
  86000. /**
  86001. * Native Oimo/Cannon/Energy data
  86002. */
  86003. nativeParams?: any;
  86004. }
  86005. /**
  86006. * This is a holder class for the physics joint created by the physics plugin
  86007. * It holds a set of functions to control the underlying joint
  86008. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86009. */
  86010. export class PhysicsJoint {
  86011. /**
  86012. * The type of the physics joint
  86013. */
  86014. type: number;
  86015. /**
  86016. * The data for the physics joint
  86017. */
  86018. jointData: PhysicsJointData;
  86019. private _physicsJoint;
  86020. protected _physicsPlugin: IPhysicsEnginePlugin;
  86021. /**
  86022. * Initializes the physics joint
  86023. * @param type The type of the physics joint
  86024. * @param jointData The data for the physics joint
  86025. */
  86026. constructor(
  86027. /**
  86028. * The type of the physics joint
  86029. */
  86030. type: number,
  86031. /**
  86032. * The data for the physics joint
  86033. */
  86034. jointData: PhysicsJointData);
  86035. /**
  86036. * Gets the physics joint
  86037. */
  86038. /**
  86039. * Sets the physics joint
  86040. */
  86041. physicsJoint: any;
  86042. /**
  86043. * Sets the physics plugin
  86044. */
  86045. physicsPlugin: IPhysicsEnginePlugin;
  86046. /**
  86047. * Execute a function that is physics-plugin specific.
  86048. * @param {Function} func the function that will be executed.
  86049. * It accepts two parameters: the physics world and the physics joint
  86050. */
  86051. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  86052. /**
  86053. * Distance-Joint type
  86054. */
  86055. static DistanceJoint: number;
  86056. /**
  86057. * Hinge-Joint type
  86058. */
  86059. static HingeJoint: number;
  86060. /**
  86061. * Ball-and-Socket joint type
  86062. */
  86063. static BallAndSocketJoint: number;
  86064. /**
  86065. * Wheel-Joint type
  86066. */
  86067. static WheelJoint: number;
  86068. /**
  86069. * Slider-Joint type
  86070. */
  86071. static SliderJoint: number;
  86072. /**
  86073. * Prismatic-Joint type
  86074. */
  86075. static PrismaticJoint: number;
  86076. /**
  86077. * Universal-Joint type
  86078. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  86079. */
  86080. static UniversalJoint: number;
  86081. /**
  86082. * Hinge-Joint 2 type
  86083. */
  86084. static Hinge2Joint: number;
  86085. /**
  86086. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  86087. */
  86088. static PointToPointJoint: number;
  86089. /**
  86090. * Spring-Joint type
  86091. */
  86092. static SpringJoint: number;
  86093. /**
  86094. * Lock-Joint type
  86095. */
  86096. static LockJoint: number;
  86097. }
  86098. /**
  86099. * A class representing a physics distance joint
  86100. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86101. */
  86102. export class DistanceJoint extends PhysicsJoint {
  86103. /**
  86104. *
  86105. * @param jointData The data for the Distance-Joint
  86106. */
  86107. constructor(jointData: DistanceJointData);
  86108. /**
  86109. * Update the predefined distance.
  86110. * @param maxDistance The maximum preferred distance
  86111. * @param minDistance The minimum preferred distance
  86112. */
  86113. updateDistance(maxDistance: number, minDistance?: number): void;
  86114. }
  86115. /**
  86116. * Represents a Motor-Enabled Joint
  86117. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86118. */
  86119. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  86120. /**
  86121. * Initializes the Motor-Enabled Joint
  86122. * @param type The type of the joint
  86123. * @param jointData The physica joint data for the joint
  86124. */
  86125. constructor(type: number, jointData: PhysicsJointData);
  86126. /**
  86127. * Set the motor values.
  86128. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86129. * @param force the force to apply
  86130. * @param maxForce max force for this motor.
  86131. */
  86132. setMotor(force?: number, maxForce?: number): void;
  86133. /**
  86134. * Set the motor's limits.
  86135. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86136. * @param upperLimit The upper limit of the motor
  86137. * @param lowerLimit The lower limit of the motor
  86138. */
  86139. setLimit(upperLimit: number, lowerLimit?: number): void;
  86140. }
  86141. /**
  86142. * This class represents a single physics Hinge-Joint
  86143. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86144. */
  86145. export class HingeJoint extends MotorEnabledJoint {
  86146. /**
  86147. * Initializes the Hinge-Joint
  86148. * @param jointData The joint data for the Hinge-Joint
  86149. */
  86150. constructor(jointData: PhysicsJointData);
  86151. /**
  86152. * Set the motor values.
  86153. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86154. * @param {number} force the force to apply
  86155. * @param {number} maxForce max force for this motor.
  86156. */
  86157. setMotor(force?: number, maxForce?: number): void;
  86158. /**
  86159. * Set the motor's limits.
  86160. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86161. * @param upperLimit The upper limit of the motor
  86162. * @param lowerLimit The lower limit of the motor
  86163. */
  86164. setLimit(upperLimit: number, lowerLimit?: number): void;
  86165. }
  86166. /**
  86167. * This class represents a dual hinge physics joint (same as wheel joint)
  86168. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86169. */
  86170. export class Hinge2Joint extends MotorEnabledJoint {
  86171. /**
  86172. * Initializes the Hinge2-Joint
  86173. * @param jointData The joint data for the Hinge2-Joint
  86174. */
  86175. constructor(jointData: PhysicsJointData);
  86176. /**
  86177. * Set the motor values.
  86178. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86179. * @param {number} targetSpeed the speed the motor is to reach
  86180. * @param {number} maxForce max force for this motor.
  86181. * @param {motorIndex} the motor's index, 0 or 1.
  86182. */
  86183. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  86184. /**
  86185. * Set the motor limits.
  86186. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86187. * @param {number} upperLimit the upper limit
  86188. * @param {number} lowerLimit lower limit
  86189. * @param {motorIndex} the motor's index, 0 or 1.
  86190. */
  86191. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  86192. }
  86193. /**
  86194. * Interface for a motor enabled joint
  86195. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86196. */
  86197. export interface IMotorEnabledJoint {
  86198. /**
  86199. * Physics joint
  86200. */
  86201. physicsJoint: any;
  86202. /**
  86203. * Sets the motor of the motor-enabled joint
  86204. * @param force The force of the motor
  86205. * @param maxForce The maximum force of the motor
  86206. * @param motorIndex The index of the motor
  86207. */
  86208. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  86209. /**
  86210. * Sets the limit of the motor
  86211. * @param upperLimit The upper limit of the motor
  86212. * @param lowerLimit The lower limit of the motor
  86213. * @param motorIndex The index of the motor
  86214. */
  86215. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  86216. }
  86217. /**
  86218. * Joint data for a Distance-Joint
  86219. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86220. */
  86221. export interface DistanceJointData extends PhysicsJointData {
  86222. /**
  86223. * Max distance the 2 joint objects can be apart
  86224. */
  86225. maxDistance: number;
  86226. }
  86227. /**
  86228. * Joint data from a spring joint
  86229. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86230. */
  86231. export interface SpringJointData extends PhysicsJointData {
  86232. /**
  86233. * Length of the spring
  86234. */
  86235. length: number;
  86236. /**
  86237. * Stiffness of the spring
  86238. */
  86239. stiffness: number;
  86240. /**
  86241. * Damping of the spring
  86242. */
  86243. damping: number;
  86244. /** this callback will be called when applying the force to the impostors. */
  86245. forceApplicationCallback: () => void;
  86246. }
  86247. }
  86248. declare module BABYLON {
  86249. /**
  86250. * Holds the data for the raycast result
  86251. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86252. */
  86253. export class PhysicsRaycastResult {
  86254. private _hasHit;
  86255. private _hitDistance;
  86256. private _hitNormalWorld;
  86257. private _hitPointWorld;
  86258. private _rayFromWorld;
  86259. private _rayToWorld;
  86260. /**
  86261. * Gets if there was a hit
  86262. */
  86263. readonly hasHit: boolean;
  86264. /**
  86265. * Gets the distance from the hit
  86266. */
  86267. readonly hitDistance: number;
  86268. /**
  86269. * Gets the hit normal/direction in the world
  86270. */
  86271. readonly hitNormalWorld: Vector3;
  86272. /**
  86273. * Gets the hit point in the world
  86274. */
  86275. readonly hitPointWorld: Vector3;
  86276. /**
  86277. * Gets the ray "start point" of the ray in the world
  86278. */
  86279. readonly rayFromWorld: Vector3;
  86280. /**
  86281. * Gets the ray "end point" of the ray in the world
  86282. */
  86283. readonly rayToWorld: Vector3;
  86284. /**
  86285. * Sets the hit data (normal & point in world space)
  86286. * @param hitNormalWorld defines the normal in world space
  86287. * @param hitPointWorld defines the point in world space
  86288. */
  86289. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  86290. /**
  86291. * Sets the distance from the start point to the hit point
  86292. * @param distance
  86293. */
  86294. setHitDistance(distance: number): void;
  86295. /**
  86296. * Calculates the distance manually
  86297. */
  86298. calculateHitDistance(): void;
  86299. /**
  86300. * Resets all the values to default
  86301. * @param from The from point on world space
  86302. * @param to The to point on world space
  86303. */
  86304. reset(from?: Vector3, to?: Vector3): void;
  86305. }
  86306. /**
  86307. * Interface for the size containing width and height
  86308. */
  86309. interface IXYZ {
  86310. /**
  86311. * X
  86312. */
  86313. x: number;
  86314. /**
  86315. * Y
  86316. */
  86317. y: number;
  86318. /**
  86319. * Z
  86320. */
  86321. z: number;
  86322. }
  86323. }
  86324. declare module BABYLON {
  86325. /**
  86326. * Interface used to describe a physics joint
  86327. */
  86328. export interface PhysicsImpostorJoint {
  86329. /** Defines the main impostor to which the joint is linked */
  86330. mainImpostor: PhysicsImpostor;
  86331. /** Defines the impostor that is connected to the main impostor using this joint */
  86332. connectedImpostor: PhysicsImpostor;
  86333. /** Defines the joint itself */
  86334. joint: PhysicsJoint;
  86335. }
  86336. /** @hidden */
  86337. export interface IPhysicsEnginePlugin {
  86338. world: any;
  86339. name: string;
  86340. setGravity(gravity: Vector3): void;
  86341. setTimeStep(timeStep: number): void;
  86342. getTimeStep(): number;
  86343. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  86344. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  86345. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  86346. generatePhysicsBody(impostor: PhysicsImpostor): void;
  86347. removePhysicsBody(impostor: PhysicsImpostor): void;
  86348. generateJoint(joint: PhysicsImpostorJoint): void;
  86349. removeJoint(joint: PhysicsImpostorJoint): void;
  86350. isSupported(): boolean;
  86351. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  86352. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  86353. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  86354. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  86355. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  86356. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  86357. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  86358. getBodyMass(impostor: PhysicsImpostor): number;
  86359. getBodyFriction(impostor: PhysicsImpostor): number;
  86360. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  86361. getBodyRestitution(impostor: PhysicsImpostor): number;
  86362. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  86363. getBodyPressure?(impostor: PhysicsImpostor): number;
  86364. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  86365. getBodyStiffness?(impostor: PhysicsImpostor): number;
  86366. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  86367. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  86368. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  86369. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  86370. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  86371. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  86372. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  86373. sleepBody(impostor: PhysicsImpostor): void;
  86374. wakeUpBody(impostor: PhysicsImpostor): void;
  86375. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  86376. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  86377. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  86378. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  86379. getRadius(impostor: PhysicsImpostor): number;
  86380. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  86381. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  86382. dispose(): void;
  86383. }
  86384. /**
  86385. * Interface used to define a physics engine
  86386. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  86387. */
  86388. export interface IPhysicsEngine {
  86389. /**
  86390. * Gets the gravity vector used by the simulation
  86391. */
  86392. gravity: Vector3;
  86393. /**
  86394. * Sets the gravity vector used by the simulation
  86395. * @param gravity defines the gravity vector to use
  86396. */
  86397. setGravity(gravity: Vector3): void;
  86398. /**
  86399. * Set the time step of the physics engine.
  86400. * Default is 1/60.
  86401. * To slow it down, enter 1/600 for example.
  86402. * To speed it up, 1/30
  86403. * @param newTimeStep the new timestep to apply to this world.
  86404. */
  86405. setTimeStep(newTimeStep: number): void;
  86406. /**
  86407. * Get the time step of the physics engine.
  86408. * @returns the current time step
  86409. */
  86410. getTimeStep(): number;
  86411. /**
  86412. * Release all resources
  86413. */
  86414. dispose(): void;
  86415. /**
  86416. * Gets the name of the current physics plugin
  86417. * @returns the name of the plugin
  86418. */
  86419. getPhysicsPluginName(): string;
  86420. /**
  86421. * Adding a new impostor for the impostor tracking.
  86422. * This will be done by the impostor itself.
  86423. * @param impostor the impostor to add
  86424. */
  86425. addImpostor(impostor: PhysicsImpostor): void;
  86426. /**
  86427. * Remove an impostor from the engine.
  86428. * This impostor and its mesh will not longer be updated by the physics engine.
  86429. * @param impostor the impostor to remove
  86430. */
  86431. removeImpostor(impostor: PhysicsImpostor): void;
  86432. /**
  86433. * Add a joint to the physics engine
  86434. * @param mainImpostor defines the main impostor to which the joint is added.
  86435. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  86436. * @param joint defines the joint that will connect both impostors.
  86437. */
  86438. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  86439. /**
  86440. * Removes a joint from the simulation
  86441. * @param mainImpostor defines the impostor used with the joint
  86442. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  86443. * @param joint defines the joint to remove
  86444. */
  86445. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  86446. /**
  86447. * Gets the current plugin used to run the simulation
  86448. * @returns current plugin
  86449. */
  86450. getPhysicsPlugin(): IPhysicsEnginePlugin;
  86451. /**
  86452. * Gets the list of physic impostors
  86453. * @returns an array of PhysicsImpostor
  86454. */
  86455. getImpostors(): Array<PhysicsImpostor>;
  86456. /**
  86457. * Gets the impostor for a physics enabled object
  86458. * @param object defines the object impersonated by the impostor
  86459. * @returns the PhysicsImpostor or null if not found
  86460. */
  86461. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  86462. /**
  86463. * Gets the impostor for a physics body object
  86464. * @param body defines physics body used by the impostor
  86465. * @returns the PhysicsImpostor or null if not found
  86466. */
  86467. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  86468. /**
  86469. * Does a raycast in the physics world
  86470. * @param from when should the ray start?
  86471. * @param to when should the ray end?
  86472. * @returns PhysicsRaycastResult
  86473. */
  86474. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  86475. /**
  86476. * Called by the scene. No need to call it.
  86477. * @param delta defines the timespam between frames
  86478. */
  86479. _step(delta: number): void;
  86480. }
  86481. }
  86482. declare module BABYLON {
  86483. /**
  86484. * The interface for the physics imposter parameters
  86485. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86486. */
  86487. export interface PhysicsImpostorParameters {
  86488. /**
  86489. * The mass of the physics imposter
  86490. */
  86491. mass: number;
  86492. /**
  86493. * The friction of the physics imposter
  86494. */
  86495. friction?: number;
  86496. /**
  86497. * The coefficient of restitution of the physics imposter
  86498. */
  86499. restitution?: number;
  86500. /**
  86501. * The native options of the physics imposter
  86502. */
  86503. nativeOptions?: any;
  86504. /**
  86505. * Specifies if the parent should be ignored
  86506. */
  86507. ignoreParent?: boolean;
  86508. /**
  86509. * Specifies if bi-directional transformations should be disabled
  86510. */
  86511. disableBidirectionalTransformation?: boolean;
  86512. /**
  86513. * The pressure inside the physics imposter, soft object only
  86514. */
  86515. pressure?: number;
  86516. /**
  86517. * The stiffness the physics imposter, soft object only
  86518. */
  86519. stiffness?: number;
  86520. /**
  86521. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  86522. */
  86523. velocityIterations?: number;
  86524. /**
  86525. * The number of iterations used in maintaining consistent vertex positions, soft object only
  86526. */
  86527. positionIterations?: number;
  86528. /**
  86529. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  86530. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  86531. * Add to fix multiple points
  86532. */
  86533. fixedPoints?: number;
  86534. /**
  86535. * The collision margin around a soft object
  86536. */
  86537. margin?: number;
  86538. /**
  86539. * The collision margin around a soft object
  86540. */
  86541. damping?: number;
  86542. /**
  86543. * The path for a rope based on an extrusion
  86544. */
  86545. path?: any;
  86546. /**
  86547. * The shape of an extrusion used for a rope based on an extrusion
  86548. */
  86549. shape?: any;
  86550. }
  86551. /**
  86552. * Interface for a physics-enabled object
  86553. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86554. */
  86555. export interface IPhysicsEnabledObject {
  86556. /**
  86557. * The position of the physics-enabled object
  86558. */
  86559. position: Vector3;
  86560. /**
  86561. * The rotation of the physics-enabled object
  86562. */
  86563. rotationQuaternion: Nullable<Quaternion>;
  86564. /**
  86565. * The scale of the physics-enabled object
  86566. */
  86567. scaling: Vector3;
  86568. /**
  86569. * The rotation of the physics-enabled object
  86570. */
  86571. rotation?: Vector3;
  86572. /**
  86573. * The parent of the physics-enabled object
  86574. */
  86575. parent?: any;
  86576. /**
  86577. * The bounding info of the physics-enabled object
  86578. * @returns The bounding info of the physics-enabled object
  86579. */
  86580. getBoundingInfo(): BoundingInfo;
  86581. /**
  86582. * Computes the world matrix
  86583. * @param force Specifies if the world matrix should be computed by force
  86584. * @returns A world matrix
  86585. */
  86586. computeWorldMatrix(force: boolean): Matrix;
  86587. /**
  86588. * Gets the world matrix
  86589. * @returns A world matrix
  86590. */
  86591. getWorldMatrix?(): Matrix;
  86592. /**
  86593. * Gets the child meshes
  86594. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  86595. * @returns An array of abstract meshes
  86596. */
  86597. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  86598. /**
  86599. * Gets the vertex data
  86600. * @param kind The type of vertex data
  86601. * @returns A nullable array of numbers, or a float32 array
  86602. */
  86603. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  86604. /**
  86605. * Gets the indices from the mesh
  86606. * @returns A nullable array of index arrays
  86607. */
  86608. getIndices?(): Nullable<IndicesArray>;
  86609. /**
  86610. * Gets the scene from the mesh
  86611. * @returns the indices array or null
  86612. */
  86613. getScene?(): Scene;
  86614. /**
  86615. * Gets the absolute position from the mesh
  86616. * @returns the absolute position
  86617. */
  86618. getAbsolutePosition(): Vector3;
  86619. /**
  86620. * Gets the absolute pivot point from the mesh
  86621. * @returns the absolute pivot point
  86622. */
  86623. getAbsolutePivotPoint(): Vector3;
  86624. /**
  86625. * Rotates the mesh
  86626. * @param axis The axis of rotation
  86627. * @param amount The amount of rotation
  86628. * @param space The space of the rotation
  86629. * @returns The rotation transform node
  86630. */
  86631. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  86632. /**
  86633. * Translates the mesh
  86634. * @param axis The axis of translation
  86635. * @param distance The distance of translation
  86636. * @param space The space of the translation
  86637. * @returns The transform node
  86638. */
  86639. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  86640. /**
  86641. * Sets the absolute position of the mesh
  86642. * @param absolutePosition The absolute position of the mesh
  86643. * @returns The transform node
  86644. */
  86645. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  86646. /**
  86647. * Gets the class name of the mesh
  86648. * @returns The class name
  86649. */
  86650. getClassName(): string;
  86651. }
  86652. /**
  86653. * Represents a physics imposter
  86654. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86655. */
  86656. export class PhysicsImpostor {
  86657. /**
  86658. * The physics-enabled object used as the physics imposter
  86659. */
  86660. object: IPhysicsEnabledObject;
  86661. /**
  86662. * The type of the physics imposter
  86663. */
  86664. type: number;
  86665. private _options;
  86666. private _scene?;
  86667. /**
  86668. * The default object size of the imposter
  86669. */
  86670. static DEFAULT_OBJECT_SIZE: Vector3;
  86671. /**
  86672. * The identity quaternion of the imposter
  86673. */
  86674. static IDENTITY_QUATERNION: Quaternion;
  86675. /** @hidden */
  86676. _pluginData: any;
  86677. private _physicsEngine;
  86678. private _physicsBody;
  86679. private _bodyUpdateRequired;
  86680. private _onBeforePhysicsStepCallbacks;
  86681. private _onAfterPhysicsStepCallbacks;
  86682. /** @hidden */
  86683. _onPhysicsCollideCallbacks: Array<{
  86684. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  86685. otherImpostors: Array<PhysicsImpostor>;
  86686. }>;
  86687. private _deltaPosition;
  86688. private _deltaRotation;
  86689. private _deltaRotationConjugated;
  86690. /** @hidden */
  86691. _isFromLine: boolean;
  86692. private _parent;
  86693. private _isDisposed;
  86694. private static _tmpVecs;
  86695. private static _tmpQuat;
  86696. /**
  86697. * Specifies if the physics imposter is disposed
  86698. */
  86699. readonly isDisposed: boolean;
  86700. /**
  86701. * Gets the mass of the physics imposter
  86702. */
  86703. mass: number;
  86704. /**
  86705. * Gets the coefficient of friction
  86706. */
  86707. /**
  86708. * Sets the coefficient of friction
  86709. */
  86710. friction: number;
  86711. /**
  86712. * Gets the coefficient of restitution
  86713. */
  86714. /**
  86715. * Sets the coefficient of restitution
  86716. */
  86717. restitution: number;
  86718. /**
  86719. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  86720. */
  86721. /**
  86722. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  86723. */
  86724. pressure: number;
  86725. /**
  86726. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  86727. */
  86728. /**
  86729. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  86730. */
  86731. stiffness: number;
  86732. /**
  86733. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  86734. */
  86735. /**
  86736. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  86737. */
  86738. velocityIterations: number;
  86739. /**
  86740. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  86741. */
  86742. /**
  86743. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  86744. */
  86745. positionIterations: number;
  86746. /**
  86747. * The unique id of the physics imposter
  86748. * set by the physics engine when adding this impostor to the array
  86749. */
  86750. uniqueId: number;
  86751. /**
  86752. * @hidden
  86753. */
  86754. soft: boolean;
  86755. /**
  86756. * @hidden
  86757. */
  86758. segments: number;
  86759. private _joints;
  86760. /**
  86761. * Initializes the physics imposter
  86762. * @param object The physics-enabled object used as the physics imposter
  86763. * @param type The type of the physics imposter
  86764. * @param _options The options for the physics imposter
  86765. * @param _scene The Babylon scene
  86766. */
  86767. constructor(
  86768. /**
  86769. * The physics-enabled object used as the physics imposter
  86770. */
  86771. object: IPhysicsEnabledObject,
  86772. /**
  86773. * The type of the physics imposter
  86774. */
  86775. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  86776. /**
  86777. * This function will completly initialize this impostor.
  86778. * It will create a new body - but only if this mesh has no parent.
  86779. * If it has, this impostor will not be used other than to define the impostor
  86780. * of the child mesh.
  86781. * @hidden
  86782. */
  86783. _init(): void;
  86784. private _getPhysicsParent;
  86785. /**
  86786. * Should a new body be generated.
  86787. * @returns boolean specifying if body initialization is required
  86788. */
  86789. isBodyInitRequired(): boolean;
  86790. /**
  86791. * Sets the updated scaling
  86792. * @param updated Specifies if the scaling is updated
  86793. */
  86794. setScalingUpdated(): void;
  86795. /**
  86796. * Force a regeneration of this or the parent's impostor's body.
  86797. * Use under cautious - This will remove all joints already implemented.
  86798. */
  86799. forceUpdate(): void;
  86800. /**
  86801. * Gets the body that holds this impostor. Either its own, or its parent.
  86802. */
  86803. /**
  86804. * Set the physics body. Used mainly by the physics engine/plugin
  86805. */
  86806. physicsBody: any;
  86807. /**
  86808. * Get the parent of the physics imposter
  86809. * @returns Physics imposter or null
  86810. */
  86811. /**
  86812. * Sets the parent of the physics imposter
  86813. */
  86814. parent: Nullable<PhysicsImpostor>;
  86815. /**
  86816. * Resets the update flags
  86817. */
  86818. resetUpdateFlags(): void;
  86819. /**
  86820. * Gets the object extend size
  86821. * @returns the object extend size
  86822. */
  86823. getObjectExtendSize(): Vector3;
  86824. /**
  86825. * Gets the object center
  86826. * @returns The object center
  86827. */
  86828. getObjectCenter(): Vector3;
  86829. /**
  86830. * Get a specific parametes from the options parameter
  86831. * @param paramName The object parameter name
  86832. * @returns The object parameter
  86833. */
  86834. getParam(paramName: string): any;
  86835. /**
  86836. * Sets a specific parameter in the options given to the physics plugin
  86837. * @param paramName The parameter name
  86838. * @param value The value of the parameter
  86839. */
  86840. setParam(paramName: string, value: number): void;
  86841. /**
  86842. * Specifically change the body's mass option. Won't recreate the physics body object
  86843. * @param mass The mass of the physics imposter
  86844. */
  86845. setMass(mass: number): void;
  86846. /**
  86847. * Gets the linear velocity
  86848. * @returns linear velocity or null
  86849. */
  86850. getLinearVelocity(): Nullable<Vector3>;
  86851. /**
  86852. * Sets the linear velocity
  86853. * @param velocity linear velocity or null
  86854. */
  86855. setLinearVelocity(velocity: Nullable<Vector3>): void;
  86856. /**
  86857. * Gets the angular velocity
  86858. * @returns angular velocity or null
  86859. */
  86860. getAngularVelocity(): Nullable<Vector3>;
  86861. /**
  86862. * Sets the angular velocity
  86863. * @param velocity The velocity or null
  86864. */
  86865. setAngularVelocity(velocity: Nullable<Vector3>): void;
  86866. /**
  86867. * Execute a function with the physics plugin native code
  86868. * Provide a function the will have two variables - the world object and the physics body object
  86869. * @param func The function to execute with the physics plugin native code
  86870. */
  86871. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  86872. /**
  86873. * Register a function that will be executed before the physics world is stepping forward
  86874. * @param func The function to execute before the physics world is stepped forward
  86875. */
  86876. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  86877. /**
  86878. * Unregister a function that will be executed before the physics world is stepping forward
  86879. * @param func The function to execute before the physics world is stepped forward
  86880. */
  86881. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  86882. /**
  86883. * Register a function that will be executed after the physics step
  86884. * @param func The function to execute after physics step
  86885. */
  86886. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  86887. /**
  86888. * Unregisters a function that will be executed after the physics step
  86889. * @param func The function to execute after physics step
  86890. */
  86891. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  86892. /**
  86893. * register a function that will be executed when this impostor collides against a different body
  86894. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  86895. * @param func Callback that is executed on collision
  86896. */
  86897. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  86898. /**
  86899. * Unregisters the physics imposter on contact
  86900. * @param collideAgainst The physics object to collide against
  86901. * @param func Callback to execute on collision
  86902. */
  86903. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  86904. private _tmpQuat;
  86905. private _tmpQuat2;
  86906. /**
  86907. * Get the parent rotation
  86908. * @returns The parent rotation
  86909. */
  86910. getParentsRotation(): Quaternion;
  86911. /**
  86912. * this function is executed by the physics engine.
  86913. */
  86914. beforeStep: () => void;
  86915. /**
  86916. * this function is executed by the physics engine
  86917. */
  86918. afterStep: () => void;
  86919. /**
  86920. * Legacy collision detection event support
  86921. */
  86922. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  86923. /**
  86924. * event and body object due to cannon's event-based architecture.
  86925. */
  86926. onCollide: (e: {
  86927. body: any;
  86928. }) => void;
  86929. /**
  86930. * Apply a force
  86931. * @param force The force to apply
  86932. * @param contactPoint The contact point for the force
  86933. * @returns The physics imposter
  86934. */
  86935. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  86936. /**
  86937. * Apply an impulse
  86938. * @param force The impulse force
  86939. * @param contactPoint The contact point for the impulse force
  86940. * @returns The physics imposter
  86941. */
  86942. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  86943. /**
  86944. * A help function to create a joint
  86945. * @param otherImpostor A physics imposter used to create a joint
  86946. * @param jointType The type of joint
  86947. * @param jointData The data for the joint
  86948. * @returns The physics imposter
  86949. */
  86950. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  86951. /**
  86952. * Add a joint to this impostor with a different impostor
  86953. * @param otherImpostor A physics imposter used to add a joint
  86954. * @param joint The joint to add
  86955. * @returns The physics imposter
  86956. */
  86957. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  86958. /**
  86959. * Add an anchor to a cloth impostor
  86960. * @param otherImpostor rigid impostor to anchor to
  86961. * @param width ratio across width from 0 to 1
  86962. * @param height ratio up height from 0 to 1
  86963. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  86964. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  86965. * @returns impostor the soft imposter
  86966. */
  86967. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  86968. /**
  86969. * Add a hook to a rope impostor
  86970. * @param otherImpostor rigid impostor to anchor to
  86971. * @param length ratio across rope from 0 to 1
  86972. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  86973. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  86974. * @returns impostor the rope imposter
  86975. */
  86976. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  86977. /**
  86978. * Will keep this body still, in a sleep mode.
  86979. * @returns the physics imposter
  86980. */
  86981. sleep(): PhysicsImpostor;
  86982. /**
  86983. * Wake the body up.
  86984. * @returns The physics imposter
  86985. */
  86986. wakeUp(): PhysicsImpostor;
  86987. /**
  86988. * Clones the physics imposter
  86989. * @param newObject The physics imposter clones to this physics-enabled object
  86990. * @returns A nullable physics imposter
  86991. */
  86992. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  86993. /**
  86994. * Disposes the physics imposter
  86995. */
  86996. dispose(): void;
  86997. /**
  86998. * Sets the delta position
  86999. * @param position The delta position amount
  87000. */
  87001. setDeltaPosition(position: Vector3): void;
  87002. /**
  87003. * Sets the delta rotation
  87004. * @param rotation The delta rotation amount
  87005. */
  87006. setDeltaRotation(rotation: Quaternion): void;
  87007. /**
  87008. * Gets the box size of the physics imposter and stores the result in the input parameter
  87009. * @param result Stores the box size
  87010. * @returns The physics imposter
  87011. */
  87012. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  87013. /**
  87014. * Gets the radius of the physics imposter
  87015. * @returns Radius of the physics imposter
  87016. */
  87017. getRadius(): number;
  87018. /**
  87019. * Sync a bone with this impostor
  87020. * @param bone The bone to sync to the impostor.
  87021. * @param boneMesh The mesh that the bone is influencing.
  87022. * @param jointPivot The pivot of the joint / bone in local space.
  87023. * @param distToJoint Optional distance from the impostor to the joint.
  87024. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  87025. */
  87026. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  87027. /**
  87028. * Sync impostor to a bone
  87029. * @param bone The bone that the impostor will be synced to.
  87030. * @param boneMesh The mesh that the bone is influencing.
  87031. * @param jointPivot The pivot of the joint / bone in local space.
  87032. * @param distToJoint Optional distance from the impostor to the joint.
  87033. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  87034. * @param boneAxis Optional vector3 axis the bone is aligned with
  87035. */
  87036. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  87037. /**
  87038. * No-Imposter type
  87039. */
  87040. static NoImpostor: number;
  87041. /**
  87042. * Sphere-Imposter type
  87043. */
  87044. static SphereImpostor: number;
  87045. /**
  87046. * Box-Imposter type
  87047. */
  87048. static BoxImpostor: number;
  87049. /**
  87050. * Plane-Imposter type
  87051. */
  87052. static PlaneImpostor: number;
  87053. /**
  87054. * Mesh-imposter type
  87055. */
  87056. static MeshImpostor: number;
  87057. /**
  87058. * Capsule-Impostor type (Ammo.js plugin only)
  87059. */
  87060. static CapsuleImpostor: number;
  87061. /**
  87062. * Cylinder-Imposter type
  87063. */
  87064. static CylinderImpostor: number;
  87065. /**
  87066. * Particle-Imposter type
  87067. */
  87068. static ParticleImpostor: number;
  87069. /**
  87070. * Heightmap-Imposter type
  87071. */
  87072. static HeightmapImpostor: number;
  87073. /**
  87074. * ConvexHull-Impostor type (Ammo.js plugin only)
  87075. */
  87076. static ConvexHullImpostor: number;
  87077. /**
  87078. * Rope-Imposter type
  87079. */
  87080. static RopeImpostor: number;
  87081. /**
  87082. * Cloth-Imposter type
  87083. */
  87084. static ClothImpostor: number;
  87085. /**
  87086. * Softbody-Imposter type
  87087. */
  87088. static SoftbodyImpostor: number;
  87089. }
  87090. }
  87091. declare module BABYLON {
  87092. /**
  87093. * @hidden
  87094. **/
  87095. export class _CreationDataStorage {
  87096. closePath?: boolean;
  87097. closeArray?: boolean;
  87098. idx: number[];
  87099. dashSize: number;
  87100. gapSize: number;
  87101. path3D: Path3D;
  87102. pathArray: Vector3[][];
  87103. arc: number;
  87104. radius: number;
  87105. cap: number;
  87106. tessellation: number;
  87107. }
  87108. /**
  87109. * @hidden
  87110. **/
  87111. class _InstanceDataStorage {
  87112. visibleInstances: any;
  87113. batchCache: _InstancesBatch;
  87114. instancesBufferSize: number;
  87115. instancesBuffer: Nullable<Buffer>;
  87116. instancesData: Float32Array;
  87117. overridenInstanceCount: number;
  87118. isFrozen: boolean;
  87119. previousBatch: Nullable<_InstancesBatch>;
  87120. hardwareInstancedRendering: boolean;
  87121. sideOrientation: number;
  87122. }
  87123. /**
  87124. * @hidden
  87125. **/
  87126. export class _InstancesBatch {
  87127. mustReturn: boolean;
  87128. visibleInstances: Nullable<InstancedMesh[]>[];
  87129. renderSelf: boolean[];
  87130. hardwareInstancedRendering: boolean[];
  87131. }
  87132. /**
  87133. * Class used to represent renderable models
  87134. */
  87135. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  87136. /**
  87137. * Mesh side orientation : usually the external or front surface
  87138. */
  87139. static readonly FRONTSIDE: number;
  87140. /**
  87141. * Mesh side orientation : usually the internal or back surface
  87142. */
  87143. static readonly BACKSIDE: number;
  87144. /**
  87145. * Mesh side orientation : both internal and external or front and back surfaces
  87146. */
  87147. static readonly DOUBLESIDE: number;
  87148. /**
  87149. * Mesh side orientation : by default, `FRONTSIDE`
  87150. */
  87151. static readonly DEFAULTSIDE: number;
  87152. /**
  87153. * Mesh cap setting : no cap
  87154. */
  87155. static readonly NO_CAP: number;
  87156. /**
  87157. * Mesh cap setting : one cap at the beginning of the mesh
  87158. */
  87159. static readonly CAP_START: number;
  87160. /**
  87161. * Mesh cap setting : one cap at the end of the mesh
  87162. */
  87163. static readonly CAP_END: number;
  87164. /**
  87165. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  87166. */
  87167. static readonly CAP_ALL: number;
  87168. /**
  87169. * Mesh pattern setting : no flip or rotate
  87170. */
  87171. static readonly NO_FLIP: number;
  87172. /**
  87173. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  87174. */
  87175. static readonly FLIP_TILE: number;
  87176. /**
  87177. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  87178. */
  87179. static readonly ROTATE_TILE: number;
  87180. /**
  87181. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  87182. */
  87183. static readonly FLIP_ROW: number;
  87184. /**
  87185. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  87186. */
  87187. static readonly ROTATE_ROW: number;
  87188. /**
  87189. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  87190. */
  87191. static readonly FLIP_N_ROTATE_TILE: number;
  87192. /**
  87193. * Mesh pattern setting : rotate pattern and rotate
  87194. */
  87195. static readonly FLIP_N_ROTATE_ROW: number;
  87196. /**
  87197. * Mesh tile positioning : part tiles same on left/right or top/bottom
  87198. */
  87199. static readonly CENTER: number;
  87200. /**
  87201. * Mesh tile positioning : part tiles on left
  87202. */
  87203. static readonly LEFT: number;
  87204. /**
  87205. * Mesh tile positioning : part tiles on right
  87206. */
  87207. static readonly RIGHT: number;
  87208. /**
  87209. * Mesh tile positioning : part tiles on top
  87210. */
  87211. static readonly TOP: number;
  87212. /**
  87213. * Mesh tile positioning : part tiles on bottom
  87214. */
  87215. static readonly BOTTOM: number;
  87216. /**
  87217. * Gets the default side orientation.
  87218. * @param orientation the orientation to value to attempt to get
  87219. * @returns the default orientation
  87220. * @hidden
  87221. */
  87222. static _GetDefaultSideOrientation(orientation?: number): number;
  87223. private _internalMeshDataInfo;
  87224. /**
  87225. * An event triggered before rendering the mesh
  87226. */
  87227. readonly onBeforeRenderObservable: Observable<Mesh>;
  87228. /**
  87229. * An event triggered before binding the mesh
  87230. */
  87231. readonly onBeforeBindObservable: Observable<Mesh>;
  87232. /**
  87233. * An event triggered after rendering the mesh
  87234. */
  87235. readonly onAfterRenderObservable: Observable<Mesh>;
  87236. /**
  87237. * An event triggered before drawing the mesh
  87238. */
  87239. readonly onBeforeDrawObservable: Observable<Mesh>;
  87240. private _onBeforeDrawObserver;
  87241. /**
  87242. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  87243. */
  87244. onBeforeDraw: () => void;
  87245. /**
  87246. * Gets the delay loading state of the mesh (when delay loading is turned on)
  87247. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  87248. */
  87249. delayLoadState: number;
  87250. /**
  87251. * Gets the list of instances created from this mesh
  87252. * it is not supposed to be modified manually.
  87253. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  87254. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87255. */
  87256. instances: InstancedMesh[];
  87257. /**
  87258. * Gets the file containing delay loading data for this mesh
  87259. */
  87260. delayLoadingFile: string;
  87261. /** @hidden */
  87262. _binaryInfo: any;
  87263. /**
  87264. * User defined function used to change how LOD level selection is done
  87265. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  87266. */
  87267. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  87268. /**
  87269. * Gets or sets the morph target manager
  87270. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87271. */
  87272. morphTargetManager: Nullable<MorphTargetManager>;
  87273. /** @hidden */
  87274. _creationDataStorage: Nullable<_CreationDataStorage>;
  87275. /** @hidden */
  87276. _geometry: Nullable<Geometry>;
  87277. /** @hidden */
  87278. _delayInfo: Array<string>;
  87279. /** @hidden */
  87280. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  87281. /** @hidden */
  87282. _instanceDataStorage: _InstanceDataStorage;
  87283. private _effectiveMaterial;
  87284. /** @hidden */
  87285. _shouldGenerateFlatShading: boolean;
  87286. /** @hidden */
  87287. _originalBuilderSideOrientation: number;
  87288. /**
  87289. * Use this property to change the original side orientation defined at construction time
  87290. */
  87291. overrideMaterialSideOrientation: Nullable<number>;
  87292. /**
  87293. * Gets the source mesh (the one used to clone this one from)
  87294. */
  87295. readonly source: Nullable<Mesh>;
  87296. /**
  87297. * Gets or sets a boolean indicating that this mesh does not use index buffer
  87298. */
  87299. isUnIndexed: boolean;
  87300. /**
  87301. * @constructor
  87302. * @param name The value used by scene.getMeshByName() to do a lookup.
  87303. * @param scene The scene to add this mesh to.
  87304. * @param parent The parent of this mesh, if it has one
  87305. * @param source An optional Mesh from which geometry is shared, cloned.
  87306. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  87307. * When false, achieved by calling a clone(), also passing False.
  87308. * This will make creation of children, recursive.
  87309. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  87310. */
  87311. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  87312. /**
  87313. * Gets the class name
  87314. * @returns the string "Mesh".
  87315. */
  87316. getClassName(): string;
  87317. /** @hidden */
  87318. readonly _isMesh: boolean;
  87319. /**
  87320. * Returns a description of this mesh
  87321. * @param fullDetails define if full details about this mesh must be used
  87322. * @returns a descriptive string representing this mesh
  87323. */
  87324. toString(fullDetails?: boolean): string;
  87325. /** @hidden */
  87326. _unBindEffect(): void;
  87327. /**
  87328. * Gets a boolean indicating if this mesh has LOD
  87329. */
  87330. readonly hasLODLevels: boolean;
  87331. /**
  87332. * Gets the list of MeshLODLevel associated with the current mesh
  87333. * @returns an array of MeshLODLevel
  87334. */
  87335. getLODLevels(): MeshLODLevel[];
  87336. private _sortLODLevels;
  87337. /**
  87338. * Add a mesh as LOD level triggered at the given distance.
  87339. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87340. * @param distance The distance from the center of the object to show this level
  87341. * @param mesh The mesh to be added as LOD level (can be null)
  87342. * @return This mesh (for chaining)
  87343. */
  87344. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  87345. /**
  87346. * Returns the LOD level mesh at the passed distance or null if not found.
  87347. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87348. * @param distance The distance from the center of the object to show this level
  87349. * @returns a Mesh or `null`
  87350. */
  87351. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  87352. /**
  87353. * Remove a mesh from the LOD array
  87354. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87355. * @param mesh defines the mesh to be removed
  87356. * @return This mesh (for chaining)
  87357. */
  87358. removeLODLevel(mesh: Mesh): Mesh;
  87359. /**
  87360. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  87361. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87362. * @param camera defines the camera to use to compute distance
  87363. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  87364. * @return This mesh (for chaining)
  87365. */
  87366. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  87367. /**
  87368. * Gets the mesh internal Geometry object
  87369. */
  87370. readonly geometry: Nullable<Geometry>;
  87371. /**
  87372. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  87373. * @returns the total number of vertices
  87374. */
  87375. getTotalVertices(): number;
  87376. /**
  87377. * Returns the content of an associated vertex buffer
  87378. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87379. * - VertexBuffer.PositionKind
  87380. * - VertexBuffer.UVKind
  87381. * - VertexBuffer.UV2Kind
  87382. * - VertexBuffer.UV3Kind
  87383. * - VertexBuffer.UV4Kind
  87384. * - VertexBuffer.UV5Kind
  87385. * - VertexBuffer.UV6Kind
  87386. * - VertexBuffer.ColorKind
  87387. * - VertexBuffer.MatricesIndicesKind
  87388. * - VertexBuffer.MatricesIndicesExtraKind
  87389. * - VertexBuffer.MatricesWeightsKind
  87390. * - VertexBuffer.MatricesWeightsExtraKind
  87391. * @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
  87392. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  87393. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  87394. */
  87395. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87396. /**
  87397. * Returns the mesh VertexBuffer object from the requested `kind`
  87398. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87399. * - VertexBuffer.PositionKind
  87400. * - VertexBuffer.NormalKind
  87401. * - VertexBuffer.UVKind
  87402. * - VertexBuffer.UV2Kind
  87403. * - VertexBuffer.UV3Kind
  87404. * - VertexBuffer.UV4Kind
  87405. * - VertexBuffer.UV5Kind
  87406. * - VertexBuffer.UV6Kind
  87407. * - VertexBuffer.ColorKind
  87408. * - VertexBuffer.MatricesIndicesKind
  87409. * - VertexBuffer.MatricesIndicesExtraKind
  87410. * - VertexBuffer.MatricesWeightsKind
  87411. * - VertexBuffer.MatricesWeightsExtraKind
  87412. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  87413. */
  87414. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  87415. /**
  87416. * Tests if a specific vertex buffer is associated with this mesh
  87417. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  87418. * - VertexBuffer.PositionKind
  87419. * - VertexBuffer.NormalKind
  87420. * - VertexBuffer.UVKind
  87421. * - VertexBuffer.UV2Kind
  87422. * - VertexBuffer.UV3Kind
  87423. * - VertexBuffer.UV4Kind
  87424. * - VertexBuffer.UV5Kind
  87425. * - VertexBuffer.UV6Kind
  87426. * - VertexBuffer.ColorKind
  87427. * - VertexBuffer.MatricesIndicesKind
  87428. * - VertexBuffer.MatricesIndicesExtraKind
  87429. * - VertexBuffer.MatricesWeightsKind
  87430. * - VertexBuffer.MatricesWeightsExtraKind
  87431. * @returns a boolean
  87432. */
  87433. isVerticesDataPresent(kind: string): boolean;
  87434. /**
  87435. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  87436. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  87437. * - VertexBuffer.PositionKind
  87438. * - VertexBuffer.UVKind
  87439. * - VertexBuffer.UV2Kind
  87440. * - VertexBuffer.UV3Kind
  87441. * - VertexBuffer.UV4Kind
  87442. * - VertexBuffer.UV5Kind
  87443. * - VertexBuffer.UV6Kind
  87444. * - VertexBuffer.ColorKind
  87445. * - VertexBuffer.MatricesIndicesKind
  87446. * - VertexBuffer.MatricesIndicesExtraKind
  87447. * - VertexBuffer.MatricesWeightsKind
  87448. * - VertexBuffer.MatricesWeightsExtraKind
  87449. * @returns a boolean
  87450. */
  87451. isVertexBufferUpdatable(kind: string): boolean;
  87452. /**
  87453. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  87454. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87455. * - VertexBuffer.PositionKind
  87456. * - VertexBuffer.NormalKind
  87457. * - VertexBuffer.UVKind
  87458. * - VertexBuffer.UV2Kind
  87459. * - VertexBuffer.UV3Kind
  87460. * - VertexBuffer.UV4Kind
  87461. * - VertexBuffer.UV5Kind
  87462. * - VertexBuffer.UV6Kind
  87463. * - VertexBuffer.ColorKind
  87464. * - VertexBuffer.MatricesIndicesKind
  87465. * - VertexBuffer.MatricesIndicesExtraKind
  87466. * - VertexBuffer.MatricesWeightsKind
  87467. * - VertexBuffer.MatricesWeightsExtraKind
  87468. * @returns an array of strings
  87469. */
  87470. getVerticesDataKinds(): string[];
  87471. /**
  87472. * Returns a positive integer : the total number of indices in this mesh geometry.
  87473. * @returns the numner of indices or zero if the mesh has no geometry.
  87474. */
  87475. getTotalIndices(): number;
  87476. /**
  87477. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87478. * @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.
  87479. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87480. * @returns the indices array or an empty array if the mesh has no geometry
  87481. */
  87482. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87483. readonly isBlocked: boolean;
  87484. /**
  87485. * Determine if the current mesh is ready to be rendered
  87486. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  87487. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  87488. * @returns true if all associated assets are ready (material, textures, shaders)
  87489. */
  87490. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  87491. /**
  87492. * 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.
  87493. */
  87494. readonly areNormalsFrozen: boolean;
  87495. /**
  87496. * 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.
  87497. * @returns the current mesh
  87498. */
  87499. freezeNormals(): Mesh;
  87500. /**
  87501. * 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
  87502. * @returns the current mesh
  87503. */
  87504. unfreezeNormals(): Mesh;
  87505. /**
  87506. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  87507. */
  87508. overridenInstanceCount: number;
  87509. /** @hidden */
  87510. _preActivate(): Mesh;
  87511. /** @hidden */
  87512. _preActivateForIntermediateRendering(renderId: number): Mesh;
  87513. /** @hidden */
  87514. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  87515. /**
  87516. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87517. * This means the mesh underlying bounding box and sphere are recomputed.
  87518. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87519. * @returns the current mesh
  87520. */
  87521. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  87522. /** @hidden */
  87523. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  87524. /**
  87525. * This function will subdivide the mesh into multiple submeshes
  87526. * @param count defines the expected number of submeshes
  87527. */
  87528. subdivide(count: number): void;
  87529. /**
  87530. * Copy a FloatArray into a specific associated vertex buffer
  87531. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87532. * - VertexBuffer.PositionKind
  87533. * - VertexBuffer.UVKind
  87534. * - VertexBuffer.UV2Kind
  87535. * - VertexBuffer.UV3Kind
  87536. * - VertexBuffer.UV4Kind
  87537. * - VertexBuffer.UV5Kind
  87538. * - VertexBuffer.UV6Kind
  87539. * - VertexBuffer.ColorKind
  87540. * - VertexBuffer.MatricesIndicesKind
  87541. * - VertexBuffer.MatricesIndicesExtraKind
  87542. * - VertexBuffer.MatricesWeightsKind
  87543. * - VertexBuffer.MatricesWeightsExtraKind
  87544. * @param data defines the data source
  87545. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  87546. * @param stride defines the data stride size (can be null)
  87547. * @returns the current mesh
  87548. */
  87549. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  87550. /**
  87551. * Flags an associated vertex buffer as updatable
  87552. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  87553. * - VertexBuffer.PositionKind
  87554. * - VertexBuffer.UVKind
  87555. * - VertexBuffer.UV2Kind
  87556. * - VertexBuffer.UV3Kind
  87557. * - VertexBuffer.UV4Kind
  87558. * - VertexBuffer.UV5Kind
  87559. * - VertexBuffer.UV6Kind
  87560. * - VertexBuffer.ColorKind
  87561. * - VertexBuffer.MatricesIndicesKind
  87562. * - VertexBuffer.MatricesIndicesExtraKind
  87563. * - VertexBuffer.MatricesWeightsKind
  87564. * - VertexBuffer.MatricesWeightsExtraKind
  87565. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  87566. */
  87567. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  87568. /**
  87569. * Sets the mesh global Vertex Buffer
  87570. * @param buffer defines the buffer to use
  87571. * @returns the current mesh
  87572. */
  87573. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  87574. /**
  87575. * Update a specific associated vertex buffer
  87576. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87577. * - VertexBuffer.PositionKind
  87578. * - VertexBuffer.UVKind
  87579. * - VertexBuffer.UV2Kind
  87580. * - VertexBuffer.UV3Kind
  87581. * - VertexBuffer.UV4Kind
  87582. * - VertexBuffer.UV5Kind
  87583. * - VertexBuffer.UV6Kind
  87584. * - VertexBuffer.ColorKind
  87585. * - VertexBuffer.MatricesIndicesKind
  87586. * - VertexBuffer.MatricesIndicesExtraKind
  87587. * - VertexBuffer.MatricesWeightsKind
  87588. * - VertexBuffer.MatricesWeightsExtraKind
  87589. * @param data defines the data source
  87590. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  87591. * @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)
  87592. * @returns the current mesh
  87593. */
  87594. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  87595. /**
  87596. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  87597. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  87598. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  87599. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  87600. * @returns the current mesh
  87601. */
  87602. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  87603. /**
  87604. * Creates a un-shared specific occurence of the geometry for the mesh.
  87605. * @returns the current mesh
  87606. */
  87607. makeGeometryUnique(): Mesh;
  87608. /**
  87609. * Set the index buffer of this mesh
  87610. * @param indices defines the source data
  87611. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  87612. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  87613. * @returns the current mesh
  87614. */
  87615. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  87616. /**
  87617. * Update the current index buffer
  87618. * @param indices defines the source data
  87619. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  87620. * @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)
  87621. * @returns the current mesh
  87622. */
  87623. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  87624. /**
  87625. * Invert the geometry to move from a right handed system to a left handed one.
  87626. * @returns the current mesh
  87627. */
  87628. toLeftHanded(): Mesh;
  87629. /** @hidden */
  87630. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  87631. /** @hidden */
  87632. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  87633. /**
  87634. * Registers for this mesh a javascript function called just before the rendering process
  87635. * @param func defines the function to call before rendering this mesh
  87636. * @returns the current mesh
  87637. */
  87638. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  87639. /**
  87640. * Disposes a previously registered javascript function called before the rendering
  87641. * @param func defines the function to remove
  87642. * @returns the current mesh
  87643. */
  87644. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  87645. /**
  87646. * Registers for this mesh a javascript function called just after the rendering is complete
  87647. * @param func defines the function to call after rendering this mesh
  87648. * @returns the current mesh
  87649. */
  87650. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  87651. /**
  87652. * Disposes a previously registered javascript function called after the rendering.
  87653. * @param func defines the function to remove
  87654. * @returns the current mesh
  87655. */
  87656. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  87657. /** @hidden */
  87658. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  87659. /** @hidden */
  87660. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  87661. /** @hidden */
  87662. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  87663. /** @hidden */
  87664. _rebuild(): void;
  87665. /** @hidden */
  87666. _freeze(): void;
  87667. /** @hidden */
  87668. _unFreeze(): void;
  87669. /**
  87670. * 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
  87671. * @param subMesh defines the subMesh to render
  87672. * @param enableAlphaMode defines if alpha mode can be changed
  87673. * @returns the current mesh
  87674. */
  87675. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  87676. private _onBeforeDraw;
  87677. /**
  87678. * Renormalize the mesh and patch it up if there are no weights
  87679. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  87680. * However in the case of zero weights then we set just a single influence to 1.
  87681. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  87682. */
  87683. cleanMatrixWeights(): void;
  87684. private normalizeSkinFourWeights;
  87685. private normalizeSkinWeightsAndExtra;
  87686. /**
  87687. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  87688. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  87689. * the user know there was an issue with importing the mesh
  87690. * @returns a validation object with skinned, valid and report string
  87691. */
  87692. validateSkinning(): {
  87693. skinned: boolean;
  87694. valid: boolean;
  87695. report: string;
  87696. };
  87697. /** @hidden */
  87698. _checkDelayState(): Mesh;
  87699. private _queueLoad;
  87700. /**
  87701. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  87702. * A mesh is in the frustum if its bounding box intersects the frustum
  87703. * @param frustumPlanes defines the frustum to test
  87704. * @returns true if the mesh is in the frustum planes
  87705. */
  87706. isInFrustum(frustumPlanes: Plane[]): boolean;
  87707. /**
  87708. * Sets the mesh material by the material or multiMaterial `id` property
  87709. * @param id is a string identifying the material or the multiMaterial
  87710. * @returns the current mesh
  87711. */
  87712. setMaterialByID(id: string): Mesh;
  87713. /**
  87714. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  87715. * @returns an array of IAnimatable
  87716. */
  87717. getAnimatables(): IAnimatable[];
  87718. /**
  87719. * Modifies the mesh geometry according to the passed transformation matrix.
  87720. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  87721. * The mesh normals are modified using the same transformation.
  87722. * Note that, under the hood, this method sets a new VertexBuffer each call.
  87723. * @param transform defines the transform matrix to use
  87724. * @see http://doc.babylonjs.com/resources/baking_transformations
  87725. * @returns the current mesh
  87726. */
  87727. bakeTransformIntoVertices(transform: Matrix): Mesh;
  87728. /**
  87729. * Modifies the mesh geometry according to its own current World Matrix.
  87730. * The mesh World Matrix is then reset.
  87731. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  87732. * Note that, under the hood, this method sets a new VertexBuffer each call.
  87733. * @see http://doc.babylonjs.com/resources/baking_transformations
  87734. * @returns the current mesh
  87735. */
  87736. bakeCurrentTransformIntoVertices(): Mesh;
  87737. /** @hidden */
  87738. readonly _positions: Nullable<Vector3[]>;
  87739. /** @hidden */
  87740. _resetPointsArrayCache(): Mesh;
  87741. /** @hidden */
  87742. _generatePointsArray(): boolean;
  87743. /**
  87744. * Returns a new Mesh object generated from the current mesh properties.
  87745. * This method must not get confused with createInstance()
  87746. * @param name is a string, the name given to the new mesh
  87747. * @param newParent can be any Node object (default `null`)
  87748. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  87749. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  87750. * @returns a new mesh
  87751. */
  87752. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  87753. /**
  87754. * Releases resources associated with this mesh.
  87755. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87756. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87757. */
  87758. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87759. /**
  87760. * Modifies the mesh geometry according to a displacement map.
  87761. * 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.
  87762. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  87763. * @param url is a string, the URL from the image file is to be downloaded.
  87764. * @param minHeight is the lower limit of the displacement.
  87765. * @param maxHeight is the upper limit of the displacement.
  87766. * @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.
  87767. * @param uvOffset is an optional vector2 used to offset UV.
  87768. * @param uvScale is an optional vector2 used to scale UV.
  87769. * @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.
  87770. * @returns the Mesh.
  87771. */
  87772. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  87773. /**
  87774. * Modifies the mesh geometry according to a displacementMap buffer.
  87775. * 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.
  87776. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  87777. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  87778. * @param heightMapWidth is the width of the buffer image.
  87779. * @param heightMapHeight is the height of the buffer image.
  87780. * @param minHeight is the lower limit of the displacement.
  87781. * @param maxHeight is the upper limit of the displacement.
  87782. * @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.
  87783. * @param uvOffset is an optional vector2 used to offset UV.
  87784. * @param uvScale is an optional vector2 used to scale UV.
  87785. * @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.
  87786. * @returns the Mesh.
  87787. */
  87788. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  87789. /**
  87790. * Modify the mesh to get a flat shading rendering.
  87791. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  87792. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  87793. * @returns current mesh
  87794. */
  87795. convertToFlatShadedMesh(): Mesh;
  87796. /**
  87797. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  87798. * In other words, more vertices, no more indices and a single bigger VBO.
  87799. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  87800. * @returns current mesh
  87801. */
  87802. convertToUnIndexedMesh(): Mesh;
  87803. /**
  87804. * Inverses facet orientations.
  87805. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  87806. * @param flipNormals will also inverts the normals
  87807. * @returns current mesh
  87808. */
  87809. flipFaces(flipNormals?: boolean): Mesh;
  87810. /**
  87811. * Increase the number of facets and hence vertices in a mesh
  87812. * Vertex normals are interpolated from existing vertex normals
  87813. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  87814. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  87815. */
  87816. increaseVertices(numberPerEdge: number): void;
  87817. /**
  87818. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  87819. * This will undo any application of covertToFlatShadedMesh
  87820. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  87821. */
  87822. forceSharedVertices(): void;
  87823. /** @hidden */
  87824. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  87825. /** @hidden */
  87826. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  87827. /**
  87828. * Creates a new InstancedMesh object from the mesh model.
  87829. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87830. * @param name defines the name of the new instance
  87831. * @returns a new InstancedMesh
  87832. */
  87833. createInstance(name: string): InstancedMesh;
  87834. /**
  87835. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  87836. * After this call, all the mesh instances have the same submeshes than the current mesh.
  87837. * @returns the current mesh
  87838. */
  87839. synchronizeInstances(): Mesh;
  87840. /**
  87841. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  87842. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  87843. * This should be used together with the simplification to avoid disappearing triangles.
  87844. * @param successCallback an optional success callback to be called after the optimization finished.
  87845. * @returns the current mesh
  87846. */
  87847. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  87848. /**
  87849. * Serialize current mesh
  87850. * @param serializationObject defines the object which will receive the serialization data
  87851. */
  87852. serialize(serializationObject: any): void;
  87853. /** @hidden */
  87854. _syncGeometryWithMorphTargetManager(): void;
  87855. /** @hidden */
  87856. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  87857. /**
  87858. * Returns a new Mesh object parsed from the source provided.
  87859. * @param parsedMesh is the source
  87860. * @param scene defines the hosting scene
  87861. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  87862. * @returns a new Mesh
  87863. */
  87864. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  87865. /**
  87866. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  87867. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  87868. * @param name defines the name of the mesh to create
  87869. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  87870. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  87871. * @param closePath creates a seam between the first and the last points of each path of the path array
  87872. * @param offset is taken in account only if the `pathArray` is containing a single path
  87873. * @param scene defines the hosting scene
  87874. * @param updatable defines if the mesh must be flagged as updatable
  87875. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87876. * @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)
  87877. * @returns a new Mesh
  87878. */
  87879. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  87880. /**
  87881. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  87882. * @param name defines the name of the mesh to create
  87883. * @param radius sets the radius size (float) of the polygon (default 0.5)
  87884. * @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
  87885. * @param scene defines the hosting scene
  87886. * @param updatable defines if the mesh must be flagged as updatable
  87887. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87888. * @returns a new Mesh
  87889. */
  87890. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  87891. /**
  87892. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  87893. * @param name defines the name of the mesh to create
  87894. * @param size sets the size (float) of each box side (default 1)
  87895. * @param scene defines the hosting scene
  87896. * @param updatable defines if the mesh must be flagged as updatable
  87897. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87898. * @returns a new Mesh
  87899. */
  87900. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  87901. /**
  87902. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  87903. * @param name defines the name of the mesh to create
  87904. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  87905. * @param diameter sets the diameter size (float) of the sphere (default 1)
  87906. * @param scene defines the hosting scene
  87907. * @param updatable defines if the mesh must be flagged as updatable
  87908. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87909. * @returns a new Mesh
  87910. */
  87911. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  87912. /**
  87913. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  87914. * @param name defines the name of the mesh to create
  87915. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  87916. * @param diameter sets the diameter size (float) of the sphere (default 1)
  87917. * @param scene defines the hosting scene
  87918. * @returns a new Mesh
  87919. */
  87920. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  87921. /**
  87922. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  87923. * @param name defines the name of the mesh to create
  87924. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  87925. * @param diameterTop set the top cap diameter (floats, default 1)
  87926. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  87927. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  87928. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  87929. * @param scene defines the hosting scene
  87930. * @param updatable defines if the mesh must be flagged as updatable
  87931. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87932. * @returns a new Mesh
  87933. */
  87934. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  87935. /**
  87936. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  87937. * @param name defines the name of the mesh to create
  87938. * @param diameter sets the diameter size (float) of the torus (default 1)
  87939. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  87940. * @param tessellation sets the number of torus sides (postive integer, default 16)
  87941. * @param scene defines the hosting scene
  87942. * @param updatable defines if the mesh must be flagged as updatable
  87943. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87944. * @returns a new Mesh
  87945. */
  87946. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  87947. /**
  87948. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  87949. * @param name defines the name of the mesh to create
  87950. * @param radius sets the global radius size (float) of the torus knot (default 2)
  87951. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  87952. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  87953. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  87954. * @param p the number of windings on X axis (positive integers, default 2)
  87955. * @param q the number of windings on Y axis (positive integers, default 3)
  87956. * @param scene defines the hosting scene
  87957. * @param updatable defines if the mesh must be flagged as updatable
  87958. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87959. * @returns a new Mesh
  87960. */
  87961. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  87962. /**
  87963. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  87964. * @param name defines the name of the mesh to create
  87965. * @param points is an array successive Vector3
  87966. * @param scene defines the hosting scene
  87967. * @param updatable defines if the mesh must be flagged as updatable
  87968. * @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).
  87969. * @returns a new Mesh
  87970. */
  87971. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  87972. /**
  87973. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  87974. * @param name defines the name of the mesh to create
  87975. * @param points is an array successive Vector3
  87976. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  87977. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  87978. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  87979. * @param scene defines the hosting scene
  87980. * @param updatable defines if the mesh must be flagged as updatable
  87981. * @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)
  87982. * @returns a new Mesh
  87983. */
  87984. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  87985. /**
  87986. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  87987. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  87988. * 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.
  87989. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87990. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  87991. * Remember you can only change the shape positions, not their number when updating a polygon.
  87992. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  87993. * @param name defines the name of the mesh to create
  87994. * @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
  87995. * @param scene defines the hosting scene
  87996. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  87997. * @param updatable defines if the mesh must be flagged as updatable
  87998. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87999. * @param earcutInjection can be used to inject your own earcut reference
  88000. * @returns a new Mesh
  88001. */
  88002. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  88003. /**
  88004. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  88005. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  88006. * @param name defines the name of the mesh to create
  88007. * @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
  88008. * @param depth defines the height of extrusion
  88009. * @param scene defines the hosting scene
  88010. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  88011. * @param updatable defines if the mesh must be flagged as updatable
  88012. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88013. * @param earcutInjection can be used to inject your own earcut reference
  88014. * @returns a new Mesh
  88015. */
  88016. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  88017. /**
  88018. * Creates an extruded shape mesh.
  88019. * 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
  88020. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88021. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88022. * @param name defines the name of the mesh to create
  88023. * @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
  88024. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  88025. * @param scale is the value to scale the shape
  88026. * @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
  88027. * @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
  88028. * @param scene defines the hosting scene
  88029. * @param updatable defines if the mesh must be flagged as updatable
  88030. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88031. * @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)
  88032. * @returns a new Mesh
  88033. */
  88034. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  88035. /**
  88036. * Creates an custom extruded shape mesh.
  88037. * The custom extrusion is a parametric shape.
  88038. * It has no predefined shape. Its final shape will depend on the input parameters.
  88039. * Please consider using the same method from the MeshBuilder class instead
  88040. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88041. * @param name defines the name of the mesh to create
  88042. * @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
  88043. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  88044. * @param scaleFunction is a custom Javascript function called on each path point
  88045. * @param rotationFunction is a custom Javascript function called on each path point
  88046. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  88047. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  88048. * @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
  88049. * @param scene defines the hosting scene
  88050. * @param updatable defines if the mesh must be flagged as updatable
  88051. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88052. * @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)
  88053. * @returns a new Mesh
  88054. */
  88055. 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;
  88056. /**
  88057. * Creates lathe mesh.
  88058. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  88059. * Please consider using the same method from the MeshBuilder class instead
  88060. * @param name defines the name of the mesh to create
  88061. * @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
  88062. * @param radius is the radius value of the lathe
  88063. * @param tessellation is the side number of the lathe.
  88064. * @param scene defines the hosting scene
  88065. * @param updatable defines if the mesh must be flagged as updatable
  88066. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88067. * @returns a new Mesh
  88068. */
  88069. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88070. /**
  88071. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  88072. * @param name defines the name of the mesh to create
  88073. * @param size sets the size (float) of both sides of the plane at once (default 1)
  88074. * @param scene defines the hosting scene
  88075. * @param updatable defines if the mesh must be flagged as updatable
  88076. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88077. * @returns a new Mesh
  88078. */
  88079. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  88080. /**
  88081. * Creates a ground mesh.
  88082. * Please consider using the same method from the MeshBuilder class instead
  88083. * @param name defines the name of the mesh to create
  88084. * @param width set the width of the ground
  88085. * @param height set the height of the ground
  88086. * @param subdivisions sets the number of subdivisions per side
  88087. * @param scene defines the hosting scene
  88088. * @param updatable defines if the mesh must be flagged as updatable
  88089. * @returns a new Mesh
  88090. */
  88091. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  88092. /**
  88093. * Creates a tiled ground mesh.
  88094. * Please consider using the same method from the MeshBuilder class instead
  88095. * @param name defines the name of the mesh to create
  88096. * @param xmin set the ground minimum X coordinate
  88097. * @param zmin set the ground minimum Y coordinate
  88098. * @param xmax set the ground maximum X coordinate
  88099. * @param zmax set the ground maximum Z coordinate
  88100. * @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
  88101. * @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
  88102. * @param scene defines the hosting scene
  88103. * @param updatable defines if the mesh must be flagged as updatable
  88104. * @returns a new Mesh
  88105. */
  88106. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  88107. w: number;
  88108. h: number;
  88109. }, precision: {
  88110. w: number;
  88111. h: number;
  88112. }, scene: Scene, updatable?: boolean): Mesh;
  88113. /**
  88114. * Creates a ground mesh from a height map.
  88115. * Please consider using the same method from the MeshBuilder class instead
  88116. * @see http://doc.babylonjs.com/babylon101/height_map
  88117. * @param name defines the name of the mesh to create
  88118. * @param url sets the URL of the height map image resource
  88119. * @param width set the ground width size
  88120. * @param height set the ground height size
  88121. * @param subdivisions sets the number of subdivision per side
  88122. * @param minHeight is the minimum altitude on the ground
  88123. * @param maxHeight is the maximum altitude on the ground
  88124. * @param scene defines the hosting scene
  88125. * @param updatable defines if the mesh must be flagged as updatable
  88126. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  88127. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  88128. * @returns a new Mesh
  88129. */
  88130. 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;
  88131. /**
  88132. * Creates a tube mesh.
  88133. * The tube is a parametric shape.
  88134. * It has no predefined shape. Its final shape will depend on the input parameters.
  88135. * Please consider using the same method from the MeshBuilder class instead
  88136. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88137. * @param name defines the name of the mesh to create
  88138. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  88139. * @param radius sets the tube radius size
  88140. * @param tessellation is the number of sides on the tubular surface
  88141. * @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
  88142. * @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
  88143. * @param scene defines the hosting scene
  88144. * @param updatable defines if the mesh must be flagged as updatable
  88145. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88146. * @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)
  88147. * @returns a new Mesh
  88148. */
  88149. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  88150. (i: number, distance: number): number;
  88151. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  88152. /**
  88153. * Creates a polyhedron mesh.
  88154. * Please consider using the same method from the MeshBuilder class instead.
  88155. * * 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
  88156. * * The parameter `size` (positive float, default 1) sets the polygon size
  88157. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  88158. * * 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`
  88159. * * 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
  88160. * * 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)`)
  88161. * * 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
  88162. * * 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
  88163. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88164. * * If you create a double-sided mesh, you can choose what parts of 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
  88165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88166. * @param name defines the name of the mesh to create
  88167. * @param options defines the options used to create the mesh
  88168. * @param scene defines the hosting scene
  88169. * @returns a new Mesh
  88170. */
  88171. static CreatePolyhedron(name: string, options: {
  88172. type?: number;
  88173. size?: number;
  88174. sizeX?: number;
  88175. sizeY?: number;
  88176. sizeZ?: number;
  88177. custom?: any;
  88178. faceUV?: Vector4[];
  88179. faceColors?: Color4[];
  88180. updatable?: boolean;
  88181. sideOrientation?: number;
  88182. }, scene: Scene): Mesh;
  88183. /**
  88184. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  88185. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  88186. * * 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`)
  88187. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  88188. * * 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
  88189. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88190. * * If you create a double-sided mesh, you can choose what parts of 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
  88191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88192. * @param name defines the name of the mesh
  88193. * @param options defines the options used to create the mesh
  88194. * @param scene defines the hosting scene
  88195. * @returns a new Mesh
  88196. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  88197. */
  88198. static CreateIcoSphere(name: string, options: {
  88199. radius?: number;
  88200. flat?: boolean;
  88201. subdivisions?: number;
  88202. sideOrientation?: number;
  88203. updatable?: boolean;
  88204. }, scene: Scene): Mesh;
  88205. /**
  88206. * Creates a decal mesh.
  88207. * Please consider using the same method from the MeshBuilder class instead.
  88208. * A decal is a mesh usually applied as a model onto the surface of another mesh
  88209. * @param name defines the name of the mesh
  88210. * @param sourceMesh defines the mesh receiving the decal
  88211. * @param position sets the position of the decal in world coordinates
  88212. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  88213. * @param size sets the decal scaling
  88214. * @param angle sets the angle to rotate the decal
  88215. * @returns a new Mesh
  88216. */
  88217. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  88218. /**
  88219. * Prepare internal position array for software CPU skinning
  88220. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  88221. */
  88222. setPositionsForCPUSkinning(): Float32Array;
  88223. /**
  88224. * Prepare internal normal array for software CPU skinning
  88225. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  88226. */
  88227. setNormalsForCPUSkinning(): Float32Array;
  88228. /**
  88229. * Updates the vertex buffer by applying transformation from the bones
  88230. * @param skeleton defines the skeleton to apply to current mesh
  88231. * @returns the current mesh
  88232. */
  88233. applySkeleton(skeleton: Skeleton): Mesh;
  88234. /**
  88235. * 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
  88236. * @param meshes defines the list of meshes to scan
  88237. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  88238. */
  88239. static MinMax(meshes: AbstractMesh[]): {
  88240. min: Vector3;
  88241. max: Vector3;
  88242. };
  88243. /**
  88244. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  88245. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  88246. * @returns a vector3
  88247. */
  88248. static Center(meshesOrMinMaxVector: {
  88249. min: Vector3;
  88250. max: Vector3;
  88251. } | AbstractMesh[]): Vector3;
  88252. /**
  88253. * Merge the array of meshes into a single mesh for performance reasons.
  88254. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  88255. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  88256. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  88257. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  88258. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  88259. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  88260. * @returns a new mesh
  88261. */
  88262. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  88263. /** @hidden */
  88264. addInstance(instance: InstancedMesh): void;
  88265. /** @hidden */
  88266. removeInstance(instance: InstancedMesh): void;
  88267. }
  88268. }
  88269. declare module BABYLON {
  88270. /**
  88271. * This is the base class of all the camera used in the application.
  88272. * @see http://doc.babylonjs.com/features/cameras
  88273. */
  88274. export class Camera extends Node {
  88275. /** @hidden */
  88276. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  88277. /**
  88278. * This is the default projection mode used by the cameras.
  88279. * It helps recreating a feeling of perspective and better appreciate depth.
  88280. * This is the best way to simulate real life cameras.
  88281. */
  88282. static readonly PERSPECTIVE_CAMERA: number;
  88283. /**
  88284. * This helps creating camera with an orthographic mode.
  88285. * 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.
  88286. */
  88287. static readonly ORTHOGRAPHIC_CAMERA: number;
  88288. /**
  88289. * This is the default FOV mode for perspective cameras.
  88290. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  88291. */
  88292. static readonly FOVMODE_VERTICAL_FIXED: number;
  88293. /**
  88294. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  88295. */
  88296. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  88297. /**
  88298. * This specifies ther is no need for a camera rig.
  88299. * Basically only one eye is rendered corresponding to the camera.
  88300. */
  88301. static readonly RIG_MODE_NONE: number;
  88302. /**
  88303. * Simulates a camera Rig with one blue eye and one red eye.
  88304. * This can be use with 3d blue and red glasses.
  88305. */
  88306. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  88307. /**
  88308. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  88309. */
  88310. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  88311. /**
  88312. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  88313. */
  88314. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  88315. /**
  88316. * Defines that both eyes of the camera will be rendered over under each other.
  88317. */
  88318. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  88319. /**
  88320. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  88321. */
  88322. static readonly RIG_MODE_VR: number;
  88323. /**
  88324. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  88325. */
  88326. static readonly RIG_MODE_WEBVR: number;
  88327. /**
  88328. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  88329. */
  88330. static readonly RIG_MODE_CUSTOM: number;
  88331. /**
  88332. * Defines if by default attaching controls should prevent the default javascript event to continue.
  88333. */
  88334. static ForceAttachControlToAlwaysPreventDefault: boolean;
  88335. /**
  88336. * Define the input manager associated with the camera.
  88337. */
  88338. inputs: CameraInputsManager<Camera>;
  88339. /** @hidden */
  88340. _position: Vector3;
  88341. /**
  88342. * Define the current local position of the camera in the scene
  88343. */
  88344. position: Vector3;
  88345. /**
  88346. * The vector the camera should consider as up.
  88347. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  88348. */
  88349. upVector: Vector3;
  88350. /**
  88351. * Define the current limit on the left side for an orthographic camera
  88352. * In scene unit
  88353. */
  88354. orthoLeft: Nullable<number>;
  88355. /**
  88356. * Define the current limit on the right side for an orthographic camera
  88357. * In scene unit
  88358. */
  88359. orthoRight: Nullable<number>;
  88360. /**
  88361. * Define the current limit on the bottom side for an orthographic camera
  88362. * In scene unit
  88363. */
  88364. orthoBottom: Nullable<number>;
  88365. /**
  88366. * Define the current limit on the top side for an orthographic camera
  88367. * In scene unit
  88368. */
  88369. orthoTop: Nullable<number>;
  88370. /**
  88371. * Field Of View is set in Radians. (default is 0.8)
  88372. */
  88373. fov: number;
  88374. /**
  88375. * Define the minimum distance the camera can see from.
  88376. * This is important to note that the depth buffer are not infinite and the closer it starts
  88377. * the more your scene might encounter depth fighting issue.
  88378. */
  88379. minZ: number;
  88380. /**
  88381. * Define the maximum distance the camera can see to.
  88382. * This is important to note that the depth buffer are not infinite and the further it end
  88383. * the more your scene might encounter depth fighting issue.
  88384. */
  88385. maxZ: number;
  88386. /**
  88387. * Define the default inertia of the camera.
  88388. * This helps giving a smooth feeling to the camera movement.
  88389. */
  88390. inertia: number;
  88391. /**
  88392. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  88393. */
  88394. mode: number;
  88395. /**
  88396. * Define wether the camera is intermediate.
  88397. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  88398. */
  88399. isIntermediate: boolean;
  88400. /**
  88401. * Define the viewport of the camera.
  88402. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  88403. */
  88404. viewport: Viewport;
  88405. /**
  88406. * Restricts the camera to viewing objects with the same layerMask.
  88407. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  88408. */
  88409. layerMask: number;
  88410. /**
  88411. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  88412. */
  88413. fovMode: number;
  88414. /**
  88415. * Rig mode of the camera.
  88416. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  88417. * This is normally controlled byt the camera themselves as internal use.
  88418. */
  88419. cameraRigMode: number;
  88420. /**
  88421. * Defines the distance between both "eyes" in case of a RIG
  88422. */
  88423. interaxialDistance: number;
  88424. /**
  88425. * Defines if stereoscopic rendering is done side by side or over under.
  88426. */
  88427. isStereoscopicSideBySide: boolean;
  88428. /**
  88429. * 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
  88430. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  88431. * else in the scene. (Eg. security camera)
  88432. *
  88433. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  88434. */
  88435. customRenderTargets: RenderTargetTexture[];
  88436. /**
  88437. * When set, the camera will render to this render target instead of the default canvas
  88438. *
  88439. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  88440. */
  88441. outputRenderTarget: Nullable<RenderTargetTexture>;
  88442. /**
  88443. * Observable triggered when the camera view matrix has changed.
  88444. */
  88445. onViewMatrixChangedObservable: Observable<Camera>;
  88446. /**
  88447. * Observable triggered when the camera Projection matrix has changed.
  88448. */
  88449. onProjectionMatrixChangedObservable: Observable<Camera>;
  88450. /**
  88451. * Observable triggered when the inputs have been processed.
  88452. */
  88453. onAfterCheckInputsObservable: Observable<Camera>;
  88454. /**
  88455. * Observable triggered when reset has been called and applied to the camera.
  88456. */
  88457. onRestoreStateObservable: Observable<Camera>;
  88458. /** @hidden */
  88459. _cameraRigParams: any;
  88460. /** @hidden */
  88461. _rigCameras: Camera[];
  88462. /** @hidden */
  88463. _rigPostProcess: Nullable<PostProcess>;
  88464. protected _webvrViewMatrix: Matrix;
  88465. /** @hidden */
  88466. _skipRendering: boolean;
  88467. /** @hidden */
  88468. _projectionMatrix: Matrix;
  88469. /** @hidden */
  88470. _postProcesses: Nullable<PostProcess>[];
  88471. /** @hidden */
  88472. _activeMeshes: SmartArray<AbstractMesh>;
  88473. protected _globalPosition: Vector3;
  88474. /** @hidden */
  88475. _computedViewMatrix: Matrix;
  88476. private _doNotComputeProjectionMatrix;
  88477. private _transformMatrix;
  88478. private _frustumPlanes;
  88479. private _refreshFrustumPlanes;
  88480. private _storedFov;
  88481. private _stateStored;
  88482. /**
  88483. * Instantiates a new camera object.
  88484. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  88485. * @see http://doc.babylonjs.com/features/cameras
  88486. * @param name Defines the name of the camera in the scene
  88487. * @param position Defines the position of the camera
  88488. * @param scene Defines the scene the camera belongs too
  88489. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  88490. */
  88491. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  88492. /**
  88493. * Store current camera state (fov, position, etc..)
  88494. * @returns the camera
  88495. */
  88496. storeState(): Camera;
  88497. /**
  88498. * Restores the camera state values if it has been stored. You must call storeState() first
  88499. */
  88500. protected _restoreStateValues(): boolean;
  88501. /**
  88502. * Restored camera state. You must call storeState() first.
  88503. * @returns true if restored and false otherwise
  88504. */
  88505. restoreState(): boolean;
  88506. /**
  88507. * Gets the class name of the camera.
  88508. * @returns the class name
  88509. */
  88510. getClassName(): string;
  88511. /** @hidden */
  88512. readonly _isCamera: boolean;
  88513. /**
  88514. * Gets a string representation of the camera useful for debug purpose.
  88515. * @param fullDetails Defines that a more verboe level of logging is required
  88516. * @returns the string representation
  88517. */
  88518. toString(fullDetails?: boolean): string;
  88519. /**
  88520. * Gets the current world space position of the camera.
  88521. */
  88522. readonly globalPosition: Vector3;
  88523. /**
  88524. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  88525. * @returns the active meshe list
  88526. */
  88527. getActiveMeshes(): SmartArray<AbstractMesh>;
  88528. /**
  88529. * Check wether a mesh is part of the current active mesh list of the camera
  88530. * @param mesh Defines the mesh to check
  88531. * @returns true if active, false otherwise
  88532. */
  88533. isActiveMesh(mesh: Mesh): boolean;
  88534. /**
  88535. * Is this camera ready to be used/rendered
  88536. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  88537. * @return true if the camera is ready
  88538. */
  88539. isReady(completeCheck?: boolean): boolean;
  88540. /** @hidden */
  88541. _initCache(): void;
  88542. /** @hidden */
  88543. _updateCache(ignoreParentClass?: boolean): void;
  88544. /** @hidden */
  88545. _isSynchronized(): boolean;
  88546. /** @hidden */
  88547. _isSynchronizedViewMatrix(): boolean;
  88548. /** @hidden */
  88549. _isSynchronizedProjectionMatrix(): boolean;
  88550. /**
  88551. * Attach the input controls to a specific dom element to get the input from.
  88552. * @param element Defines the element the controls should be listened from
  88553. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  88554. */
  88555. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  88556. /**
  88557. * Detach the current controls from the specified dom element.
  88558. * @param element Defines the element to stop listening the inputs from
  88559. */
  88560. detachControl(element: HTMLElement): void;
  88561. /**
  88562. * Update the camera state according to the different inputs gathered during the frame.
  88563. */
  88564. update(): void;
  88565. /** @hidden */
  88566. _checkInputs(): void;
  88567. /** @hidden */
  88568. readonly rigCameras: Camera[];
  88569. /**
  88570. * Gets the post process used by the rig cameras
  88571. */
  88572. readonly rigPostProcess: Nullable<PostProcess>;
  88573. /**
  88574. * Internal, gets the first post proces.
  88575. * @returns the first post process to be run on this camera.
  88576. */
  88577. _getFirstPostProcess(): Nullable<PostProcess>;
  88578. private _cascadePostProcessesToRigCams;
  88579. /**
  88580. * Attach a post process to the camera.
  88581. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  88582. * @param postProcess The post process to attach to the camera
  88583. * @param insertAt The position of the post process in case several of them are in use in the scene
  88584. * @returns the position the post process has been inserted at
  88585. */
  88586. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  88587. /**
  88588. * Detach a post process to the camera.
  88589. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  88590. * @param postProcess The post process to detach from the camera
  88591. */
  88592. detachPostProcess(postProcess: PostProcess): void;
  88593. /**
  88594. * Gets the current world matrix of the camera
  88595. */
  88596. getWorldMatrix(): Matrix;
  88597. /** @hidden */
  88598. _getViewMatrix(): Matrix;
  88599. /**
  88600. * Gets the current view matrix of the camera.
  88601. * @param force forces the camera to recompute the matrix without looking at the cached state
  88602. * @returns the view matrix
  88603. */
  88604. getViewMatrix(force?: boolean): Matrix;
  88605. /**
  88606. * Freeze the projection matrix.
  88607. * It will prevent the cache check of the camera projection compute and can speed up perf
  88608. * if no parameter of the camera are meant to change
  88609. * @param projection Defines manually a projection if necessary
  88610. */
  88611. freezeProjectionMatrix(projection?: Matrix): void;
  88612. /**
  88613. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  88614. */
  88615. unfreezeProjectionMatrix(): void;
  88616. /**
  88617. * Gets the current projection matrix of the camera.
  88618. * @param force forces the camera to recompute the matrix without looking at the cached state
  88619. * @returns the projection matrix
  88620. */
  88621. getProjectionMatrix(force?: boolean): Matrix;
  88622. /**
  88623. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  88624. * @returns a Matrix
  88625. */
  88626. getTransformationMatrix(): Matrix;
  88627. private _updateFrustumPlanes;
  88628. /**
  88629. * Checks if a cullable object (mesh...) is in the camera frustum
  88630. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  88631. * @param target The object to check
  88632. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  88633. * @returns true if the object is in frustum otherwise false
  88634. */
  88635. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  88636. /**
  88637. * Checks if a cullable object (mesh...) is in the camera frustum
  88638. * Unlike isInFrustum this cheks the full bounding box
  88639. * @param target The object to check
  88640. * @returns true if the object is in frustum otherwise false
  88641. */
  88642. isCompletelyInFrustum(target: ICullable): boolean;
  88643. /**
  88644. * Gets a ray in the forward direction from the camera.
  88645. * @param length Defines the length of the ray to create
  88646. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  88647. * @param origin Defines the start point of the ray which defaults to the camera position
  88648. * @returns the forward ray
  88649. */
  88650. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  88651. /**
  88652. * Releases resources associated with this node.
  88653. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88654. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88655. */
  88656. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88657. /** @hidden */
  88658. _isLeftCamera: boolean;
  88659. /**
  88660. * Gets the left camera of a rig setup in case of Rigged Camera
  88661. */
  88662. readonly isLeftCamera: boolean;
  88663. /** @hidden */
  88664. _isRightCamera: boolean;
  88665. /**
  88666. * Gets the right camera of a rig setup in case of Rigged Camera
  88667. */
  88668. readonly isRightCamera: boolean;
  88669. /**
  88670. * Gets the left camera of a rig setup in case of Rigged Camera
  88671. */
  88672. readonly leftCamera: Nullable<FreeCamera>;
  88673. /**
  88674. * Gets the right camera of a rig setup in case of Rigged Camera
  88675. */
  88676. readonly rightCamera: Nullable<FreeCamera>;
  88677. /**
  88678. * Gets the left camera target of a rig setup in case of Rigged Camera
  88679. * @returns the target position
  88680. */
  88681. getLeftTarget(): Nullable<Vector3>;
  88682. /**
  88683. * Gets the right camera target of a rig setup in case of Rigged Camera
  88684. * @returns the target position
  88685. */
  88686. getRightTarget(): Nullable<Vector3>;
  88687. /**
  88688. * @hidden
  88689. */
  88690. setCameraRigMode(mode: number, rigParams: any): void;
  88691. /** @hidden */
  88692. static _setStereoscopicRigMode(camera: Camera): void;
  88693. /** @hidden */
  88694. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  88695. /** @hidden */
  88696. static _setVRRigMode(camera: Camera, rigParams: any): void;
  88697. /** @hidden */
  88698. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  88699. /** @hidden */
  88700. _getVRProjectionMatrix(): Matrix;
  88701. protected _updateCameraRotationMatrix(): void;
  88702. protected _updateWebVRCameraRotationMatrix(): void;
  88703. /**
  88704. * This function MUST be overwritten by the different WebVR cameras available.
  88705. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  88706. * @hidden
  88707. */
  88708. _getWebVRProjectionMatrix(): Matrix;
  88709. /**
  88710. * This function MUST be overwritten by the different WebVR cameras available.
  88711. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  88712. * @hidden
  88713. */
  88714. _getWebVRViewMatrix(): Matrix;
  88715. /** @hidden */
  88716. setCameraRigParameter(name: string, value: any): void;
  88717. /**
  88718. * needs to be overridden by children so sub has required properties to be copied
  88719. * @hidden
  88720. */
  88721. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  88722. /**
  88723. * May need to be overridden by children
  88724. * @hidden
  88725. */
  88726. _updateRigCameras(): void;
  88727. /** @hidden */
  88728. _setupInputs(): void;
  88729. /**
  88730. * Serialiaze the camera setup to a json represention
  88731. * @returns the JSON representation
  88732. */
  88733. serialize(): any;
  88734. /**
  88735. * Clones the current camera.
  88736. * @param name The cloned camera name
  88737. * @returns the cloned camera
  88738. */
  88739. clone(name: string): Camera;
  88740. /**
  88741. * Gets the direction of the camera relative to a given local axis.
  88742. * @param localAxis Defines the reference axis to provide a relative direction.
  88743. * @return the direction
  88744. */
  88745. getDirection(localAxis: Vector3): Vector3;
  88746. /**
  88747. * Gets the direction of the camera relative to a given local axis into a passed vector.
  88748. * @param localAxis Defines the reference axis to provide a relative direction.
  88749. * @param result Defines the vector to store the result in
  88750. */
  88751. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  88752. /**
  88753. * Gets a camera constructor for a given camera type
  88754. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  88755. * @param name The name of the camera the result will be able to instantiate
  88756. * @param scene The scene the result will construct the camera in
  88757. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  88758. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  88759. * @returns a factory method to construc the camera
  88760. */
  88761. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  88762. /**
  88763. * Compute the world matrix of the camera.
  88764. * @returns the camera workd matrix
  88765. */
  88766. computeWorldMatrix(): Matrix;
  88767. /**
  88768. * Parse a JSON and creates the camera from the parsed information
  88769. * @param parsedCamera The JSON to parse
  88770. * @param scene The scene to instantiate the camera in
  88771. * @returns the newly constructed camera
  88772. */
  88773. static Parse(parsedCamera: any, scene: Scene): Camera;
  88774. }
  88775. }
  88776. declare module BABYLON {
  88777. /**
  88778. * Class containing static functions to help procedurally build meshes
  88779. */
  88780. export class DiscBuilder {
  88781. /**
  88782. * Creates a plane polygonal mesh. By default, this is a disc
  88783. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  88784. * * 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
  88785. * * 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
  88786. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88787. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  88788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88789. * @param name defines the name of the mesh
  88790. * @param options defines the options used to create the mesh
  88791. * @param scene defines the hosting scene
  88792. * @returns the plane polygonal mesh
  88793. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  88794. */
  88795. static CreateDisc(name: string, options: {
  88796. radius?: number;
  88797. tessellation?: number;
  88798. arc?: number;
  88799. updatable?: boolean;
  88800. sideOrientation?: number;
  88801. frontUVs?: Vector4;
  88802. backUVs?: Vector4;
  88803. }, scene?: Nullable<Scene>): Mesh;
  88804. }
  88805. }
  88806. declare module BABYLON {
  88807. /**
  88808. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  88809. *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.
  88810. * The SPS is also a particle system. It provides some methods to manage the particles.
  88811. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  88812. *
  88813. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  88814. */
  88815. export class SolidParticleSystem implements IDisposable {
  88816. /**
  88817. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  88818. * Example : var p = SPS.particles[i];
  88819. */
  88820. particles: SolidParticle[];
  88821. /**
  88822. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  88823. */
  88824. nbParticles: number;
  88825. /**
  88826. * If the particles must ever face the camera (default false). Useful for planar particles.
  88827. */
  88828. billboard: boolean;
  88829. /**
  88830. * Recompute normals when adding a shape
  88831. */
  88832. recomputeNormals: boolean;
  88833. /**
  88834. * This a counter ofr your own usage. It's not set by any SPS functions.
  88835. */
  88836. counter: number;
  88837. /**
  88838. * The SPS name. This name is also given to the underlying mesh.
  88839. */
  88840. name: string;
  88841. /**
  88842. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  88843. */
  88844. mesh: Mesh;
  88845. /**
  88846. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  88847. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  88848. */
  88849. vars: any;
  88850. /**
  88851. * This array is populated when the SPS is set as 'pickable'.
  88852. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  88853. * Each element of this array is an object `{idx: int, faceId: int}`.
  88854. * `idx` is the picked particle index in the `SPS.particles` array
  88855. * `faceId` is the picked face index counted within this particle.
  88856. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  88857. */
  88858. pickedParticles: {
  88859. idx: number;
  88860. faceId: number;
  88861. }[];
  88862. /**
  88863. * This array is populated when `enableDepthSort` is set to true.
  88864. * Each element of this array is an instance of the class DepthSortedParticle.
  88865. */
  88866. depthSortedParticles: DepthSortedParticle[];
  88867. /**
  88868. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  88869. * @hidden
  88870. */
  88871. _bSphereOnly: boolean;
  88872. /**
  88873. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  88874. * @hidden
  88875. */
  88876. _bSphereRadiusFactor: number;
  88877. private _scene;
  88878. private _positions;
  88879. private _indices;
  88880. private _normals;
  88881. private _colors;
  88882. private _uvs;
  88883. private _indices32;
  88884. private _positions32;
  88885. private _normals32;
  88886. private _fixedNormal32;
  88887. private _colors32;
  88888. private _uvs32;
  88889. private _index;
  88890. private _updatable;
  88891. private _pickable;
  88892. private _isVisibilityBoxLocked;
  88893. private _alwaysVisible;
  88894. private _depthSort;
  88895. private _shapeCounter;
  88896. private _copy;
  88897. private _color;
  88898. private _computeParticleColor;
  88899. private _computeParticleTexture;
  88900. private _computeParticleRotation;
  88901. private _computeParticleVertex;
  88902. private _computeBoundingBox;
  88903. private _depthSortParticles;
  88904. private _camera;
  88905. private _mustUnrotateFixedNormals;
  88906. private _particlesIntersect;
  88907. private _needs32Bits;
  88908. /**
  88909. * Creates a SPS (Solid Particle System) object.
  88910. * @param name (String) is the SPS name, this will be the underlying mesh name.
  88911. * @param scene (Scene) is the scene in which the SPS is added.
  88912. * @param options defines the options of the sps e.g.
  88913. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  88914. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  88915. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  88916. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  88917. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  88918. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  88919. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  88920. */
  88921. constructor(name: string, scene: Scene, options?: {
  88922. updatable?: boolean;
  88923. isPickable?: boolean;
  88924. enableDepthSort?: boolean;
  88925. particleIntersection?: boolean;
  88926. boundingSphereOnly?: boolean;
  88927. bSphereRadiusFactor?: number;
  88928. });
  88929. /**
  88930. * Builds the SPS underlying mesh. Returns a standard Mesh.
  88931. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  88932. * @returns the created mesh
  88933. */
  88934. buildMesh(): Mesh;
  88935. /**
  88936. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  88937. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  88938. * Thus the particles generated from `digest()` have their property `position` set yet.
  88939. * @param mesh ( Mesh ) is the mesh to be digested
  88940. * @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
  88941. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  88942. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  88943. * @returns the current SPS
  88944. */
  88945. digest(mesh: Mesh, options?: {
  88946. facetNb?: number;
  88947. number?: number;
  88948. delta?: number;
  88949. }): SolidParticleSystem;
  88950. private _unrotateFixedNormals;
  88951. private _resetCopy;
  88952. private _meshBuilder;
  88953. private _posToShape;
  88954. private _uvsToShapeUV;
  88955. private _addParticle;
  88956. /**
  88957. * Adds some particles to the SPS from the model shape. Returns the shape id.
  88958. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  88959. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  88960. * @param nb (positive integer) the number of particles to be created from this model
  88961. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  88962. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  88963. * @returns the number of shapes in the system
  88964. */
  88965. addShape(mesh: Mesh, nb: number, options?: {
  88966. positionFunction?: any;
  88967. vertexFunction?: any;
  88968. }): number;
  88969. private _rebuildParticle;
  88970. /**
  88971. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  88972. * @returns the SPS.
  88973. */
  88974. rebuildMesh(): SolidParticleSystem;
  88975. /**
  88976. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  88977. * This method calls `updateParticle()` for each particle of the SPS.
  88978. * For an animated SPS, it is usually called within the render loop.
  88979. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  88980. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  88981. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  88982. * @returns the SPS.
  88983. */
  88984. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  88985. /**
  88986. * Disposes the SPS.
  88987. */
  88988. dispose(): void;
  88989. /**
  88990. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  88991. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  88992. * @returns the SPS.
  88993. */
  88994. refreshVisibleSize(): SolidParticleSystem;
  88995. /**
  88996. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  88997. * @param size the size (float) of the visibility box
  88998. * note : this doesn't lock the SPS mesh bounding box.
  88999. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89000. */
  89001. setVisibilityBox(size: number): void;
  89002. /**
  89003. * Gets whether the SPS as always visible or not
  89004. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89005. */
  89006. /**
  89007. * Sets the SPS as always visible or not
  89008. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89009. */
  89010. isAlwaysVisible: boolean;
  89011. /**
  89012. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  89013. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89014. */
  89015. /**
  89016. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  89017. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  89018. */
  89019. isVisibilityBoxLocked: boolean;
  89020. /**
  89021. * Tells to `setParticles()` to compute the particle rotations or not.
  89022. * Default value : true. The SPS is faster when it's set to false.
  89023. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  89024. */
  89025. /**
  89026. * Gets if `setParticles()` computes the particle rotations or not.
  89027. * Default value : true. The SPS is faster when it's set to false.
  89028. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  89029. */
  89030. computeParticleRotation: boolean;
  89031. /**
  89032. * Tells to `setParticles()` to compute the particle colors or not.
  89033. * Default value : true. The SPS is faster when it's set to false.
  89034. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  89035. */
  89036. /**
  89037. * Gets if `setParticles()` computes the particle colors or not.
  89038. * Default value : true. The SPS is faster when it's set to false.
  89039. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  89040. */
  89041. computeParticleColor: boolean;
  89042. /**
  89043. * Gets if `setParticles()` computes the particle textures or not.
  89044. * Default value : true. The SPS is faster when it's set to false.
  89045. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  89046. */
  89047. computeParticleTexture: boolean;
  89048. /**
  89049. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  89050. * Default value : false. The SPS is faster when it's set to false.
  89051. * Note : the particle custom vertex positions aren't stored values.
  89052. */
  89053. /**
  89054. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  89055. * Default value : false. The SPS is faster when it's set to false.
  89056. * Note : the particle custom vertex positions aren't stored values.
  89057. */
  89058. computeParticleVertex: boolean;
  89059. /**
  89060. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  89061. */
  89062. /**
  89063. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  89064. */
  89065. computeBoundingBox: boolean;
  89066. /**
  89067. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  89068. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  89069. * Default : `true`
  89070. */
  89071. /**
  89072. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  89073. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  89074. * Default : `true`
  89075. */
  89076. depthSortParticles: boolean;
  89077. /**
  89078. * This function does nothing. It may be overwritten to set all the particle first values.
  89079. * The SPS doesn't call this function, you may have to call it by your own.
  89080. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  89081. */
  89082. initParticles(): void;
  89083. /**
  89084. * This function does nothing. It may be overwritten to recycle a particle.
  89085. * The SPS doesn't call this function, you may have to call it by your own.
  89086. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  89087. * @param particle The particle to recycle
  89088. * @returns the recycled particle
  89089. */
  89090. recycleParticle(particle: SolidParticle): SolidParticle;
  89091. /**
  89092. * Updates a particle : this function should be overwritten by the user.
  89093. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  89094. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  89095. * @example : just set a particle position or velocity and recycle conditions
  89096. * @param particle The particle to update
  89097. * @returns the updated particle
  89098. */
  89099. updateParticle(particle: SolidParticle): SolidParticle;
  89100. /**
  89101. * Updates a vertex of a particle : it can be overwritten by the user.
  89102. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  89103. * @param particle the current particle
  89104. * @param vertex the current index of the current particle
  89105. * @param pt the index of the current vertex in the particle shape
  89106. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  89107. * @example : just set a vertex particle position
  89108. * @returns the updated vertex
  89109. */
  89110. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  89111. /**
  89112. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  89113. * This does nothing and may be overwritten by the user.
  89114. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89115. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89116. * @param update the boolean update value actually passed to setParticles()
  89117. */
  89118. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  89119. /**
  89120. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  89121. * This will be passed three parameters.
  89122. * This does nothing and may be overwritten by the user.
  89123. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89124. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  89125. * @param update the boolean update value actually passed to setParticles()
  89126. */
  89127. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  89128. }
  89129. }
  89130. declare module BABYLON {
  89131. /**
  89132. * Represents one particle of a solid particle system.
  89133. */
  89134. export class SolidParticle {
  89135. /**
  89136. * particle global index
  89137. */
  89138. idx: number;
  89139. /**
  89140. * The color of the particle
  89141. */
  89142. color: Nullable<Color4>;
  89143. /**
  89144. * The world space position of the particle.
  89145. */
  89146. position: Vector3;
  89147. /**
  89148. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  89149. */
  89150. rotation: Vector3;
  89151. /**
  89152. * The world space rotation quaternion of the particle.
  89153. */
  89154. rotationQuaternion: Nullable<Quaternion>;
  89155. /**
  89156. * The scaling of the particle.
  89157. */
  89158. scaling: Vector3;
  89159. /**
  89160. * The uvs of the particle.
  89161. */
  89162. uvs: Vector4;
  89163. /**
  89164. * The current speed of the particle.
  89165. */
  89166. velocity: Vector3;
  89167. /**
  89168. * The pivot point in the particle local space.
  89169. */
  89170. pivot: Vector3;
  89171. /**
  89172. * Must the particle be translated from its pivot point in its local space ?
  89173. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  89174. * Default : false
  89175. */
  89176. translateFromPivot: boolean;
  89177. /**
  89178. * Is the particle active or not ?
  89179. */
  89180. alive: boolean;
  89181. /**
  89182. * Is the particle visible or not ?
  89183. */
  89184. isVisible: boolean;
  89185. /**
  89186. * Index of this particle in the global "positions" array (Internal use)
  89187. * @hidden
  89188. */
  89189. _pos: number;
  89190. /**
  89191. * @hidden Index of this particle in the global "indices" array (Internal use)
  89192. */
  89193. _ind: number;
  89194. /**
  89195. * @hidden ModelShape of this particle (Internal use)
  89196. */
  89197. _model: ModelShape;
  89198. /**
  89199. * ModelShape id of this particle
  89200. */
  89201. shapeId: number;
  89202. /**
  89203. * Index of the particle in its shape id (Internal use)
  89204. */
  89205. idxInShape: number;
  89206. /**
  89207. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  89208. */
  89209. _modelBoundingInfo: BoundingInfo;
  89210. /**
  89211. * @hidden Particle BoundingInfo object (Internal use)
  89212. */
  89213. _boundingInfo: BoundingInfo;
  89214. /**
  89215. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  89216. */
  89217. _sps: SolidParticleSystem;
  89218. /**
  89219. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  89220. */
  89221. _stillInvisible: boolean;
  89222. /**
  89223. * @hidden Last computed particle rotation matrix
  89224. */
  89225. _rotationMatrix: number[];
  89226. /**
  89227. * Parent particle Id, if any.
  89228. * Default null.
  89229. */
  89230. parentId: Nullable<number>;
  89231. /**
  89232. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  89233. * The possible values are :
  89234. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  89235. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  89236. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  89237. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  89238. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  89239. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  89240. * */
  89241. cullingStrategy: number;
  89242. /**
  89243. * @hidden Internal global position in the SPS.
  89244. */
  89245. _globalPosition: Vector3;
  89246. /**
  89247. * Creates a Solid Particle object.
  89248. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  89249. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  89250. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  89251. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  89252. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  89253. * @param shapeId (integer) is the model shape identifier in the SPS.
  89254. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  89255. * @param sps defines the sps it is associated to
  89256. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  89257. */
  89258. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  89259. /**
  89260. * Legacy support, changed scale to scaling
  89261. */
  89262. /**
  89263. * Legacy support, changed scale to scaling
  89264. */
  89265. scale: Vector3;
  89266. /**
  89267. * Legacy support, changed quaternion to rotationQuaternion
  89268. */
  89269. /**
  89270. * Legacy support, changed quaternion to rotationQuaternion
  89271. */
  89272. quaternion: Nullable<Quaternion>;
  89273. /**
  89274. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  89275. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  89276. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  89277. * @returns true if it intersects
  89278. */
  89279. intersectsMesh(target: Mesh | SolidParticle): boolean;
  89280. /**
  89281. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  89282. * A particle is in the frustum if its bounding box intersects the frustum
  89283. * @param frustumPlanes defines the frustum to test
  89284. * @returns true if the particle is in the frustum planes
  89285. */
  89286. isInFrustum(frustumPlanes: Plane[]): boolean;
  89287. /**
  89288. * get the rotation matrix of the particle
  89289. * @hidden
  89290. */
  89291. getRotationMatrix(m: Matrix): void;
  89292. }
  89293. /**
  89294. * Represents the shape of the model used by one particle of a solid particle system.
  89295. * SPS internal tool, don't use it manually.
  89296. */
  89297. export class ModelShape {
  89298. /**
  89299. * The shape id
  89300. * @hidden
  89301. */
  89302. shapeID: number;
  89303. /**
  89304. * flat array of model positions (internal use)
  89305. * @hidden
  89306. */
  89307. _shape: Vector3[];
  89308. /**
  89309. * flat array of model UVs (internal use)
  89310. * @hidden
  89311. */
  89312. _shapeUV: number[];
  89313. /**
  89314. * length of the shape in the model indices array (internal use)
  89315. * @hidden
  89316. */
  89317. _indicesLength: number;
  89318. /**
  89319. * Custom position function (internal use)
  89320. * @hidden
  89321. */
  89322. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  89323. /**
  89324. * Custom vertex function (internal use)
  89325. * @hidden
  89326. */
  89327. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  89328. /**
  89329. * 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.
  89330. * SPS internal tool, don't use it manually.
  89331. * @hidden
  89332. */
  89333. 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>);
  89334. }
  89335. /**
  89336. * Represents a Depth Sorted Particle in the solid particle system.
  89337. */
  89338. export class DepthSortedParticle {
  89339. /**
  89340. * Index of the particle in the "indices" array
  89341. */
  89342. ind: number;
  89343. /**
  89344. * Length of the particle shape in the "indices" array
  89345. */
  89346. indicesLength: number;
  89347. /**
  89348. * Squared distance from the particle to the camera
  89349. */
  89350. sqDistance: number;
  89351. }
  89352. }
  89353. declare module BABYLON {
  89354. /**
  89355. * @hidden
  89356. */
  89357. export class _MeshCollisionData {
  89358. _checkCollisions: boolean;
  89359. _collisionMask: number;
  89360. _collisionGroup: number;
  89361. _collider: Nullable<Collider>;
  89362. _oldPositionForCollisions: Vector3;
  89363. _diffPositionForCollisions: Vector3;
  89364. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  89365. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  89366. }
  89367. }
  89368. declare module BABYLON {
  89369. /** @hidden */
  89370. class _FacetDataStorage {
  89371. facetPositions: Vector3[];
  89372. facetNormals: Vector3[];
  89373. facetPartitioning: number[][];
  89374. facetNb: number;
  89375. partitioningSubdivisions: number;
  89376. partitioningBBoxRatio: number;
  89377. facetDataEnabled: boolean;
  89378. facetParameters: any;
  89379. bbSize: Vector3;
  89380. subDiv: {
  89381. max: number;
  89382. X: number;
  89383. Y: number;
  89384. Z: number;
  89385. };
  89386. facetDepthSort: boolean;
  89387. facetDepthSortEnabled: boolean;
  89388. depthSortedIndices: IndicesArray;
  89389. depthSortedFacets: {
  89390. ind: number;
  89391. sqDistance: number;
  89392. }[];
  89393. facetDepthSortFunction: (f1: {
  89394. ind: number;
  89395. sqDistance: number;
  89396. }, f2: {
  89397. ind: number;
  89398. sqDistance: number;
  89399. }) => number;
  89400. facetDepthSortFrom: Vector3;
  89401. facetDepthSortOrigin: Vector3;
  89402. invertedMatrix: Matrix;
  89403. }
  89404. /**
  89405. * @hidden
  89406. **/
  89407. class _InternalAbstractMeshDataInfo {
  89408. _hasVertexAlpha: boolean;
  89409. _useVertexColors: boolean;
  89410. _numBoneInfluencers: number;
  89411. _applyFog: boolean;
  89412. _receiveShadows: boolean;
  89413. _facetData: _FacetDataStorage;
  89414. _visibility: number;
  89415. _skeleton: Nullable<Skeleton>;
  89416. _layerMask: number;
  89417. _computeBonesUsingShaders: boolean;
  89418. _isActive: boolean;
  89419. _onlyForInstances: boolean;
  89420. _isActiveIntermediate: boolean;
  89421. _onlyForInstancesIntermediate: boolean;
  89422. }
  89423. /**
  89424. * Class used to store all common mesh properties
  89425. */
  89426. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  89427. /** No occlusion */
  89428. static OCCLUSION_TYPE_NONE: number;
  89429. /** Occlusion set to optimisitic */
  89430. static OCCLUSION_TYPE_OPTIMISTIC: number;
  89431. /** Occlusion set to strict */
  89432. static OCCLUSION_TYPE_STRICT: number;
  89433. /** Use an accurante occlusion algorithm */
  89434. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  89435. /** Use a conservative occlusion algorithm */
  89436. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  89437. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  89438. * Test order :
  89439. * Is the bounding sphere outside the frustum ?
  89440. * If not, are the bounding box vertices outside the frustum ?
  89441. * It not, then the cullable object is in the frustum.
  89442. */
  89443. static readonly CULLINGSTRATEGY_STANDARD: number;
  89444. /** Culling strategy : Bounding Sphere Only.
  89445. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  89446. * It's also less accurate than the standard because some not visible objects can still be selected.
  89447. * Test : is the bounding sphere outside the frustum ?
  89448. * If not, then the cullable object is in the frustum.
  89449. */
  89450. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  89451. /** Culling strategy : Optimistic Inclusion.
  89452. * This in an inclusion test first, then the standard exclusion test.
  89453. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  89454. * 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.
  89455. * Anyway, it's as accurate as the standard strategy.
  89456. * Test :
  89457. * Is the cullable object bounding sphere center in the frustum ?
  89458. * If not, apply the default culling strategy.
  89459. */
  89460. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  89461. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  89462. * This in an inclusion test first, then the bounding sphere only exclusion test.
  89463. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  89464. * 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.
  89465. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  89466. * Test :
  89467. * Is the cullable object bounding sphere center in the frustum ?
  89468. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  89469. */
  89470. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  89471. /**
  89472. * No billboard
  89473. */
  89474. static readonly BILLBOARDMODE_NONE: number;
  89475. /** Billboard on X axis */
  89476. static readonly BILLBOARDMODE_X: number;
  89477. /** Billboard on Y axis */
  89478. static readonly BILLBOARDMODE_Y: number;
  89479. /** Billboard on Z axis */
  89480. static readonly BILLBOARDMODE_Z: number;
  89481. /** Billboard on all axes */
  89482. static readonly BILLBOARDMODE_ALL: number;
  89483. /** @hidden */
  89484. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  89485. /**
  89486. * The culling strategy to use to check whether the mesh must be rendered or not.
  89487. * This value can be changed at any time and will be used on the next render mesh selection.
  89488. * The possible values are :
  89489. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  89490. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  89491. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  89492. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  89493. * Please read each static variable documentation to get details about the culling process.
  89494. * */
  89495. cullingStrategy: number;
  89496. /**
  89497. * Gets the number of facets in the mesh
  89498. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  89499. */
  89500. readonly facetNb: number;
  89501. /**
  89502. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  89503. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  89504. */
  89505. partitioningSubdivisions: number;
  89506. /**
  89507. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  89508. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  89509. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  89510. */
  89511. partitioningBBoxRatio: number;
  89512. /**
  89513. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  89514. * Works only for updatable meshes.
  89515. * Doesn't work with multi-materials
  89516. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  89517. */
  89518. mustDepthSortFacets: boolean;
  89519. /**
  89520. * The location (Vector3) where the facet depth sort must be computed from.
  89521. * By default, the active camera position.
  89522. * Used only when facet depth sort is enabled
  89523. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  89524. */
  89525. facetDepthSortFrom: Vector3;
  89526. /**
  89527. * gets a boolean indicating if facetData is enabled
  89528. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  89529. */
  89530. readonly isFacetDataEnabled: boolean;
  89531. /** @hidden */
  89532. _updateNonUniformScalingState(value: boolean): boolean;
  89533. /**
  89534. * An event triggered when this mesh collides with another one
  89535. */
  89536. onCollideObservable: Observable<AbstractMesh>;
  89537. /** Set a function to call when this mesh collides with another one */
  89538. onCollide: () => void;
  89539. /**
  89540. * An event triggered when the collision's position changes
  89541. */
  89542. onCollisionPositionChangeObservable: Observable<Vector3>;
  89543. /** Set a function to call when the collision's position changes */
  89544. onCollisionPositionChange: () => void;
  89545. /**
  89546. * An event triggered when material is changed
  89547. */
  89548. onMaterialChangedObservable: Observable<AbstractMesh>;
  89549. /**
  89550. * Gets or sets the orientation for POV movement & rotation
  89551. */
  89552. definedFacingForward: boolean;
  89553. /** @hidden */
  89554. _occlusionQuery: Nullable<WebGLQuery>;
  89555. /** @hidden */
  89556. _renderingGroup: Nullable<RenderingGroup>;
  89557. /**
  89558. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  89559. */
  89560. /**
  89561. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  89562. */
  89563. visibility: number;
  89564. /** Gets or sets the alpha index used to sort transparent meshes
  89565. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  89566. */
  89567. alphaIndex: number;
  89568. /**
  89569. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  89570. */
  89571. isVisible: boolean;
  89572. /**
  89573. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  89574. */
  89575. isPickable: boolean;
  89576. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  89577. showSubMeshesBoundingBox: boolean;
  89578. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  89579. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  89580. */
  89581. isBlocker: boolean;
  89582. /**
  89583. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  89584. */
  89585. enablePointerMoveEvents: boolean;
  89586. /**
  89587. * Specifies the rendering group id for this mesh (0 by default)
  89588. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  89589. */
  89590. renderingGroupId: number;
  89591. private _material;
  89592. /** Gets or sets current material */
  89593. material: Nullable<Material>;
  89594. /**
  89595. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  89596. * @see http://doc.babylonjs.com/babylon101/shadows
  89597. */
  89598. receiveShadows: boolean;
  89599. /** Defines color to use when rendering outline */
  89600. outlineColor: Color3;
  89601. /** Define width to use when rendering outline */
  89602. outlineWidth: number;
  89603. /** Defines color to use when rendering overlay */
  89604. overlayColor: Color3;
  89605. /** Defines alpha to use when rendering overlay */
  89606. overlayAlpha: number;
  89607. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  89608. hasVertexAlpha: boolean;
  89609. /** 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) */
  89610. useVertexColors: boolean;
  89611. /**
  89612. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  89613. */
  89614. computeBonesUsingShaders: boolean;
  89615. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  89616. numBoneInfluencers: number;
  89617. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  89618. applyFog: boolean;
  89619. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  89620. useOctreeForRenderingSelection: boolean;
  89621. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  89622. useOctreeForPicking: boolean;
  89623. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  89624. useOctreeForCollisions: boolean;
  89625. /**
  89626. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  89627. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  89628. */
  89629. layerMask: number;
  89630. /**
  89631. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  89632. */
  89633. alwaysSelectAsActiveMesh: boolean;
  89634. /**
  89635. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  89636. */
  89637. doNotSyncBoundingInfo: boolean;
  89638. /**
  89639. * Gets or sets the current action manager
  89640. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  89641. */
  89642. actionManager: Nullable<AbstractActionManager>;
  89643. private _meshCollisionData;
  89644. /**
  89645. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  89646. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89647. */
  89648. ellipsoid: Vector3;
  89649. /**
  89650. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  89651. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89652. */
  89653. ellipsoidOffset: Vector3;
  89654. /**
  89655. * Gets or sets a collision mask used to mask collisions (default is -1).
  89656. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  89657. */
  89658. collisionMask: number;
  89659. /**
  89660. * Gets or sets the current collision group mask (-1 by default).
  89661. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  89662. */
  89663. collisionGroup: number;
  89664. /**
  89665. * Defines edge width used when edgesRenderer is enabled
  89666. * @see https://www.babylonjs-playground.com/#10OJSG#13
  89667. */
  89668. edgesWidth: number;
  89669. /**
  89670. * Defines edge color used when edgesRenderer is enabled
  89671. * @see https://www.babylonjs-playground.com/#10OJSG#13
  89672. */
  89673. edgesColor: Color4;
  89674. /** @hidden */
  89675. _edgesRenderer: Nullable<IEdgesRenderer>;
  89676. /** @hidden */
  89677. _masterMesh: Nullable<AbstractMesh>;
  89678. /** @hidden */
  89679. _boundingInfo: Nullable<BoundingInfo>;
  89680. /** @hidden */
  89681. _renderId: number;
  89682. /**
  89683. * Gets or sets the list of subMeshes
  89684. * @see http://doc.babylonjs.com/how_to/multi_materials
  89685. */
  89686. subMeshes: SubMesh[];
  89687. /** @hidden */
  89688. _intersectionsInProgress: AbstractMesh[];
  89689. /** @hidden */
  89690. _unIndexed: boolean;
  89691. /** @hidden */
  89692. _lightSources: Light[];
  89693. /** Gets the list of lights affecting that mesh */
  89694. readonly lightSources: Light[];
  89695. /** @hidden */
  89696. readonly _positions: Nullable<Vector3[]>;
  89697. /** @hidden */
  89698. _waitingData: {
  89699. lods: Nullable<any>;
  89700. actions: Nullable<any>;
  89701. freezeWorldMatrix: Nullable<boolean>;
  89702. };
  89703. /** @hidden */
  89704. _bonesTransformMatrices: Nullable<Float32Array>;
  89705. /** @hidden */
  89706. _transformMatrixTexture: Nullable<RawTexture>;
  89707. /**
  89708. * Gets or sets a skeleton to apply skining transformations
  89709. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  89710. */
  89711. skeleton: Nullable<Skeleton>;
  89712. /**
  89713. * An event triggered when the mesh is rebuilt.
  89714. */
  89715. onRebuildObservable: Observable<AbstractMesh>;
  89716. /**
  89717. * Creates a new AbstractMesh
  89718. * @param name defines the name of the mesh
  89719. * @param scene defines the hosting scene
  89720. */
  89721. constructor(name: string, scene?: Nullable<Scene>);
  89722. /**
  89723. * Returns the string "AbstractMesh"
  89724. * @returns "AbstractMesh"
  89725. */
  89726. getClassName(): string;
  89727. /**
  89728. * Gets a string representation of the current mesh
  89729. * @param fullDetails defines a boolean indicating if full details must be included
  89730. * @returns a string representation of the current mesh
  89731. */
  89732. toString(fullDetails?: boolean): string;
  89733. /**
  89734. * @hidden
  89735. */
  89736. protected _getEffectiveParent(): Nullable<Node>;
  89737. /** @hidden */
  89738. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  89739. /** @hidden */
  89740. _rebuild(): void;
  89741. /** @hidden */
  89742. _resyncLightSources(): void;
  89743. /** @hidden */
  89744. _resyncLighSource(light: Light): void;
  89745. /** @hidden */
  89746. _unBindEffect(): void;
  89747. /** @hidden */
  89748. _removeLightSource(light: Light): void;
  89749. private _markSubMeshesAsDirty;
  89750. /** @hidden */
  89751. _markSubMeshesAsLightDirty(): void;
  89752. /** @hidden */
  89753. _markSubMeshesAsAttributesDirty(): void;
  89754. /** @hidden */
  89755. _markSubMeshesAsMiscDirty(): void;
  89756. /**
  89757. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  89758. */
  89759. scaling: Vector3;
  89760. /**
  89761. * Returns true if the mesh is blocked. Implemented by child classes
  89762. */
  89763. readonly isBlocked: boolean;
  89764. /**
  89765. * Returns the mesh itself by default. Implemented by child classes
  89766. * @param camera defines the camera to use to pick the right LOD level
  89767. * @returns the currentAbstractMesh
  89768. */
  89769. getLOD(camera: Camera): Nullable<AbstractMesh>;
  89770. /**
  89771. * Returns 0 by default. Implemented by child classes
  89772. * @returns an integer
  89773. */
  89774. getTotalVertices(): number;
  89775. /**
  89776. * Returns a positive integer : the total number of indices in this mesh geometry.
  89777. * @returns the numner of indices or zero if the mesh has no geometry.
  89778. */
  89779. getTotalIndices(): number;
  89780. /**
  89781. * Returns null by default. Implemented by child classes
  89782. * @returns null
  89783. */
  89784. getIndices(): Nullable<IndicesArray>;
  89785. /**
  89786. * Returns the array of the requested vertex data kind. Implemented by child classes
  89787. * @param kind defines the vertex data kind to use
  89788. * @returns null
  89789. */
  89790. getVerticesData(kind: string): Nullable<FloatArray>;
  89791. /**
  89792. * Sets the vertex data of the mesh geometry for the requested `kind`.
  89793. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  89794. * Note that a new underlying VertexBuffer object is created each call.
  89795. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  89796. * @param kind defines vertex data kind:
  89797. * * VertexBuffer.PositionKind
  89798. * * VertexBuffer.UVKind
  89799. * * VertexBuffer.UV2Kind
  89800. * * VertexBuffer.UV3Kind
  89801. * * VertexBuffer.UV4Kind
  89802. * * VertexBuffer.UV5Kind
  89803. * * VertexBuffer.UV6Kind
  89804. * * VertexBuffer.ColorKind
  89805. * * VertexBuffer.MatricesIndicesKind
  89806. * * VertexBuffer.MatricesIndicesExtraKind
  89807. * * VertexBuffer.MatricesWeightsKind
  89808. * * VertexBuffer.MatricesWeightsExtraKind
  89809. * @param data defines the data source
  89810. * @param updatable defines if the data must be flagged as updatable (or static)
  89811. * @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
  89812. * @returns the current mesh
  89813. */
  89814. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89815. /**
  89816. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  89817. * If the mesh has no geometry, it is simply returned as it is.
  89818. * @param kind defines vertex data kind:
  89819. * * VertexBuffer.PositionKind
  89820. * * VertexBuffer.UVKind
  89821. * * VertexBuffer.UV2Kind
  89822. * * VertexBuffer.UV3Kind
  89823. * * VertexBuffer.UV4Kind
  89824. * * VertexBuffer.UV5Kind
  89825. * * VertexBuffer.UV6Kind
  89826. * * VertexBuffer.ColorKind
  89827. * * VertexBuffer.MatricesIndicesKind
  89828. * * VertexBuffer.MatricesIndicesExtraKind
  89829. * * VertexBuffer.MatricesWeightsKind
  89830. * * VertexBuffer.MatricesWeightsExtraKind
  89831. * @param data defines the data source
  89832. * @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
  89833. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  89834. * @returns the current mesh
  89835. */
  89836. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  89837. /**
  89838. * Sets the mesh indices,
  89839. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  89840. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  89841. * @param totalVertices Defines the total number of vertices
  89842. * @returns the current mesh
  89843. */
  89844. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  89845. /**
  89846. * Gets a boolean indicating if specific vertex data is present
  89847. * @param kind defines the vertex data kind to use
  89848. * @returns true is data kind is present
  89849. */
  89850. isVerticesDataPresent(kind: string): boolean;
  89851. /**
  89852. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  89853. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  89854. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  89855. * @returns a BoundingInfo
  89856. */
  89857. getBoundingInfo(): BoundingInfo;
  89858. /**
  89859. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  89860. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  89861. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  89862. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  89863. * @returns the current mesh
  89864. */
  89865. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  89866. /**
  89867. * Overwrite the current bounding info
  89868. * @param boundingInfo defines the new bounding info
  89869. * @returns the current mesh
  89870. */
  89871. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  89872. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  89873. readonly useBones: boolean;
  89874. /** @hidden */
  89875. _preActivate(): void;
  89876. /** @hidden */
  89877. _preActivateForIntermediateRendering(renderId: number): void;
  89878. /** @hidden */
  89879. _activate(renderId: number, intermediateRendering: boolean): boolean;
  89880. /** @hidden */
  89881. _postActivate(): void;
  89882. /** @hidden */
  89883. _freeze(): void;
  89884. /** @hidden */
  89885. _unFreeze(): void;
  89886. /**
  89887. * Gets the current world matrix
  89888. * @returns a Matrix
  89889. */
  89890. getWorldMatrix(): Matrix;
  89891. /** @hidden */
  89892. _getWorldMatrixDeterminant(): number;
  89893. /**
  89894. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  89895. */
  89896. readonly isAnInstance: boolean;
  89897. /**
  89898. * Perform relative position change from the point of view of behind the front of the mesh.
  89899. * This is performed taking into account the meshes current rotation, so you do not have to care.
  89900. * Supports definition of mesh facing forward or backward
  89901. * @param amountRight defines the distance on the right axis
  89902. * @param amountUp defines the distance on the up axis
  89903. * @param amountForward defines the distance on the forward axis
  89904. * @returns the current mesh
  89905. */
  89906. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  89907. /**
  89908. * Calculate relative position change from the point of view of behind the front of the mesh.
  89909. * This is performed taking into account the meshes current rotation, so you do not have to care.
  89910. * Supports definition of mesh facing forward or backward
  89911. * @param amountRight defines the distance on the right axis
  89912. * @param amountUp defines the distance on the up axis
  89913. * @param amountForward defines the distance on the forward axis
  89914. * @returns the new displacement vector
  89915. */
  89916. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  89917. /**
  89918. * Perform relative rotation change from the point of view of behind the front of the mesh.
  89919. * Supports definition of mesh facing forward or backward
  89920. * @param flipBack defines the flip
  89921. * @param twirlClockwise defines the twirl
  89922. * @param tiltRight defines the tilt
  89923. * @returns the current mesh
  89924. */
  89925. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  89926. /**
  89927. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  89928. * Supports definition of mesh facing forward or backward.
  89929. * @param flipBack defines the flip
  89930. * @param twirlClockwise defines the twirl
  89931. * @param tiltRight defines the tilt
  89932. * @returns the new rotation vector
  89933. */
  89934. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  89935. /**
  89936. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89937. * This means the mesh underlying bounding box and sphere are recomputed.
  89938. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89939. * @returns the current mesh
  89940. */
  89941. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  89942. /** @hidden */
  89943. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  89944. /** @hidden */
  89945. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  89946. /** @hidden */
  89947. _updateBoundingInfo(): AbstractMesh;
  89948. /** @hidden */
  89949. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  89950. /** @hidden */
  89951. protected _afterComputeWorldMatrix(): void;
  89952. /** @hidden */
  89953. readonly _effectiveMesh: AbstractMesh;
  89954. /**
  89955. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  89956. * A mesh is in the frustum if its bounding box intersects the frustum
  89957. * @param frustumPlanes defines the frustum to test
  89958. * @returns true if the mesh is in the frustum planes
  89959. */
  89960. isInFrustum(frustumPlanes: Plane[]): boolean;
  89961. /**
  89962. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  89963. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  89964. * @param frustumPlanes defines the frustum to test
  89965. * @returns true if the mesh is completely in the frustum planes
  89966. */
  89967. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  89968. /**
  89969. * True if the mesh intersects another mesh or a SolidParticle object
  89970. * @param mesh defines a target mesh or SolidParticle to test
  89971. * @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)
  89972. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  89973. * @returns true if there is an intersection
  89974. */
  89975. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  89976. /**
  89977. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  89978. * @param point defines the point to test
  89979. * @returns true if there is an intersection
  89980. */
  89981. intersectsPoint(point: Vector3): boolean;
  89982. /**
  89983. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  89984. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89985. */
  89986. checkCollisions: boolean;
  89987. /**
  89988. * Gets Collider object used to compute collisions (not physics)
  89989. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89990. */
  89991. readonly collider: Nullable<Collider>;
  89992. /**
  89993. * Move the mesh using collision engine
  89994. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89995. * @param displacement defines the requested displacement vector
  89996. * @returns the current mesh
  89997. */
  89998. moveWithCollisions(displacement: Vector3): AbstractMesh;
  89999. private _onCollisionPositionChange;
  90000. /** @hidden */
  90001. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  90002. /** @hidden */
  90003. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  90004. /** @hidden */
  90005. _checkCollision(collider: Collider): AbstractMesh;
  90006. /** @hidden */
  90007. _generatePointsArray(): boolean;
  90008. /**
  90009. * Checks if the passed Ray intersects with the mesh
  90010. * @param ray defines the ray to use
  90011. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  90012. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  90013. * @returns the picking info
  90014. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  90015. */
  90016. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  90017. /**
  90018. * Clones the current mesh
  90019. * @param name defines the mesh name
  90020. * @param newParent defines the new mesh parent
  90021. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  90022. * @returns the new mesh
  90023. */
  90024. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  90025. /**
  90026. * Disposes all the submeshes of the current meshnp
  90027. * @returns the current mesh
  90028. */
  90029. releaseSubMeshes(): AbstractMesh;
  90030. /**
  90031. * Releases resources associated with this abstract mesh.
  90032. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90033. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90034. */
  90035. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90036. /**
  90037. * Adds the passed mesh as a child to the current mesh
  90038. * @param mesh defines the child mesh
  90039. * @returns the current mesh
  90040. */
  90041. addChild(mesh: AbstractMesh): AbstractMesh;
  90042. /**
  90043. * Removes the passed mesh from the current mesh children list
  90044. * @param mesh defines the child mesh
  90045. * @returns the current mesh
  90046. */
  90047. removeChild(mesh: AbstractMesh): AbstractMesh;
  90048. /** @hidden */
  90049. private _initFacetData;
  90050. /**
  90051. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  90052. * This method can be called within the render loop.
  90053. * 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
  90054. * @returns the current mesh
  90055. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90056. */
  90057. updateFacetData(): AbstractMesh;
  90058. /**
  90059. * Returns the facetLocalNormals array.
  90060. * The normals are expressed in the mesh local spac
  90061. * @returns an array of Vector3
  90062. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90063. */
  90064. getFacetLocalNormals(): Vector3[];
  90065. /**
  90066. * Returns the facetLocalPositions array.
  90067. * The facet positions are expressed in the mesh local space
  90068. * @returns an array of Vector3
  90069. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90070. */
  90071. getFacetLocalPositions(): Vector3[];
  90072. /**
  90073. * Returns the facetLocalPartioning array
  90074. * @returns an array of array of numbers
  90075. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90076. */
  90077. getFacetLocalPartitioning(): number[][];
  90078. /**
  90079. * Returns the i-th facet position in the world system.
  90080. * This method allocates a new Vector3 per call
  90081. * @param i defines the facet index
  90082. * @returns a new Vector3
  90083. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90084. */
  90085. getFacetPosition(i: number): Vector3;
  90086. /**
  90087. * Sets the reference Vector3 with the i-th facet position in the world system
  90088. * @param i defines the facet index
  90089. * @param ref defines the target vector
  90090. * @returns the current mesh
  90091. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90092. */
  90093. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  90094. /**
  90095. * Returns the i-th facet normal in the world system.
  90096. * This method allocates a new Vector3 per call
  90097. * @param i defines the facet index
  90098. * @returns a new Vector3
  90099. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90100. */
  90101. getFacetNormal(i: number): Vector3;
  90102. /**
  90103. * Sets the reference Vector3 with the i-th facet normal in the world system
  90104. * @param i defines the facet index
  90105. * @param ref defines the target vector
  90106. * @returns the current mesh
  90107. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90108. */
  90109. getFacetNormalToRef(i: number, ref: Vector3): this;
  90110. /**
  90111. * 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)
  90112. * @param x defines x coordinate
  90113. * @param y defines y coordinate
  90114. * @param z defines z coordinate
  90115. * @returns the array of facet indexes
  90116. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90117. */
  90118. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  90119. /**
  90120. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  90121. * @param projected sets as the (x,y,z) world projection on the facet
  90122. * @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
  90123. * @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
  90124. * @param x defines x coordinate
  90125. * @param y defines y coordinate
  90126. * @param z defines z coordinate
  90127. * @returns the face index if found (or null instead)
  90128. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90129. */
  90130. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  90131. /**
  90132. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  90133. * @param projected sets as the (x,y,z) local projection on the facet
  90134. * @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
  90135. * @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
  90136. * @param x defines x coordinate
  90137. * @param y defines y coordinate
  90138. * @param z defines z coordinate
  90139. * @returns the face index if found (or null instead)
  90140. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90141. */
  90142. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  90143. /**
  90144. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  90145. * @returns the parameters
  90146. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90147. */
  90148. getFacetDataParameters(): any;
  90149. /**
  90150. * Disables the feature FacetData and frees the related memory
  90151. * @returns the current mesh
  90152. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90153. */
  90154. disableFacetData(): AbstractMesh;
  90155. /**
  90156. * Updates the AbstractMesh indices array
  90157. * @param indices defines the data source
  90158. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  90159. * @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)
  90160. * @returns the current mesh
  90161. */
  90162. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  90163. /**
  90164. * Creates new normals data for the mesh
  90165. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  90166. * @returns the current mesh
  90167. */
  90168. createNormals(updatable: boolean): AbstractMesh;
  90169. /**
  90170. * Align the mesh with a normal
  90171. * @param normal defines the normal to use
  90172. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  90173. * @returns the current mesh
  90174. */
  90175. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  90176. /** @hidden */
  90177. _checkOcclusionQuery(): boolean;
  90178. /**
  90179. * Disables the mesh edge rendering mode
  90180. * @returns the currentAbstractMesh
  90181. */
  90182. disableEdgesRendering(): AbstractMesh;
  90183. /**
  90184. * Enables the edge rendering mode on the mesh.
  90185. * This mode makes the mesh edges visible
  90186. * @param epsilon defines the maximal distance between two angles to detect a face
  90187. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90188. * @returns the currentAbstractMesh
  90189. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90190. */
  90191. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  90192. }
  90193. }
  90194. declare module BABYLON {
  90195. /**
  90196. * Interface used to define ActionEvent
  90197. */
  90198. export interface IActionEvent {
  90199. /** The mesh or sprite that triggered the action */
  90200. source: any;
  90201. /** The X mouse cursor position at the time of the event */
  90202. pointerX: number;
  90203. /** The Y mouse cursor position at the time of the event */
  90204. pointerY: number;
  90205. /** The mesh that is currently pointed at (can be null) */
  90206. meshUnderPointer: Nullable<AbstractMesh>;
  90207. /** the original (browser) event that triggered the ActionEvent */
  90208. sourceEvent?: any;
  90209. /** additional data for the event */
  90210. additionalData?: any;
  90211. }
  90212. /**
  90213. * ActionEvent is the event being sent when an action is triggered.
  90214. */
  90215. export class ActionEvent implements IActionEvent {
  90216. /** The mesh or sprite that triggered the action */
  90217. source: any;
  90218. /** The X mouse cursor position at the time of the event */
  90219. pointerX: number;
  90220. /** The Y mouse cursor position at the time of the event */
  90221. pointerY: number;
  90222. /** The mesh that is currently pointed at (can be null) */
  90223. meshUnderPointer: Nullable<AbstractMesh>;
  90224. /** the original (browser) event that triggered the ActionEvent */
  90225. sourceEvent?: any;
  90226. /** additional data for the event */
  90227. additionalData?: any;
  90228. /**
  90229. * Creates a new ActionEvent
  90230. * @param source The mesh or sprite that triggered the action
  90231. * @param pointerX The X mouse cursor position at the time of the event
  90232. * @param pointerY The Y mouse cursor position at the time of the event
  90233. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  90234. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  90235. * @param additionalData additional data for the event
  90236. */
  90237. constructor(
  90238. /** The mesh or sprite that triggered the action */
  90239. source: any,
  90240. /** The X mouse cursor position at the time of the event */
  90241. pointerX: number,
  90242. /** The Y mouse cursor position at the time of the event */
  90243. pointerY: number,
  90244. /** The mesh that is currently pointed at (can be null) */
  90245. meshUnderPointer: Nullable<AbstractMesh>,
  90246. /** the original (browser) event that triggered the ActionEvent */
  90247. sourceEvent?: any,
  90248. /** additional data for the event */
  90249. additionalData?: any);
  90250. /**
  90251. * Helper function to auto-create an ActionEvent from a source mesh.
  90252. * @param source The source mesh that triggered the event
  90253. * @param evt The original (browser) event
  90254. * @param additionalData additional data for the event
  90255. * @returns the new ActionEvent
  90256. */
  90257. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  90258. /**
  90259. * Helper function to auto-create an ActionEvent from a source sprite
  90260. * @param source The source sprite that triggered the event
  90261. * @param scene Scene associated with the sprite
  90262. * @param evt The original (browser) event
  90263. * @param additionalData additional data for the event
  90264. * @returns the new ActionEvent
  90265. */
  90266. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  90267. /**
  90268. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  90269. * @param scene the scene where the event occurred
  90270. * @param evt The original (browser) event
  90271. * @returns the new ActionEvent
  90272. */
  90273. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  90274. /**
  90275. * Helper function to auto-create an ActionEvent from a primitive
  90276. * @param prim defines the target primitive
  90277. * @param pointerPos defines the pointer position
  90278. * @param evt The original (browser) event
  90279. * @param additionalData additional data for the event
  90280. * @returns the new ActionEvent
  90281. */
  90282. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  90283. }
  90284. }
  90285. declare module BABYLON {
  90286. /**
  90287. * Abstract class used to decouple action Manager from scene and meshes.
  90288. * Do not instantiate.
  90289. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90290. */
  90291. export abstract class AbstractActionManager implements IDisposable {
  90292. /** Gets the list of active triggers */
  90293. static Triggers: {
  90294. [key: string]: number;
  90295. };
  90296. /** Gets the cursor to use when hovering items */
  90297. hoverCursor: string;
  90298. /** Gets the list of actions */
  90299. actions: IAction[];
  90300. /**
  90301. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  90302. */
  90303. isRecursive: boolean;
  90304. /**
  90305. * Releases all associated resources
  90306. */
  90307. abstract dispose(): void;
  90308. /**
  90309. * Does this action manager has pointer triggers
  90310. */
  90311. abstract readonly hasPointerTriggers: boolean;
  90312. /**
  90313. * Does this action manager has pick triggers
  90314. */
  90315. abstract readonly hasPickTriggers: boolean;
  90316. /**
  90317. * Process a specific trigger
  90318. * @param trigger defines the trigger to process
  90319. * @param evt defines the event details to be processed
  90320. */
  90321. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  90322. /**
  90323. * Does this action manager handles actions of any of the given triggers
  90324. * @param triggers defines the triggers to be tested
  90325. * @return a boolean indicating whether one (or more) of the triggers is handled
  90326. */
  90327. abstract hasSpecificTriggers(triggers: number[]): boolean;
  90328. /**
  90329. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  90330. * speed.
  90331. * @param triggerA defines the trigger to be tested
  90332. * @param triggerB defines the trigger to be tested
  90333. * @return a boolean indicating whether one (or more) of the triggers is handled
  90334. */
  90335. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  90336. /**
  90337. * Does this action manager handles actions of a given trigger
  90338. * @param trigger defines the trigger to be tested
  90339. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  90340. * @return whether the trigger is handled
  90341. */
  90342. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  90343. /**
  90344. * Serialize this manager to a JSON object
  90345. * @param name defines the property name to store this manager
  90346. * @returns a JSON representation of this manager
  90347. */
  90348. abstract serialize(name: string): any;
  90349. /**
  90350. * Registers an action to this action manager
  90351. * @param action defines the action to be registered
  90352. * @return the action amended (prepared) after registration
  90353. */
  90354. abstract registerAction(action: IAction): Nullable<IAction>;
  90355. /**
  90356. * Unregisters an action to this action manager
  90357. * @param action defines the action to be unregistered
  90358. * @return a boolean indicating whether the action has been unregistered
  90359. */
  90360. abstract unregisterAction(action: IAction): Boolean;
  90361. /**
  90362. * Does exist one action manager with at least one trigger
  90363. **/
  90364. static readonly HasTriggers: boolean;
  90365. /**
  90366. * Does exist one action manager with at least one pick trigger
  90367. **/
  90368. static readonly HasPickTriggers: boolean;
  90369. /**
  90370. * Does exist one action manager that handles actions of a given trigger
  90371. * @param trigger defines the trigger to be tested
  90372. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  90373. **/
  90374. static HasSpecificTrigger(trigger: number): boolean;
  90375. }
  90376. }
  90377. declare module BABYLON {
  90378. /**
  90379. * Defines how a node can be built from a string name.
  90380. */
  90381. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  90382. /**
  90383. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  90384. */
  90385. export class Node implements IBehaviorAware<Node> {
  90386. /** @hidden */
  90387. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  90388. private static _NodeConstructors;
  90389. /**
  90390. * Add a new node constructor
  90391. * @param type defines the type name of the node to construct
  90392. * @param constructorFunc defines the constructor function
  90393. */
  90394. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  90395. /**
  90396. * Returns a node constructor based on type name
  90397. * @param type defines the type name
  90398. * @param name defines the new node name
  90399. * @param scene defines the hosting scene
  90400. * @param options defines optional options to transmit to constructors
  90401. * @returns the new constructor or null
  90402. */
  90403. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  90404. /**
  90405. * Gets or sets the name of the node
  90406. */
  90407. name: string;
  90408. /**
  90409. * Gets or sets the id of the node
  90410. */
  90411. id: string;
  90412. /**
  90413. * Gets or sets the unique id of the node
  90414. */
  90415. uniqueId: number;
  90416. /**
  90417. * Gets or sets a string used to store user defined state for the node
  90418. */
  90419. state: string;
  90420. /**
  90421. * Gets or sets an object used to store user defined information for the node
  90422. */
  90423. metadata: any;
  90424. /**
  90425. * For internal use only. Please do not use.
  90426. */
  90427. reservedDataStore: any;
  90428. /**
  90429. * List of inspectable custom properties (used by the Inspector)
  90430. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  90431. */
  90432. inspectableCustomProperties: IInspectable[];
  90433. /**
  90434. * Gets or sets a boolean used to define if the node must be serialized
  90435. */
  90436. doNotSerialize: boolean;
  90437. /** @hidden */
  90438. _isDisposed: boolean;
  90439. /**
  90440. * Gets a list of Animations associated with the node
  90441. */
  90442. animations: Animation[];
  90443. protected _ranges: {
  90444. [name: string]: Nullable<AnimationRange>;
  90445. };
  90446. /**
  90447. * Callback raised when the node is ready to be used
  90448. */
  90449. onReady: Nullable<(node: Node) => void>;
  90450. private _isEnabled;
  90451. private _isParentEnabled;
  90452. private _isReady;
  90453. /** @hidden */
  90454. _currentRenderId: number;
  90455. private _parentUpdateId;
  90456. /** @hidden */
  90457. _childUpdateId: number;
  90458. /** @hidden */
  90459. _waitingParentId: Nullable<string>;
  90460. /** @hidden */
  90461. _scene: Scene;
  90462. /** @hidden */
  90463. _cache: any;
  90464. private _parentNode;
  90465. private _children;
  90466. /** @hidden */
  90467. _worldMatrix: Matrix;
  90468. /** @hidden */
  90469. _worldMatrixDeterminant: number;
  90470. /** @hidden */
  90471. _worldMatrixDeterminantIsDirty: boolean;
  90472. /** @hidden */
  90473. private _sceneRootNodesIndex;
  90474. /**
  90475. * Gets a boolean indicating if the node has been disposed
  90476. * @returns true if the node was disposed
  90477. */
  90478. isDisposed(): boolean;
  90479. /**
  90480. * Gets or sets the parent of the node (without keeping the current position in the scene)
  90481. * @see https://doc.babylonjs.com/how_to/parenting
  90482. */
  90483. parent: Nullable<Node>;
  90484. private addToSceneRootNodes;
  90485. private removeFromSceneRootNodes;
  90486. private _animationPropertiesOverride;
  90487. /**
  90488. * Gets or sets the animation properties override
  90489. */
  90490. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  90491. /**
  90492. * Gets a string idenfifying the name of the class
  90493. * @returns "Node" string
  90494. */
  90495. getClassName(): string;
  90496. /** @hidden */
  90497. readonly _isNode: boolean;
  90498. /**
  90499. * An event triggered when the mesh is disposed
  90500. */
  90501. onDisposeObservable: Observable<Node>;
  90502. private _onDisposeObserver;
  90503. /**
  90504. * Sets a callback that will be raised when the node will be disposed
  90505. */
  90506. onDispose: () => void;
  90507. /**
  90508. * Creates a new Node
  90509. * @param name the name and id to be given to this node
  90510. * @param scene the scene this node will be added to
  90511. * @param addToRootNodes the node will be added to scene.rootNodes
  90512. */
  90513. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  90514. /**
  90515. * Gets the scene of the node
  90516. * @returns a scene
  90517. */
  90518. getScene(): Scene;
  90519. /**
  90520. * Gets the engine of the node
  90521. * @returns a Engine
  90522. */
  90523. getEngine(): Engine;
  90524. private _behaviors;
  90525. /**
  90526. * Attach a behavior to the node
  90527. * @see http://doc.babylonjs.com/features/behaviour
  90528. * @param behavior defines the behavior to attach
  90529. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  90530. * @returns the current Node
  90531. */
  90532. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  90533. /**
  90534. * Remove an attached behavior
  90535. * @see http://doc.babylonjs.com/features/behaviour
  90536. * @param behavior defines the behavior to attach
  90537. * @returns the current Node
  90538. */
  90539. removeBehavior(behavior: Behavior<Node>): Node;
  90540. /**
  90541. * Gets the list of attached behaviors
  90542. * @see http://doc.babylonjs.com/features/behaviour
  90543. */
  90544. readonly behaviors: Behavior<Node>[];
  90545. /**
  90546. * Gets an attached behavior by name
  90547. * @param name defines the name of the behavior to look for
  90548. * @see http://doc.babylonjs.com/features/behaviour
  90549. * @returns null if behavior was not found else the requested behavior
  90550. */
  90551. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  90552. /**
  90553. * Returns the latest update of the World matrix
  90554. * @returns a Matrix
  90555. */
  90556. getWorldMatrix(): Matrix;
  90557. /** @hidden */
  90558. _getWorldMatrixDeterminant(): number;
  90559. /**
  90560. * Returns directly the latest state of the mesh World matrix.
  90561. * A Matrix is returned.
  90562. */
  90563. readonly worldMatrixFromCache: Matrix;
  90564. /** @hidden */
  90565. _initCache(): void;
  90566. /** @hidden */
  90567. updateCache(force?: boolean): void;
  90568. /** @hidden */
  90569. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  90570. /** @hidden */
  90571. _updateCache(ignoreParentClass?: boolean): void;
  90572. /** @hidden */
  90573. _isSynchronized(): boolean;
  90574. /** @hidden */
  90575. _markSyncedWithParent(): void;
  90576. /** @hidden */
  90577. isSynchronizedWithParent(): boolean;
  90578. /** @hidden */
  90579. isSynchronized(): boolean;
  90580. /**
  90581. * Is this node ready to be used/rendered
  90582. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  90583. * @return true if the node is ready
  90584. */
  90585. isReady(completeCheck?: boolean): boolean;
  90586. /**
  90587. * Is this node enabled?
  90588. * 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
  90589. * @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
  90590. * @return whether this node (and its parent) is enabled
  90591. */
  90592. isEnabled(checkAncestors?: boolean): boolean;
  90593. /** @hidden */
  90594. protected _syncParentEnabledState(): void;
  90595. /**
  90596. * Set the enabled state of this node
  90597. * @param value defines the new enabled state
  90598. */
  90599. setEnabled(value: boolean): void;
  90600. /**
  90601. * Is this node a descendant of the given node?
  90602. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  90603. * @param ancestor defines the parent node to inspect
  90604. * @returns a boolean indicating if this node is a descendant of the given node
  90605. */
  90606. isDescendantOf(ancestor: Node): boolean;
  90607. /** @hidden */
  90608. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  90609. /**
  90610. * Will return all nodes that have this node as ascendant
  90611. * @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
  90612. * @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
  90613. * @return all children nodes of all types
  90614. */
  90615. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  90616. /**
  90617. * Get all child-meshes of this node
  90618. * @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)
  90619. * @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
  90620. * @returns an array of AbstractMesh
  90621. */
  90622. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  90623. /**
  90624. * Get all direct children of this node
  90625. * @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
  90626. * @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)
  90627. * @returns an array of Node
  90628. */
  90629. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  90630. /** @hidden */
  90631. _setReady(state: boolean): void;
  90632. /**
  90633. * Get an animation by name
  90634. * @param name defines the name of the animation to look for
  90635. * @returns null if not found else the requested animation
  90636. */
  90637. getAnimationByName(name: string): Nullable<Animation>;
  90638. /**
  90639. * Creates an animation range for this node
  90640. * @param name defines the name of the range
  90641. * @param from defines the starting key
  90642. * @param to defines the end key
  90643. */
  90644. createAnimationRange(name: string, from: number, to: number): void;
  90645. /**
  90646. * Delete a specific animation range
  90647. * @param name defines the name of the range to delete
  90648. * @param deleteFrames defines if animation frames from the range must be deleted as well
  90649. */
  90650. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  90651. /**
  90652. * Get an animation range by name
  90653. * @param name defines the name of the animation range to look for
  90654. * @returns null if not found else the requested animation range
  90655. */
  90656. getAnimationRange(name: string): Nullable<AnimationRange>;
  90657. /**
  90658. * Gets the list of all animation ranges defined on this node
  90659. * @returns an array
  90660. */
  90661. getAnimationRanges(): Nullable<AnimationRange>[];
  90662. /**
  90663. * Will start the animation sequence
  90664. * @param name defines the range frames for animation sequence
  90665. * @param loop defines if the animation should loop (false by default)
  90666. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  90667. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  90668. * @returns the object created for this animation. If range does not exist, it will return null
  90669. */
  90670. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  90671. /**
  90672. * Serialize animation ranges into a JSON compatible object
  90673. * @returns serialization object
  90674. */
  90675. serializeAnimationRanges(): any;
  90676. /**
  90677. * Computes the world matrix of the node
  90678. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  90679. * @returns the world matrix
  90680. */
  90681. computeWorldMatrix(force?: boolean): Matrix;
  90682. /**
  90683. * Releases resources associated with this node.
  90684. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90685. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90686. */
  90687. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90688. /**
  90689. * Parse animation range data from a serialization object and store them into a given node
  90690. * @param node defines where to store the animation ranges
  90691. * @param parsedNode defines the serialization object to read data from
  90692. * @param scene defines the hosting scene
  90693. */
  90694. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  90695. /**
  90696. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  90697. * @param includeDescendants Include bounding info from descendants as well (true by default)
  90698. * @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
  90699. * @returns the new bounding vectors
  90700. */
  90701. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  90702. min: Vector3;
  90703. max: Vector3;
  90704. };
  90705. }
  90706. }
  90707. declare module BABYLON {
  90708. /**
  90709. * @hidden
  90710. */
  90711. export class _IAnimationState {
  90712. key: number;
  90713. repeatCount: number;
  90714. workValue?: any;
  90715. loopMode?: number;
  90716. offsetValue?: any;
  90717. highLimitValue?: any;
  90718. }
  90719. /**
  90720. * Class used to store any kind of animation
  90721. */
  90722. export class Animation {
  90723. /**Name of the animation */
  90724. name: string;
  90725. /**Property to animate */
  90726. targetProperty: string;
  90727. /**The frames per second of the animation */
  90728. framePerSecond: number;
  90729. /**The data type of the animation */
  90730. dataType: number;
  90731. /**The loop mode of the animation */
  90732. loopMode?: number | undefined;
  90733. /**Specifies if blending should be enabled */
  90734. enableBlending?: boolean | undefined;
  90735. /**
  90736. * Use matrix interpolation instead of using direct key value when animating matrices
  90737. */
  90738. static AllowMatricesInterpolation: boolean;
  90739. /**
  90740. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  90741. */
  90742. static AllowMatrixDecomposeForInterpolation: boolean;
  90743. /**
  90744. * Stores the key frames of the animation
  90745. */
  90746. private _keys;
  90747. /**
  90748. * Stores the easing function of the animation
  90749. */
  90750. private _easingFunction;
  90751. /**
  90752. * @hidden Internal use only
  90753. */
  90754. _runtimeAnimations: RuntimeAnimation[];
  90755. /**
  90756. * The set of event that will be linked to this animation
  90757. */
  90758. private _events;
  90759. /**
  90760. * Stores an array of target property paths
  90761. */
  90762. targetPropertyPath: string[];
  90763. /**
  90764. * Stores the blending speed of the animation
  90765. */
  90766. blendingSpeed: number;
  90767. /**
  90768. * Stores the animation ranges for the animation
  90769. */
  90770. private _ranges;
  90771. /**
  90772. * @hidden Internal use
  90773. */
  90774. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  90775. /**
  90776. * Sets up an animation
  90777. * @param property The property to animate
  90778. * @param animationType The animation type to apply
  90779. * @param framePerSecond The frames per second of the animation
  90780. * @param easingFunction The easing function used in the animation
  90781. * @returns The created animation
  90782. */
  90783. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  90784. /**
  90785. * Create and start an animation on a node
  90786. * @param name defines the name of the global animation that will be run on all nodes
  90787. * @param node defines the root node where the animation will take place
  90788. * @param targetProperty defines property to animate
  90789. * @param framePerSecond defines the number of frame per second yo use
  90790. * @param totalFrame defines the number of frames in total
  90791. * @param from defines the initial value
  90792. * @param to defines the final value
  90793. * @param loopMode defines which loop mode you want to use (off by default)
  90794. * @param easingFunction defines the easing function to use (linear by default)
  90795. * @param onAnimationEnd defines the callback to call when animation end
  90796. * @returns the animatable created for this animation
  90797. */
  90798. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  90799. /**
  90800. * Create and start an animation on a node and its descendants
  90801. * @param name defines the name of the global animation that will be run on all nodes
  90802. * @param node defines the root node where the animation will take place
  90803. * @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
  90804. * @param targetProperty defines property to animate
  90805. * @param framePerSecond defines the number of frame per second to use
  90806. * @param totalFrame defines the number of frames in total
  90807. * @param from defines the initial value
  90808. * @param to defines the final value
  90809. * @param loopMode defines which loop mode you want to use (off by default)
  90810. * @param easingFunction defines the easing function to use (linear by default)
  90811. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  90812. * @returns the list of animatables created for all nodes
  90813. * @example https://www.babylonjs-playground.com/#MH0VLI
  90814. */
  90815. 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[]>;
  90816. /**
  90817. * Creates a new animation, merges it with the existing animations and starts it
  90818. * @param name Name of the animation
  90819. * @param node Node which contains the scene that begins the animations
  90820. * @param targetProperty Specifies which property to animate
  90821. * @param framePerSecond The frames per second of the animation
  90822. * @param totalFrame The total number of frames
  90823. * @param from The frame at the beginning of the animation
  90824. * @param to The frame at the end of the animation
  90825. * @param loopMode Specifies the loop mode of the animation
  90826. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  90827. * @param onAnimationEnd Callback to run once the animation is complete
  90828. * @returns Nullable animation
  90829. */
  90830. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  90831. /**
  90832. * Transition property of an host to the target Value
  90833. * @param property The property to transition
  90834. * @param targetValue The target Value of the property
  90835. * @param host The object where the property to animate belongs
  90836. * @param scene Scene used to run the animation
  90837. * @param frameRate Framerate (in frame/s) to use
  90838. * @param transition The transition type we want to use
  90839. * @param duration The duration of the animation, in milliseconds
  90840. * @param onAnimationEnd Callback trigger at the end of the animation
  90841. * @returns Nullable animation
  90842. */
  90843. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  90844. /**
  90845. * Return the array of runtime animations currently using this animation
  90846. */
  90847. readonly runtimeAnimations: RuntimeAnimation[];
  90848. /**
  90849. * Specifies if any of the runtime animations are currently running
  90850. */
  90851. readonly hasRunningRuntimeAnimations: boolean;
  90852. /**
  90853. * Initializes the animation
  90854. * @param name Name of the animation
  90855. * @param targetProperty Property to animate
  90856. * @param framePerSecond The frames per second of the animation
  90857. * @param dataType The data type of the animation
  90858. * @param loopMode The loop mode of the animation
  90859. * @param enableBlending Specifies if blending should be enabled
  90860. */
  90861. constructor(
  90862. /**Name of the animation */
  90863. name: string,
  90864. /**Property to animate */
  90865. targetProperty: string,
  90866. /**The frames per second of the animation */
  90867. framePerSecond: number,
  90868. /**The data type of the animation */
  90869. dataType: number,
  90870. /**The loop mode of the animation */
  90871. loopMode?: number | undefined,
  90872. /**Specifies if blending should be enabled */
  90873. enableBlending?: boolean | undefined);
  90874. /**
  90875. * Converts the animation to a string
  90876. * @param fullDetails support for multiple levels of logging within scene loading
  90877. * @returns String form of the animation
  90878. */
  90879. toString(fullDetails?: boolean): string;
  90880. /**
  90881. * Add an event to this animation
  90882. * @param event Event to add
  90883. */
  90884. addEvent(event: AnimationEvent): void;
  90885. /**
  90886. * Remove all events found at the given frame
  90887. * @param frame The frame to remove events from
  90888. */
  90889. removeEvents(frame: number): void;
  90890. /**
  90891. * Retrieves all the events from the animation
  90892. * @returns Events from the animation
  90893. */
  90894. getEvents(): AnimationEvent[];
  90895. /**
  90896. * Creates an animation range
  90897. * @param name Name of the animation range
  90898. * @param from Starting frame of the animation range
  90899. * @param to Ending frame of the animation
  90900. */
  90901. createRange(name: string, from: number, to: number): void;
  90902. /**
  90903. * Deletes an animation range by name
  90904. * @param name Name of the animation range to delete
  90905. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  90906. */
  90907. deleteRange(name: string, deleteFrames?: boolean): void;
  90908. /**
  90909. * Gets the animation range by name, or null if not defined
  90910. * @param name Name of the animation range
  90911. * @returns Nullable animation range
  90912. */
  90913. getRange(name: string): Nullable<AnimationRange>;
  90914. /**
  90915. * Gets the key frames from the animation
  90916. * @returns The key frames of the animation
  90917. */
  90918. getKeys(): Array<IAnimationKey>;
  90919. /**
  90920. * Gets the highest frame rate of the animation
  90921. * @returns Highest frame rate of the animation
  90922. */
  90923. getHighestFrame(): number;
  90924. /**
  90925. * Gets the easing function of the animation
  90926. * @returns Easing function of the animation
  90927. */
  90928. getEasingFunction(): IEasingFunction;
  90929. /**
  90930. * Sets the easing function of the animation
  90931. * @param easingFunction A custom mathematical formula for animation
  90932. */
  90933. setEasingFunction(easingFunction: EasingFunction): void;
  90934. /**
  90935. * Interpolates a scalar linearly
  90936. * @param startValue Start value of the animation curve
  90937. * @param endValue End value of the animation curve
  90938. * @param gradient Scalar amount to interpolate
  90939. * @returns Interpolated scalar value
  90940. */
  90941. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  90942. /**
  90943. * Interpolates a scalar cubically
  90944. * @param startValue Start value of the animation curve
  90945. * @param outTangent End tangent of the animation
  90946. * @param endValue End value of the animation curve
  90947. * @param inTangent Start tangent of the animation curve
  90948. * @param gradient Scalar amount to interpolate
  90949. * @returns Interpolated scalar value
  90950. */
  90951. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  90952. /**
  90953. * Interpolates a quaternion using a spherical linear interpolation
  90954. * @param startValue Start value of the animation curve
  90955. * @param endValue End value of the animation curve
  90956. * @param gradient Scalar amount to interpolate
  90957. * @returns Interpolated quaternion value
  90958. */
  90959. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  90960. /**
  90961. * Interpolates a quaternion cubically
  90962. * @param startValue Start value of the animation curve
  90963. * @param outTangent End tangent of the animation curve
  90964. * @param endValue End value of the animation curve
  90965. * @param inTangent Start tangent of the animation curve
  90966. * @param gradient Scalar amount to interpolate
  90967. * @returns Interpolated quaternion value
  90968. */
  90969. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  90970. /**
  90971. * Interpolates a Vector3 linearl
  90972. * @param startValue Start value of the animation curve
  90973. * @param endValue End value of the animation curve
  90974. * @param gradient Scalar amount to interpolate
  90975. * @returns Interpolated scalar value
  90976. */
  90977. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  90978. /**
  90979. * Interpolates a Vector3 cubically
  90980. * @param startValue Start value of the animation curve
  90981. * @param outTangent End tangent of the animation
  90982. * @param endValue End value of the animation curve
  90983. * @param inTangent Start tangent of the animation curve
  90984. * @param gradient Scalar amount to interpolate
  90985. * @returns InterpolatedVector3 value
  90986. */
  90987. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  90988. /**
  90989. * Interpolates a Vector2 linearly
  90990. * @param startValue Start value of the animation curve
  90991. * @param endValue End value of the animation curve
  90992. * @param gradient Scalar amount to interpolate
  90993. * @returns Interpolated Vector2 value
  90994. */
  90995. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  90996. /**
  90997. * Interpolates a Vector2 cubically
  90998. * @param startValue Start value of the animation curve
  90999. * @param outTangent End tangent of the animation
  91000. * @param endValue End value of the animation curve
  91001. * @param inTangent Start tangent of the animation curve
  91002. * @param gradient Scalar amount to interpolate
  91003. * @returns Interpolated Vector2 value
  91004. */
  91005. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  91006. /**
  91007. * Interpolates a size linearly
  91008. * @param startValue Start value of the animation curve
  91009. * @param endValue End value of the animation curve
  91010. * @param gradient Scalar amount to interpolate
  91011. * @returns Interpolated Size value
  91012. */
  91013. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  91014. /**
  91015. * Interpolates a Color3 linearly
  91016. * @param startValue Start value of the animation curve
  91017. * @param endValue End value of the animation curve
  91018. * @param gradient Scalar amount to interpolate
  91019. * @returns Interpolated Color3 value
  91020. */
  91021. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  91022. /**
  91023. * @hidden Internal use only
  91024. */
  91025. _getKeyValue(value: any): any;
  91026. /**
  91027. * @hidden Internal use only
  91028. */
  91029. _interpolate(currentFrame: number, state: _IAnimationState): any;
  91030. /**
  91031. * Defines the function to use to interpolate matrices
  91032. * @param startValue defines the start matrix
  91033. * @param endValue defines the end matrix
  91034. * @param gradient defines the gradient between both matrices
  91035. * @param result defines an optional target matrix where to store the interpolation
  91036. * @returns the interpolated matrix
  91037. */
  91038. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  91039. /**
  91040. * Makes a copy of the animation
  91041. * @returns Cloned animation
  91042. */
  91043. clone(): Animation;
  91044. /**
  91045. * Sets the key frames of the animation
  91046. * @param values The animation key frames to set
  91047. */
  91048. setKeys(values: Array<IAnimationKey>): void;
  91049. /**
  91050. * Serializes the animation to an object
  91051. * @returns Serialized object
  91052. */
  91053. serialize(): any;
  91054. /**
  91055. * Float animation type
  91056. */
  91057. private static _ANIMATIONTYPE_FLOAT;
  91058. /**
  91059. * Vector3 animation type
  91060. */
  91061. private static _ANIMATIONTYPE_VECTOR3;
  91062. /**
  91063. * Quaternion animation type
  91064. */
  91065. private static _ANIMATIONTYPE_QUATERNION;
  91066. /**
  91067. * Matrix animation type
  91068. */
  91069. private static _ANIMATIONTYPE_MATRIX;
  91070. /**
  91071. * Color3 animation type
  91072. */
  91073. private static _ANIMATIONTYPE_COLOR3;
  91074. /**
  91075. * Vector2 animation type
  91076. */
  91077. private static _ANIMATIONTYPE_VECTOR2;
  91078. /**
  91079. * Size animation type
  91080. */
  91081. private static _ANIMATIONTYPE_SIZE;
  91082. /**
  91083. * Relative Loop Mode
  91084. */
  91085. private static _ANIMATIONLOOPMODE_RELATIVE;
  91086. /**
  91087. * Cycle Loop Mode
  91088. */
  91089. private static _ANIMATIONLOOPMODE_CYCLE;
  91090. /**
  91091. * Constant Loop Mode
  91092. */
  91093. private static _ANIMATIONLOOPMODE_CONSTANT;
  91094. /**
  91095. * Get the float animation type
  91096. */
  91097. static readonly ANIMATIONTYPE_FLOAT: number;
  91098. /**
  91099. * Get the Vector3 animation type
  91100. */
  91101. static readonly ANIMATIONTYPE_VECTOR3: number;
  91102. /**
  91103. * Get the Vector2 animation type
  91104. */
  91105. static readonly ANIMATIONTYPE_VECTOR2: number;
  91106. /**
  91107. * Get the Size animation type
  91108. */
  91109. static readonly ANIMATIONTYPE_SIZE: number;
  91110. /**
  91111. * Get the Quaternion animation type
  91112. */
  91113. static readonly ANIMATIONTYPE_QUATERNION: number;
  91114. /**
  91115. * Get the Matrix animation type
  91116. */
  91117. static readonly ANIMATIONTYPE_MATRIX: number;
  91118. /**
  91119. * Get the Color3 animation type
  91120. */
  91121. static readonly ANIMATIONTYPE_COLOR3: number;
  91122. /**
  91123. * Get the Relative Loop Mode
  91124. */
  91125. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  91126. /**
  91127. * Get the Cycle Loop Mode
  91128. */
  91129. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  91130. /**
  91131. * Get the Constant Loop Mode
  91132. */
  91133. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  91134. /** @hidden */
  91135. static _UniversalLerp(left: any, right: any, amount: number): any;
  91136. /**
  91137. * Parses an animation object and creates an animation
  91138. * @param parsedAnimation Parsed animation object
  91139. * @returns Animation object
  91140. */
  91141. static Parse(parsedAnimation: any): Animation;
  91142. /**
  91143. * Appends the serialized animations from the source animations
  91144. * @param source Source containing the animations
  91145. * @param destination Target to store the animations
  91146. */
  91147. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  91148. }
  91149. }
  91150. declare module BABYLON {
  91151. /**
  91152. * Interface containing an array of animations
  91153. */
  91154. export interface IAnimatable {
  91155. /**
  91156. * Array of animations
  91157. */
  91158. animations: Nullable<Array<Animation>>;
  91159. }
  91160. }
  91161. declare module BABYLON {
  91162. /**
  91163. * This represents all the required information to add a fresnel effect on a material:
  91164. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  91165. */
  91166. export class FresnelParameters {
  91167. private _isEnabled;
  91168. /**
  91169. * Define if the fresnel effect is enable or not.
  91170. */
  91171. isEnabled: boolean;
  91172. /**
  91173. * Define the color used on edges (grazing angle)
  91174. */
  91175. leftColor: Color3;
  91176. /**
  91177. * Define the color used on center
  91178. */
  91179. rightColor: Color3;
  91180. /**
  91181. * Define bias applied to computed fresnel term
  91182. */
  91183. bias: number;
  91184. /**
  91185. * Defined the power exponent applied to fresnel term
  91186. */
  91187. power: number;
  91188. /**
  91189. * Clones the current fresnel and its valuues
  91190. * @returns a clone fresnel configuration
  91191. */
  91192. clone(): FresnelParameters;
  91193. /**
  91194. * Serializes the current fresnel parameters to a JSON representation.
  91195. * @return the JSON serialization
  91196. */
  91197. serialize(): any;
  91198. /**
  91199. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  91200. * @param parsedFresnelParameters Define the JSON representation
  91201. * @returns the parsed parameters
  91202. */
  91203. static Parse(parsedFresnelParameters: any): FresnelParameters;
  91204. }
  91205. }
  91206. declare module BABYLON {
  91207. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  91208. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91209. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91210. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91211. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91212. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91213. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91214. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91215. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91216. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91217. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91218. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91219. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91220. /**
  91221. * Decorator used to define property that can be serialized as reference to a camera
  91222. * @param sourceName defines the name of the property to decorate
  91223. */
  91224. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91225. /**
  91226. * Class used to help serialization objects
  91227. */
  91228. export class SerializationHelper {
  91229. /** @hidden */
  91230. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  91231. /** @hidden */
  91232. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  91233. /** @hidden */
  91234. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  91235. /** @hidden */
  91236. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  91237. /**
  91238. * Appends the serialized animations from the source animations
  91239. * @param source Source containing the animations
  91240. * @param destination Target to store the animations
  91241. */
  91242. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  91243. /**
  91244. * Static function used to serialized a specific entity
  91245. * @param entity defines the entity to serialize
  91246. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  91247. * @returns a JSON compatible object representing the serialization of the entity
  91248. */
  91249. static Serialize<T>(entity: T, serializationObject?: any): any;
  91250. /**
  91251. * Creates a new entity from a serialization data object
  91252. * @param creationFunction defines a function used to instanciated the new entity
  91253. * @param source defines the source serialization data
  91254. * @param scene defines the hosting scene
  91255. * @param rootUrl defines the root url for resources
  91256. * @returns a new entity
  91257. */
  91258. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  91259. /**
  91260. * Clones an object
  91261. * @param creationFunction defines the function used to instanciate the new object
  91262. * @param source defines the source object
  91263. * @returns the cloned object
  91264. */
  91265. static Clone<T>(creationFunction: () => T, source: T): T;
  91266. /**
  91267. * Instanciates a new object based on a source one (some data will be shared between both object)
  91268. * @param creationFunction defines the function used to instanciate the new object
  91269. * @param source defines the source object
  91270. * @returns the new object
  91271. */
  91272. static Instanciate<T>(creationFunction: () => T, source: T): T;
  91273. }
  91274. }
  91275. declare module BABYLON {
  91276. /**
  91277. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  91278. */
  91279. export interface CubeMapInfo {
  91280. /**
  91281. * The pixel array for the front face.
  91282. * This is stored in format, left to right, up to down format.
  91283. */
  91284. front: Nullable<ArrayBufferView>;
  91285. /**
  91286. * The pixel array for the back face.
  91287. * This is stored in format, left to right, up to down format.
  91288. */
  91289. back: Nullable<ArrayBufferView>;
  91290. /**
  91291. * The pixel array for the left face.
  91292. * This is stored in format, left to right, up to down format.
  91293. */
  91294. left: Nullable<ArrayBufferView>;
  91295. /**
  91296. * The pixel array for the right face.
  91297. * This is stored in format, left to right, up to down format.
  91298. */
  91299. right: Nullable<ArrayBufferView>;
  91300. /**
  91301. * The pixel array for the up face.
  91302. * This is stored in format, left to right, up to down format.
  91303. */
  91304. up: Nullable<ArrayBufferView>;
  91305. /**
  91306. * The pixel array for the down face.
  91307. * This is stored in format, left to right, up to down format.
  91308. */
  91309. down: Nullable<ArrayBufferView>;
  91310. /**
  91311. * The size of the cubemap stored.
  91312. *
  91313. * Each faces will be size * size pixels.
  91314. */
  91315. size: number;
  91316. /**
  91317. * The format of the texture.
  91318. *
  91319. * RGBA, RGB.
  91320. */
  91321. format: number;
  91322. /**
  91323. * The type of the texture data.
  91324. *
  91325. * UNSIGNED_INT, FLOAT.
  91326. */
  91327. type: number;
  91328. /**
  91329. * Specifies whether the texture is in gamma space.
  91330. */
  91331. gammaSpace: boolean;
  91332. }
  91333. /**
  91334. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  91335. */
  91336. export class PanoramaToCubeMapTools {
  91337. private static FACE_FRONT;
  91338. private static FACE_BACK;
  91339. private static FACE_RIGHT;
  91340. private static FACE_LEFT;
  91341. private static FACE_DOWN;
  91342. private static FACE_UP;
  91343. /**
  91344. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  91345. *
  91346. * @param float32Array The source data.
  91347. * @param inputWidth The width of the input panorama.
  91348. * @param inputHeight The height of the input panorama.
  91349. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  91350. * @return The cubemap data
  91351. */
  91352. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  91353. private static CreateCubemapTexture;
  91354. private static CalcProjectionSpherical;
  91355. }
  91356. }
  91357. declare module BABYLON {
  91358. /**
  91359. * Helper class dealing with the extraction of spherical polynomial dataArray
  91360. * from a cube map.
  91361. */
  91362. export class CubeMapToSphericalPolynomialTools {
  91363. private static FileFaces;
  91364. /**
  91365. * Converts a texture to the according Spherical Polynomial data.
  91366. * This extracts the first 3 orders only as they are the only one used in the lighting.
  91367. *
  91368. * @param texture The texture to extract the information from.
  91369. * @return The Spherical Polynomial data.
  91370. */
  91371. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  91372. /**
  91373. * Converts a cubemap to the according Spherical Polynomial data.
  91374. * This extracts the first 3 orders only as they are the only one used in the lighting.
  91375. *
  91376. * @param cubeInfo The Cube map to extract the information from.
  91377. * @return The Spherical Polynomial data.
  91378. */
  91379. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  91380. }
  91381. }
  91382. declare module BABYLON {
  91383. /**
  91384. * Class used to manipulate GUIDs
  91385. */
  91386. export class GUID {
  91387. /**
  91388. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  91389. * Be aware Math.random() could cause collisions, but:
  91390. * "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"
  91391. * @returns a pseudo random id
  91392. */
  91393. static RandomId(): string;
  91394. }
  91395. }
  91396. declare module BABYLON {
  91397. /**
  91398. * Base class of all the textures in babylon.
  91399. * It groups all the common properties the materials, post process, lights... might need
  91400. * in order to make a correct use of the texture.
  91401. */
  91402. export class BaseTexture implements IAnimatable {
  91403. /**
  91404. * Default anisotropic filtering level for the application.
  91405. * It is set to 4 as a good tradeoff between perf and quality.
  91406. */
  91407. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  91408. /**
  91409. * Gets or sets the unique id of the texture
  91410. */
  91411. uniqueId: number;
  91412. /**
  91413. * Define the name of the texture.
  91414. */
  91415. name: string;
  91416. /**
  91417. * Gets or sets an object used to store user defined information.
  91418. */
  91419. metadata: any;
  91420. /**
  91421. * For internal use only. Please do not use.
  91422. */
  91423. reservedDataStore: any;
  91424. private _hasAlpha;
  91425. /**
  91426. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  91427. */
  91428. hasAlpha: boolean;
  91429. /**
  91430. * Defines if the alpha value should be determined via the rgb values.
  91431. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  91432. */
  91433. getAlphaFromRGB: boolean;
  91434. /**
  91435. * Intensity or strength of the texture.
  91436. * It is commonly used by materials to fine tune the intensity of the texture
  91437. */
  91438. level: number;
  91439. /**
  91440. * Define the UV chanel to use starting from 0 and defaulting to 0.
  91441. * This is part of the texture as textures usually maps to one uv set.
  91442. */
  91443. coordinatesIndex: number;
  91444. private _coordinatesMode;
  91445. /**
  91446. * How a texture is mapped.
  91447. *
  91448. * | Value | Type | Description |
  91449. * | ----- | ----------------------------------- | ----------- |
  91450. * | 0 | EXPLICIT_MODE | |
  91451. * | 1 | SPHERICAL_MODE | |
  91452. * | 2 | PLANAR_MODE | |
  91453. * | 3 | CUBIC_MODE | |
  91454. * | 4 | PROJECTION_MODE | |
  91455. * | 5 | SKYBOX_MODE | |
  91456. * | 6 | INVCUBIC_MODE | |
  91457. * | 7 | EQUIRECTANGULAR_MODE | |
  91458. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  91459. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  91460. */
  91461. coordinatesMode: number;
  91462. /**
  91463. * | Value | Type | Description |
  91464. * | ----- | ------------------ | ----------- |
  91465. * | 0 | CLAMP_ADDRESSMODE | |
  91466. * | 1 | WRAP_ADDRESSMODE | |
  91467. * | 2 | MIRROR_ADDRESSMODE | |
  91468. */
  91469. wrapU: number;
  91470. /**
  91471. * | Value | Type | Description |
  91472. * | ----- | ------------------ | ----------- |
  91473. * | 0 | CLAMP_ADDRESSMODE | |
  91474. * | 1 | WRAP_ADDRESSMODE | |
  91475. * | 2 | MIRROR_ADDRESSMODE | |
  91476. */
  91477. wrapV: number;
  91478. /**
  91479. * | Value | Type | Description |
  91480. * | ----- | ------------------ | ----------- |
  91481. * | 0 | CLAMP_ADDRESSMODE | |
  91482. * | 1 | WRAP_ADDRESSMODE | |
  91483. * | 2 | MIRROR_ADDRESSMODE | |
  91484. */
  91485. wrapR: number;
  91486. /**
  91487. * With compliant hardware and browser (supporting anisotropic filtering)
  91488. * this defines the level of anisotropic filtering in the texture.
  91489. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  91490. */
  91491. anisotropicFilteringLevel: number;
  91492. /**
  91493. * Define if the texture is a cube texture or if false a 2d texture.
  91494. */
  91495. isCube: boolean;
  91496. /**
  91497. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  91498. */
  91499. is3D: boolean;
  91500. /**
  91501. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  91502. * HDR texture are usually stored in linear space.
  91503. * This only impacts the PBR and Background materials
  91504. */
  91505. gammaSpace: boolean;
  91506. /**
  91507. * Gets whether or not the texture contains RGBD data.
  91508. */
  91509. readonly isRGBD: boolean;
  91510. /**
  91511. * Is Z inverted in the texture (useful in a cube texture).
  91512. */
  91513. invertZ: boolean;
  91514. /**
  91515. * Are mip maps generated for this texture or not.
  91516. */
  91517. readonly noMipmap: boolean;
  91518. /**
  91519. * @hidden
  91520. */
  91521. lodLevelInAlpha: boolean;
  91522. /**
  91523. * With prefiltered texture, defined the offset used during the prefiltering steps.
  91524. */
  91525. lodGenerationOffset: number;
  91526. /**
  91527. * With prefiltered texture, defined the scale used during the prefiltering steps.
  91528. */
  91529. lodGenerationScale: number;
  91530. /**
  91531. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  91532. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  91533. * average roughness values.
  91534. */
  91535. linearSpecularLOD: boolean;
  91536. /**
  91537. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  91538. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  91539. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  91540. */
  91541. irradianceTexture: Nullable<BaseTexture>;
  91542. /**
  91543. * Define if the texture is a render target.
  91544. */
  91545. isRenderTarget: boolean;
  91546. /**
  91547. * Define the unique id of the texture in the scene.
  91548. */
  91549. readonly uid: string;
  91550. /**
  91551. * Return a string representation of the texture.
  91552. * @returns the texture as a string
  91553. */
  91554. toString(): string;
  91555. /**
  91556. * Get the class name of the texture.
  91557. * @returns "BaseTexture"
  91558. */
  91559. getClassName(): string;
  91560. /**
  91561. * Define the list of animation attached to the texture.
  91562. */
  91563. animations: Animation[];
  91564. /**
  91565. * An event triggered when the texture is disposed.
  91566. */
  91567. onDisposeObservable: Observable<BaseTexture>;
  91568. private _onDisposeObserver;
  91569. /**
  91570. * Callback triggered when the texture has been disposed.
  91571. * Kept for back compatibility, you can use the onDisposeObservable instead.
  91572. */
  91573. onDispose: () => void;
  91574. /**
  91575. * Define the current state of the loading sequence when in delayed load mode.
  91576. */
  91577. delayLoadState: number;
  91578. private _scene;
  91579. /** @hidden */
  91580. _texture: Nullable<InternalTexture>;
  91581. private _uid;
  91582. /**
  91583. * Define if the texture is preventinga material to render or not.
  91584. * If not and the texture is not ready, the engine will use a default black texture instead.
  91585. */
  91586. readonly isBlocking: boolean;
  91587. /**
  91588. * Instantiates a new BaseTexture.
  91589. * Base class of all the textures in babylon.
  91590. * It groups all the common properties the materials, post process, lights... might need
  91591. * in order to make a correct use of the texture.
  91592. * @param scene Define the scene the texture blongs to
  91593. */
  91594. constructor(scene: Nullable<Scene>);
  91595. /**
  91596. * Get the scene the texture belongs to.
  91597. * @returns the scene or null if undefined
  91598. */
  91599. getScene(): Nullable<Scene>;
  91600. /**
  91601. * Get the texture transform matrix used to offset tile the texture for istance.
  91602. * @returns the transformation matrix
  91603. */
  91604. getTextureMatrix(): Matrix;
  91605. /**
  91606. * Get the texture reflection matrix used to rotate/transform the reflection.
  91607. * @returns the reflection matrix
  91608. */
  91609. getReflectionTextureMatrix(): Matrix;
  91610. /**
  91611. * Get the underlying lower level texture from Babylon.
  91612. * @returns the insternal texture
  91613. */
  91614. getInternalTexture(): Nullable<InternalTexture>;
  91615. /**
  91616. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  91617. * @returns true if ready or not blocking
  91618. */
  91619. isReadyOrNotBlocking(): boolean;
  91620. /**
  91621. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  91622. * @returns true if fully ready
  91623. */
  91624. isReady(): boolean;
  91625. private _cachedSize;
  91626. /**
  91627. * Get the size of the texture.
  91628. * @returns the texture size.
  91629. */
  91630. getSize(): ISize;
  91631. /**
  91632. * Get the base size of the texture.
  91633. * It can be different from the size if the texture has been resized for POT for instance
  91634. * @returns the base size
  91635. */
  91636. getBaseSize(): ISize;
  91637. /**
  91638. * Update the sampling mode of the texture.
  91639. * Default is Trilinear mode.
  91640. *
  91641. * | Value | Type | Description |
  91642. * | ----- | ------------------ | ----------- |
  91643. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  91644. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  91645. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  91646. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  91647. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  91648. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  91649. * | 7 | NEAREST_LINEAR | |
  91650. * | 8 | NEAREST_NEAREST | |
  91651. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  91652. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  91653. * | 11 | LINEAR_LINEAR | |
  91654. * | 12 | LINEAR_NEAREST | |
  91655. *
  91656. * > _mag_: magnification filter (close to the viewer)
  91657. * > _min_: minification filter (far from the viewer)
  91658. * > _mip_: filter used between mip map levels
  91659. *@param samplingMode Define the new sampling mode of the texture
  91660. */
  91661. updateSamplingMode(samplingMode: number): void;
  91662. /**
  91663. * Scales the texture if is `canRescale()`
  91664. * @param ratio the resize factor we want to use to rescale
  91665. */
  91666. scale(ratio: number): void;
  91667. /**
  91668. * Get if the texture can rescale.
  91669. */
  91670. readonly canRescale: boolean;
  91671. /** @hidden */
  91672. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  91673. /** @hidden */
  91674. _rebuild(): void;
  91675. /**
  91676. * Triggers the load sequence in delayed load mode.
  91677. */
  91678. delayLoad(): void;
  91679. /**
  91680. * Clones the texture.
  91681. * @returns the cloned texture
  91682. */
  91683. clone(): Nullable<BaseTexture>;
  91684. /**
  91685. * Get the texture underlying type (INT, FLOAT...)
  91686. */
  91687. readonly textureType: number;
  91688. /**
  91689. * Get the texture underlying format (RGB, RGBA...)
  91690. */
  91691. readonly textureFormat: number;
  91692. /**
  91693. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  91694. * This will returns an RGBA array buffer containing either in values (0-255) or
  91695. * float values (0-1) depending of the underlying buffer type.
  91696. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  91697. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  91698. * @param buffer defines a user defined buffer to fill with data (can be null)
  91699. * @returns The Array buffer containing the pixels data.
  91700. */
  91701. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  91702. /**
  91703. * Release and destroy the underlying lower level texture aka internalTexture.
  91704. */
  91705. releaseInternalTexture(): void;
  91706. /**
  91707. * Get the polynomial representation of the texture data.
  91708. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  91709. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  91710. */
  91711. sphericalPolynomial: Nullable<SphericalPolynomial>;
  91712. /** @hidden */
  91713. readonly _lodTextureHigh: Nullable<BaseTexture>;
  91714. /** @hidden */
  91715. readonly _lodTextureMid: Nullable<BaseTexture>;
  91716. /** @hidden */
  91717. readonly _lodTextureLow: Nullable<BaseTexture>;
  91718. /**
  91719. * Dispose the texture and release its associated resources.
  91720. */
  91721. dispose(): void;
  91722. /**
  91723. * Serialize the texture into a JSON representation that can be parsed later on.
  91724. * @returns the JSON representation of the texture
  91725. */
  91726. serialize(): any;
  91727. /**
  91728. * Helper function to be called back once a list of texture contains only ready textures.
  91729. * @param textures Define the list of textures to wait for
  91730. * @param callback Define the callback triggered once the entire list will be ready
  91731. */
  91732. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  91733. }
  91734. }
  91735. declare module BABYLON {
  91736. /**
  91737. * Class used to store data associated with WebGL texture data for the engine
  91738. * This class should not be used directly
  91739. */
  91740. export class InternalTexture {
  91741. /** @hidden */
  91742. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  91743. /**
  91744. * The source of the texture data is unknown
  91745. */
  91746. static DATASOURCE_UNKNOWN: number;
  91747. /**
  91748. * Texture data comes from an URL
  91749. */
  91750. static DATASOURCE_URL: number;
  91751. /**
  91752. * Texture data is only used for temporary storage
  91753. */
  91754. static DATASOURCE_TEMP: number;
  91755. /**
  91756. * Texture data comes from raw data (ArrayBuffer)
  91757. */
  91758. static DATASOURCE_RAW: number;
  91759. /**
  91760. * Texture content is dynamic (video or dynamic texture)
  91761. */
  91762. static DATASOURCE_DYNAMIC: number;
  91763. /**
  91764. * Texture content is generated by rendering to it
  91765. */
  91766. static DATASOURCE_RENDERTARGET: number;
  91767. /**
  91768. * Texture content is part of a multi render target process
  91769. */
  91770. static DATASOURCE_MULTIRENDERTARGET: number;
  91771. /**
  91772. * Texture data comes from a cube data file
  91773. */
  91774. static DATASOURCE_CUBE: number;
  91775. /**
  91776. * Texture data comes from a raw cube data
  91777. */
  91778. static DATASOURCE_CUBERAW: number;
  91779. /**
  91780. * Texture data come from a prefiltered cube data file
  91781. */
  91782. static DATASOURCE_CUBEPREFILTERED: number;
  91783. /**
  91784. * Texture content is raw 3D data
  91785. */
  91786. static DATASOURCE_RAW3D: number;
  91787. /**
  91788. * Texture content is a depth texture
  91789. */
  91790. static DATASOURCE_DEPTHTEXTURE: number;
  91791. /**
  91792. * Texture data comes from a raw cube data encoded with RGBD
  91793. */
  91794. static DATASOURCE_CUBERAW_RGBD: number;
  91795. /**
  91796. * Defines if the texture is ready
  91797. */
  91798. isReady: boolean;
  91799. /**
  91800. * Defines if the texture is a cube texture
  91801. */
  91802. isCube: boolean;
  91803. /**
  91804. * Defines if the texture contains 3D data
  91805. */
  91806. is3D: boolean;
  91807. /**
  91808. * Defines if the texture contains multiview data
  91809. */
  91810. isMultiview: boolean;
  91811. /**
  91812. * Gets the URL used to load this texture
  91813. */
  91814. url: string;
  91815. /**
  91816. * Gets the sampling mode of the texture
  91817. */
  91818. samplingMode: number;
  91819. /**
  91820. * Gets a boolean indicating if the texture needs mipmaps generation
  91821. */
  91822. generateMipMaps: boolean;
  91823. /**
  91824. * Gets the number of samples used by the texture (WebGL2+ only)
  91825. */
  91826. samples: number;
  91827. /**
  91828. * Gets the type of the texture (int, float...)
  91829. */
  91830. type: number;
  91831. /**
  91832. * Gets the format of the texture (RGB, RGBA...)
  91833. */
  91834. format: number;
  91835. /**
  91836. * Observable called when the texture is loaded
  91837. */
  91838. onLoadedObservable: Observable<InternalTexture>;
  91839. /**
  91840. * Gets the width of the texture
  91841. */
  91842. width: number;
  91843. /**
  91844. * Gets the height of the texture
  91845. */
  91846. height: number;
  91847. /**
  91848. * Gets the depth of the texture
  91849. */
  91850. depth: number;
  91851. /**
  91852. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  91853. */
  91854. baseWidth: number;
  91855. /**
  91856. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  91857. */
  91858. baseHeight: number;
  91859. /**
  91860. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  91861. */
  91862. baseDepth: number;
  91863. /**
  91864. * Gets a boolean indicating if the texture is inverted on Y axis
  91865. */
  91866. invertY: boolean;
  91867. /** @hidden */
  91868. _invertVScale: boolean;
  91869. /** @hidden */
  91870. _associatedChannel: number;
  91871. /** @hidden */
  91872. _dataSource: number;
  91873. /** @hidden */
  91874. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  91875. /** @hidden */
  91876. _bufferView: Nullable<ArrayBufferView>;
  91877. /** @hidden */
  91878. _bufferViewArray: Nullable<ArrayBufferView[]>;
  91879. /** @hidden */
  91880. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  91881. /** @hidden */
  91882. _size: number;
  91883. /** @hidden */
  91884. _extension: string;
  91885. /** @hidden */
  91886. _files: Nullable<string[]>;
  91887. /** @hidden */
  91888. _workingCanvas: Nullable<HTMLCanvasElement>;
  91889. /** @hidden */
  91890. _workingContext: Nullable<CanvasRenderingContext2D>;
  91891. /** @hidden */
  91892. _framebuffer: Nullable<WebGLFramebuffer>;
  91893. /** @hidden */
  91894. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  91895. /** @hidden */
  91896. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  91897. /** @hidden */
  91898. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  91899. /** @hidden */
  91900. _attachments: Nullable<number[]>;
  91901. /** @hidden */
  91902. _cachedCoordinatesMode: Nullable<number>;
  91903. /** @hidden */
  91904. _cachedWrapU: Nullable<number>;
  91905. /** @hidden */
  91906. _cachedWrapV: Nullable<number>;
  91907. /** @hidden */
  91908. _cachedWrapR: Nullable<number>;
  91909. /** @hidden */
  91910. _cachedAnisotropicFilteringLevel: Nullable<number>;
  91911. /** @hidden */
  91912. _isDisabled: boolean;
  91913. /** @hidden */
  91914. _compression: Nullable<string>;
  91915. /** @hidden */
  91916. _generateStencilBuffer: boolean;
  91917. /** @hidden */
  91918. _generateDepthBuffer: boolean;
  91919. /** @hidden */
  91920. _comparisonFunction: number;
  91921. /** @hidden */
  91922. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  91923. /** @hidden */
  91924. _lodGenerationScale: number;
  91925. /** @hidden */
  91926. _lodGenerationOffset: number;
  91927. /** @hidden */
  91928. _colorTextureArray: Nullable<WebGLTexture>;
  91929. /** @hidden */
  91930. _depthStencilTextureArray: Nullable<WebGLTexture>;
  91931. /** @hidden */
  91932. _lodTextureHigh: Nullable<BaseTexture>;
  91933. /** @hidden */
  91934. _lodTextureMid: Nullable<BaseTexture>;
  91935. /** @hidden */
  91936. _lodTextureLow: Nullable<BaseTexture>;
  91937. /** @hidden */
  91938. _isRGBD: boolean;
  91939. /** @hidden */
  91940. _linearSpecularLOD: boolean;
  91941. /** @hidden */
  91942. _irradianceTexture: Nullable<BaseTexture>;
  91943. /** @hidden */
  91944. _webGLTexture: Nullable<WebGLTexture>;
  91945. /** @hidden */
  91946. _references: number;
  91947. private _engine;
  91948. /**
  91949. * Gets the Engine the texture belongs to.
  91950. * @returns The babylon engine
  91951. */
  91952. getEngine(): Engine;
  91953. /**
  91954. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  91955. */
  91956. readonly dataSource: number;
  91957. /**
  91958. * Creates a new InternalTexture
  91959. * @param engine defines the engine to use
  91960. * @param dataSource defines the type of data that will be used
  91961. * @param delayAllocation if the texture allocation should be delayed (default: false)
  91962. */
  91963. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  91964. /**
  91965. * Increments the number of references (ie. the number of Texture that point to it)
  91966. */
  91967. incrementReferences(): void;
  91968. /**
  91969. * Change the size of the texture (not the size of the content)
  91970. * @param width defines the new width
  91971. * @param height defines the new height
  91972. * @param depth defines the new depth (1 by default)
  91973. */
  91974. updateSize(width: int, height: int, depth?: int): void;
  91975. /** @hidden */
  91976. _rebuild(): void;
  91977. /** @hidden */
  91978. _swapAndDie(target: InternalTexture): void;
  91979. /**
  91980. * Dispose the current allocated resources
  91981. */
  91982. dispose(): void;
  91983. }
  91984. }
  91985. declare module BABYLON {
  91986. /**
  91987. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  91988. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  91989. */
  91990. export class EffectFallbacks {
  91991. private _defines;
  91992. private _currentRank;
  91993. private _maxRank;
  91994. private _mesh;
  91995. /**
  91996. * Removes the fallback from the bound mesh.
  91997. */
  91998. unBindMesh(): void;
  91999. /**
  92000. * Adds a fallback on the specified property.
  92001. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92002. * @param define The name of the define in the shader
  92003. */
  92004. addFallback(rank: number, define: string): void;
  92005. /**
  92006. * Sets the mesh to use CPU skinning when needing to fallback.
  92007. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  92008. * @param mesh The mesh to use the fallbacks.
  92009. */
  92010. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  92011. /**
  92012. * Checks to see if more fallbacks are still availible.
  92013. */
  92014. readonly isMoreFallbacks: boolean;
  92015. /**
  92016. * Removes the defines that should be removed when falling back.
  92017. * @param currentDefines defines the current define statements for the shader.
  92018. * @param effect defines the current effect we try to compile
  92019. * @returns The resulting defines with defines of the current rank removed.
  92020. */
  92021. reduce(currentDefines: string, effect: Effect): string;
  92022. }
  92023. /**
  92024. * Options to be used when creating an effect.
  92025. */
  92026. export class EffectCreationOptions {
  92027. /**
  92028. * Atrributes that will be used in the shader.
  92029. */
  92030. attributes: string[];
  92031. /**
  92032. * Uniform varible names that will be set in the shader.
  92033. */
  92034. uniformsNames: string[];
  92035. /**
  92036. * Uniform buffer varible names that will be set in the shader.
  92037. */
  92038. uniformBuffersNames: string[];
  92039. /**
  92040. * Sampler texture variable names that will be set in the shader.
  92041. */
  92042. samplers: string[];
  92043. /**
  92044. * Define statements that will be set in the shader.
  92045. */
  92046. defines: any;
  92047. /**
  92048. * Possible fallbacks for this effect to improve performance when needed.
  92049. */
  92050. fallbacks: Nullable<EffectFallbacks>;
  92051. /**
  92052. * Callback that will be called when the shader is compiled.
  92053. */
  92054. onCompiled: Nullable<(effect: Effect) => void>;
  92055. /**
  92056. * Callback that will be called if an error occurs during shader compilation.
  92057. */
  92058. onError: Nullable<(effect: Effect, errors: string) => void>;
  92059. /**
  92060. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92061. */
  92062. indexParameters: any;
  92063. /**
  92064. * Max number of lights that can be used in the shader.
  92065. */
  92066. maxSimultaneousLights: number;
  92067. /**
  92068. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  92069. */
  92070. transformFeedbackVaryings: Nullable<string[]>;
  92071. }
  92072. /**
  92073. * Effect containing vertex and fragment shader that can be executed on an object.
  92074. */
  92075. export class Effect implements IDisposable {
  92076. /**
  92077. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  92078. */
  92079. static ShadersRepository: string;
  92080. /**
  92081. * Name of the effect.
  92082. */
  92083. name: any;
  92084. /**
  92085. * String container all the define statements that should be set on the shader.
  92086. */
  92087. defines: string;
  92088. /**
  92089. * Callback that will be called when the shader is compiled.
  92090. */
  92091. onCompiled: Nullable<(effect: Effect) => void>;
  92092. /**
  92093. * Callback that will be called if an error occurs during shader compilation.
  92094. */
  92095. onError: Nullable<(effect: Effect, errors: string) => void>;
  92096. /**
  92097. * Callback that will be called when effect is bound.
  92098. */
  92099. onBind: Nullable<(effect: Effect) => void>;
  92100. /**
  92101. * Unique ID of the effect.
  92102. */
  92103. uniqueId: number;
  92104. /**
  92105. * Observable that will be called when the shader is compiled.
  92106. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  92107. */
  92108. onCompileObservable: Observable<Effect>;
  92109. /**
  92110. * Observable that will be called if an error occurs during shader compilation.
  92111. */
  92112. onErrorObservable: Observable<Effect>;
  92113. /** @hidden */
  92114. _onBindObservable: Nullable<Observable<Effect>>;
  92115. /**
  92116. * Observable that will be called when effect is bound.
  92117. */
  92118. readonly onBindObservable: Observable<Effect>;
  92119. /** @hidden */
  92120. _bonesComputationForcedToCPU: boolean;
  92121. private static _uniqueIdSeed;
  92122. private _engine;
  92123. private _uniformBuffersNames;
  92124. private _uniformsNames;
  92125. private _samplerList;
  92126. private _samplers;
  92127. private _isReady;
  92128. private _compilationError;
  92129. private _attributesNames;
  92130. private _attributes;
  92131. private _uniforms;
  92132. /**
  92133. * Key for the effect.
  92134. * @hidden
  92135. */
  92136. _key: string;
  92137. private _indexParameters;
  92138. private _fallbacks;
  92139. private _vertexSourceCode;
  92140. private _fragmentSourceCode;
  92141. private _vertexSourceCodeOverride;
  92142. private _fragmentSourceCodeOverride;
  92143. private _transformFeedbackVaryings;
  92144. /**
  92145. * Compiled shader to webGL program.
  92146. * @hidden
  92147. */
  92148. _pipelineContext: Nullable<IPipelineContext>;
  92149. private _valueCache;
  92150. private static _baseCache;
  92151. /**
  92152. * Instantiates an effect.
  92153. * An effect can be used to create/manage/execute vertex and fragment shaders.
  92154. * @param baseName Name of the effect.
  92155. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  92156. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  92157. * @param samplers List of sampler variables that will be passed to the shader.
  92158. * @param engine Engine to be used to render the effect
  92159. * @param defines Define statements to be added to the shader.
  92160. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  92161. * @param onCompiled Callback that will be called when the shader is compiled.
  92162. * @param onError Callback that will be called if an error occurs during shader compilation.
  92163. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92164. */
  92165. 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);
  92166. private _useFinalCode;
  92167. /**
  92168. * Unique key for this effect
  92169. */
  92170. readonly key: string;
  92171. /**
  92172. * If the effect has been compiled and prepared.
  92173. * @returns if the effect is compiled and prepared.
  92174. */
  92175. isReady(): boolean;
  92176. /**
  92177. * The engine the effect was initialized with.
  92178. * @returns the engine.
  92179. */
  92180. getEngine(): Engine;
  92181. /**
  92182. * The pipeline context for this effect
  92183. * @returns the associated pipeline context
  92184. */
  92185. getPipelineContext(): Nullable<IPipelineContext>;
  92186. /**
  92187. * The set of names of attribute variables for the shader.
  92188. * @returns An array of attribute names.
  92189. */
  92190. getAttributesNames(): string[];
  92191. /**
  92192. * Returns the attribute at the given index.
  92193. * @param index The index of the attribute.
  92194. * @returns The location of the attribute.
  92195. */
  92196. getAttributeLocation(index: number): number;
  92197. /**
  92198. * Returns the attribute based on the name of the variable.
  92199. * @param name of the attribute to look up.
  92200. * @returns the attribute location.
  92201. */
  92202. getAttributeLocationByName(name: string): number;
  92203. /**
  92204. * The number of attributes.
  92205. * @returns the numnber of attributes.
  92206. */
  92207. getAttributesCount(): number;
  92208. /**
  92209. * Gets the index of a uniform variable.
  92210. * @param uniformName of the uniform to look up.
  92211. * @returns the index.
  92212. */
  92213. getUniformIndex(uniformName: string): number;
  92214. /**
  92215. * Returns the attribute based on the name of the variable.
  92216. * @param uniformName of the uniform to look up.
  92217. * @returns the location of the uniform.
  92218. */
  92219. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  92220. /**
  92221. * Returns an array of sampler variable names
  92222. * @returns The array of sampler variable neames.
  92223. */
  92224. getSamplers(): string[];
  92225. /**
  92226. * The error from the last compilation.
  92227. * @returns the error string.
  92228. */
  92229. getCompilationError(): string;
  92230. /**
  92231. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  92232. * @param func The callback to be used.
  92233. */
  92234. executeWhenCompiled(func: (effect: Effect) => void): void;
  92235. private _checkIsReady;
  92236. /** @hidden */
  92237. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  92238. /** @hidden */
  92239. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  92240. /** @hidden */
  92241. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  92242. /**
  92243. * Recompiles the webGL program
  92244. * @param vertexSourceCode The source code for the vertex shader.
  92245. * @param fragmentSourceCode The source code for the fragment shader.
  92246. * @param onCompiled Callback called when completed.
  92247. * @param onError Callback called on error.
  92248. * @hidden
  92249. */
  92250. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  92251. /**
  92252. * Prepares the effect
  92253. * @hidden
  92254. */
  92255. _prepareEffect(): void;
  92256. /**
  92257. * Checks if the effect is supported. (Must be called after compilation)
  92258. */
  92259. readonly isSupported: boolean;
  92260. /**
  92261. * Binds a texture to the engine to be used as output of the shader.
  92262. * @param channel Name of the output variable.
  92263. * @param texture Texture to bind.
  92264. * @hidden
  92265. */
  92266. _bindTexture(channel: string, texture: InternalTexture): void;
  92267. /**
  92268. * Sets a texture on the engine to be used in the shader.
  92269. * @param channel Name of the sampler variable.
  92270. * @param texture Texture to set.
  92271. */
  92272. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  92273. /**
  92274. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  92275. * @param channel Name of the sampler variable.
  92276. * @param texture Texture to set.
  92277. */
  92278. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  92279. /**
  92280. * Sets an array of textures on the engine to be used in the shader.
  92281. * @param channel Name of the variable.
  92282. * @param textures Textures to set.
  92283. */
  92284. setTextureArray(channel: string, textures: BaseTexture[]): void;
  92285. /**
  92286. * 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)
  92287. * @param channel Name of the sampler variable.
  92288. * @param postProcess Post process to get the input texture from.
  92289. */
  92290. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  92291. /**
  92292. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  92293. * 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)
  92294. * @param channel Name of the sampler variable.
  92295. * @param postProcess Post process to get the output texture from.
  92296. */
  92297. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  92298. /** @hidden */
  92299. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  92300. /** @hidden */
  92301. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  92302. /** @hidden */
  92303. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  92304. /** @hidden */
  92305. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  92306. /**
  92307. * Binds a buffer to a uniform.
  92308. * @param buffer Buffer to bind.
  92309. * @param name Name of the uniform variable to bind to.
  92310. */
  92311. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  92312. /**
  92313. * Binds block to a uniform.
  92314. * @param blockName Name of the block to bind.
  92315. * @param index Index to bind.
  92316. */
  92317. bindUniformBlock(blockName: string, index: number): void;
  92318. /**
  92319. * Sets an interger value on a uniform variable.
  92320. * @param uniformName Name of the variable.
  92321. * @param value Value to be set.
  92322. * @returns this effect.
  92323. */
  92324. setInt(uniformName: string, value: number): Effect;
  92325. /**
  92326. * Sets an int array on a uniform variable.
  92327. * @param uniformName Name of the variable.
  92328. * @param array array to be set.
  92329. * @returns this effect.
  92330. */
  92331. setIntArray(uniformName: string, array: Int32Array): Effect;
  92332. /**
  92333. * 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)
  92334. * @param uniformName Name of the variable.
  92335. * @param array array to be set.
  92336. * @returns this effect.
  92337. */
  92338. setIntArray2(uniformName: string, array: Int32Array): Effect;
  92339. /**
  92340. * 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)
  92341. * @param uniformName Name of the variable.
  92342. * @param array array to be set.
  92343. * @returns this effect.
  92344. */
  92345. setIntArray3(uniformName: string, array: Int32Array): Effect;
  92346. /**
  92347. * 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)
  92348. * @param uniformName Name of the variable.
  92349. * @param array array to be set.
  92350. * @returns this effect.
  92351. */
  92352. setIntArray4(uniformName: string, array: Int32Array): Effect;
  92353. /**
  92354. * Sets an float array on a uniform variable.
  92355. * @param uniformName Name of the variable.
  92356. * @param array array to be set.
  92357. * @returns this effect.
  92358. */
  92359. setFloatArray(uniformName: string, array: Float32Array): Effect;
  92360. /**
  92361. * 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)
  92362. * @param uniformName Name of the variable.
  92363. * @param array array to be set.
  92364. * @returns this effect.
  92365. */
  92366. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  92367. /**
  92368. * 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)
  92369. * @param uniformName Name of the variable.
  92370. * @param array array to be set.
  92371. * @returns this effect.
  92372. */
  92373. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  92374. /**
  92375. * 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)
  92376. * @param uniformName Name of the variable.
  92377. * @param array array to be set.
  92378. * @returns this effect.
  92379. */
  92380. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  92381. /**
  92382. * Sets an array on a uniform variable.
  92383. * @param uniformName Name of the variable.
  92384. * @param array array to be set.
  92385. * @returns this effect.
  92386. */
  92387. setArray(uniformName: string, array: number[]): Effect;
  92388. /**
  92389. * 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)
  92390. * @param uniformName Name of the variable.
  92391. * @param array array to be set.
  92392. * @returns this effect.
  92393. */
  92394. setArray2(uniformName: string, array: number[]): Effect;
  92395. /**
  92396. * 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)
  92397. * @param uniformName Name of the variable.
  92398. * @param array array to be set.
  92399. * @returns this effect.
  92400. */
  92401. setArray3(uniformName: string, array: number[]): Effect;
  92402. /**
  92403. * 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)
  92404. * @param uniformName Name of the variable.
  92405. * @param array array to be set.
  92406. * @returns this effect.
  92407. */
  92408. setArray4(uniformName: string, array: number[]): Effect;
  92409. /**
  92410. * Sets matrices on a uniform variable.
  92411. * @param uniformName Name of the variable.
  92412. * @param matrices matrices to be set.
  92413. * @returns this effect.
  92414. */
  92415. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  92416. /**
  92417. * Sets matrix on a uniform variable.
  92418. * @param uniformName Name of the variable.
  92419. * @param matrix matrix to be set.
  92420. * @returns this effect.
  92421. */
  92422. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  92423. /**
  92424. * 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)
  92425. * @param uniformName Name of the variable.
  92426. * @param matrix matrix to be set.
  92427. * @returns this effect.
  92428. */
  92429. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  92430. /**
  92431. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  92432. * @param uniformName Name of the variable.
  92433. * @param matrix matrix to be set.
  92434. * @returns this effect.
  92435. */
  92436. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  92437. /**
  92438. * Sets a float on a uniform variable.
  92439. * @param uniformName Name of the variable.
  92440. * @param value value to be set.
  92441. * @returns this effect.
  92442. */
  92443. setFloat(uniformName: string, value: number): Effect;
  92444. /**
  92445. * Sets a boolean on a uniform variable.
  92446. * @param uniformName Name of the variable.
  92447. * @param bool value to be set.
  92448. * @returns this effect.
  92449. */
  92450. setBool(uniformName: string, bool: boolean): Effect;
  92451. /**
  92452. * Sets a Vector2 on a uniform variable.
  92453. * @param uniformName Name of the variable.
  92454. * @param vector2 vector2 to be set.
  92455. * @returns this effect.
  92456. */
  92457. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  92458. /**
  92459. * Sets a float2 on a uniform variable.
  92460. * @param uniformName Name of the variable.
  92461. * @param x First float in float2.
  92462. * @param y Second float in float2.
  92463. * @returns this effect.
  92464. */
  92465. setFloat2(uniformName: string, x: number, y: number): Effect;
  92466. /**
  92467. * Sets a Vector3 on a uniform variable.
  92468. * @param uniformName Name of the variable.
  92469. * @param vector3 Value to be set.
  92470. * @returns this effect.
  92471. */
  92472. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  92473. /**
  92474. * Sets a float3 on a uniform variable.
  92475. * @param uniformName Name of the variable.
  92476. * @param x First float in float3.
  92477. * @param y Second float in float3.
  92478. * @param z Third float in float3.
  92479. * @returns this effect.
  92480. */
  92481. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  92482. /**
  92483. * Sets a Vector4 on a uniform variable.
  92484. * @param uniformName Name of the variable.
  92485. * @param vector4 Value to be set.
  92486. * @returns this effect.
  92487. */
  92488. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  92489. /**
  92490. * Sets a float4 on a uniform variable.
  92491. * @param uniformName Name of the variable.
  92492. * @param x First float in float4.
  92493. * @param y Second float in float4.
  92494. * @param z Third float in float4.
  92495. * @param w Fourth float in float4.
  92496. * @returns this effect.
  92497. */
  92498. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  92499. /**
  92500. * Sets a Color3 on a uniform variable.
  92501. * @param uniformName Name of the variable.
  92502. * @param color3 Value to be set.
  92503. * @returns this effect.
  92504. */
  92505. setColor3(uniformName: string, color3: IColor3Like): Effect;
  92506. /**
  92507. * Sets a Color4 on a uniform variable.
  92508. * @param uniformName Name of the variable.
  92509. * @param color3 Value to be set.
  92510. * @param alpha Alpha value to be set.
  92511. * @returns this effect.
  92512. */
  92513. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  92514. /**
  92515. * Sets a Color4 on a uniform variable
  92516. * @param uniformName defines the name of the variable
  92517. * @param color4 defines the value to be set
  92518. * @returns this effect.
  92519. */
  92520. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  92521. /** Release all associated resources */
  92522. dispose(): void;
  92523. /**
  92524. * This function will add a new shader to the shader store
  92525. * @param name the name of the shader
  92526. * @param pixelShader optional pixel shader content
  92527. * @param vertexShader optional vertex shader content
  92528. */
  92529. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  92530. /**
  92531. * Store of each shader (The can be looked up using effect.key)
  92532. */
  92533. static ShadersStore: {
  92534. [key: string]: string;
  92535. };
  92536. /**
  92537. * Store of each included file for a shader (The can be looked up using effect.key)
  92538. */
  92539. static IncludesShadersStore: {
  92540. [key: string]: string;
  92541. };
  92542. /**
  92543. * Resets the cache of effects.
  92544. */
  92545. static ResetCache(): void;
  92546. }
  92547. }
  92548. declare module BABYLON {
  92549. /**
  92550. * Uniform buffer objects.
  92551. *
  92552. * Handles blocks of uniform on the GPU.
  92553. *
  92554. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  92555. *
  92556. * For more information, please refer to :
  92557. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  92558. */
  92559. export class UniformBuffer {
  92560. private _engine;
  92561. private _buffer;
  92562. private _data;
  92563. private _bufferData;
  92564. private _dynamic?;
  92565. private _uniformLocations;
  92566. private _uniformSizes;
  92567. private _uniformLocationPointer;
  92568. private _needSync;
  92569. private _noUBO;
  92570. private _currentEffect;
  92571. private static _MAX_UNIFORM_SIZE;
  92572. private static _tempBuffer;
  92573. /**
  92574. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  92575. * This is dynamic to allow compat with webgl 1 and 2.
  92576. * You will need to pass the name of the uniform as well as the value.
  92577. */
  92578. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  92579. /**
  92580. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  92581. * This is dynamic to allow compat with webgl 1 and 2.
  92582. * You will need to pass the name of the uniform as well as the value.
  92583. */
  92584. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  92585. /**
  92586. * Lambda to Update a single float in a uniform buffer.
  92587. * This is dynamic to allow compat with webgl 1 and 2.
  92588. * You will need to pass the name of the uniform as well as the value.
  92589. */
  92590. updateFloat: (name: string, x: number) => void;
  92591. /**
  92592. * Lambda to Update a vec2 of float in a uniform buffer.
  92593. * This is dynamic to allow compat with webgl 1 and 2.
  92594. * You will need to pass the name of the uniform as well as the value.
  92595. */
  92596. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  92597. /**
  92598. * Lambda to Update a vec3 of float in a uniform buffer.
  92599. * This is dynamic to allow compat with webgl 1 and 2.
  92600. * You will need to pass the name of the uniform as well as the value.
  92601. */
  92602. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  92603. /**
  92604. * Lambda to Update a vec4 of float in a uniform buffer.
  92605. * This is dynamic to allow compat with webgl 1 and 2.
  92606. * You will need to pass the name of the uniform as well as the value.
  92607. */
  92608. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  92609. /**
  92610. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  92611. * This is dynamic to allow compat with webgl 1 and 2.
  92612. * You will need to pass the name of the uniform as well as the value.
  92613. */
  92614. updateMatrix: (name: string, mat: Matrix) => void;
  92615. /**
  92616. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  92617. * This is dynamic to allow compat with webgl 1 and 2.
  92618. * You will need to pass the name of the uniform as well as the value.
  92619. */
  92620. updateVector3: (name: string, vector: Vector3) => void;
  92621. /**
  92622. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  92623. * This is dynamic to allow compat with webgl 1 and 2.
  92624. * You will need to pass the name of the uniform as well as the value.
  92625. */
  92626. updateVector4: (name: string, vector: Vector4) => void;
  92627. /**
  92628. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  92629. * This is dynamic to allow compat with webgl 1 and 2.
  92630. * You will need to pass the name of the uniform as well as the value.
  92631. */
  92632. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  92633. /**
  92634. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  92635. * This is dynamic to allow compat with webgl 1 and 2.
  92636. * You will need to pass the name of the uniform as well as the value.
  92637. */
  92638. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  92639. /**
  92640. * Instantiates a new Uniform buffer objects.
  92641. *
  92642. * Handles blocks of uniform on the GPU.
  92643. *
  92644. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  92645. *
  92646. * For more information, please refer to :
  92647. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  92648. * @param engine Define the engine the buffer is associated with
  92649. * @param data Define the data contained in the buffer
  92650. * @param dynamic Define if the buffer is updatable
  92651. */
  92652. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  92653. /**
  92654. * Indicates if the buffer is using the WebGL2 UBO implementation,
  92655. * or just falling back on setUniformXXX calls.
  92656. */
  92657. readonly useUbo: boolean;
  92658. /**
  92659. * Indicates if the WebGL underlying uniform buffer is in sync
  92660. * with the javascript cache data.
  92661. */
  92662. readonly isSync: boolean;
  92663. /**
  92664. * Indicates if the WebGL underlying uniform buffer is dynamic.
  92665. * Also, a dynamic UniformBuffer will disable cache verification and always
  92666. * update the underlying WebGL uniform buffer to the GPU.
  92667. * @returns if Dynamic, otherwise false
  92668. */
  92669. isDynamic(): boolean;
  92670. /**
  92671. * The data cache on JS side.
  92672. * @returns the underlying data as a float array
  92673. */
  92674. getData(): Float32Array;
  92675. /**
  92676. * The underlying WebGL Uniform buffer.
  92677. * @returns the webgl buffer
  92678. */
  92679. getBuffer(): Nullable<DataBuffer>;
  92680. /**
  92681. * std140 layout specifies how to align data within an UBO structure.
  92682. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  92683. * for specs.
  92684. */
  92685. private _fillAlignment;
  92686. /**
  92687. * Adds an uniform in the buffer.
  92688. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  92689. * for the layout to be correct !
  92690. * @param name Name of the uniform, as used in the uniform block in the shader.
  92691. * @param size Data size, or data directly.
  92692. */
  92693. addUniform(name: string, size: number | number[]): void;
  92694. /**
  92695. * Adds a Matrix 4x4 to the uniform buffer.
  92696. * @param name Name of the uniform, as used in the uniform block in the shader.
  92697. * @param mat A 4x4 matrix.
  92698. */
  92699. addMatrix(name: string, mat: Matrix): void;
  92700. /**
  92701. * Adds a vec2 to the uniform buffer.
  92702. * @param name Name of the uniform, as used in the uniform block in the shader.
  92703. * @param x Define the x component value of the vec2
  92704. * @param y Define the y component value of the vec2
  92705. */
  92706. addFloat2(name: string, x: number, y: number): void;
  92707. /**
  92708. * Adds a vec3 to the uniform buffer.
  92709. * @param name Name of the uniform, as used in the uniform block in the shader.
  92710. * @param x Define the x component value of the vec3
  92711. * @param y Define the y component value of the vec3
  92712. * @param z Define the z component value of the vec3
  92713. */
  92714. addFloat3(name: string, x: number, y: number, z: number): void;
  92715. /**
  92716. * Adds a vec3 to the uniform buffer.
  92717. * @param name Name of the uniform, as used in the uniform block in the shader.
  92718. * @param color Define the vec3 from a Color
  92719. */
  92720. addColor3(name: string, color: Color3): void;
  92721. /**
  92722. * Adds a vec4 to the uniform buffer.
  92723. * @param name Name of the uniform, as used in the uniform block in the shader.
  92724. * @param color Define the rgb components from a Color
  92725. * @param alpha Define the a component of the vec4
  92726. */
  92727. addColor4(name: string, color: Color3, alpha: number): void;
  92728. /**
  92729. * Adds a vec3 to the uniform buffer.
  92730. * @param name Name of the uniform, as used in the uniform block in the shader.
  92731. * @param vector Define the vec3 components from a Vector
  92732. */
  92733. addVector3(name: string, vector: Vector3): void;
  92734. /**
  92735. * Adds a Matrix 3x3 to the uniform buffer.
  92736. * @param name Name of the uniform, as used in the uniform block in the shader.
  92737. */
  92738. addMatrix3x3(name: string): void;
  92739. /**
  92740. * Adds a Matrix 2x2 to the uniform buffer.
  92741. * @param name Name of the uniform, as used in the uniform block in the shader.
  92742. */
  92743. addMatrix2x2(name: string): void;
  92744. /**
  92745. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  92746. */
  92747. create(): void;
  92748. /** @hidden */
  92749. _rebuild(): void;
  92750. /**
  92751. * Updates the WebGL Uniform Buffer on the GPU.
  92752. * If the `dynamic` flag is set to true, no cache comparison is done.
  92753. * Otherwise, the buffer will be updated only if the cache differs.
  92754. */
  92755. update(): void;
  92756. /**
  92757. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  92758. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  92759. * @param data Define the flattened data
  92760. * @param size Define the size of the data.
  92761. */
  92762. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  92763. private _updateMatrix3x3ForUniform;
  92764. private _updateMatrix3x3ForEffect;
  92765. private _updateMatrix2x2ForEffect;
  92766. private _updateMatrix2x2ForUniform;
  92767. private _updateFloatForEffect;
  92768. private _updateFloatForUniform;
  92769. private _updateFloat2ForEffect;
  92770. private _updateFloat2ForUniform;
  92771. private _updateFloat3ForEffect;
  92772. private _updateFloat3ForUniform;
  92773. private _updateFloat4ForEffect;
  92774. private _updateFloat4ForUniform;
  92775. private _updateMatrixForEffect;
  92776. private _updateMatrixForUniform;
  92777. private _updateVector3ForEffect;
  92778. private _updateVector3ForUniform;
  92779. private _updateVector4ForEffect;
  92780. private _updateVector4ForUniform;
  92781. private _updateColor3ForEffect;
  92782. private _updateColor3ForUniform;
  92783. private _updateColor4ForEffect;
  92784. private _updateColor4ForUniform;
  92785. /**
  92786. * Sets a sampler uniform on the effect.
  92787. * @param name Define the name of the sampler.
  92788. * @param texture Define the texture to set in the sampler
  92789. */
  92790. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  92791. /**
  92792. * Directly updates the value of the uniform in the cache AND on the GPU.
  92793. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  92794. * @param data Define the flattened data
  92795. */
  92796. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  92797. /**
  92798. * Binds this uniform buffer to an effect.
  92799. * @param effect Define the effect to bind the buffer to
  92800. * @param name Name of the uniform block in the shader.
  92801. */
  92802. bindToEffect(effect: Effect, name: string): void;
  92803. /**
  92804. * Disposes the uniform buffer.
  92805. */
  92806. dispose(): void;
  92807. }
  92808. }
  92809. declare module BABYLON {
  92810. /**
  92811. * Class used to work with sound analyzer using fast fourier transform (FFT)
  92812. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92813. */
  92814. export class Analyser {
  92815. /**
  92816. * Gets or sets the smoothing
  92817. * @ignorenaming
  92818. */
  92819. SMOOTHING: number;
  92820. /**
  92821. * Gets or sets the FFT table size
  92822. * @ignorenaming
  92823. */
  92824. FFT_SIZE: number;
  92825. /**
  92826. * Gets or sets the bar graph amplitude
  92827. * @ignorenaming
  92828. */
  92829. BARGRAPHAMPLITUDE: number;
  92830. /**
  92831. * Gets or sets the position of the debug canvas
  92832. * @ignorenaming
  92833. */
  92834. DEBUGCANVASPOS: {
  92835. x: number;
  92836. y: number;
  92837. };
  92838. /**
  92839. * Gets or sets the debug canvas size
  92840. * @ignorenaming
  92841. */
  92842. DEBUGCANVASSIZE: {
  92843. width: number;
  92844. height: number;
  92845. };
  92846. private _byteFreqs;
  92847. private _byteTime;
  92848. private _floatFreqs;
  92849. private _webAudioAnalyser;
  92850. private _debugCanvas;
  92851. private _debugCanvasContext;
  92852. private _scene;
  92853. private _registerFunc;
  92854. private _audioEngine;
  92855. /**
  92856. * Creates a new analyser
  92857. * @param scene defines hosting scene
  92858. */
  92859. constructor(scene: Scene);
  92860. /**
  92861. * Get the number of data values you will have to play with for the visualization
  92862. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  92863. * @returns a number
  92864. */
  92865. getFrequencyBinCount(): number;
  92866. /**
  92867. * Gets the current frequency data as a byte array
  92868. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  92869. * @returns a Uint8Array
  92870. */
  92871. getByteFrequencyData(): Uint8Array;
  92872. /**
  92873. * Gets the current waveform as a byte array
  92874. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  92875. * @returns a Uint8Array
  92876. */
  92877. getByteTimeDomainData(): Uint8Array;
  92878. /**
  92879. * Gets the current frequency data as a float array
  92880. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  92881. * @returns a Float32Array
  92882. */
  92883. getFloatFrequencyData(): Float32Array;
  92884. /**
  92885. * Renders the debug canvas
  92886. */
  92887. drawDebugCanvas(): void;
  92888. /**
  92889. * Stops rendering the debug canvas and removes it
  92890. */
  92891. stopDebugCanvas(): void;
  92892. /**
  92893. * Connects two audio nodes
  92894. * @param inputAudioNode defines first node to connect
  92895. * @param outputAudioNode defines second node to connect
  92896. */
  92897. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  92898. /**
  92899. * Releases all associated resources
  92900. */
  92901. dispose(): void;
  92902. }
  92903. }
  92904. declare module BABYLON {
  92905. /**
  92906. * This represents an audio engine and it is responsible
  92907. * to play, synchronize and analyse sounds throughout the application.
  92908. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92909. */
  92910. export interface IAudioEngine extends IDisposable {
  92911. /**
  92912. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  92913. */
  92914. readonly canUseWebAudio: boolean;
  92915. /**
  92916. * Gets the current AudioContext if available.
  92917. */
  92918. readonly audioContext: Nullable<AudioContext>;
  92919. /**
  92920. * The master gain node defines the global audio volume of your audio engine.
  92921. */
  92922. readonly masterGain: GainNode;
  92923. /**
  92924. * Gets whether or not mp3 are supported by your browser.
  92925. */
  92926. readonly isMP3supported: boolean;
  92927. /**
  92928. * Gets whether or not ogg are supported by your browser.
  92929. */
  92930. readonly isOGGsupported: boolean;
  92931. /**
  92932. * Defines if Babylon should emit a warning if WebAudio is not supported.
  92933. * @ignoreNaming
  92934. */
  92935. WarnedWebAudioUnsupported: boolean;
  92936. /**
  92937. * Defines if the audio engine relies on a custom unlocked button.
  92938. * In this case, the embedded button will not be displayed.
  92939. */
  92940. useCustomUnlockedButton: boolean;
  92941. /**
  92942. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  92943. */
  92944. readonly unlocked: boolean;
  92945. /**
  92946. * Event raised when audio has been unlocked on the browser.
  92947. */
  92948. onAudioUnlockedObservable: Observable<AudioEngine>;
  92949. /**
  92950. * Event raised when audio has been locked on the browser.
  92951. */
  92952. onAudioLockedObservable: Observable<AudioEngine>;
  92953. /**
  92954. * Flags the audio engine in Locked state.
  92955. * This happens due to new browser policies preventing audio to autoplay.
  92956. */
  92957. lock(): void;
  92958. /**
  92959. * Unlocks the audio engine once a user action has been done on the dom.
  92960. * This is helpful to resume play once browser policies have been satisfied.
  92961. */
  92962. unlock(): void;
  92963. }
  92964. /**
  92965. * This represents the default audio engine used in babylon.
  92966. * It is responsible to play, synchronize and analyse sounds throughout the application.
  92967. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92968. */
  92969. export class AudioEngine implements IAudioEngine {
  92970. private _audioContext;
  92971. private _audioContextInitialized;
  92972. private _muteButton;
  92973. private _hostElement;
  92974. /**
  92975. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  92976. */
  92977. canUseWebAudio: boolean;
  92978. /**
  92979. * The master gain node defines the global audio volume of your audio engine.
  92980. */
  92981. masterGain: GainNode;
  92982. /**
  92983. * Defines if Babylon should emit a warning if WebAudio is not supported.
  92984. * @ignoreNaming
  92985. */
  92986. WarnedWebAudioUnsupported: boolean;
  92987. /**
  92988. * Gets whether or not mp3 are supported by your browser.
  92989. */
  92990. isMP3supported: boolean;
  92991. /**
  92992. * Gets whether or not ogg are supported by your browser.
  92993. */
  92994. isOGGsupported: boolean;
  92995. /**
  92996. * Gets whether audio has been unlocked on the device.
  92997. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  92998. * a user interaction has happened.
  92999. */
  93000. unlocked: boolean;
  93001. /**
  93002. * Defines if the audio engine relies on a custom unlocked button.
  93003. * In this case, the embedded button will not be displayed.
  93004. */
  93005. useCustomUnlockedButton: boolean;
  93006. /**
  93007. * Event raised when audio has been unlocked on the browser.
  93008. */
  93009. onAudioUnlockedObservable: Observable<AudioEngine>;
  93010. /**
  93011. * Event raised when audio has been locked on the browser.
  93012. */
  93013. onAudioLockedObservable: Observable<AudioEngine>;
  93014. /**
  93015. * Gets the current AudioContext if available.
  93016. */
  93017. readonly audioContext: Nullable<AudioContext>;
  93018. private _connectedAnalyser;
  93019. /**
  93020. * Instantiates a new audio engine.
  93021. *
  93022. * There should be only one per page as some browsers restrict the number
  93023. * of audio contexts you can create.
  93024. * @param hostElement defines the host element where to display the mute icon if necessary
  93025. */
  93026. constructor(hostElement?: Nullable<HTMLElement>);
  93027. /**
  93028. * Flags the audio engine in Locked state.
  93029. * This happens due to new browser policies preventing audio to autoplay.
  93030. */
  93031. lock(): void;
  93032. /**
  93033. * Unlocks the audio engine once a user action has been done on the dom.
  93034. * This is helpful to resume play once browser policies have been satisfied.
  93035. */
  93036. unlock(): void;
  93037. private _resumeAudioContext;
  93038. private _initializeAudioContext;
  93039. private _tryToRun;
  93040. private _triggerRunningState;
  93041. private _triggerSuspendedState;
  93042. private _displayMuteButton;
  93043. private _moveButtonToTopLeft;
  93044. private _onResize;
  93045. private _hideMuteButton;
  93046. /**
  93047. * Destroy and release the resources associated with the audio ccontext.
  93048. */
  93049. dispose(): void;
  93050. /**
  93051. * Gets the global volume sets on the master gain.
  93052. * @returns the global volume if set or -1 otherwise
  93053. */
  93054. getGlobalVolume(): number;
  93055. /**
  93056. * Sets the global volume of your experience (sets on the master gain).
  93057. * @param newVolume Defines the new global volume of the application
  93058. */
  93059. setGlobalVolume(newVolume: number): void;
  93060. /**
  93061. * Connect the audio engine to an audio analyser allowing some amazing
  93062. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  93063. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  93064. * @param analyser The analyser to connect to the engine
  93065. */
  93066. connectToAnalyser(analyser: Analyser): void;
  93067. }
  93068. }
  93069. declare module BABYLON {
  93070. /**
  93071. * Interface used to present a loading screen while loading a scene
  93072. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  93073. */
  93074. export interface ILoadingScreen {
  93075. /**
  93076. * Function called to display the loading screen
  93077. */
  93078. displayLoadingUI: () => void;
  93079. /**
  93080. * Function called to hide the loading screen
  93081. */
  93082. hideLoadingUI: () => void;
  93083. /**
  93084. * Gets or sets the color to use for the background
  93085. */
  93086. loadingUIBackgroundColor: string;
  93087. /**
  93088. * Gets or sets the text to display while loading
  93089. */
  93090. loadingUIText: string;
  93091. }
  93092. /**
  93093. * Class used for the default loading screen
  93094. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  93095. */
  93096. export class DefaultLoadingScreen implements ILoadingScreen {
  93097. private _renderingCanvas;
  93098. private _loadingText;
  93099. private _loadingDivBackgroundColor;
  93100. private _loadingDiv;
  93101. private _loadingTextDiv;
  93102. /** Gets or sets the logo url to use for the default loading screen */
  93103. static DefaultLogoUrl: string;
  93104. /** Gets or sets the spinner url to use for the default loading screen */
  93105. static DefaultSpinnerUrl: string;
  93106. /**
  93107. * Creates a new default loading screen
  93108. * @param _renderingCanvas defines the canvas used to render the scene
  93109. * @param _loadingText defines the default text to display
  93110. * @param _loadingDivBackgroundColor defines the default background color
  93111. */
  93112. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  93113. /**
  93114. * Function called to display the loading screen
  93115. */
  93116. displayLoadingUI(): void;
  93117. /**
  93118. * Function called to hide the loading screen
  93119. */
  93120. hideLoadingUI(): void;
  93121. /**
  93122. * Gets or sets the text to display while loading
  93123. */
  93124. loadingUIText: string;
  93125. /**
  93126. * Gets or sets the color to use for the background
  93127. */
  93128. loadingUIBackgroundColor: string;
  93129. private _resizeLoadingUI;
  93130. }
  93131. }
  93132. declare module BABYLON {
  93133. /** @hidden */
  93134. export class WebGLPipelineContext implements IPipelineContext {
  93135. engine: Engine;
  93136. program: Nullable<WebGLProgram>;
  93137. context?: WebGLRenderingContext;
  93138. vertexShader?: WebGLShader;
  93139. fragmentShader?: WebGLShader;
  93140. isParallelCompiled: boolean;
  93141. onCompiled?: () => void;
  93142. transformFeedback?: WebGLTransformFeedback | null;
  93143. readonly isAsync: boolean;
  93144. readonly isReady: boolean;
  93145. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  93146. }
  93147. }
  93148. declare module BABYLON {
  93149. /** @hidden */
  93150. export class WebGLDataBuffer extends DataBuffer {
  93151. private _buffer;
  93152. constructor(resource: WebGLBuffer);
  93153. readonly underlyingResource: any;
  93154. }
  93155. }
  93156. declare module BABYLON {
  93157. /** @hidden */
  93158. export class WebGL2ShaderProcessor implements IShaderProcessor {
  93159. attributeProcessor(attribute: string): string;
  93160. varyingProcessor(varying: string, isFragment: boolean): string;
  93161. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  93162. }
  93163. }
  93164. declare module BABYLON {
  93165. /**
  93166. * This class is used to track a performance counter which is number based.
  93167. * The user has access to many properties which give statistics of different nature.
  93168. *
  93169. * The implementer can track two kinds of Performance Counter: time and count.
  93170. * 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.
  93171. * 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.
  93172. */
  93173. export class PerfCounter {
  93174. /**
  93175. * Gets or sets a global boolean to turn on and off all the counters
  93176. */
  93177. static Enabled: boolean;
  93178. /**
  93179. * Returns the smallest value ever
  93180. */
  93181. readonly min: number;
  93182. /**
  93183. * Returns the biggest value ever
  93184. */
  93185. readonly max: number;
  93186. /**
  93187. * Returns the average value since the performance counter is running
  93188. */
  93189. readonly average: number;
  93190. /**
  93191. * Returns the average value of the last second the counter was monitored
  93192. */
  93193. readonly lastSecAverage: number;
  93194. /**
  93195. * Returns the current value
  93196. */
  93197. readonly current: number;
  93198. /**
  93199. * Gets the accumulated total
  93200. */
  93201. readonly total: number;
  93202. /**
  93203. * Gets the total value count
  93204. */
  93205. readonly count: number;
  93206. /**
  93207. * Creates a new counter
  93208. */
  93209. constructor();
  93210. /**
  93211. * Call this method to start monitoring a new frame.
  93212. * 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.
  93213. */
  93214. fetchNewFrame(): void;
  93215. /**
  93216. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  93217. * @param newCount the count value to add to the monitored count
  93218. * @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.
  93219. */
  93220. addCount(newCount: number, fetchResult: boolean): void;
  93221. /**
  93222. * Start monitoring this performance counter
  93223. */
  93224. beginMonitoring(): void;
  93225. /**
  93226. * Compute the time lapsed since the previous beginMonitoring() call.
  93227. * @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
  93228. */
  93229. endMonitoring(newFrame?: boolean): void;
  93230. private _fetchResult;
  93231. private _startMonitoringTime;
  93232. private _min;
  93233. private _max;
  93234. private _average;
  93235. private _current;
  93236. private _totalValueCount;
  93237. private _totalAccumulated;
  93238. private _lastSecAverage;
  93239. private _lastSecAccumulated;
  93240. private _lastSecTime;
  93241. private _lastSecValueCount;
  93242. }
  93243. }
  93244. declare module BABYLON {
  93245. /**
  93246. * Interface for any object that can request an animation frame
  93247. */
  93248. export interface ICustomAnimationFrameRequester {
  93249. /**
  93250. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  93251. */
  93252. renderFunction?: Function;
  93253. /**
  93254. * Called to request the next frame to render to
  93255. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  93256. */
  93257. requestAnimationFrame: Function;
  93258. /**
  93259. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  93260. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  93261. */
  93262. requestID?: number;
  93263. }
  93264. }
  93265. declare module BABYLON {
  93266. /**
  93267. * Settings for finer control over video usage
  93268. */
  93269. export interface VideoTextureSettings {
  93270. /**
  93271. * Applies `autoplay` to video, if specified
  93272. */
  93273. autoPlay?: boolean;
  93274. /**
  93275. * Applies `loop` to video, if specified
  93276. */
  93277. loop?: boolean;
  93278. /**
  93279. * Automatically updates internal texture from video at every frame in the render loop
  93280. */
  93281. autoUpdateTexture: boolean;
  93282. /**
  93283. * Image src displayed during the video loading or until the user interacts with the video.
  93284. */
  93285. poster?: string;
  93286. }
  93287. /**
  93288. * If you want to display a video in your scene, this is the special texture for that.
  93289. * This special texture works similar to other textures, with the exception of a few parameters.
  93290. * @see https://doc.babylonjs.com/how_to/video_texture
  93291. */
  93292. export class VideoTexture extends Texture {
  93293. /**
  93294. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  93295. */
  93296. readonly autoUpdateTexture: boolean;
  93297. /**
  93298. * The video instance used by the texture internally
  93299. */
  93300. readonly video: HTMLVideoElement;
  93301. private _onUserActionRequestedObservable;
  93302. /**
  93303. * Event triggerd when a dom action is required by the user to play the video.
  93304. * This happens due to recent changes in browser policies preventing video to auto start.
  93305. */
  93306. readonly onUserActionRequestedObservable: Observable<Texture>;
  93307. private _generateMipMaps;
  93308. private _engine;
  93309. private _stillImageCaptured;
  93310. private _displayingPosterTexture;
  93311. private _settings;
  93312. private _createInternalTextureOnEvent;
  93313. /**
  93314. * Creates a video texture.
  93315. * If you want to display a video in your scene, this is the special texture for that.
  93316. * This special texture works similar to other textures, with the exception of a few parameters.
  93317. * @see https://doc.babylonjs.com/how_to/video_texture
  93318. * @param name optional name, will detect from video source, if not defined
  93319. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  93320. * @param scene is obviously the current scene.
  93321. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  93322. * @param invertY is false by default but can be used to invert video on Y axis
  93323. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  93324. * @param settings allows finer control over video usage
  93325. */
  93326. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  93327. private _getName;
  93328. private _getVideo;
  93329. private _createInternalTexture;
  93330. private reset;
  93331. /**
  93332. * @hidden Internal method to initiate `update`.
  93333. */
  93334. _rebuild(): void;
  93335. /**
  93336. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  93337. */
  93338. update(): void;
  93339. /**
  93340. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  93341. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  93342. */
  93343. updateTexture(isVisible: boolean): void;
  93344. protected _updateInternalTexture: () => void;
  93345. /**
  93346. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  93347. * @param url New url.
  93348. */
  93349. updateURL(url: string): void;
  93350. /**
  93351. * Dispose the texture and release its associated resources.
  93352. */
  93353. dispose(): void;
  93354. /**
  93355. * Creates a video texture straight from a stream.
  93356. * @param scene Define the scene the texture should be created in
  93357. * @param stream Define the stream the texture should be created from
  93358. * @returns The created video texture as a promise
  93359. */
  93360. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  93361. /**
  93362. * Creates a video texture straight from your WebCam video feed.
  93363. * @param scene Define the scene the texture should be created in
  93364. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  93365. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  93366. * @returns The created video texture as a promise
  93367. */
  93368. static CreateFromWebCamAsync(scene: Scene, constraints: {
  93369. minWidth: number;
  93370. maxWidth: number;
  93371. minHeight: number;
  93372. maxHeight: number;
  93373. deviceId: string;
  93374. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  93375. /**
  93376. * Creates a video texture straight from your WebCam video feed.
  93377. * @param scene Define the scene the texture should be created in
  93378. * @param onReady Define a callback to triggered once the texture will be ready
  93379. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  93380. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  93381. */
  93382. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  93383. minWidth: number;
  93384. maxWidth: number;
  93385. minHeight: number;
  93386. maxHeight: number;
  93387. deviceId: string;
  93388. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  93389. }
  93390. }
  93391. declare module BABYLON {
  93392. /**
  93393. * Defines the interface used by objects containing a viewport (like a camera)
  93394. */
  93395. interface IViewportOwnerLike {
  93396. /**
  93397. * Gets or sets the viewport
  93398. */
  93399. viewport: IViewportLike;
  93400. }
  93401. /**
  93402. * Interface for attribute information associated with buffer instanciation
  93403. */
  93404. export class InstancingAttributeInfo {
  93405. /**
  93406. * Index/offset of the attribute in the vertex shader
  93407. */
  93408. index: number;
  93409. /**
  93410. * size of the attribute, 1, 2, 3 or 4
  93411. */
  93412. attributeSize: number;
  93413. /**
  93414. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  93415. * default is FLOAT
  93416. */
  93417. attribyteType: number;
  93418. /**
  93419. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  93420. */
  93421. normalized: boolean;
  93422. /**
  93423. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  93424. */
  93425. offset: number;
  93426. /**
  93427. * Name of the GLSL attribute, for debugging purpose only
  93428. */
  93429. attributeName: string;
  93430. }
  93431. /**
  93432. * Define options used to create a depth texture
  93433. */
  93434. export class DepthTextureCreationOptions {
  93435. /** Specifies whether or not a stencil should be allocated in the texture */
  93436. generateStencil?: boolean;
  93437. /** Specifies whether or not bilinear filtering is enable on the texture */
  93438. bilinearFiltering?: boolean;
  93439. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  93440. comparisonFunction?: number;
  93441. /** Specifies if the created texture is a cube texture */
  93442. isCube?: boolean;
  93443. }
  93444. /**
  93445. * Class used to describe the capabilities of the engine relatively to the current browser
  93446. */
  93447. export class EngineCapabilities {
  93448. /** Maximum textures units per fragment shader */
  93449. maxTexturesImageUnits: number;
  93450. /** Maximum texture units per vertex shader */
  93451. maxVertexTextureImageUnits: number;
  93452. /** Maximum textures units in the entire pipeline */
  93453. maxCombinedTexturesImageUnits: number;
  93454. /** Maximum texture size */
  93455. maxTextureSize: number;
  93456. /** Maximum cube texture size */
  93457. maxCubemapTextureSize: number;
  93458. /** Maximum render texture size */
  93459. maxRenderTextureSize: number;
  93460. /** Maximum number of vertex attributes */
  93461. maxVertexAttribs: number;
  93462. /** Maximum number of varyings */
  93463. maxVaryingVectors: number;
  93464. /** Maximum number of uniforms per vertex shader */
  93465. maxVertexUniformVectors: number;
  93466. /** Maximum number of uniforms per fragment shader */
  93467. maxFragmentUniformVectors: number;
  93468. /** Defines if standard derivates (dx/dy) are supported */
  93469. standardDerivatives: boolean;
  93470. /** Defines if s3tc texture compression is supported */
  93471. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  93472. /** Defines if pvrtc texture compression is supported */
  93473. pvrtc: any;
  93474. /** Defines if etc1 texture compression is supported */
  93475. etc1: any;
  93476. /** Defines if etc2 texture compression is supported */
  93477. etc2: any;
  93478. /** Defines if astc texture compression is supported */
  93479. astc: any;
  93480. /** Defines if float textures are supported */
  93481. textureFloat: boolean;
  93482. /** Defines if vertex array objects are supported */
  93483. vertexArrayObject: boolean;
  93484. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  93485. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  93486. /** Gets the maximum level of anisotropy supported */
  93487. maxAnisotropy: number;
  93488. /** Defines if instancing is supported */
  93489. instancedArrays: boolean;
  93490. /** Defines if 32 bits indices are supported */
  93491. uintIndices: boolean;
  93492. /** Defines if high precision shaders are supported */
  93493. highPrecisionShaderSupported: boolean;
  93494. /** Defines if depth reading in the fragment shader is supported */
  93495. fragmentDepthSupported: boolean;
  93496. /** Defines if float texture linear filtering is supported*/
  93497. textureFloatLinearFiltering: boolean;
  93498. /** Defines if rendering to float textures is supported */
  93499. textureFloatRender: boolean;
  93500. /** Defines if half float textures are supported*/
  93501. textureHalfFloat: boolean;
  93502. /** Defines if half float texture linear filtering is supported*/
  93503. textureHalfFloatLinearFiltering: boolean;
  93504. /** Defines if rendering to half float textures is supported */
  93505. textureHalfFloatRender: boolean;
  93506. /** Defines if textureLOD shader command is supported */
  93507. textureLOD: boolean;
  93508. /** Defines if draw buffers extension is supported */
  93509. drawBuffersExtension: boolean;
  93510. /** Defines if depth textures are supported */
  93511. depthTextureExtension: boolean;
  93512. /** Defines if float color buffer are supported */
  93513. colorBufferFloat: boolean;
  93514. /** Gets disjoint timer query extension (null if not supported) */
  93515. timerQuery: EXT_disjoint_timer_query;
  93516. /** Defines if timestamp can be used with timer query */
  93517. canUseTimestampForTimerQuery: boolean;
  93518. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  93519. multiview: any;
  93520. /** Function used to let the system compiles shaders in background */
  93521. parallelShaderCompile: {
  93522. COMPLETION_STATUS_KHR: number;
  93523. };
  93524. }
  93525. /** Interface defining initialization parameters for Engine class */
  93526. export interface EngineOptions extends WebGLContextAttributes {
  93527. /**
  93528. * Defines if the engine should no exceed a specified device ratio
  93529. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  93530. */
  93531. limitDeviceRatio?: number;
  93532. /**
  93533. * Defines if webvr should be enabled automatically
  93534. * @see http://doc.babylonjs.com/how_to/webvr_camera
  93535. */
  93536. autoEnableWebVR?: boolean;
  93537. /**
  93538. * Defines if webgl2 should be turned off even if supported
  93539. * @see http://doc.babylonjs.com/features/webgl2
  93540. */
  93541. disableWebGL2Support?: boolean;
  93542. /**
  93543. * Defines if webaudio should be initialized as well
  93544. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93545. */
  93546. audioEngine?: boolean;
  93547. /**
  93548. * Defines if animations should run using a deterministic lock step
  93549. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  93550. */
  93551. deterministicLockstep?: boolean;
  93552. /** Defines the maximum steps to use with deterministic lock step mode */
  93553. lockstepMaxSteps?: number;
  93554. /**
  93555. * Defines that engine should ignore context lost events
  93556. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  93557. */
  93558. doNotHandleContextLost?: boolean;
  93559. /**
  93560. * Defines that engine should ignore modifying touch action attribute and style
  93561. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  93562. */
  93563. doNotHandleTouchAction?: boolean;
  93564. /**
  93565. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  93566. */
  93567. useHighPrecisionFloats?: boolean;
  93568. }
  93569. /**
  93570. * Defines the interface used by display changed events
  93571. */
  93572. export interface IDisplayChangedEventArgs {
  93573. /** Gets the vrDisplay object (if any) */
  93574. vrDisplay: Nullable<any>;
  93575. /** Gets a boolean indicating if webVR is supported */
  93576. vrSupported: boolean;
  93577. }
  93578. /**
  93579. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  93580. */
  93581. export class Engine {
  93582. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  93583. static ExceptionList: ({
  93584. key: string;
  93585. capture: string;
  93586. captureConstraint: number;
  93587. targets: string[];
  93588. } | {
  93589. key: string;
  93590. capture: null;
  93591. captureConstraint: null;
  93592. targets: string[];
  93593. })[];
  93594. /** Gets the list of created engines */
  93595. static readonly Instances: Engine[];
  93596. /**
  93597. * Gets the latest created engine
  93598. */
  93599. static readonly LastCreatedEngine: Nullable<Engine>;
  93600. /**
  93601. * Gets the latest created scene
  93602. */
  93603. static readonly LastCreatedScene: Nullable<Scene>;
  93604. /**
  93605. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  93606. * @param flag defines which part of the materials must be marked as dirty
  93607. * @param predicate defines a predicate used to filter which materials should be affected
  93608. */
  93609. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  93610. /** @hidden */
  93611. static _TextureLoaders: IInternalTextureLoader[];
  93612. /** Defines that alpha blending is disabled */
  93613. static readonly ALPHA_DISABLE: number;
  93614. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  93615. static readonly ALPHA_ADD: number;
  93616. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  93617. static readonly ALPHA_COMBINE: number;
  93618. /** Defines that alpha blending to DEST - SRC * DEST */
  93619. static readonly ALPHA_SUBTRACT: number;
  93620. /** Defines that alpha blending to SRC * DEST */
  93621. static readonly ALPHA_MULTIPLY: number;
  93622. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  93623. static readonly ALPHA_MAXIMIZED: number;
  93624. /** Defines that alpha blending to SRC + DEST */
  93625. static readonly ALPHA_ONEONE: number;
  93626. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  93627. static readonly ALPHA_PREMULTIPLIED: number;
  93628. /**
  93629. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  93630. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  93631. */
  93632. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  93633. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  93634. static readonly ALPHA_INTERPOLATE: number;
  93635. /**
  93636. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  93637. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  93638. */
  93639. static readonly ALPHA_SCREENMODE: number;
  93640. /** Defines that the ressource is not delayed*/
  93641. static readonly DELAYLOADSTATE_NONE: number;
  93642. /** Defines that the ressource was successfully delay loaded */
  93643. static readonly DELAYLOADSTATE_LOADED: number;
  93644. /** Defines that the ressource is currently delay loading */
  93645. static readonly DELAYLOADSTATE_LOADING: number;
  93646. /** Defines that the ressource is delayed and has not started loading */
  93647. static readonly DELAYLOADSTATE_NOTLOADED: number;
  93648. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  93649. static readonly NEVER: number;
  93650. /** 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 */
  93651. static readonly ALWAYS: number;
  93652. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  93653. static readonly LESS: number;
  93654. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  93655. static readonly EQUAL: number;
  93656. /** 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 */
  93657. static readonly LEQUAL: number;
  93658. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  93659. static readonly GREATER: number;
  93660. /** 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 */
  93661. static readonly GEQUAL: number;
  93662. /** 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 */
  93663. static readonly NOTEQUAL: number;
  93664. /** Passed to stencilOperation to specify that stencil value must be kept */
  93665. static readonly KEEP: number;
  93666. /** Passed to stencilOperation to specify that stencil value must be replaced */
  93667. static readonly REPLACE: number;
  93668. /** Passed to stencilOperation to specify that stencil value must be incremented */
  93669. static readonly INCR: number;
  93670. /** Passed to stencilOperation to specify that stencil value must be decremented */
  93671. static readonly DECR: number;
  93672. /** Passed to stencilOperation to specify that stencil value must be inverted */
  93673. static readonly INVERT: number;
  93674. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  93675. static readonly INCR_WRAP: number;
  93676. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  93677. static readonly DECR_WRAP: number;
  93678. /** Texture is not repeating outside of 0..1 UVs */
  93679. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  93680. /** Texture is repeating outside of 0..1 UVs */
  93681. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  93682. /** Texture is repeating and mirrored */
  93683. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  93684. /** ALPHA */
  93685. static readonly TEXTUREFORMAT_ALPHA: number;
  93686. /** LUMINANCE */
  93687. static readonly TEXTUREFORMAT_LUMINANCE: number;
  93688. /** LUMINANCE_ALPHA */
  93689. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  93690. /** RGB */
  93691. static readonly TEXTUREFORMAT_RGB: number;
  93692. /** RGBA */
  93693. static readonly TEXTUREFORMAT_RGBA: number;
  93694. /** RED */
  93695. static readonly TEXTUREFORMAT_RED: number;
  93696. /** RED (2nd reference) */
  93697. static readonly TEXTUREFORMAT_R: number;
  93698. /** RG */
  93699. static readonly TEXTUREFORMAT_RG: number;
  93700. /** RED_INTEGER */
  93701. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  93702. /** RED_INTEGER (2nd reference) */
  93703. static readonly TEXTUREFORMAT_R_INTEGER: number;
  93704. /** RG_INTEGER */
  93705. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  93706. /** RGB_INTEGER */
  93707. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  93708. /** RGBA_INTEGER */
  93709. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  93710. /** UNSIGNED_BYTE */
  93711. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  93712. /** UNSIGNED_BYTE (2nd reference) */
  93713. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  93714. /** FLOAT */
  93715. static readonly TEXTURETYPE_FLOAT: number;
  93716. /** HALF_FLOAT */
  93717. static readonly TEXTURETYPE_HALF_FLOAT: number;
  93718. /** BYTE */
  93719. static readonly TEXTURETYPE_BYTE: number;
  93720. /** SHORT */
  93721. static readonly TEXTURETYPE_SHORT: number;
  93722. /** UNSIGNED_SHORT */
  93723. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  93724. /** INT */
  93725. static readonly TEXTURETYPE_INT: number;
  93726. /** UNSIGNED_INT */
  93727. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  93728. /** UNSIGNED_SHORT_4_4_4_4 */
  93729. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  93730. /** UNSIGNED_SHORT_5_5_5_1 */
  93731. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  93732. /** UNSIGNED_SHORT_5_6_5 */
  93733. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  93734. /** UNSIGNED_INT_2_10_10_10_REV */
  93735. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  93736. /** UNSIGNED_INT_24_8 */
  93737. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  93738. /** UNSIGNED_INT_10F_11F_11F_REV */
  93739. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  93740. /** UNSIGNED_INT_5_9_9_9_REV */
  93741. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  93742. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  93743. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  93744. /** nearest is mag = nearest and min = nearest and mip = linear */
  93745. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  93746. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93747. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  93748. /** Trilinear is mag = linear and min = linear and mip = linear */
  93749. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  93750. /** nearest is mag = nearest and min = nearest and mip = linear */
  93751. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  93752. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93753. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  93754. /** Trilinear is mag = linear and min = linear and mip = linear */
  93755. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  93756. /** mag = nearest and min = nearest and mip = nearest */
  93757. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  93758. /** mag = nearest and min = linear and mip = nearest */
  93759. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  93760. /** mag = nearest and min = linear and mip = linear */
  93761. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  93762. /** mag = nearest and min = linear and mip = none */
  93763. static readonly TEXTURE_NEAREST_LINEAR: number;
  93764. /** mag = nearest and min = nearest and mip = none */
  93765. static readonly TEXTURE_NEAREST_NEAREST: number;
  93766. /** mag = linear and min = nearest and mip = nearest */
  93767. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  93768. /** mag = linear and min = nearest and mip = linear */
  93769. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  93770. /** mag = linear and min = linear and mip = none */
  93771. static readonly TEXTURE_LINEAR_LINEAR: number;
  93772. /** mag = linear and min = nearest and mip = none */
  93773. static readonly TEXTURE_LINEAR_NEAREST: number;
  93774. /** Explicit coordinates mode */
  93775. static readonly TEXTURE_EXPLICIT_MODE: number;
  93776. /** Spherical coordinates mode */
  93777. static readonly TEXTURE_SPHERICAL_MODE: number;
  93778. /** Planar coordinates mode */
  93779. static readonly TEXTURE_PLANAR_MODE: number;
  93780. /** Cubic coordinates mode */
  93781. static readonly TEXTURE_CUBIC_MODE: number;
  93782. /** Projection coordinates mode */
  93783. static readonly TEXTURE_PROJECTION_MODE: number;
  93784. /** Skybox coordinates mode */
  93785. static readonly TEXTURE_SKYBOX_MODE: number;
  93786. /** Inverse Cubic coordinates mode */
  93787. static readonly TEXTURE_INVCUBIC_MODE: number;
  93788. /** Equirectangular coordinates mode */
  93789. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  93790. /** Equirectangular Fixed coordinates mode */
  93791. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  93792. /** Equirectangular Fixed Mirrored coordinates mode */
  93793. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  93794. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  93795. static readonly SCALEMODE_FLOOR: number;
  93796. /** Defines that texture rescaling will look for the nearest power of 2 size */
  93797. static readonly SCALEMODE_NEAREST: number;
  93798. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  93799. static readonly SCALEMODE_CEILING: number;
  93800. /**
  93801. * Returns the current npm package of the sdk
  93802. */
  93803. static readonly NpmPackage: string;
  93804. /**
  93805. * Returns the current version of the framework
  93806. */
  93807. static readonly Version: string;
  93808. /**
  93809. * Returns a string describing the current engine
  93810. */
  93811. readonly description: string;
  93812. /**
  93813. * Gets or sets the epsilon value used by collision engine
  93814. */
  93815. static CollisionsEpsilon: number;
  93816. /**
  93817. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  93818. */
  93819. static ShadersRepository: string;
  93820. /**
  93821. * Method called to create the default loading screen.
  93822. * This can be overriden in your own app.
  93823. * @param canvas The rendering canvas element
  93824. * @returns The loading screen
  93825. */
  93826. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  93827. /**
  93828. * Method called to create the default rescale post process on each engine.
  93829. */
  93830. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  93831. /** @hidden */
  93832. _shaderProcessor: IShaderProcessor;
  93833. /**
  93834. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  93835. */
  93836. forcePOTTextures: boolean;
  93837. /**
  93838. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  93839. */
  93840. isFullscreen: boolean;
  93841. /**
  93842. * Gets a boolean indicating if the pointer is currently locked
  93843. */
  93844. isPointerLock: boolean;
  93845. /**
  93846. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  93847. */
  93848. cullBackFaces: boolean;
  93849. /**
  93850. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  93851. */
  93852. renderEvenInBackground: boolean;
  93853. /**
  93854. * Gets or sets a boolean indicating that cache can be kept between frames
  93855. */
  93856. preventCacheWipeBetweenFrames: boolean;
  93857. /**
  93858. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  93859. **/
  93860. enableOfflineSupport: boolean;
  93861. /**
  93862. * 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)
  93863. **/
  93864. disableManifestCheck: boolean;
  93865. /**
  93866. * Gets the list of created scenes
  93867. */
  93868. scenes: Scene[];
  93869. /**
  93870. * Event raised when a new scene is created
  93871. */
  93872. onNewSceneAddedObservable: Observable<Scene>;
  93873. /**
  93874. * Gets the list of created postprocesses
  93875. */
  93876. postProcesses: PostProcess[];
  93877. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  93878. validateShaderPrograms: boolean;
  93879. /**
  93880. * Observable event triggered each time the rendering canvas is resized
  93881. */
  93882. onResizeObservable: Observable<Engine>;
  93883. /**
  93884. * Observable event triggered each time the canvas loses focus
  93885. */
  93886. onCanvasBlurObservable: Observable<Engine>;
  93887. /**
  93888. * Observable event triggered each time the canvas gains focus
  93889. */
  93890. onCanvasFocusObservable: Observable<Engine>;
  93891. /**
  93892. * Observable event triggered each time the canvas receives pointerout event
  93893. */
  93894. onCanvasPointerOutObservable: Observable<PointerEvent>;
  93895. /**
  93896. * Observable event triggered before each texture is initialized
  93897. */
  93898. onBeforeTextureInitObservable: Observable<Texture>;
  93899. /**
  93900. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  93901. */
  93902. disableUniformBuffers: boolean;
  93903. /** @hidden */
  93904. _uniformBuffers: UniformBuffer[];
  93905. /**
  93906. * Gets a boolean indicating that the engine supports uniform buffers
  93907. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  93908. */
  93909. readonly supportsUniformBuffers: boolean;
  93910. /**
  93911. * Observable raised when the engine begins a new frame
  93912. */
  93913. onBeginFrameObservable: Observable<Engine>;
  93914. /**
  93915. * If set, will be used to request the next animation frame for the render loop
  93916. */
  93917. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  93918. /**
  93919. * Observable raised when the engine ends the current frame
  93920. */
  93921. onEndFrameObservable: Observable<Engine>;
  93922. /**
  93923. * Observable raised when the engine is about to compile a shader
  93924. */
  93925. onBeforeShaderCompilationObservable: Observable<Engine>;
  93926. /**
  93927. * Observable raised when the engine has jsut compiled a shader
  93928. */
  93929. onAfterShaderCompilationObservable: Observable<Engine>;
  93930. /** @hidden */
  93931. _gl: WebGLRenderingContext;
  93932. private _renderingCanvas;
  93933. private _windowIsBackground;
  93934. private _webGLVersion;
  93935. protected _highPrecisionShadersAllowed: boolean;
  93936. /** @hidden */
  93937. readonly _shouldUseHighPrecisionShader: boolean;
  93938. /**
  93939. * Gets a boolean indicating that only power of 2 textures are supported
  93940. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  93941. */
  93942. readonly needPOTTextures: boolean;
  93943. /** @hidden */
  93944. _badOS: boolean;
  93945. /** @hidden */
  93946. _badDesktopOS: boolean;
  93947. /**
  93948. * Gets the audio engine
  93949. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93950. * @ignorenaming
  93951. */
  93952. static audioEngine: IAudioEngine;
  93953. /**
  93954. * Default AudioEngine factory responsible of creating the Audio Engine.
  93955. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  93956. */
  93957. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  93958. /**
  93959. * Default offline support factory responsible of creating a tool used to store data locally.
  93960. * By default, this will create a Database object if the workload has been embedded.
  93961. */
  93962. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  93963. private _onFocus;
  93964. private _onBlur;
  93965. private _onCanvasPointerOut;
  93966. private _onCanvasBlur;
  93967. private _onCanvasFocus;
  93968. private _onFullscreenChange;
  93969. private _onPointerLockChange;
  93970. private _hardwareScalingLevel;
  93971. /** @hidden */
  93972. _caps: EngineCapabilities;
  93973. private _pointerLockRequested;
  93974. private _isStencilEnable;
  93975. private _colorWrite;
  93976. private _loadingScreen;
  93977. /** @hidden */
  93978. _drawCalls: PerfCounter;
  93979. private _glVersion;
  93980. private _glRenderer;
  93981. private _glVendor;
  93982. private _videoTextureSupported;
  93983. private _renderingQueueLaunched;
  93984. private _activeRenderLoops;
  93985. private _deterministicLockstep;
  93986. private _lockstepMaxSteps;
  93987. /**
  93988. * Observable signaled when a context lost event is raised
  93989. */
  93990. onContextLostObservable: Observable<Engine>;
  93991. /**
  93992. * Observable signaled when a context restored event is raised
  93993. */
  93994. onContextRestoredObservable: Observable<Engine>;
  93995. private _onContextLost;
  93996. private _onContextRestored;
  93997. private _contextWasLost;
  93998. /** @hidden */
  93999. _doNotHandleContextLost: boolean;
  94000. /**
  94001. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  94002. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  94003. */
  94004. doNotHandleContextLost: boolean;
  94005. private _performanceMonitor;
  94006. private _fps;
  94007. private _deltaTime;
  94008. /**
  94009. * Turn this value on if you want to pause FPS computation when in background
  94010. */
  94011. disablePerformanceMonitorInBackground: boolean;
  94012. /**
  94013. * Gets the performance monitor attached to this engine
  94014. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  94015. */
  94016. readonly performanceMonitor: PerformanceMonitor;
  94017. /**
  94018. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  94019. */
  94020. disableVertexArrayObjects: boolean;
  94021. /** @hidden */
  94022. protected _depthCullingState: _DepthCullingState;
  94023. /** @hidden */
  94024. protected _stencilState: _StencilState;
  94025. /** @hidden */
  94026. protected _alphaState: _AlphaState;
  94027. /** @hidden */
  94028. protected _alphaMode: number;
  94029. /** @hidden */
  94030. _internalTexturesCache: InternalTexture[];
  94031. /** @hidden */
  94032. protected _activeChannel: number;
  94033. private _currentTextureChannel;
  94034. /** @hidden */
  94035. protected _boundTexturesCache: {
  94036. [key: string]: Nullable<InternalTexture>;
  94037. };
  94038. /** @hidden */
  94039. protected _currentEffect: Nullable<Effect>;
  94040. /** @hidden */
  94041. protected _currentProgram: Nullable<WebGLProgram>;
  94042. private _compiledEffects;
  94043. private _vertexAttribArraysEnabled;
  94044. /** @hidden */
  94045. protected _cachedViewport: Nullable<IViewportLike>;
  94046. private _cachedVertexArrayObject;
  94047. /** @hidden */
  94048. protected _cachedVertexBuffers: any;
  94049. /** @hidden */
  94050. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  94051. /** @hidden */
  94052. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  94053. /** @hidden */
  94054. _currentRenderTarget: Nullable<InternalTexture>;
  94055. private _uintIndicesCurrentlySet;
  94056. private _currentBoundBuffer;
  94057. /** @hidden */
  94058. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  94059. private _currentBufferPointers;
  94060. private _currentInstanceLocations;
  94061. private _currentInstanceBuffers;
  94062. private _textureUnits;
  94063. /** @hidden */
  94064. _workingCanvas: Nullable<HTMLCanvasElement>;
  94065. /** @hidden */
  94066. _workingContext: Nullable<CanvasRenderingContext2D>;
  94067. private _rescalePostProcess;
  94068. private _dummyFramebuffer;
  94069. private _externalData;
  94070. /** @hidden */
  94071. _bindedRenderFunction: any;
  94072. private _vaoRecordInProgress;
  94073. private _mustWipeVertexAttributes;
  94074. private _emptyTexture;
  94075. private _emptyCubeTexture;
  94076. private _emptyTexture3D;
  94077. /** @hidden */
  94078. _frameHandler: number;
  94079. private _nextFreeTextureSlots;
  94080. private _maxSimultaneousTextures;
  94081. private _activeRequests;
  94082. private _texturesSupported;
  94083. /** @hidden */
  94084. _textureFormatInUse: Nullable<string>;
  94085. /**
  94086. * Gets the list of texture formats supported
  94087. */
  94088. readonly texturesSupported: Array<string>;
  94089. /**
  94090. * Gets the list of texture formats in use
  94091. */
  94092. readonly textureFormatInUse: Nullable<string>;
  94093. /**
  94094. * Gets the current viewport
  94095. */
  94096. readonly currentViewport: Nullable<IViewportLike>;
  94097. /**
  94098. * Gets the default empty texture
  94099. */
  94100. readonly emptyTexture: InternalTexture;
  94101. /**
  94102. * Gets the default empty 3D texture
  94103. */
  94104. readonly emptyTexture3D: InternalTexture;
  94105. /**
  94106. * Gets the default empty cube texture
  94107. */
  94108. readonly emptyCubeTexture: InternalTexture;
  94109. /**
  94110. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  94111. */
  94112. readonly premultipliedAlpha: boolean;
  94113. /**
  94114. * Creates a new engine
  94115. * @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
  94116. * @param antialias defines enable antialiasing (default: false)
  94117. * @param options defines further options to be sent to the getContext() function
  94118. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  94119. */
  94120. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  94121. /**
  94122. * Initializes a webVR display and starts listening to display change events
  94123. * The onVRDisplayChangedObservable will be notified upon these changes
  94124. * @returns The onVRDisplayChangedObservable
  94125. */
  94126. initWebVR(): Observable<IDisplayChangedEventArgs>;
  94127. /** @hidden */
  94128. _prepareVRComponent(): void;
  94129. /** @hidden */
  94130. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  94131. /** @hidden */
  94132. _submitVRFrame(): void;
  94133. /**
  94134. * Call this function to leave webVR mode
  94135. * Will do nothing if webVR is not supported or if there is no webVR device
  94136. * @see http://doc.babylonjs.com/how_to/webvr_camera
  94137. */
  94138. disableVR(): void;
  94139. /**
  94140. * Gets a boolean indicating that the system is in VR mode and is presenting
  94141. * @returns true if VR mode is engaged
  94142. */
  94143. isVRPresenting(): boolean;
  94144. /** @hidden */
  94145. _requestVRFrame(): void;
  94146. private _disableTouchAction;
  94147. private _rebuildInternalTextures;
  94148. private _rebuildEffects;
  94149. /**
  94150. * Gets a boolean indicating if all created effects are ready
  94151. * @returns true if all effects are ready
  94152. */
  94153. areAllEffectsReady(): boolean;
  94154. private _rebuildBuffers;
  94155. private _initGLContext;
  94156. /**
  94157. * Gets version of the current webGL context
  94158. */
  94159. readonly webGLVersion: number;
  94160. /**
  94161. * Gets a string idenfifying the name of the class
  94162. * @returns "Engine" string
  94163. */
  94164. getClassName(): string;
  94165. /**
  94166. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  94167. */
  94168. readonly isStencilEnable: boolean;
  94169. /** @hidden */
  94170. _prepareWorkingCanvas(): void;
  94171. /**
  94172. * Reset the texture cache to empty state
  94173. */
  94174. resetTextureCache(): void;
  94175. /**
  94176. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  94177. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94178. * @returns true if engine is in deterministic lock step mode
  94179. */
  94180. isDeterministicLockStep(): boolean;
  94181. /**
  94182. * Gets the max steps when engine is running in deterministic lock step
  94183. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94184. * @returns the max steps
  94185. */
  94186. getLockstepMaxSteps(): number;
  94187. /**
  94188. * Gets an object containing information about the current webGL context
  94189. * @returns an object containing the vender, the renderer and the version of the current webGL context
  94190. */
  94191. getGlInfo(): {
  94192. vendor: string;
  94193. renderer: string;
  94194. version: string;
  94195. };
  94196. /**
  94197. * Gets current aspect ratio
  94198. * @param viewportOwner defines the camera to use to get the aspect ratio
  94199. * @param useScreen defines if screen size must be used (or the current render target if any)
  94200. * @returns a number defining the aspect ratio
  94201. */
  94202. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  94203. /**
  94204. * Gets current screen aspect ratio
  94205. * @returns a number defining the aspect ratio
  94206. */
  94207. getScreenAspectRatio(): number;
  94208. /**
  94209. * Gets the current render width
  94210. * @param useScreen defines if screen size must be used (or the current render target if any)
  94211. * @returns a number defining the current render width
  94212. */
  94213. getRenderWidth(useScreen?: boolean): number;
  94214. /**
  94215. * Gets the current render height
  94216. * @param useScreen defines if screen size must be used (or the current render target if any)
  94217. * @returns a number defining the current render height
  94218. */
  94219. getRenderHeight(useScreen?: boolean): number;
  94220. /**
  94221. * Gets the HTML canvas attached with the current webGL context
  94222. * @returns a HTML canvas
  94223. */
  94224. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  94225. /**
  94226. * Gets the client rect of the HTML canvas attached with the current webGL context
  94227. * @returns a client rectanglee
  94228. */
  94229. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  94230. /**
  94231. * Defines the hardware scaling level.
  94232. * By default the hardware scaling level is computed from the window device ratio.
  94233. * 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.
  94234. * @param level defines the level to use
  94235. */
  94236. setHardwareScalingLevel(level: number): void;
  94237. /**
  94238. * Gets the current hardware scaling level.
  94239. * By default the hardware scaling level is computed from the window device ratio.
  94240. * 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.
  94241. * @returns a number indicating the current hardware scaling level
  94242. */
  94243. getHardwareScalingLevel(): number;
  94244. /**
  94245. * Gets the list of loaded textures
  94246. * @returns an array containing all loaded textures
  94247. */
  94248. getLoadedTexturesCache(): InternalTexture[];
  94249. /**
  94250. * Gets the object containing all engine capabilities
  94251. * @returns the EngineCapabilities object
  94252. */
  94253. getCaps(): EngineCapabilities;
  94254. /**
  94255. * Gets the current depth function
  94256. * @returns a number defining the depth function
  94257. */
  94258. getDepthFunction(): Nullable<number>;
  94259. /**
  94260. * Sets the current depth function
  94261. * @param depthFunc defines the function to use
  94262. */
  94263. setDepthFunction(depthFunc: number): void;
  94264. /**
  94265. * Sets the current depth function to GREATER
  94266. */
  94267. setDepthFunctionToGreater(): void;
  94268. /**
  94269. * Sets the current depth function to GEQUAL
  94270. */
  94271. setDepthFunctionToGreaterOrEqual(): void;
  94272. /**
  94273. * Sets the current depth function to LESS
  94274. */
  94275. setDepthFunctionToLess(): void;
  94276. private _cachedStencilBuffer;
  94277. private _cachedStencilFunction;
  94278. private _cachedStencilMask;
  94279. private _cachedStencilOperationPass;
  94280. private _cachedStencilOperationFail;
  94281. private _cachedStencilOperationDepthFail;
  94282. private _cachedStencilReference;
  94283. /**
  94284. * Caches the the state of the stencil buffer
  94285. */
  94286. cacheStencilState(): void;
  94287. /**
  94288. * Restores the state of the stencil buffer
  94289. */
  94290. restoreStencilState(): void;
  94291. /**
  94292. * Sets the current depth function to LEQUAL
  94293. */
  94294. setDepthFunctionToLessOrEqual(): void;
  94295. /**
  94296. * Gets a boolean indicating if stencil buffer is enabled
  94297. * @returns the current stencil buffer state
  94298. */
  94299. getStencilBuffer(): boolean;
  94300. /**
  94301. * Enable or disable the stencil buffer
  94302. * @param enable defines if the stencil buffer must be enabled or disabled
  94303. */
  94304. setStencilBuffer(enable: boolean): void;
  94305. /**
  94306. * Gets the current stencil mask
  94307. * @returns a number defining the new stencil mask to use
  94308. */
  94309. getStencilMask(): number;
  94310. /**
  94311. * Sets the current stencil mask
  94312. * @param mask defines the new stencil mask to use
  94313. */
  94314. setStencilMask(mask: number): void;
  94315. /**
  94316. * Gets the current stencil function
  94317. * @returns a number defining the stencil function to use
  94318. */
  94319. getStencilFunction(): number;
  94320. /**
  94321. * Gets the current stencil reference value
  94322. * @returns a number defining the stencil reference value to use
  94323. */
  94324. getStencilFunctionReference(): number;
  94325. /**
  94326. * Gets the current stencil mask
  94327. * @returns a number defining the stencil mask to use
  94328. */
  94329. getStencilFunctionMask(): number;
  94330. /**
  94331. * Sets the current stencil function
  94332. * @param stencilFunc defines the new stencil function to use
  94333. */
  94334. setStencilFunction(stencilFunc: number): void;
  94335. /**
  94336. * Sets the current stencil reference
  94337. * @param reference defines the new stencil reference to use
  94338. */
  94339. setStencilFunctionReference(reference: number): void;
  94340. /**
  94341. * Sets the current stencil mask
  94342. * @param mask defines the new stencil mask to use
  94343. */
  94344. setStencilFunctionMask(mask: number): void;
  94345. /**
  94346. * Gets the current stencil operation when stencil fails
  94347. * @returns a number defining stencil operation to use when stencil fails
  94348. */
  94349. getStencilOperationFail(): number;
  94350. /**
  94351. * Gets the current stencil operation when depth fails
  94352. * @returns a number defining stencil operation to use when depth fails
  94353. */
  94354. getStencilOperationDepthFail(): number;
  94355. /**
  94356. * Gets the current stencil operation when stencil passes
  94357. * @returns a number defining stencil operation to use when stencil passes
  94358. */
  94359. getStencilOperationPass(): number;
  94360. /**
  94361. * Sets the stencil operation to use when stencil fails
  94362. * @param operation defines the stencil operation to use when stencil fails
  94363. */
  94364. setStencilOperationFail(operation: number): void;
  94365. /**
  94366. * Sets the stencil operation to use when depth fails
  94367. * @param operation defines the stencil operation to use when depth fails
  94368. */
  94369. setStencilOperationDepthFail(operation: number): void;
  94370. /**
  94371. * Sets the stencil operation to use when stencil passes
  94372. * @param operation defines the stencil operation to use when stencil passes
  94373. */
  94374. setStencilOperationPass(operation: number): void;
  94375. /**
  94376. * Sets a boolean indicating if the dithering state is enabled or disabled
  94377. * @param value defines the dithering state
  94378. */
  94379. setDitheringState(value: boolean): void;
  94380. /**
  94381. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  94382. * @param value defines the rasterizer state
  94383. */
  94384. setRasterizerState(value: boolean): void;
  94385. /**
  94386. * stop executing a render loop function and remove it from the execution array
  94387. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  94388. */
  94389. stopRenderLoop(renderFunction?: () => void): void;
  94390. /** @hidden */
  94391. _renderLoop(): void;
  94392. /**
  94393. * Register and execute a render loop. The engine can have more than one render function
  94394. * @param renderFunction defines the function to continuously execute
  94395. */
  94396. runRenderLoop(renderFunction: () => void): void;
  94397. /**
  94398. * Toggle full screen mode
  94399. * @param requestPointerLock defines if a pointer lock should be requested from the user
  94400. */
  94401. switchFullscreen(requestPointerLock: boolean): void;
  94402. /**
  94403. * Enters full screen mode
  94404. * @param requestPointerLock defines if a pointer lock should be requested from the user
  94405. */
  94406. enterFullscreen(requestPointerLock: boolean): void;
  94407. /**
  94408. * Exits full screen mode
  94409. */
  94410. exitFullscreen(): void;
  94411. /**
  94412. * Enters Pointerlock mode
  94413. */
  94414. enterPointerlock(): void;
  94415. /**
  94416. * Exits Pointerlock mode
  94417. */
  94418. exitPointerlock(): void;
  94419. /**
  94420. * Clear the current render buffer or the current render target (if any is set up)
  94421. * @param color defines the color to use
  94422. * @param backBuffer defines if the back buffer must be cleared
  94423. * @param depth defines if the depth buffer must be cleared
  94424. * @param stencil defines if the stencil buffer must be cleared
  94425. */
  94426. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  94427. /**
  94428. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  94429. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  94430. * @param y defines the y-coordinate of the corner of the clear rectangle
  94431. * @param width defines the width of the clear rectangle
  94432. * @param height defines the height of the clear rectangle
  94433. * @param clearColor defines the clear color
  94434. */
  94435. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  94436. /**
  94437. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  94438. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  94439. * @param y defines the y-coordinate of the corner of the clear rectangle
  94440. * @param width defines the width of the clear rectangle
  94441. * @param height defines the height of the clear rectangle
  94442. */
  94443. enableScissor(x: number, y: number, width: number, height: number): void;
  94444. /**
  94445. * Disable previously set scissor test rectangle
  94446. */
  94447. disableScissor(): void;
  94448. private _viewportCached;
  94449. /** @hidden */
  94450. _viewport(x: number, y: number, width: number, height: number): void;
  94451. /**
  94452. * Set the WebGL's viewport
  94453. * @param viewport defines the viewport element to be used
  94454. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  94455. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  94456. */
  94457. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  94458. /**
  94459. * Directly set the WebGL Viewport
  94460. * @param x defines the x coordinate of the viewport (in screen space)
  94461. * @param y defines the y coordinate of the viewport (in screen space)
  94462. * @param width defines the width of the viewport (in screen space)
  94463. * @param height defines the height of the viewport (in screen space)
  94464. * @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
  94465. */
  94466. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  94467. /**
  94468. * Begin a new frame
  94469. */
  94470. beginFrame(): void;
  94471. /**
  94472. * Enf the current frame
  94473. */
  94474. endFrame(): void;
  94475. /**
  94476. * Resize the view according to the canvas' size
  94477. */
  94478. resize(): void;
  94479. /**
  94480. * Force a specific size of the canvas
  94481. * @param width defines the new canvas' width
  94482. * @param height defines the new canvas' height
  94483. */
  94484. setSize(width: number, height: number): void;
  94485. /**
  94486. * Binds the frame buffer to the specified texture.
  94487. * @param texture The texture to render to or null for the default canvas
  94488. * @param faceIndex The face of the texture to render to in case of cube texture
  94489. * @param requiredWidth The width of the target to render to
  94490. * @param requiredHeight The height of the target to render to
  94491. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  94492. * @param depthStencilTexture The depth stencil texture to use to render
  94493. * @param lodLevel defines le lod level to bind to the frame buffer
  94494. */
  94495. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  94496. /** @hidden */
  94497. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  94498. /**
  94499. * Unbind the current render target texture from the webGL context
  94500. * @param texture defines the render target texture to unbind
  94501. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  94502. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  94503. */
  94504. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  94505. /**
  94506. * Force the mipmap generation for the given render target texture
  94507. * @param texture defines the render target texture to use
  94508. */
  94509. generateMipMapsForCubemap(texture: InternalTexture): void;
  94510. /**
  94511. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  94512. */
  94513. flushFramebuffer(): void;
  94514. /**
  94515. * Unbind the current render target and bind the default framebuffer
  94516. */
  94517. restoreDefaultFramebuffer(): void;
  94518. /**
  94519. * Create an uniform buffer
  94520. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  94521. * @param elements defines the content of the uniform buffer
  94522. * @returns the webGL uniform buffer
  94523. */
  94524. createUniformBuffer(elements: FloatArray): DataBuffer;
  94525. /**
  94526. * Create a dynamic uniform buffer
  94527. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  94528. * @param elements defines the content of the uniform buffer
  94529. * @returns the webGL uniform buffer
  94530. */
  94531. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  94532. /**
  94533. * Update an existing uniform buffer
  94534. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  94535. * @param uniformBuffer defines the target uniform buffer
  94536. * @param elements defines the content to update
  94537. * @param offset defines the offset in the uniform buffer where update should start
  94538. * @param count defines the size of the data to update
  94539. */
  94540. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  94541. private _resetVertexBufferBinding;
  94542. /**
  94543. * Creates a vertex buffer
  94544. * @param data the data for the vertex buffer
  94545. * @returns the new WebGL static buffer
  94546. */
  94547. createVertexBuffer(data: DataArray): DataBuffer;
  94548. /**
  94549. * Creates a dynamic vertex buffer
  94550. * @param data the data for the dynamic vertex buffer
  94551. * @returns the new WebGL dynamic buffer
  94552. */
  94553. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  94554. /**
  94555. * Update a dynamic index buffer
  94556. * @param indexBuffer defines the target index buffer
  94557. * @param indices defines the data to update
  94558. * @param offset defines the offset in the target index buffer where update should start
  94559. */
  94560. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  94561. /**
  94562. * Updates a dynamic vertex buffer.
  94563. * @param vertexBuffer the vertex buffer to update
  94564. * @param data the data used to update the vertex buffer
  94565. * @param byteOffset the byte offset of the data
  94566. * @param byteLength the byte length of the data
  94567. */
  94568. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  94569. private _resetIndexBufferBinding;
  94570. /**
  94571. * Creates a new index buffer
  94572. * @param indices defines the content of the index buffer
  94573. * @param updatable defines if the index buffer must be updatable
  94574. * @returns a new webGL buffer
  94575. */
  94576. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  94577. /**
  94578. * Bind a webGL buffer to the webGL context
  94579. * @param buffer defines the buffer to bind
  94580. */
  94581. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  94582. /**
  94583. * Bind an uniform buffer to the current webGL context
  94584. * @param buffer defines the buffer to bind
  94585. */
  94586. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  94587. /**
  94588. * Bind a buffer to the current webGL context at a given location
  94589. * @param buffer defines the buffer to bind
  94590. * @param location defines the index where to bind the buffer
  94591. */
  94592. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  94593. /**
  94594. * Bind a specific block at a given index in a specific shader program
  94595. * @param pipelineContext defines the pipeline context to use
  94596. * @param blockName defines the block name
  94597. * @param index defines the index where to bind the block
  94598. */
  94599. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  94600. private bindIndexBuffer;
  94601. private bindBuffer;
  94602. /**
  94603. * update the bound buffer with the given data
  94604. * @param data defines the data to update
  94605. */
  94606. updateArrayBuffer(data: Float32Array): void;
  94607. private _vertexAttribPointer;
  94608. private _bindIndexBufferWithCache;
  94609. private _bindVertexBuffersAttributes;
  94610. /**
  94611. * Records a vertex array object
  94612. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  94613. * @param vertexBuffers defines the list of vertex buffers to store
  94614. * @param indexBuffer defines the index buffer to store
  94615. * @param effect defines the effect to store
  94616. * @returns the new vertex array object
  94617. */
  94618. recordVertexArrayObject(vertexBuffers: {
  94619. [key: string]: VertexBuffer;
  94620. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  94621. /**
  94622. * Bind a specific vertex array object
  94623. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  94624. * @param vertexArrayObject defines the vertex array object to bind
  94625. * @param indexBuffer defines the index buffer to bind
  94626. */
  94627. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  94628. /**
  94629. * Bind webGl buffers directly to the webGL context
  94630. * @param vertexBuffer defines the vertex buffer to bind
  94631. * @param indexBuffer defines the index buffer to bind
  94632. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  94633. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  94634. * @param effect defines the effect associated with the vertex buffer
  94635. */
  94636. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  94637. private _unbindVertexArrayObject;
  94638. /**
  94639. * Bind a list of vertex buffers to the webGL context
  94640. * @param vertexBuffers defines the list of vertex buffers to bind
  94641. * @param indexBuffer defines the index buffer to bind
  94642. * @param effect defines the effect associated with the vertex buffers
  94643. */
  94644. bindBuffers(vertexBuffers: {
  94645. [key: string]: Nullable<VertexBuffer>;
  94646. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  94647. /**
  94648. * Unbind all instance attributes
  94649. */
  94650. unbindInstanceAttributes(): void;
  94651. /**
  94652. * Release and free the memory of a vertex array object
  94653. * @param vao defines the vertex array object to delete
  94654. */
  94655. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  94656. /** @hidden */
  94657. _releaseBuffer(buffer: DataBuffer): boolean;
  94658. /**
  94659. * Creates a webGL buffer to use with instanciation
  94660. * @param capacity defines the size of the buffer
  94661. * @returns the webGL buffer
  94662. */
  94663. createInstancesBuffer(capacity: number): DataBuffer;
  94664. /**
  94665. * Delete a webGL buffer used with instanciation
  94666. * @param buffer defines the webGL buffer to delete
  94667. */
  94668. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  94669. /**
  94670. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  94671. * @param instancesBuffer defines the webGL buffer to update and bind
  94672. * @param data defines the data to store in the buffer
  94673. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  94674. */
  94675. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  94676. /**
  94677. * Apply all cached states (depth, culling, stencil and alpha)
  94678. */
  94679. applyStates(): void;
  94680. /**
  94681. * Send a draw order
  94682. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  94683. * @param indexStart defines the starting index
  94684. * @param indexCount defines the number of index to draw
  94685. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  94686. */
  94687. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  94688. /**
  94689. * Draw a list of points
  94690. * @param verticesStart defines the index of first vertex to draw
  94691. * @param verticesCount defines the count of vertices to draw
  94692. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  94693. */
  94694. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  94695. /**
  94696. * Draw a list of unindexed primitives
  94697. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  94698. * @param verticesStart defines the index of first vertex to draw
  94699. * @param verticesCount defines the count of vertices to draw
  94700. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  94701. */
  94702. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  94703. /**
  94704. * Draw a list of indexed primitives
  94705. * @param fillMode defines the primitive to use
  94706. * @param indexStart defines the starting index
  94707. * @param indexCount defines the number of index to draw
  94708. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  94709. */
  94710. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  94711. /**
  94712. * Draw a list of unindexed primitives
  94713. * @param fillMode defines the primitive to use
  94714. * @param verticesStart defines the index of first vertex to draw
  94715. * @param verticesCount defines the count of vertices to draw
  94716. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  94717. */
  94718. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  94719. private _drawMode;
  94720. /** @hidden */
  94721. _releaseEffect(effect: Effect): void;
  94722. /** @hidden */
  94723. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  94724. /**
  94725. * Create a new effect (used to store vertex/fragment shaders)
  94726. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  94727. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  94728. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  94729. * @param samplers defines an array of string used to represent textures
  94730. * @param defines defines the string containing the defines to use to compile the shaders
  94731. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  94732. * @param onCompiled defines a function to call when the effect creation is successful
  94733. * @param onError defines a function to call when the effect creation has failed
  94734. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  94735. * @returns the new Effect
  94736. */
  94737. 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;
  94738. private _compileShader;
  94739. private _compileRawShader;
  94740. /**
  94741. * Directly creates a webGL program
  94742. * @param pipelineContext defines the pipeline context to attach to
  94743. * @param vertexCode defines the vertex shader code to use
  94744. * @param fragmentCode defines the fragment shader code to use
  94745. * @param context defines the webGL context to use (if not set, the current one will be used)
  94746. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  94747. * @returns the new webGL program
  94748. */
  94749. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  94750. /**
  94751. * Creates a webGL program
  94752. * @param pipelineContext defines the pipeline context to attach to
  94753. * @param vertexCode defines the vertex shader code to use
  94754. * @param fragmentCode defines the fragment shader code to use
  94755. * @param defines defines the string containing the defines to use to compile the shaders
  94756. * @param context defines the webGL context to use (if not set, the current one will be used)
  94757. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  94758. * @returns the new webGL program
  94759. */
  94760. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  94761. /**
  94762. * Creates a new pipeline context
  94763. * @returns the new pipeline
  94764. */
  94765. createPipelineContext(): WebGLPipelineContext;
  94766. private _createShaderProgram;
  94767. private _finalizePipelineContext;
  94768. /** @hidden */
  94769. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  94770. /** @hidden */
  94771. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  94772. /** @hidden */
  94773. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  94774. /**
  94775. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  94776. * @param pipelineContext defines the pipeline context to use
  94777. * @param uniformsNames defines the list of uniform names
  94778. * @returns an array of webGL uniform locations
  94779. */
  94780. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  94781. /**
  94782. * Gets the lsit of active attributes for a given webGL program
  94783. * @param pipelineContext defines the pipeline context to use
  94784. * @param attributesNames defines the list of attribute names to get
  94785. * @returns an array of indices indicating the offset of each attribute
  94786. */
  94787. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  94788. /**
  94789. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  94790. * @param effect defines the effect to activate
  94791. */
  94792. enableEffect(effect: Nullable<Effect>): void;
  94793. /**
  94794. * Set the value of an uniform to an array of int32
  94795. * @param uniform defines the webGL uniform location where to store the value
  94796. * @param array defines the array of int32 to store
  94797. */
  94798. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  94799. /**
  94800. * Set the value of an uniform to an array of int32 (stored as vec2)
  94801. * @param uniform defines the webGL uniform location where to store the value
  94802. * @param array defines the array of int32 to store
  94803. */
  94804. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  94805. /**
  94806. * Set the value of an uniform to an array of int32 (stored as vec3)
  94807. * @param uniform defines the webGL uniform location where to store the value
  94808. * @param array defines the array of int32 to store
  94809. */
  94810. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  94811. /**
  94812. * Set the value of an uniform to an array of int32 (stored as vec4)
  94813. * @param uniform defines the webGL uniform location where to store the value
  94814. * @param array defines the array of int32 to store
  94815. */
  94816. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  94817. /**
  94818. * Set the value of an uniform to an array of float32
  94819. * @param uniform defines the webGL uniform location where to store the value
  94820. * @param array defines the array of float32 to store
  94821. */
  94822. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  94823. /**
  94824. * Set the value of an uniform to an array of float32 (stored as vec2)
  94825. * @param uniform defines the webGL uniform location where to store the value
  94826. * @param array defines the array of float32 to store
  94827. */
  94828. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  94829. /**
  94830. * Set the value of an uniform to an array of float32 (stored as vec3)
  94831. * @param uniform defines the webGL uniform location where to store the value
  94832. * @param array defines the array of float32 to store
  94833. */
  94834. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  94835. /**
  94836. * Set the value of an uniform to an array of float32 (stored as vec4)
  94837. * @param uniform defines the webGL uniform location where to store the value
  94838. * @param array defines the array of float32 to store
  94839. */
  94840. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  94841. /**
  94842. * Set the value of an uniform to an array of number
  94843. * @param uniform defines the webGL uniform location where to store the value
  94844. * @param array defines the array of number to store
  94845. */
  94846. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  94847. /**
  94848. * Set the value of an uniform to an array of number (stored as vec2)
  94849. * @param uniform defines the webGL uniform location where to store the value
  94850. * @param array defines the array of number to store
  94851. */
  94852. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  94853. /**
  94854. * Set the value of an uniform to an array of number (stored as vec3)
  94855. * @param uniform defines the webGL uniform location where to store the value
  94856. * @param array defines the array of number to store
  94857. */
  94858. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  94859. /**
  94860. * Set the value of an uniform to an array of number (stored as vec4)
  94861. * @param uniform defines the webGL uniform location where to store the value
  94862. * @param array defines the array of number to store
  94863. */
  94864. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  94865. /**
  94866. * Set the value of an uniform to an array of float32 (stored as matrices)
  94867. * @param uniform defines the webGL uniform location where to store the value
  94868. * @param matrices defines the array of float32 to store
  94869. */
  94870. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  94871. /**
  94872. * Set the value of an uniform to a matrix (3x3)
  94873. * @param uniform defines the webGL uniform location where to store the value
  94874. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  94875. */
  94876. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  94877. /**
  94878. * Set the value of an uniform to a matrix (2x2)
  94879. * @param uniform defines the webGL uniform location where to store the value
  94880. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  94881. */
  94882. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  94883. /**
  94884. * Set the value of an uniform to a number (int)
  94885. * @param uniform defines the webGL uniform location where to store the value
  94886. * @param value defines the int number to store
  94887. */
  94888. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  94889. /**
  94890. * Set the value of an uniform to a number (float)
  94891. * @param uniform defines the webGL uniform location where to store the value
  94892. * @param value defines the float number to store
  94893. */
  94894. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  94895. /**
  94896. * Set the value of an uniform to a vec2
  94897. * @param uniform defines the webGL uniform location where to store the value
  94898. * @param x defines the 1st component of the value
  94899. * @param y defines the 2nd component of the value
  94900. */
  94901. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  94902. /**
  94903. * Set the value of an uniform to a vec3
  94904. * @param uniform defines the webGL uniform location where to store the value
  94905. * @param x defines the 1st component of the value
  94906. * @param y defines the 2nd component of the value
  94907. * @param z defines the 3rd component of the value
  94908. */
  94909. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  94910. /**
  94911. * Set the value of an uniform to a boolean
  94912. * @param uniform defines the webGL uniform location where to store the value
  94913. * @param bool defines the boolean to store
  94914. */
  94915. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  94916. /**
  94917. * Set the value of an uniform to a vec4
  94918. * @param uniform defines the webGL uniform location where to store the value
  94919. * @param x defines the 1st component of the value
  94920. * @param y defines the 2nd component of the value
  94921. * @param z defines the 3rd component of the value
  94922. * @param w defines the 4th component of the value
  94923. */
  94924. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  94925. /**
  94926. * Sets a Color4 on a uniform variable
  94927. * @param uniform defines the uniform location
  94928. * @param color4 defines the value to be set
  94929. */
  94930. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  94931. /**
  94932. * Set various states to the webGL context
  94933. * @param culling defines backface culling state
  94934. * @param zOffset defines the value to apply to zOffset (0 by default)
  94935. * @param force defines if states must be applied even if cache is up to date
  94936. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  94937. */
  94938. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  94939. /**
  94940. * Set the z offset to apply to current rendering
  94941. * @param value defines the offset to apply
  94942. */
  94943. setZOffset(value: number): void;
  94944. /**
  94945. * Gets the current value of the zOffset
  94946. * @returns the current zOffset state
  94947. */
  94948. getZOffset(): number;
  94949. /**
  94950. * Enable or disable depth buffering
  94951. * @param enable defines the state to set
  94952. */
  94953. setDepthBuffer(enable: boolean): void;
  94954. /**
  94955. * Gets a boolean indicating if depth writing is enabled
  94956. * @returns the current depth writing state
  94957. */
  94958. getDepthWrite(): boolean;
  94959. /**
  94960. * Enable or disable depth writing
  94961. * @param enable defines the state to set
  94962. */
  94963. setDepthWrite(enable: boolean): void;
  94964. /**
  94965. * Enable or disable color writing
  94966. * @param enable defines the state to set
  94967. */
  94968. setColorWrite(enable: boolean): void;
  94969. /**
  94970. * Gets a boolean indicating if color writing is enabled
  94971. * @returns the current color writing state
  94972. */
  94973. getColorWrite(): boolean;
  94974. /**
  94975. * Sets alpha constants used by some alpha blending modes
  94976. * @param r defines the red component
  94977. * @param g defines the green component
  94978. * @param b defines the blue component
  94979. * @param a defines the alpha component
  94980. */
  94981. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  94982. /**
  94983. * Sets the current alpha mode
  94984. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  94985. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  94986. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  94987. */
  94988. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  94989. /**
  94990. * Gets the current alpha mode
  94991. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  94992. * @returns the current alpha mode
  94993. */
  94994. getAlphaMode(): number;
  94995. /**
  94996. * Clears the list of texture accessible through engine.
  94997. * This can help preventing texture load conflict due to name collision.
  94998. */
  94999. clearInternalTexturesCache(): void;
  95000. /**
  95001. * Force the entire cache to be cleared
  95002. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  95003. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  95004. */
  95005. wipeCaches(bruteForce?: boolean): void;
  95006. /**
  95007. * Set the compressed texture format to use, based on the formats you have, and the formats
  95008. * supported by the hardware / browser.
  95009. *
  95010. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  95011. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  95012. * to API arguments needed to compressed textures. This puts the burden on the container
  95013. * generator to house the arcane code for determining these for current & future formats.
  95014. *
  95015. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  95016. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  95017. *
  95018. * Note: The result of this call is not taken into account when a texture is base64.
  95019. *
  95020. * @param formatsAvailable defines the list of those format families you have created
  95021. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  95022. *
  95023. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  95024. * @returns The extension selected.
  95025. */
  95026. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  95027. /** @hidden */
  95028. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  95029. min: number;
  95030. mag: number;
  95031. };
  95032. /** @hidden */
  95033. _createTexture(): WebGLTexture;
  95034. /**
  95035. * Usually called from Texture.ts.
  95036. * Passed information to create a WebGLTexture
  95037. * @param urlArg defines a value which contains one of the following:
  95038. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  95039. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  95040. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  95041. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  95042. * @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)
  95043. * @param scene needed for loading to the correct scene
  95044. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  95045. * @param onLoad optional callback to be called upon successful completion
  95046. * @param onError optional callback to be called upon failure
  95047. * @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
  95048. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  95049. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  95050. * @param forcedExtension defines the extension to use to pick the right loader
  95051. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  95052. * @returns a InternalTexture for assignment back into BABYLON.Texture
  95053. */
  95054. 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;
  95055. /**
  95056. * @hidden
  95057. * Rescales a texture
  95058. * @param source input texutre
  95059. * @param destination destination texture
  95060. * @param scene scene to use to render the resize
  95061. * @param internalFormat format to use when resizing
  95062. * @param onComplete callback to be called when resize has completed
  95063. */
  95064. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  95065. private _unpackFlipYCached;
  95066. /**
  95067. * In case you are sharing the context with other applications, it might
  95068. * be interested to not cache the unpack flip y state to ensure a consistent
  95069. * value would be set.
  95070. */
  95071. enableUnpackFlipYCached: boolean;
  95072. /** @hidden */
  95073. _unpackFlipY(value: boolean): void;
  95074. /** @hidden */
  95075. _getUnpackAlignement(): number;
  95076. /**
  95077. * Creates a dynamic texture
  95078. * @param width defines the width of the texture
  95079. * @param height defines the height of the texture
  95080. * @param generateMipMaps defines if the engine should generate the mip levels
  95081. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  95082. * @returns the dynamic texture inside an InternalTexture
  95083. */
  95084. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  95085. /**
  95086. * Update the sampling mode of a given texture
  95087. * @param samplingMode defines the required sampling mode
  95088. * @param texture defines the texture to update
  95089. */
  95090. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  95091. /**
  95092. * Update the content of a dynamic texture
  95093. * @param texture defines the texture to update
  95094. * @param canvas defines the canvas containing the source
  95095. * @param invertY defines if data must be stored with Y axis inverted
  95096. * @param premulAlpha defines if alpha is stored as premultiplied
  95097. * @param format defines the format of the data
  95098. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  95099. */
  95100. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  95101. /**
  95102. * Update a video texture
  95103. * @param texture defines the texture to update
  95104. * @param video defines the video element to use
  95105. * @param invertY defines if data must be stored with Y axis inverted
  95106. */
  95107. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  95108. /**
  95109. * Updates a depth texture Comparison Mode and Function.
  95110. * If the comparison Function is equal to 0, the mode will be set to none.
  95111. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  95112. * @param texture The texture to set the comparison function for
  95113. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  95114. */
  95115. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  95116. /** @hidden */
  95117. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  95118. width: number;
  95119. height: number;
  95120. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  95121. /**
  95122. * Creates a depth stencil texture.
  95123. * This is only available in WebGL 2 or with the depth texture extension available.
  95124. * @param size The size of face edge in the texture.
  95125. * @param options The options defining the texture.
  95126. * @returns The texture
  95127. */
  95128. createDepthStencilTexture(size: number | {
  95129. width: number;
  95130. height: number;
  95131. }, options: DepthTextureCreationOptions): InternalTexture;
  95132. /**
  95133. * Creates a depth stencil texture.
  95134. * This is only available in WebGL 2 or with the depth texture extension available.
  95135. * @param size The size of face edge in the texture.
  95136. * @param options The options defining the texture.
  95137. * @returns The texture
  95138. */
  95139. private _createDepthStencilTexture;
  95140. /**
  95141. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  95142. * @param renderTarget The render target to set the frame buffer for
  95143. */
  95144. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  95145. /**
  95146. * Creates a new render target texture
  95147. * @param size defines the size of the texture
  95148. * @param options defines the options used to create the texture
  95149. * @returns a new render target texture stored in an InternalTexture
  95150. */
  95151. createRenderTargetTexture(size: number | {
  95152. width: number;
  95153. height: number;
  95154. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  95155. /** @hidden */
  95156. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  95157. /**
  95158. * Updates the sample count of a render target texture
  95159. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  95160. * @param texture defines the texture to update
  95161. * @param samples defines the sample count to set
  95162. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  95163. */
  95164. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  95165. /** @hidden */
  95166. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  95167. /** @hidden */
  95168. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  95169. /** @hidden */
  95170. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  95171. /** @hidden */
  95172. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  95173. /**
  95174. * @hidden
  95175. */
  95176. _setCubeMapTextureParams(loadMipmap: boolean): void;
  95177. private _prepareWebGLTextureContinuation;
  95178. private _prepareWebGLTexture;
  95179. /** @hidden */
  95180. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  95181. /** @hidden */
  95182. _releaseFramebufferObjects(texture: InternalTexture): void;
  95183. /** @hidden */
  95184. _releaseTexture(texture: InternalTexture): void;
  95185. private setProgram;
  95186. private _boundUniforms;
  95187. /**
  95188. * Binds an effect to the webGL context
  95189. * @param effect defines the effect to bind
  95190. */
  95191. bindSamplers(effect: Effect): void;
  95192. private _activateCurrentTexture;
  95193. /** @hidden */
  95194. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  95195. /** @hidden */
  95196. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  95197. /**
  95198. * Sets a texture to the webGL context from a postprocess
  95199. * @param channel defines the channel to use
  95200. * @param postProcess defines the source postprocess
  95201. */
  95202. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  95203. /**
  95204. * Binds the output of the passed in post process to the texture channel specified
  95205. * @param channel The channel the texture should be bound to
  95206. * @param postProcess The post process which's output should be bound
  95207. */
  95208. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  95209. /**
  95210. * Unbind all textures from the webGL context
  95211. */
  95212. unbindAllTextures(): void;
  95213. /**
  95214. * Sets a texture to the according uniform.
  95215. * @param channel The texture channel
  95216. * @param uniform The uniform to set
  95217. * @param texture The texture to apply
  95218. */
  95219. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  95220. /**
  95221. * Sets a depth stencil texture from a render target to the according uniform.
  95222. * @param channel The texture channel
  95223. * @param uniform The uniform to set
  95224. * @param texture The render target texture containing the depth stencil texture to apply
  95225. */
  95226. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  95227. private _bindSamplerUniformToChannel;
  95228. private _getTextureWrapMode;
  95229. private _setTexture;
  95230. /**
  95231. * Sets an array of texture to the webGL context
  95232. * @param channel defines the channel where the texture array must be set
  95233. * @param uniform defines the associated uniform location
  95234. * @param textures defines the array of textures to bind
  95235. */
  95236. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  95237. /** @hidden */
  95238. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  95239. private _setTextureParameterFloat;
  95240. private _setTextureParameterInteger;
  95241. /**
  95242. * Reads pixels from the current frame buffer. Please note that this function can be slow
  95243. * @param x defines the x coordinate of the rectangle where pixels must be read
  95244. * @param y defines the y coordinate of the rectangle where pixels must be read
  95245. * @param width defines the width of the rectangle where pixels must be read
  95246. * @param height defines the height of the rectangle where pixels must be read
  95247. * @returns a Uint8Array containing RGBA colors
  95248. */
  95249. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  95250. /**
  95251. * Add an externaly attached data from its key.
  95252. * This method call will fail and return false, if such key already exists.
  95253. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  95254. * @param key the unique key that identifies the data
  95255. * @param data the data object to associate to the key for this Engine instance
  95256. * @return true if no such key were already present and the data was added successfully, false otherwise
  95257. */
  95258. addExternalData<T>(key: string, data: T): boolean;
  95259. /**
  95260. * Get an externaly attached data from its key
  95261. * @param key the unique key that identifies the data
  95262. * @return the associated data, if present (can be null), or undefined if not present
  95263. */
  95264. getExternalData<T>(key: string): T;
  95265. /**
  95266. * Get an externaly attached data from its key, create it using a factory if it's not already present
  95267. * @param key the unique key that identifies the data
  95268. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  95269. * @return the associated data, can be null if the factory returned null.
  95270. */
  95271. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  95272. /**
  95273. * Remove an externaly attached data from the Engine instance
  95274. * @param key the unique key that identifies the data
  95275. * @return true if the data was successfully removed, false if it doesn't exist
  95276. */
  95277. removeExternalData(key: string): boolean;
  95278. /**
  95279. * Unbind all vertex attributes from the webGL context
  95280. */
  95281. unbindAllAttributes(): void;
  95282. /**
  95283. * 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
  95284. */
  95285. releaseEffects(): void;
  95286. /**
  95287. * Dispose and release all associated resources
  95288. */
  95289. dispose(): void;
  95290. /**
  95291. * Display the loading screen
  95292. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95293. */
  95294. displayLoadingUI(): void;
  95295. /**
  95296. * Hide the loading screen
  95297. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95298. */
  95299. hideLoadingUI(): void;
  95300. /**
  95301. * Gets the current loading screen object
  95302. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95303. */
  95304. /**
  95305. * Sets the current loading screen object
  95306. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95307. */
  95308. loadingScreen: ILoadingScreen;
  95309. /**
  95310. * Sets the current loading screen text
  95311. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95312. */
  95313. loadingUIText: string;
  95314. /**
  95315. * Sets the current loading screen background color
  95316. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95317. */
  95318. loadingUIBackgroundColor: string;
  95319. /**
  95320. * Attach a new callback raised when context lost event is fired
  95321. * @param callback defines the callback to call
  95322. */
  95323. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  95324. /**
  95325. * Attach a new callback raised when context restored event is fired
  95326. * @param callback defines the callback to call
  95327. */
  95328. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  95329. /**
  95330. * Gets the source code of the vertex shader associated with a specific webGL program
  95331. * @param program defines the program to use
  95332. * @returns a string containing the source code of the vertex shader associated with the program
  95333. */
  95334. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  95335. /**
  95336. * Gets the source code of the fragment shader associated with a specific webGL program
  95337. * @param program defines the program to use
  95338. * @returns a string containing the source code of the fragment shader associated with the program
  95339. */
  95340. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  95341. /**
  95342. * Get the current error code of the webGL context
  95343. * @returns the error code
  95344. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  95345. */
  95346. getError(): number;
  95347. /**
  95348. * Gets the current framerate
  95349. * @returns a number representing the framerate
  95350. */
  95351. getFps(): number;
  95352. /**
  95353. * Gets the time spent between current and previous frame
  95354. * @returns a number representing the delta time in ms
  95355. */
  95356. getDeltaTime(): number;
  95357. private _measureFps;
  95358. /** @hidden */
  95359. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  95360. private _canRenderToFloatFramebuffer;
  95361. private _canRenderToHalfFloatFramebuffer;
  95362. private _canRenderToFramebuffer;
  95363. /** @hidden */
  95364. _getWebGLTextureType(type: number): number;
  95365. /** @hidden */
  95366. _getInternalFormat(format: number): number;
  95367. /** @hidden */
  95368. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  95369. /** @hidden */
  95370. _getRGBAMultiSampleBufferFormat(type: number): number;
  95371. /** @hidden */
  95372. _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;
  95373. /** @hidden */
  95374. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  95375. /**
  95376. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  95377. * @returns true if the engine can be created
  95378. * @ignorenaming
  95379. */
  95380. static isSupported(): boolean;
  95381. /**
  95382. * Find the next highest power of two.
  95383. * @param x Number to start search from.
  95384. * @return Next highest power of two.
  95385. */
  95386. static CeilingPOT(x: number): number;
  95387. /**
  95388. * Find the next lowest power of two.
  95389. * @param x Number to start search from.
  95390. * @return Next lowest power of two.
  95391. */
  95392. static FloorPOT(x: number): number;
  95393. /**
  95394. * Find the nearest power of two.
  95395. * @param x Number to start search from.
  95396. * @return Next nearest power of two.
  95397. */
  95398. static NearestPOT(x: number): number;
  95399. /**
  95400. * Get the closest exponent of two
  95401. * @param value defines the value to approximate
  95402. * @param max defines the maximum value to return
  95403. * @param mode defines how to define the closest value
  95404. * @returns closest exponent of two of the given value
  95405. */
  95406. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  95407. /**
  95408. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  95409. * @param func - the function to be called
  95410. * @param requester - the object that will request the next frame. Falls back to window.
  95411. * @returns frame number
  95412. */
  95413. static QueueNewFrame(func: () => void, requester?: any): number;
  95414. /**
  95415. * Ask the browser to promote the current element to pointerlock mode
  95416. * @param element defines the DOM element to promote
  95417. */
  95418. static _RequestPointerlock(element: HTMLElement): void;
  95419. /**
  95420. * Asks the browser to exit pointerlock mode
  95421. */
  95422. static _ExitPointerlock(): void;
  95423. /**
  95424. * Ask the browser to promote the current element to fullscreen rendering mode
  95425. * @param element defines the DOM element to promote
  95426. */
  95427. static _RequestFullscreen(element: HTMLElement): void;
  95428. /**
  95429. * Asks the browser to exit fullscreen mode
  95430. */
  95431. static _ExitFullscreen(): void;
  95432. }
  95433. }
  95434. declare module BABYLON {
  95435. /**
  95436. * The engine store class is responsible to hold all the instances of Engine and Scene created
  95437. * during the life time of the application.
  95438. */
  95439. export class EngineStore {
  95440. /** Gets the list of created engines */
  95441. static Instances: Engine[];
  95442. /** @hidden */
  95443. static _LastCreatedScene: Nullable<Scene>;
  95444. /**
  95445. * Gets the latest created engine
  95446. */
  95447. static readonly LastCreatedEngine: Nullable<Engine>;
  95448. /**
  95449. * Gets the latest created scene
  95450. */
  95451. static readonly LastCreatedScene: Nullable<Scene>;
  95452. /**
  95453. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  95454. * @ignorenaming
  95455. */
  95456. static UseFallbackTexture: boolean;
  95457. /**
  95458. * Texture content used if a texture cannot loaded
  95459. * @ignorenaming
  95460. */
  95461. static FallbackTexture: string;
  95462. }
  95463. }
  95464. declare module BABYLON {
  95465. /**
  95466. * Helper class that provides a small promise polyfill
  95467. */
  95468. export class PromisePolyfill {
  95469. /**
  95470. * Static function used to check if the polyfill is required
  95471. * If this is the case then the function will inject the polyfill to window.Promise
  95472. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  95473. */
  95474. static Apply(force?: boolean): void;
  95475. }
  95476. }
  95477. declare module BABYLON {
  95478. interface IColor4Like {
  95479. r: float;
  95480. g: float;
  95481. b: float;
  95482. a: float;
  95483. }
  95484. /**
  95485. * Class containing a set of static utilities functions
  95486. */
  95487. export class Tools {
  95488. /**
  95489. * Gets or sets the base URL to use to load assets
  95490. */
  95491. static BaseUrl: string;
  95492. /**
  95493. * Enable/Disable Custom HTTP Request Headers globally.
  95494. * default = false
  95495. * @see CustomRequestHeaders
  95496. */
  95497. static UseCustomRequestHeaders: boolean;
  95498. /**
  95499. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  95500. * i.e. when loading files, where the server/service expects an Authorization header
  95501. */
  95502. static CustomRequestHeaders: {
  95503. [key: string]: string;
  95504. };
  95505. /**
  95506. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  95507. */
  95508. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  95509. /**
  95510. * Default behaviour for cors in the application.
  95511. * It can be a string if the expected behavior is identical in the entire app.
  95512. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  95513. */
  95514. static CorsBehavior: string | ((url: string | string[]) => string);
  95515. /**
  95516. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  95517. * @ignorenaming
  95518. */
  95519. static UseFallbackTexture: boolean;
  95520. /**
  95521. * Use this object to register external classes like custom textures or material
  95522. * to allow the laoders to instantiate them
  95523. */
  95524. static RegisteredExternalClasses: {
  95525. [key: string]: Object;
  95526. };
  95527. /**
  95528. * Texture content used if a texture cannot loaded
  95529. * @ignorenaming
  95530. */
  95531. static fallbackTexture: string;
  95532. /**
  95533. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  95534. * @param u defines the coordinate on X axis
  95535. * @param v defines the coordinate on Y axis
  95536. * @param width defines the width of the source data
  95537. * @param height defines the height of the source data
  95538. * @param pixels defines the source byte array
  95539. * @param color defines the output color
  95540. */
  95541. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  95542. /**
  95543. * Interpolates between a and b via alpha
  95544. * @param a The lower value (returned when alpha = 0)
  95545. * @param b The upper value (returned when alpha = 1)
  95546. * @param alpha The interpolation-factor
  95547. * @return The mixed value
  95548. */
  95549. static Mix(a: number, b: number, alpha: number): number;
  95550. /**
  95551. * Tries to instantiate a new object from a given class name
  95552. * @param className defines the class name to instantiate
  95553. * @returns the new object or null if the system was not able to do the instantiation
  95554. */
  95555. static Instantiate(className: string): any;
  95556. /**
  95557. * Provides a slice function that will work even on IE
  95558. * @param data defines the array to slice
  95559. * @param start defines the start of the data (optional)
  95560. * @param end defines the end of the data (optional)
  95561. * @returns the new sliced array
  95562. */
  95563. static Slice<T>(data: T, start?: number, end?: number): T;
  95564. /**
  95565. * Polyfill for setImmediate
  95566. * @param action defines the action to execute after the current execution block
  95567. */
  95568. static SetImmediate(action: () => void): void;
  95569. /**
  95570. * Function indicating if a number is an exponent of 2
  95571. * @param value defines the value to test
  95572. * @returns true if the value is an exponent of 2
  95573. */
  95574. static IsExponentOfTwo(value: number): boolean;
  95575. private static _tmpFloatArray;
  95576. /**
  95577. * Returns the nearest 32-bit single precision float representation of a Number
  95578. * @param value A Number. If the parameter is of a different type, it will get converted
  95579. * to a number or to NaN if it cannot be converted
  95580. * @returns number
  95581. */
  95582. static FloatRound(value: number): number;
  95583. /**
  95584. * Extracts the filename from a path
  95585. * @param path defines the path to use
  95586. * @returns the filename
  95587. */
  95588. static GetFilename(path: string): string;
  95589. /**
  95590. * Extracts the "folder" part of a path (everything before the filename).
  95591. * @param uri The URI to extract the info from
  95592. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  95593. * @returns The "folder" part of the path
  95594. */
  95595. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  95596. /**
  95597. * Extracts text content from a DOM element hierarchy
  95598. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  95599. */
  95600. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  95601. /**
  95602. * Convert an angle in radians to degrees
  95603. * @param angle defines the angle to convert
  95604. * @returns the angle in degrees
  95605. */
  95606. static ToDegrees(angle: number): number;
  95607. /**
  95608. * Convert an angle in degrees to radians
  95609. * @param angle defines the angle to convert
  95610. * @returns the angle in radians
  95611. */
  95612. static ToRadians(angle: number): number;
  95613. /**
  95614. * Encode a buffer to a base64 string
  95615. * @param buffer defines the buffer to encode
  95616. * @returns the encoded string
  95617. */
  95618. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  95619. /**
  95620. * Returns an array if obj is not an array
  95621. * @param obj defines the object to evaluate as an array
  95622. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  95623. * @returns either obj directly if obj is an array or a new array containing obj
  95624. */
  95625. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  95626. /**
  95627. * Gets the pointer prefix to use
  95628. * @returns "pointer" if touch is enabled. Else returns "mouse"
  95629. */
  95630. static GetPointerPrefix(): string;
  95631. /**
  95632. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  95633. * @param url define the url we are trying
  95634. * @param element define the dom element where to configure the cors policy
  95635. */
  95636. static SetCorsBehavior(url: string | string[], element: {
  95637. crossOrigin: string | null;
  95638. }): void;
  95639. /**
  95640. * Removes unwanted characters from an url
  95641. * @param url defines the url to clean
  95642. * @returns the cleaned url
  95643. */
  95644. static CleanUrl(url: string): string;
  95645. /**
  95646. * Gets or sets a function used to pre-process url before using them to load assets
  95647. */
  95648. static PreprocessUrl: (url: string) => string;
  95649. /**
  95650. * Loads an image as an HTMLImageElement.
  95651. * @param input url string, ArrayBuffer, or Blob to load
  95652. * @param onLoad callback called when the image successfully loads
  95653. * @param onError callback called when the image fails to load
  95654. * @param offlineProvider offline provider for caching
  95655. * @returns the HTMLImageElement of the loaded image
  95656. */
  95657. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  95658. /**
  95659. * Loads a file
  95660. * @param url url string, ArrayBuffer, or Blob to load
  95661. * @param onSuccess callback called when the file successfully loads
  95662. * @param onProgress callback called while file is loading (if the server supports this mode)
  95663. * @param offlineProvider defines the offline provider for caching
  95664. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  95665. * @param onError callback called when the file fails to load
  95666. * @returns a file request object
  95667. */
  95668. 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;
  95669. /**
  95670. * Loads a file from a url
  95671. * @param url the file url to load
  95672. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  95673. */
  95674. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  95675. /**
  95676. * Load a script (identified by an url). When the url returns, the
  95677. * content of this file is added into a new script element, attached to the DOM (body element)
  95678. * @param scriptUrl defines the url of the script to laod
  95679. * @param onSuccess defines the callback called when the script is loaded
  95680. * @param onError defines the callback to call if an error occurs
  95681. * @param scriptId defines the id of the script element
  95682. */
  95683. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  95684. /**
  95685. * Load an asynchronous script (identified by an url). When the url returns, the
  95686. * content of this file is added into a new script element, attached to the DOM (body element)
  95687. * @param scriptUrl defines the url of the script to laod
  95688. * @param scriptId defines the id of the script element
  95689. * @returns a promise request object
  95690. */
  95691. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  95692. /**
  95693. * Loads a file from a blob
  95694. * @param fileToLoad defines the blob to use
  95695. * @param callback defines the callback to call when data is loaded
  95696. * @param progressCallback defines the callback to call during loading process
  95697. * @returns a file request object
  95698. */
  95699. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  95700. /**
  95701. * Loads a file
  95702. * @param fileToLoad defines the file to load
  95703. * @param callback defines the callback to call when data is loaded
  95704. * @param progressCallBack defines the callback to call during loading process
  95705. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  95706. * @returns a file request object
  95707. */
  95708. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  95709. /**
  95710. * Creates a data url from a given string content
  95711. * @param content defines the content to convert
  95712. * @returns the new data url link
  95713. */
  95714. static FileAsURL(content: string): string;
  95715. /**
  95716. * Format the given number to a specific decimal format
  95717. * @param value defines the number to format
  95718. * @param decimals defines the number of decimals to use
  95719. * @returns the formatted string
  95720. */
  95721. static Format(value: number, decimals?: number): string;
  95722. /**
  95723. * Tries to copy an object by duplicating every property
  95724. * @param source defines the source object
  95725. * @param destination defines the target object
  95726. * @param doNotCopyList defines a list of properties to avoid
  95727. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  95728. */
  95729. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  95730. /**
  95731. * Gets a boolean indicating if the given object has no own property
  95732. * @param obj defines the object to test
  95733. * @returns true if object has no own property
  95734. */
  95735. static IsEmpty(obj: any): boolean;
  95736. /**
  95737. * Function used to register events at window level
  95738. * @param events defines the events to register
  95739. */
  95740. static RegisterTopRootEvents(events: {
  95741. name: string;
  95742. handler: Nullable<(e: FocusEvent) => any>;
  95743. }[]): void;
  95744. /**
  95745. * Function used to unregister events from window level
  95746. * @param events defines the events to unregister
  95747. */
  95748. static UnregisterTopRootEvents(events: {
  95749. name: string;
  95750. handler: Nullable<(e: FocusEvent) => any>;
  95751. }[]): void;
  95752. /**
  95753. * @ignore
  95754. */
  95755. static _ScreenshotCanvas: HTMLCanvasElement;
  95756. /**
  95757. * Dumps the current bound framebuffer
  95758. * @param width defines the rendering width
  95759. * @param height defines the rendering height
  95760. * @param engine defines the hosting engine
  95761. * @param successCallback defines the callback triggered once the data are available
  95762. * @param mimeType defines the mime type of the result
  95763. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  95764. */
  95765. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  95766. /**
  95767. * Converts the canvas data to blob.
  95768. * This acts as a polyfill for browsers not supporting the to blob function.
  95769. * @param canvas Defines the canvas to extract the data from
  95770. * @param successCallback Defines the callback triggered once the data are available
  95771. * @param mimeType Defines the mime type of the result
  95772. */
  95773. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  95774. /**
  95775. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  95776. * @param successCallback defines the callback triggered once the data are available
  95777. * @param mimeType defines the mime type of the result
  95778. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  95779. */
  95780. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  95781. /**
  95782. * Downloads a blob in the browser
  95783. * @param blob defines the blob to download
  95784. * @param fileName defines the name of the downloaded file
  95785. */
  95786. static Download(blob: Blob, fileName: string): void;
  95787. /**
  95788. * Captures a screenshot of the current rendering
  95789. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  95790. * @param engine defines the rendering engine
  95791. * @param camera defines the source camera
  95792. * @param size This parameter can be set to a single number or to an object with the
  95793. * following (optional) properties: precision, width, height. If a single number is passed,
  95794. * it will be used for both width and height. If an object is passed, the screenshot size
  95795. * will be derived from the parameters. The precision property is a multiplier allowing
  95796. * rendering at a higher or lower resolution
  95797. * @param successCallback defines the callback receives a single parameter which contains the
  95798. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  95799. * src parameter of an <img> to display it
  95800. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  95801. * Check your browser for supported MIME types
  95802. */
  95803. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  95804. /**
  95805. * Captures a screenshot of the current rendering
  95806. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  95807. * @param engine defines the rendering engine
  95808. * @param camera defines the source camera
  95809. * @param size This parameter can be set to a single number or to an object with the
  95810. * following (optional) properties: precision, width, height. If a single number is passed,
  95811. * it will be used for both width and height. If an object is passed, the screenshot size
  95812. * will be derived from the parameters. The precision property is a multiplier allowing
  95813. * rendering at a higher or lower resolution
  95814. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  95815. * Check your browser for supported MIME types
  95816. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  95817. * to the src parameter of an <img> to display it
  95818. */
  95819. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  95820. /**
  95821. * Generates an image screenshot from the specified camera.
  95822. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  95823. * @param engine The engine to use for rendering
  95824. * @param camera The camera to use for rendering
  95825. * @param size This parameter can be set to a single number or to an object with the
  95826. * following (optional) properties: precision, width, height. If a single number is passed,
  95827. * it will be used for both width and height. If an object is passed, the screenshot size
  95828. * will be derived from the parameters. The precision property is a multiplier allowing
  95829. * rendering at a higher or lower resolution
  95830. * @param successCallback The callback receives a single parameter which contains the
  95831. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  95832. * src parameter of an <img> to display it
  95833. * @param mimeType The MIME type of the screenshot image (default: image/png).
  95834. * Check your browser for supported MIME types
  95835. * @param samples Texture samples (default: 1)
  95836. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  95837. * @param fileName A name for for the downloaded file.
  95838. */
  95839. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  95840. /**
  95841. * Generates an image screenshot from the specified camera.
  95842. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  95843. * @param engine The engine to use for rendering
  95844. * @param camera The camera to use for rendering
  95845. * @param size This parameter can be set to a single number or to an object with the
  95846. * following (optional) properties: precision, width, height. If a single number is passed,
  95847. * it will be used for both width and height. If an object is passed, the screenshot size
  95848. * will be derived from the parameters. The precision property is a multiplier allowing
  95849. * rendering at a higher or lower resolution
  95850. * @param mimeType The MIME type of the screenshot image (default: image/png).
  95851. * Check your browser for supported MIME types
  95852. * @param samples Texture samples (default: 1)
  95853. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  95854. * @param fileName A name for for the downloaded file.
  95855. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  95856. * to the src parameter of an <img> to display it
  95857. */
  95858. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  95859. /**
  95860. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95861. * Be aware Math.random() could cause collisions, but:
  95862. * "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"
  95863. * @returns a pseudo random id
  95864. */
  95865. static RandomId(): string;
  95866. /**
  95867. * Test if the given uri is a base64 string
  95868. * @param uri The uri to test
  95869. * @return True if the uri is a base64 string or false otherwise
  95870. */
  95871. static IsBase64(uri: string): boolean;
  95872. /**
  95873. * Decode the given base64 uri.
  95874. * @param uri The uri to decode
  95875. * @return The decoded base64 data.
  95876. */
  95877. static DecodeBase64(uri: string): ArrayBuffer;
  95878. /**
  95879. * Gets the absolute url.
  95880. * @param url the input url
  95881. * @return the absolute url
  95882. */
  95883. static GetAbsoluteUrl(url: string): string;
  95884. /**
  95885. * No log
  95886. */
  95887. static readonly NoneLogLevel: number;
  95888. /**
  95889. * Only message logs
  95890. */
  95891. static readonly MessageLogLevel: number;
  95892. /**
  95893. * Only warning logs
  95894. */
  95895. static readonly WarningLogLevel: number;
  95896. /**
  95897. * Only error logs
  95898. */
  95899. static readonly ErrorLogLevel: number;
  95900. /**
  95901. * All logs
  95902. */
  95903. static readonly AllLogLevel: number;
  95904. /**
  95905. * Gets a value indicating the number of loading errors
  95906. * @ignorenaming
  95907. */
  95908. static readonly errorsCount: number;
  95909. /**
  95910. * Callback called when a new log is added
  95911. */
  95912. static OnNewCacheEntry: (entry: string) => void;
  95913. /**
  95914. * Log a message to the console
  95915. * @param message defines the message to log
  95916. */
  95917. static Log(message: string): void;
  95918. /**
  95919. * Write a warning message to the console
  95920. * @param message defines the message to log
  95921. */
  95922. static Warn(message: string): void;
  95923. /**
  95924. * Write an error message to the console
  95925. * @param message defines the message to log
  95926. */
  95927. static Error(message: string): void;
  95928. /**
  95929. * Gets current log cache (list of logs)
  95930. */
  95931. static readonly LogCache: string;
  95932. /**
  95933. * Clears the log cache
  95934. */
  95935. static ClearLogCache(): void;
  95936. /**
  95937. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  95938. */
  95939. static LogLevels: number;
  95940. /**
  95941. * Checks if the window object exists
  95942. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  95943. */
  95944. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  95945. /**
  95946. * No performance log
  95947. */
  95948. static readonly PerformanceNoneLogLevel: number;
  95949. /**
  95950. * Use user marks to log performance
  95951. */
  95952. static readonly PerformanceUserMarkLogLevel: number;
  95953. /**
  95954. * Log performance to the console
  95955. */
  95956. static readonly PerformanceConsoleLogLevel: number;
  95957. private static _performance;
  95958. /**
  95959. * Sets the current performance log level
  95960. */
  95961. static PerformanceLogLevel: number;
  95962. private static _StartPerformanceCounterDisabled;
  95963. private static _EndPerformanceCounterDisabled;
  95964. private static _StartUserMark;
  95965. private static _EndUserMark;
  95966. private static _StartPerformanceConsole;
  95967. private static _EndPerformanceConsole;
  95968. /**
  95969. * Starts a performance counter
  95970. */
  95971. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  95972. /**
  95973. * Ends a specific performance coutner
  95974. */
  95975. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  95976. /**
  95977. * Gets either window.performance.now() if supported or Date.now() else
  95978. */
  95979. static readonly Now: number;
  95980. /**
  95981. * This method will return the name of the class used to create the instance of the given object.
  95982. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  95983. * @param object the object to get the class name from
  95984. * @param isType defines if the object is actually a type
  95985. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  95986. */
  95987. static GetClassName(object: any, isType?: boolean): string;
  95988. /**
  95989. * Gets the first element of an array satisfying a given predicate
  95990. * @param array defines the array to browse
  95991. * @param predicate defines the predicate to use
  95992. * @returns null if not found or the element
  95993. */
  95994. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  95995. /**
  95996. * This method will return the name of the full name of the class, including its owning module (if any).
  95997. * 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).
  95998. * @param object the object to get the class name from
  95999. * @param isType defines if the object is actually a type
  96000. * @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.
  96001. * @ignorenaming
  96002. */
  96003. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  96004. /**
  96005. * Returns a promise that resolves after the given amount of time.
  96006. * @param delay Number of milliseconds to delay
  96007. * @returns Promise that resolves after the given amount of time
  96008. */
  96009. static DelayAsync(delay: number): Promise<void>;
  96010. }
  96011. /**
  96012. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  96013. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  96014. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  96015. * @param name The name of the class, case should be preserved
  96016. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  96017. */
  96018. export function className(name: string, module?: string): (target: Object) => void;
  96019. /**
  96020. * An implementation of a loop for asynchronous functions.
  96021. */
  96022. export class AsyncLoop {
  96023. /**
  96024. * Defines the number of iterations for the loop
  96025. */
  96026. iterations: number;
  96027. /**
  96028. * Defines the current index of the loop.
  96029. */
  96030. index: number;
  96031. private _done;
  96032. private _fn;
  96033. private _successCallback;
  96034. /**
  96035. * Constructor.
  96036. * @param iterations the number of iterations.
  96037. * @param func the function to run each iteration
  96038. * @param successCallback the callback that will be called upon succesful execution
  96039. * @param offset starting offset.
  96040. */
  96041. constructor(
  96042. /**
  96043. * Defines the number of iterations for the loop
  96044. */
  96045. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  96046. /**
  96047. * Execute the next iteration. Must be called after the last iteration was finished.
  96048. */
  96049. executeNext(): void;
  96050. /**
  96051. * Break the loop and run the success callback.
  96052. */
  96053. breakLoop(): void;
  96054. /**
  96055. * Create and run an async loop.
  96056. * @param iterations the number of iterations.
  96057. * @param fn the function to run each iteration
  96058. * @param successCallback the callback that will be called upon succesful execution
  96059. * @param offset starting offset.
  96060. * @returns the created async loop object
  96061. */
  96062. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  96063. /**
  96064. * A for-loop that will run a given number of iterations synchronous and the rest async.
  96065. * @param iterations total number of iterations
  96066. * @param syncedIterations number of synchronous iterations in each async iteration.
  96067. * @param fn the function to call each iteration.
  96068. * @param callback a success call back that will be called when iterating stops.
  96069. * @param breakFunction a break condition (optional)
  96070. * @param timeout timeout settings for the setTimeout function. default - 0.
  96071. * @returns the created async loop object
  96072. */
  96073. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  96074. }
  96075. }
  96076. declare module BABYLON {
  96077. /** @hidden */
  96078. export interface ICollisionCoordinator {
  96079. createCollider(): Collider;
  96080. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  96081. init(scene: Scene): void;
  96082. }
  96083. /** @hidden */
  96084. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  96085. private _scene;
  96086. private _scaledPosition;
  96087. private _scaledVelocity;
  96088. private _finalPosition;
  96089. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  96090. createCollider(): Collider;
  96091. init(scene: Scene): void;
  96092. private _collideWithWorld;
  96093. }
  96094. }
  96095. declare module BABYLON {
  96096. /**
  96097. * Class used to manage all inputs for the scene.
  96098. */
  96099. export class InputManager {
  96100. /** The distance in pixel that you have to move to prevent some events */
  96101. static DragMovementThreshold: number;
  96102. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  96103. static LongPressDelay: number;
  96104. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  96105. static DoubleClickDelay: number;
  96106. /** If you need to check double click without raising a single click at first click, enable this flag */
  96107. static ExclusiveDoubleClickMode: boolean;
  96108. private _wheelEventName;
  96109. private _onPointerMove;
  96110. private _onPointerDown;
  96111. private _onPointerUp;
  96112. private _initClickEvent;
  96113. private _initActionManager;
  96114. private _delayedSimpleClick;
  96115. private _delayedSimpleClickTimeout;
  96116. private _previousDelayedSimpleClickTimeout;
  96117. private _meshPickProceed;
  96118. private _previousButtonPressed;
  96119. private _currentPickResult;
  96120. private _previousPickResult;
  96121. private _totalPointersPressed;
  96122. private _doubleClickOccured;
  96123. private _pointerOverMesh;
  96124. private _pickedDownMesh;
  96125. private _pickedUpMesh;
  96126. private _pointerX;
  96127. private _pointerY;
  96128. private _unTranslatedPointerX;
  96129. private _unTranslatedPointerY;
  96130. private _startingPointerPosition;
  96131. private _previousStartingPointerPosition;
  96132. private _startingPointerTime;
  96133. private _previousStartingPointerTime;
  96134. private _pointerCaptures;
  96135. private _onKeyDown;
  96136. private _onKeyUp;
  96137. private _onCanvasFocusObserver;
  96138. private _onCanvasBlurObserver;
  96139. private _scene;
  96140. /**
  96141. * Creates a new InputManager
  96142. * @param scene defines the hosting scene
  96143. */
  96144. constructor(scene: Scene);
  96145. /**
  96146. * Gets the mesh that is currently under the pointer
  96147. */
  96148. readonly meshUnderPointer: Nullable<AbstractMesh>;
  96149. /**
  96150. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  96151. */
  96152. readonly unTranslatedPointer: Vector2;
  96153. /**
  96154. * Gets or sets the current on-screen X position of the pointer
  96155. */
  96156. pointerX: number;
  96157. /**
  96158. * Gets or sets the current on-screen Y position of the pointer
  96159. */
  96160. pointerY: number;
  96161. private _updatePointerPosition;
  96162. private _processPointerMove;
  96163. private _setRayOnPointerInfo;
  96164. private _checkPrePointerObservable;
  96165. /**
  96166. * Use this method to simulate a pointer move on a mesh
  96167. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96168. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96169. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96170. */
  96171. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  96172. /**
  96173. * Use this method to simulate a pointer down on a mesh
  96174. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96175. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96176. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96177. */
  96178. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  96179. private _processPointerDown;
  96180. /** @hidden */
  96181. _isPointerSwiping(): boolean;
  96182. /**
  96183. * Use this method to simulate a pointer up on a mesh
  96184. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96185. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96186. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96187. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  96188. */
  96189. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  96190. private _processPointerUp;
  96191. /**
  96192. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  96193. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  96194. * @returns true if the pointer was captured
  96195. */
  96196. isPointerCaptured(pointerId?: number): boolean;
  96197. /**
  96198. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  96199. * @param attachUp defines if you want to attach events to pointerup
  96200. * @param attachDown defines if you want to attach events to pointerdown
  96201. * @param attachMove defines if you want to attach events to pointermove
  96202. */
  96203. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  96204. /**
  96205. * Detaches all event handlers
  96206. */
  96207. detachControl(): void;
  96208. /**
  96209. * Force the value of meshUnderPointer
  96210. * @param mesh defines the mesh to use
  96211. */
  96212. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  96213. /**
  96214. * Gets the mesh under the pointer
  96215. * @returns a Mesh or null if no mesh is under the pointer
  96216. */
  96217. getPointerOverMesh(): Nullable<AbstractMesh>;
  96218. }
  96219. }
  96220. declare module BABYLON {
  96221. /**
  96222. * Helper class used to generate session unique ID
  96223. */
  96224. export class UniqueIdGenerator {
  96225. private static _UniqueIdCounter;
  96226. /**
  96227. * Gets an unique (relatively to the current scene) Id
  96228. */
  96229. static readonly UniqueId: number;
  96230. }
  96231. }
  96232. declare module BABYLON {
  96233. /**
  96234. * This class defines the direct association between an animation and a target
  96235. */
  96236. export class TargetedAnimation {
  96237. /**
  96238. * Animation to perform
  96239. */
  96240. animation: Animation;
  96241. /**
  96242. * Target to animate
  96243. */
  96244. target: any;
  96245. /**
  96246. * Serialize the object
  96247. * @returns the JSON object representing the current entity
  96248. */
  96249. serialize(): any;
  96250. }
  96251. /**
  96252. * Use this class to create coordinated animations on multiple targets
  96253. */
  96254. export class AnimationGroup implements IDisposable {
  96255. /** The name of the animation group */
  96256. name: string;
  96257. private _scene;
  96258. private _targetedAnimations;
  96259. private _animatables;
  96260. private _from;
  96261. private _to;
  96262. private _isStarted;
  96263. private _isPaused;
  96264. private _speedRatio;
  96265. private _loopAnimation;
  96266. /**
  96267. * Gets or sets the unique id of the node
  96268. */
  96269. uniqueId: number;
  96270. /**
  96271. * This observable will notify when one animation have ended
  96272. */
  96273. onAnimationEndObservable: Observable<TargetedAnimation>;
  96274. /**
  96275. * Observer raised when one animation loops
  96276. */
  96277. onAnimationLoopObservable: Observable<TargetedAnimation>;
  96278. /**
  96279. * This observable will notify when all animations have ended.
  96280. */
  96281. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  96282. /**
  96283. * This observable will notify when all animations have paused.
  96284. */
  96285. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  96286. /**
  96287. * This observable will notify when all animations are playing.
  96288. */
  96289. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  96290. /**
  96291. * Gets the first frame
  96292. */
  96293. readonly from: number;
  96294. /**
  96295. * Gets the last frame
  96296. */
  96297. readonly to: number;
  96298. /**
  96299. * Define if the animations are started
  96300. */
  96301. readonly isStarted: boolean;
  96302. /**
  96303. * Gets a value indicating that the current group is playing
  96304. */
  96305. readonly isPlaying: boolean;
  96306. /**
  96307. * Gets or sets the speed ratio to use for all animations
  96308. */
  96309. /**
  96310. * Gets or sets the speed ratio to use for all animations
  96311. */
  96312. speedRatio: number;
  96313. /**
  96314. * Gets or sets if all animations should loop or not
  96315. */
  96316. loopAnimation: boolean;
  96317. /**
  96318. * Gets the targeted animations for this animation group
  96319. */
  96320. readonly targetedAnimations: Array<TargetedAnimation>;
  96321. /**
  96322. * returning the list of animatables controlled by this animation group.
  96323. */
  96324. readonly animatables: Array<Animatable>;
  96325. /**
  96326. * Instantiates a new Animation Group.
  96327. * This helps managing several animations at once.
  96328. * @see http://doc.babylonjs.com/how_to/group
  96329. * @param name Defines the name of the group
  96330. * @param scene Defines the scene the group belongs to
  96331. */
  96332. constructor(
  96333. /** The name of the animation group */
  96334. name: string, scene?: Nullable<Scene>);
  96335. /**
  96336. * Add an animation (with its target) in the group
  96337. * @param animation defines the animation we want to add
  96338. * @param target defines the target of the animation
  96339. * @returns the TargetedAnimation object
  96340. */
  96341. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  96342. /**
  96343. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  96344. * It can add constant keys at begin or end
  96345. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  96346. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  96347. * @returns the animation group
  96348. */
  96349. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  96350. /**
  96351. * Start all animations on given targets
  96352. * @param loop defines if animations must loop
  96353. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  96354. * @param from defines the from key (optional)
  96355. * @param to defines the to key (optional)
  96356. * @returns the current animation group
  96357. */
  96358. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  96359. /**
  96360. * Pause all animations
  96361. * @returns the animation group
  96362. */
  96363. pause(): AnimationGroup;
  96364. /**
  96365. * Play all animations to initial state
  96366. * This function will start() the animations if they were not started or will restart() them if they were paused
  96367. * @param loop defines if animations must loop
  96368. * @returns the animation group
  96369. */
  96370. play(loop?: boolean): AnimationGroup;
  96371. /**
  96372. * Reset all animations to initial state
  96373. * @returns the animation group
  96374. */
  96375. reset(): AnimationGroup;
  96376. /**
  96377. * Restart animations from key 0
  96378. * @returns the animation group
  96379. */
  96380. restart(): AnimationGroup;
  96381. /**
  96382. * Stop all animations
  96383. * @returns the animation group
  96384. */
  96385. stop(): AnimationGroup;
  96386. /**
  96387. * Set animation weight for all animatables
  96388. * @param weight defines the weight to use
  96389. * @return the animationGroup
  96390. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  96391. */
  96392. setWeightForAllAnimatables(weight: number): AnimationGroup;
  96393. /**
  96394. * Synchronize and normalize all animatables with a source animatable
  96395. * @param root defines the root animatable to synchronize with
  96396. * @return the animationGroup
  96397. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  96398. */
  96399. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  96400. /**
  96401. * Goes to a specific frame in this animation group
  96402. * @param frame the frame number to go to
  96403. * @return the animationGroup
  96404. */
  96405. goToFrame(frame: number): AnimationGroup;
  96406. /**
  96407. * Dispose all associated resources
  96408. */
  96409. dispose(): void;
  96410. private _checkAnimationGroupEnded;
  96411. /**
  96412. * Clone the current animation group and returns a copy
  96413. * @param newName defines the name of the new group
  96414. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  96415. * @returns the new aniamtion group
  96416. */
  96417. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  96418. /**
  96419. * Serializes the animationGroup to an object
  96420. * @returns Serialized object
  96421. */
  96422. serialize(): any;
  96423. /**
  96424. * Returns a new AnimationGroup object parsed from the source provided.
  96425. * @param parsedAnimationGroup defines the source
  96426. * @param scene defines the scene that will receive the animationGroup
  96427. * @returns a new AnimationGroup
  96428. */
  96429. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  96430. /**
  96431. * Returns the string "AnimationGroup"
  96432. * @returns "AnimationGroup"
  96433. */
  96434. getClassName(): string;
  96435. /**
  96436. * Creates a detailled string about the object
  96437. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  96438. * @returns a string representing the object
  96439. */
  96440. toString(fullDetails?: boolean): string;
  96441. }
  96442. }
  96443. declare module BABYLON {
  96444. /**
  96445. * Define an interface for all classes that will hold resources
  96446. */
  96447. export interface IDisposable {
  96448. /**
  96449. * Releases all held resources
  96450. */
  96451. dispose(): void;
  96452. }
  96453. /** Interface defining initialization parameters for Scene class */
  96454. export interface SceneOptions {
  96455. /**
  96456. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  96457. * It will improve performance when the number of geometries becomes important.
  96458. */
  96459. useGeometryUniqueIdsMap?: boolean;
  96460. /**
  96461. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  96462. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  96463. */
  96464. useMaterialMeshMap?: boolean;
  96465. /**
  96466. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  96467. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  96468. */
  96469. useClonedMeshhMap?: boolean;
  96470. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  96471. virtual?: boolean;
  96472. }
  96473. /**
  96474. * Represents a scene to be rendered by the engine.
  96475. * @see http://doc.babylonjs.com/features/scene
  96476. */
  96477. export class Scene extends AbstractScene implements IAnimatable {
  96478. /** The fog is deactivated */
  96479. static readonly FOGMODE_NONE: number;
  96480. /** The fog density is following an exponential function */
  96481. static readonly FOGMODE_EXP: number;
  96482. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  96483. static readonly FOGMODE_EXP2: number;
  96484. /** The fog density is following a linear function. */
  96485. static readonly FOGMODE_LINEAR: number;
  96486. /**
  96487. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  96488. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96489. */
  96490. static MinDeltaTime: number;
  96491. /**
  96492. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  96493. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96494. */
  96495. static MaxDeltaTime: number;
  96496. /**
  96497. * Factory used to create the default material.
  96498. * @param name The name of the material to create
  96499. * @param scene The scene to create the material for
  96500. * @returns The default material
  96501. */
  96502. static DefaultMaterialFactory(scene: Scene): Material;
  96503. /**
  96504. * Factory used to create the a collision coordinator.
  96505. * @returns The collision coordinator
  96506. */
  96507. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  96508. /** @hidden */
  96509. _inputManager: InputManager;
  96510. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  96511. cameraToUseForPointers: Nullable<Camera>;
  96512. /** @hidden */
  96513. readonly _isScene: boolean;
  96514. /**
  96515. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  96516. */
  96517. autoClear: boolean;
  96518. /**
  96519. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  96520. */
  96521. autoClearDepthAndStencil: boolean;
  96522. /**
  96523. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  96524. */
  96525. clearColor: Color4;
  96526. /**
  96527. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  96528. */
  96529. ambientColor: Color3;
  96530. /**
  96531. * This is use to store the default BRDF lookup for PBR materials in your scene.
  96532. * It should only be one of the following (if not the default embedded one):
  96533. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  96534. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  96535. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  96536. * The material properties need to be setup according to the type of texture in use.
  96537. */
  96538. environmentBRDFTexture: BaseTexture;
  96539. /** @hidden */
  96540. protected _environmentTexture: Nullable<BaseTexture>;
  96541. /**
  96542. * Texture used in all pbr material as the reflection texture.
  96543. * As in the majority of the scene they are the same (exception for multi room and so on),
  96544. * this is easier to reference from here than from all the materials.
  96545. */
  96546. /**
  96547. * Texture used in all pbr material as the reflection texture.
  96548. * As in the majority of the scene they are the same (exception for multi room and so on),
  96549. * this is easier to set here than in all the materials.
  96550. */
  96551. environmentTexture: Nullable<BaseTexture>;
  96552. /** @hidden */
  96553. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  96554. /**
  96555. * Default image processing configuration used either in the rendering
  96556. * Forward main pass or through the imageProcessingPostProcess if present.
  96557. * As in the majority of the scene they are the same (exception for multi camera),
  96558. * this is easier to reference from here than from all the materials and post process.
  96559. *
  96560. * No setter as we it is a shared configuration, you can set the values instead.
  96561. */
  96562. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  96563. private _forceWireframe;
  96564. /**
  96565. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  96566. */
  96567. forceWireframe: boolean;
  96568. private _forcePointsCloud;
  96569. /**
  96570. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  96571. */
  96572. forcePointsCloud: boolean;
  96573. /**
  96574. * Gets or sets the active clipplane 1
  96575. */
  96576. clipPlane: Nullable<Plane>;
  96577. /**
  96578. * Gets or sets the active clipplane 2
  96579. */
  96580. clipPlane2: Nullable<Plane>;
  96581. /**
  96582. * Gets or sets the active clipplane 3
  96583. */
  96584. clipPlane3: Nullable<Plane>;
  96585. /**
  96586. * Gets or sets the active clipplane 4
  96587. */
  96588. clipPlane4: Nullable<Plane>;
  96589. /**
  96590. * Gets or sets a boolean indicating if animations are enabled
  96591. */
  96592. animationsEnabled: boolean;
  96593. private _animationPropertiesOverride;
  96594. /**
  96595. * Gets or sets the animation properties override
  96596. */
  96597. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  96598. /**
  96599. * Gets or sets a boolean indicating if a constant deltatime has to be used
  96600. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  96601. */
  96602. useConstantAnimationDeltaTime: boolean;
  96603. /**
  96604. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  96605. * Please note that it requires to run a ray cast through the scene on every frame
  96606. */
  96607. constantlyUpdateMeshUnderPointer: boolean;
  96608. /**
  96609. * Defines the HTML cursor to use when hovering over interactive elements
  96610. */
  96611. hoverCursor: string;
  96612. /**
  96613. * Defines the HTML default cursor to use (empty by default)
  96614. */
  96615. defaultCursor: string;
  96616. /**
  96617. * This is used to call preventDefault() on pointer down
  96618. * in order to block unwanted artifacts like system double clicks
  96619. */
  96620. preventDefaultOnPointerDown: boolean;
  96621. /**
  96622. * This is used to call preventDefault() on pointer up
  96623. * in order to block unwanted artifacts like system double clicks
  96624. */
  96625. preventDefaultOnPointerUp: boolean;
  96626. /**
  96627. * Gets or sets user defined metadata
  96628. */
  96629. metadata: any;
  96630. /**
  96631. * For internal use only. Please do not use.
  96632. */
  96633. reservedDataStore: any;
  96634. /**
  96635. * Gets the name of the plugin used to load this scene (null by default)
  96636. */
  96637. loadingPluginName: string;
  96638. /**
  96639. * Use this array to add regular expressions used to disable offline support for specific urls
  96640. */
  96641. disableOfflineSupportExceptionRules: RegExp[];
  96642. /**
  96643. * An event triggered when the scene is disposed.
  96644. */
  96645. onDisposeObservable: Observable<Scene>;
  96646. private _onDisposeObserver;
  96647. /** Sets a function to be executed when this scene is disposed. */
  96648. onDispose: () => void;
  96649. /**
  96650. * An event triggered before rendering the scene (right after animations and physics)
  96651. */
  96652. onBeforeRenderObservable: Observable<Scene>;
  96653. private _onBeforeRenderObserver;
  96654. /** Sets a function to be executed before rendering this scene */
  96655. beforeRender: Nullable<() => void>;
  96656. /**
  96657. * An event triggered after rendering the scene
  96658. */
  96659. onAfterRenderObservable: Observable<Scene>;
  96660. /**
  96661. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  96662. */
  96663. onAfterRenderCameraObservable: Observable<Camera>;
  96664. private _onAfterRenderObserver;
  96665. /** Sets a function to be executed after rendering this scene */
  96666. afterRender: Nullable<() => void>;
  96667. /**
  96668. * An event triggered before animating the scene
  96669. */
  96670. onBeforeAnimationsObservable: Observable<Scene>;
  96671. /**
  96672. * An event triggered after animations processing
  96673. */
  96674. onAfterAnimationsObservable: Observable<Scene>;
  96675. /**
  96676. * An event triggered before draw calls are ready to be sent
  96677. */
  96678. onBeforeDrawPhaseObservable: Observable<Scene>;
  96679. /**
  96680. * An event triggered after draw calls have been sent
  96681. */
  96682. onAfterDrawPhaseObservable: Observable<Scene>;
  96683. /**
  96684. * An event triggered when the scene is ready
  96685. */
  96686. onReadyObservable: Observable<Scene>;
  96687. /**
  96688. * An event triggered before rendering a camera
  96689. */
  96690. onBeforeCameraRenderObservable: Observable<Camera>;
  96691. private _onBeforeCameraRenderObserver;
  96692. /** Sets a function to be executed before rendering a camera*/
  96693. beforeCameraRender: () => void;
  96694. /**
  96695. * An event triggered after rendering a camera
  96696. */
  96697. onAfterCameraRenderObservable: Observable<Camera>;
  96698. private _onAfterCameraRenderObserver;
  96699. /** Sets a function to be executed after rendering a camera*/
  96700. afterCameraRender: () => void;
  96701. /**
  96702. * An event triggered when active meshes evaluation is about to start
  96703. */
  96704. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  96705. /**
  96706. * An event triggered when active meshes evaluation is done
  96707. */
  96708. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  96709. /**
  96710. * An event triggered when particles rendering is about to start
  96711. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  96712. */
  96713. onBeforeParticlesRenderingObservable: Observable<Scene>;
  96714. /**
  96715. * An event triggered when particles rendering is done
  96716. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  96717. */
  96718. onAfterParticlesRenderingObservable: Observable<Scene>;
  96719. /**
  96720. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  96721. */
  96722. onDataLoadedObservable: Observable<Scene>;
  96723. /**
  96724. * An event triggered when a camera is created
  96725. */
  96726. onNewCameraAddedObservable: Observable<Camera>;
  96727. /**
  96728. * An event triggered when a camera is removed
  96729. */
  96730. onCameraRemovedObservable: Observable<Camera>;
  96731. /**
  96732. * An event triggered when a light is created
  96733. */
  96734. onNewLightAddedObservable: Observable<Light>;
  96735. /**
  96736. * An event triggered when a light is removed
  96737. */
  96738. onLightRemovedObservable: Observable<Light>;
  96739. /**
  96740. * An event triggered when a geometry is created
  96741. */
  96742. onNewGeometryAddedObservable: Observable<Geometry>;
  96743. /**
  96744. * An event triggered when a geometry is removed
  96745. */
  96746. onGeometryRemovedObservable: Observable<Geometry>;
  96747. /**
  96748. * An event triggered when a transform node is created
  96749. */
  96750. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  96751. /**
  96752. * An event triggered when a transform node is removed
  96753. */
  96754. onTransformNodeRemovedObservable: Observable<TransformNode>;
  96755. /**
  96756. * An event triggered when a mesh is created
  96757. */
  96758. onNewMeshAddedObservable: Observable<AbstractMesh>;
  96759. /**
  96760. * An event triggered when a mesh is removed
  96761. */
  96762. onMeshRemovedObservable: Observable<AbstractMesh>;
  96763. /**
  96764. * An event triggered when a skeleton is created
  96765. */
  96766. onNewSkeletonAddedObservable: Observable<Skeleton>;
  96767. /**
  96768. * An event triggered when a skeleton is removed
  96769. */
  96770. onSkeletonRemovedObservable: Observable<Skeleton>;
  96771. /**
  96772. * An event triggered when a material is created
  96773. */
  96774. onNewMaterialAddedObservable: Observable<Material>;
  96775. /**
  96776. * An event triggered when a material is removed
  96777. */
  96778. onMaterialRemovedObservable: Observable<Material>;
  96779. /**
  96780. * An event triggered when a texture is created
  96781. */
  96782. onNewTextureAddedObservable: Observable<BaseTexture>;
  96783. /**
  96784. * An event triggered when a texture is removed
  96785. */
  96786. onTextureRemovedObservable: Observable<BaseTexture>;
  96787. /**
  96788. * An event triggered when render targets are about to be rendered
  96789. * Can happen multiple times per frame.
  96790. */
  96791. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  96792. /**
  96793. * An event triggered when render targets were rendered.
  96794. * Can happen multiple times per frame.
  96795. */
  96796. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  96797. /**
  96798. * An event triggered before calculating deterministic simulation step
  96799. */
  96800. onBeforeStepObservable: Observable<Scene>;
  96801. /**
  96802. * An event triggered after calculating deterministic simulation step
  96803. */
  96804. onAfterStepObservable: Observable<Scene>;
  96805. /**
  96806. * An event triggered when the activeCamera property is updated
  96807. */
  96808. onActiveCameraChanged: Observable<Scene>;
  96809. /**
  96810. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  96811. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  96812. * 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)
  96813. */
  96814. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  96815. /**
  96816. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  96817. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  96818. * 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)
  96819. */
  96820. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  96821. /**
  96822. * This Observable will when a mesh has been imported into the scene.
  96823. */
  96824. onMeshImportedObservable: Observable<AbstractMesh>;
  96825. /**
  96826. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  96827. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  96828. */
  96829. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  96830. /** @hidden */
  96831. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  96832. /**
  96833. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  96834. */
  96835. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  96836. /**
  96837. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  96838. */
  96839. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  96840. /**
  96841. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  96842. */
  96843. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  96844. /** Callback called when a pointer move is detected */
  96845. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  96846. /** Callback called when a pointer down is detected */
  96847. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  96848. /** Callback called when a pointer up is detected */
  96849. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  96850. /** Callback called when a pointer pick is detected */
  96851. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  96852. /**
  96853. * 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).
  96854. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  96855. */
  96856. onPrePointerObservable: Observable<PointerInfoPre>;
  96857. /**
  96858. * Observable event triggered each time an input event is received from the rendering canvas
  96859. */
  96860. onPointerObservable: Observable<PointerInfo>;
  96861. /**
  96862. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  96863. */
  96864. readonly unTranslatedPointer: Vector2;
  96865. /**
  96866. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  96867. */
  96868. static DragMovementThreshold: number;
  96869. /**
  96870. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  96871. */
  96872. static LongPressDelay: number;
  96873. /**
  96874. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  96875. */
  96876. static DoubleClickDelay: number;
  96877. /** If you need to check double click without raising a single click at first click, enable this flag */
  96878. static ExclusiveDoubleClickMode: boolean;
  96879. /** @hidden */
  96880. _mirroredCameraPosition: Nullable<Vector3>;
  96881. /**
  96882. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  96883. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  96884. */
  96885. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  96886. /**
  96887. * Observable event triggered each time an keyboard event is received from the hosting window
  96888. */
  96889. onKeyboardObservable: Observable<KeyboardInfo>;
  96890. private _useRightHandedSystem;
  96891. /**
  96892. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  96893. */
  96894. useRightHandedSystem: boolean;
  96895. private _timeAccumulator;
  96896. private _currentStepId;
  96897. private _currentInternalStep;
  96898. /**
  96899. * Sets the step Id used by deterministic lock step
  96900. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96901. * @param newStepId defines the step Id
  96902. */
  96903. setStepId(newStepId: number): void;
  96904. /**
  96905. * Gets the step Id used by deterministic lock step
  96906. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96907. * @returns the step Id
  96908. */
  96909. getStepId(): number;
  96910. /**
  96911. * Gets the internal step used by deterministic lock step
  96912. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96913. * @returns the internal step
  96914. */
  96915. getInternalStep(): number;
  96916. private _fogEnabled;
  96917. /**
  96918. * Gets or sets a boolean indicating if fog is enabled on this scene
  96919. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96920. * (Default is true)
  96921. */
  96922. fogEnabled: boolean;
  96923. private _fogMode;
  96924. /**
  96925. * Gets or sets the fog mode to use
  96926. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96927. * | mode | value |
  96928. * | --- | --- |
  96929. * | FOGMODE_NONE | 0 |
  96930. * | FOGMODE_EXP | 1 |
  96931. * | FOGMODE_EXP2 | 2 |
  96932. * | FOGMODE_LINEAR | 3 |
  96933. */
  96934. fogMode: number;
  96935. /**
  96936. * Gets or sets the fog color to use
  96937. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96938. * (Default is Color3(0.2, 0.2, 0.3))
  96939. */
  96940. fogColor: Color3;
  96941. /**
  96942. * Gets or sets the fog density to use
  96943. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96944. * (Default is 0.1)
  96945. */
  96946. fogDensity: number;
  96947. /**
  96948. * Gets or sets the fog start distance to use
  96949. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96950. * (Default is 0)
  96951. */
  96952. fogStart: number;
  96953. /**
  96954. * Gets or sets the fog end distance to use
  96955. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96956. * (Default is 1000)
  96957. */
  96958. fogEnd: number;
  96959. private _shadowsEnabled;
  96960. /**
  96961. * Gets or sets a boolean indicating if shadows are enabled on this scene
  96962. */
  96963. shadowsEnabled: boolean;
  96964. private _lightsEnabled;
  96965. /**
  96966. * Gets or sets a boolean indicating if lights are enabled on this scene
  96967. */
  96968. lightsEnabled: boolean;
  96969. /** All of the active cameras added to this scene. */
  96970. activeCameras: Camera[];
  96971. /** @hidden */
  96972. _activeCamera: Nullable<Camera>;
  96973. /** Gets or sets the current active camera */
  96974. activeCamera: Nullable<Camera>;
  96975. private _defaultMaterial;
  96976. /** The default material used on meshes when no material is affected */
  96977. /** The default material used on meshes when no material is affected */
  96978. defaultMaterial: Material;
  96979. private _texturesEnabled;
  96980. /**
  96981. * Gets or sets a boolean indicating if textures are enabled on this scene
  96982. */
  96983. texturesEnabled: boolean;
  96984. /**
  96985. * Gets or sets a boolean indicating if particles are enabled on this scene
  96986. */
  96987. particlesEnabled: boolean;
  96988. /**
  96989. * Gets or sets a boolean indicating if sprites are enabled on this scene
  96990. */
  96991. spritesEnabled: boolean;
  96992. private _skeletonsEnabled;
  96993. /**
  96994. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  96995. */
  96996. skeletonsEnabled: boolean;
  96997. /**
  96998. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  96999. */
  97000. lensFlaresEnabled: boolean;
  97001. /**
  97002. * Gets or sets a boolean indicating if collisions are enabled on this scene
  97003. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97004. */
  97005. collisionsEnabled: boolean;
  97006. private _collisionCoordinator;
  97007. /** @hidden */
  97008. readonly collisionCoordinator: ICollisionCoordinator;
  97009. /**
  97010. * Defines the gravity applied to this scene (used only for collisions)
  97011. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  97012. */
  97013. gravity: Vector3;
  97014. /**
  97015. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  97016. */
  97017. postProcessesEnabled: boolean;
  97018. /**
  97019. * The list of postprocesses added to the scene
  97020. */
  97021. postProcesses: PostProcess[];
  97022. /**
  97023. * Gets the current postprocess manager
  97024. */
  97025. postProcessManager: PostProcessManager;
  97026. /**
  97027. * Gets or sets a boolean indicating if render targets are enabled on this scene
  97028. */
  97029. renderTargetsEnabled: boolean;
  97030. /**
  97031. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  97032. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  97033. */
  97034. dumpNextRenderTargets: boolean;
  97035. /**
  97036. * The list of user defined render targets added to the scene
  97037. */
  97038. customRenderTargets: RenderTargetTexture[];
  97039. /**
  97040. * Defines if texture loading must be delayed
  97041. * If true, textures will only be loaded when they need to be rendered
  97042. */
  97043. useDelayedTextureLoading: boolean;
  97044. /**
  97045. * Gets the list of meshes imported to the scene through SceneLoader
  97046. */
  97047. importedMeshesFiles: String[];
  97048. /**
  97049. * Gets or sets a boolean indicating if probes are enabled on this scene
  97050. */
  97051. probesEnabled: boolean;
  97052. /**
  97053. * Gets or sets the current offline provider to use to store scene data
  97054. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  97055. */
  97056. offlineProvider: IOfflineProvider;
  97057. /**
  97058. * Gets or sets the action manager associated with the scene
  97059. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97060. */
  97061. actionManager: AbstractActionManager;
  97062. private _meshesForIntersections;
  97063. /**
  97064. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  97065. */
  97066. proceduralTexturesEnabled: boolean;
  97067. private _engine;
  97068. private _totalVertices;
  97069. /** @hidden */
  97070. _activeIndices: PerfCounter;
  97071. /** @hidden */
  97072. _activeParticles: PerfCounter;
  97073. /** @hidden */
  97074. _activeBones: PerfCounter;
  97075. private _animationRatio;
  97076. /** @hidden */
  97077. _animationTimeLast: number;
  97078. /** @hidden */
  97079. _animationTime: number;
  97080. /**
  97081. * Gets or sets a general scale for animation speed
  97082. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  97083. */
  97084. animationTimeScale: number;
  97085. /** @hidden */
  97086. _cachedMaterial: Nullable<Material>;
  97087. /** @hidden */
  97088. _cachedEffect: Nullable<Effect>;
  97089. /** @hidden */
  97090. _cachedVisibility: Nullable<number>;
  97091. private _renderId;
  97092. private _frameId;
  97093. private _executeWhenReadyTimeoutId;
  97094. private _intermediateRendering;
  97095. private _viewUpdateFlag;
  97096. private _projectionUpdateFlag;
  97097. /** @hidden */
  97098. _toBeDisposed: Nullable<IDisposable>[];
  97099. private _activeRequests;
  97100. /** @hidden */
  97101. _pendingData: any[];
  97102. private _isDisposed;
  97103. /**
  97104. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  97105. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  97106. */
  97107. dispatchAllSubMeshesOfActiveMeshes: boolean;
  97108. private _activeMeshes;
  97109. private _processedMaterials;
  97110. private _renderTargets;
  97111. /** @hidden */
  97112. _activeParticleSystems: SmartArray<IParticleSystem>;
  97113. private _activeSkeletons;
  97114. private _softwareSkinnedMeshes;
  97115. private _renderingManager;
  97116. /** @hidden */
  97117. _activeAnimatables: Animatable[];
  97118. private _transformMatrix;
  97119. private _sceneUbo;
  97120. /** @hidden */
  97121. _viewMatrix: Matrix;
  97122. private _projectionMatrix;
  97123. /** @hidden */
  97124. _forcedViewPosition: Nullable<Vector3>;
  97125. /** @hidden */
  97126. _frustumPlanes: Plane[];
  97127. /**
  97128. * Gets the list of frustum planes (built from the active camera)
  97129. */
  97130. readonly frustumPlanes: Plane[];
  97131. /**
  97132. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  97133. * This is useful if there are more lights that the maximum simulteanous authorized
  97134. */
  97135. requireLightSorting: boolean;
  97136. /** @hidden */
  97137. readonly useMaterialMeshMap: boolean;
  97138. /** @hidden */
  97139. readonly useClonedMeshhMap: boolean;
  97140. private _externalData;
  97141. private _uid;
  97142. /**
  97143. * @hidden
  97144. * Backing store of defined scene components.
  97145. */
  97146. _components: ISceneComponent[];
  97147. /**
  97148. * @hidden
  97149. * Backing store of defined scene components.
  97150. */
  97151. _serializableComponents: ISceneSerializableComponent[];
  97152. /**
  97153. * List of components to register on the next registration step.
  97154. */
  97155. private _transientComponents;
  97156. /**
  97157. * Registers the transient components if needed.
  97158. */
  97159. private _registerTransientComponents;
  97160. /**
  97161. * @hidden
  97162. * Add a component to the scene.
  97163. * Note that the ccomponent could be registered on th next frame if this is called after
  97164. * the register component stage.
  97165. * @param component Defines the component to add to the scene
  97166. */
  97167. _addComponent(component: ISceneComponent): void;
  97168. /**
  97169. * @hidden
  97170. * Gets a component from the scene.
  97171. * @param name defines the name of the component to retrieve
  97172. * @returns the component or null if not present
  97173. */
  97174. _getComponent(name: string): Nullable<ISceneComponent>;
  97175. /**
  97176. * @hidden
  97177. * Defines the actions happening before camera updates.
  97178. */
  97179. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  97180. /**
  97181. * @hidden
  97182. * Defines the actions happening before clear the canvas.
  97183. */
  97184. _beforeClearStage: Stage<SimpleStageAction>;
  97185. /**
  97186. * @hidden
  97187. * Defines the actions when collecting render targets for the frame.
  97188. */
  97189. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  97190. /**
  97191. * @hidden
  97192. * Defines the actions happening for one camera in the frame.
  97193. */
  97194. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  97195. /**
  97196. * @hidden
  97197. * Defines the actions happening during the per mesh ready checks.
  97198. */
  97199. _isReadyForMeshStage: Stage<MeshStageAction>;
  97200. /**
  97201. * @hidden
  97202. * Defines the actions happening before evaluate active mesh checks.
  97203. */
  97204. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  97205. /**
  97206. * @hidden
  97207. * Defines the actions happening during the evaluate sub mesh checks.
  97208. */
  97209. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  97210. /**
  97211. * @hidden
  97212. * Defines the actions happening during the active mesh stage.
  97213. */
  97214. _activeMeshStage: Stage<ActiveMeshStageAction>;
  97215. /**
  97216. * @hidden
  97217. * Defines the actions happening during the per camera render target step.
  97218. */
  97219. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  97220. /**
  97221. * @hidden
  97222. * Defines the actions happening just before the active camera is drawing.
  97223. */
  97224. _beforeCameraDrawStage: Stage<CameraStageAction>;
  97225. /**
  97226. * @hidden
  97227. * Defines the actions happening just before a render target is drawing.
  97228. */
  97229. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  97230. /**
  97231. * @hidden
  97232. * Defines the actions happening just before a rendering group is drawing.
  97233. */
  97234. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  97235. /**
  97236. * @hidden
  97237. * Defines the actions happening just before a mesh is drawing.
  97238. */
  97239. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  97240. /**
  97241. * @hidden
  97242. * Defines the actions happening just after a mesh has been drawn.
  97243. */
  97244. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  97245. /**
  97246. * @hidden
  97247. * Defines the actions happening just after a rendering group has been drawn.
  97248. */
  97249. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  97250. /**
  97251. * @hidden
  97252. * Defines the actions happening just after the active camera has been drawn.
  97253. */
  97254. _afterCameraDrawStage: Stage<CameraStageAction>;
  97255. /**
  97256. * @hidden
  97257. * Defines the actions happening just after a render target has been drawn.
  97258. */
  97259. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  97260. /**
  97261. * @hidden
  97262. * Defines the actions happening just after rendering all cameras and computing intersections.
  97263. */
  97264. _afterRenderStage: Stage<SimpleStageAction>;
  97265. /**
  97266. * @hidden
  97267. * Defines the actions happening when a pointer move event happens.
  97268. */
  97269. _pointerMoveStage: Stage<PointerMoveStageAction>;
  97270. /**
  97271. * @hidden
  97272. * Defines the actions happening when a pointer down event happens.
  97273. */
  97274. _pointerDownStage: Stage<PointerUpDownStageAction>;
  97275. /**
  97276. * @hidden
  97277. * Defines the actions happening when a pointer up event happens.
  97278. */
  97279. _pointerUpStage: Stage<PointerUpDownStageAction>;
  97280. /**
  97281. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  97282. */
  97283. private geometriesByUniqueId;
  97284. /**
  97285. * Creates a new Scene
  97286. * @param engine defines the engine to use to render this scene
  97287. * @param options defines the scene options
  97288. */
  97289. constructor(engine: Engine, options?: SceneOptions);
  97290. /**
  97291. * Gets a string idenfifying the name of the class
  97292. * @returns "Scene" string
  97293. */
  97294. getClassName(): string;
  97295. private _defaultMeshCandidates;
  97296. /**
  97297. * @hidden
  97298. */
  97299. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  97300. private _defaultSubMeshCandidates;
  97301. /**
  97302. * @hidden
  97303. */
  97304. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  97305. /**
  97306. * Sets the default candidate providers for the scene.
  97307. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  97308. * and getCollidingSubMeshCandidates to their default function
  97309. */
  97310. setDefaultCandidateProviders(): void;
  97311. /**
  97312. * Gets the mesh that is currently under the pointer
  97313. */
  97314. readonly meshUnderPointer: Nullable<AbstractMesh>;
  97315. /**
  97316. * Gets or sets the current on-screen X position of the pointer
  97317. */
  97318. pointerX: number;
  97319. /**
  97320. * Gets or sets the current on-screen Y position of the pointer
  97321. */
  97322. pointerY: number;
  97323. /**
  97324. * Gets the cached material (ie. the latest rendered one)
  97325. * @returns the cached material
  97326. */
  97327. getCachedMaterial(): Nullable<Material>;
  97328. /**
  97329. * Gets the cached effect (ie. the latest rendered one)
  97330. * @returns the cached effect
  97331. */
  97332. getCachedEffect(): Nullable<Effect>;
  97333. /**
  97334. * Gets the cached visibility state (ie. the latest rendered one)
  97335. * @returns the cached visibility state
  97336. */
  97337. getCachedVisibility(): Nullable<number>;
  97338. /**
  97339. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  97340. * @param material defines the current material
  97341. * @param effect defines the current effect
  97342. * @param visibility defines the current visibility state
  97343. * @returns true if one parameter is not cached
  97344. */
  97345. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  97346. /**
  97347. * Gets the engine associated with the scene
  97348. * @returns an Engine
  97349. */
  97350. getEngine(): Engine;
  97351. /**
  97352. * Gets the total number of vertices rendered per frame
  97353. * @returns the total number of vertices rendered per frame
  97354. */
  97355. getTotalVertices(): number;
  97356. /**
  97357. * Gets the performance counter for total vertices
  97358. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97359. */
  97360. readonly totalVerticesPerfCounter: PerfCounter;
  97361. /**
  97362. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  97363. * @returns the total number of active indices rendered per frame
  97364. */
  97365. getActiveIndices(): number;
  97366. /**
  97367. * Gets the performance counter for active indices
  97368. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97369. */
  97370. readonly totalActiveIndicesPerfCounter: PerfCounter;
  97371. /**
  97372. * Gets the total number of active particles rendered per frame
  97373. * @returns the total number of active particles rendered per frame
  97374. */
  97375. getActiveParticles(): number;
  97376. /**
  97377. * Gets the performance counter for active particles
  97378. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97379. */
  97380. readonly activeParticlesPerfCounter: PerfCounter;
  97381. /**
  97382. * Gets the total number of active bones rendered per frame
  97383. * @returns the total number of active bones rendered per frame
  97384. */
  97385. getActiveBones(): number;
  97386. /**
  97387. * Gets the performance counter for active bones
  97388. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97389. */
  97390. readonly activeBonesPerfCounter: PerfCounter;
  97391. /**
  97392. * Gets the array of active meshes
  97393. * @returns an array of AbstractMesh
  97394. */
  97395. getActiveMeshes(): SmartArray<AbstractMesh>;
  97396. /**
  97397. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  97398. * @returns a number
  97399. */
  97400. getAnimationRatio(): number;
  97401. /**
  97402. * Gets an unique Id for the current render phase
  97403. * @returns a number
  97404. */
  97405. getRenderId(): number;
  97406. /**
  97407. * Gets an unique Id for the current frame
  97408. * @returns a number
  97409. */
  97410. getFrameId(): number;
  97411. /** Call this function if you want to manually increment the render Id*/
  97412. incrementRenderId(): void;
  97413. private _createUbo;
  97414. /**
  97415. * Use this method to simulate a pointer move on a mesh
  97416. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97417. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97418. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97419. * @returns the current scene
  97420. */
  97421. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  97422. /**
  97423. * Use this method to simulate a pointer down on a mesh
  97424. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97425. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97426. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97427. * @returns the current scene
  97428. */
  97429. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  97430. /**
  97431. * Use this method to simulate a pointer up on a mesh
  97432. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97433. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97434. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97435. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  97436. * @returns the current scene
  97437. */
  97438. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  97439. /**
  97440. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  97441. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  97442. * @returns true if the pointer was captured
  97443. */
  97444. isPointerCaptured(pointerId?: number): boolean;
  97445. /**
  97446. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  97447. * @param attachUp defines if you want to attach events to pointerup
  97448. * @param attachDown defines if you want to attach events to pointerdown
  97449. * @param attachMove defines if you want to attach events to pointermove
  97450. */
  97451. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  97452. /** Detaches all event handlers*/
  97453. detachControl(): void;
  97454. /**
  97455. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  97456. * Delay loaded resources are not taking in account
  97457. * @return true if all required resources are ready
  97458. */
  97459. isReady(): boolean;
  97460. /** Resets all cached information relative to material (including effect and visibility) */
  97461. resetCachedMaterial(): void;
  97462. /**
  97463. * Registers a function to be called before every frame render
  97464. * @param func defines the function to register
  97465. */
  97466. registerBeforeRender(func: () => void): void;
  97467. /**
  97468. * Unregisters a function called before every frame render
  97469. * @param func defines the function to unregister
  97470. */
  97471. unregisterBeforeRender(func: () => void): void;
  97472. /**
  97473. * Registers a function to be called after every frame render
  97474. * @param func defines the function to register
  97475. */
  97476. registerAfterRender(func: () => void): void;
  97477. /**
  97478. * Unregisters a function called after every frame render
  97479. * @param func defines the function to unregister
  97480. */
  97481. unregisterAfterRender(func: () => void): void;
  97482. private _executeOnceBeforeRender;
  97483. /**
  97484. * The provided function will run before render once and will be disposed afterwards.
  97485. * A timeout delay can be provided so that the function will be executed in N ms.
  97486. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  97487. * @param func The function to be executed.
  97488. * @param timeout optional delay in ms
  97489. */
  97490. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  97491. /** @hidden */
  97492. _addPendingData(data: any): void;
  97493. /** @hidden */
  97494. _removePendingData(data: any): void;
  97495. /**
  97496. * Returns the number of items waiting to be loaded
  97497. * @returns the number of items waiting to be loaded
  97498. */
  97499. getWaitingItemsCount(): number;
  97500. /**
  97501. * Returns a boolean indicating if the scene is still loading data
  97502. */
  97503. readonly isLoading: boolean;
  97504. /**
  97505. * Registers a function to be executed when the scene is ready
  97506. * @param {Function} func - the function to be executed
  97507. */
  97508. executeWhenReady(func: () => void): void;
  97509. /**
  97510. * Returns a promise that resolves when the scene is ready
  97511. * @returns A promise that resolves when the scene is ready
  97512. */
  97513. whenReadyAsync(): Promise<void>;
  97514. /** @hidden */
  97515. _checkIsReady(): void;
  97516. /**
  97517. * Gets all animatable attached to the scene
  97518. */
  97519. readonly animatables: Animatable[];
  97520. /**
  97521. * Resets the last animation time frame.
  97522. * Useful to override when animations start running when loading a scene for the first time.
  97523. */
  97524. resetLastAnimationTimeFrame(): void;
  97525. /**
  97526. * Gets the current view matrix
  97527. * @returns a Matrix
  97528. */
  97529. getViewMatrix(): Matrix;
  97530. /**
  97531. * Gets the current projection matrix
  97532. * @returns a Matrix
  97533. */
  97534. getProjectionMatrix(): Matrix;
  97535. /**
  97536. * Gets the current transform matrix
  97537. * @returns a Matrix made of View * Projection
  97538. */
  97539. getTransformMatrix(): Matrix;
  97540. /**
  97541. * Sets the current transform matrix
  97542. * @param viewL defines the View matrix to use
  97543. * @param projectionL defines the Projection matrix to use
  97544. * @param viewR defines the right View matrix to use (if provided)
  97545. * @param projectionR defines the right Projection matrix to use (if provided)
  97546. */
  97547. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  97548. /**
  97549. * Gets the uniform buffer used to store scene data
  97550. * @returns a UniformBuffer
  97551. */
  97552. getSceneUniformBuffer(): UniformBuffer;
  97553. /**
  97554. * Gets an unique (relatively to the current scene) Id
  97555. * @returns an unique number for the scene
  97556. */
  97557. getUniqueId(): number;
  97558. /**
  97559. * Add a mesh to the list of scene's meshes
  97560. * @param newMesh defines the mesh to add
  97561. * @param recursive if all child meshes should also be added to the scene
  97562. */
  97563. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  97564. /**
  97565. * Remove a mesh for the list of scene's meshes
  97566. * @param toRemove defines the mesh to remove
  97567. * @param recursive if all child meshes should also be removed from the scene
  97568. * @returns the index where the mesh was in the mesh list
  97569. */
  97570. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  97571. /**
  97572. * Add a transform node to the list of scene's transform nodes
  97573. * @param newTransformNode defines the transform node to add
  97574. */
  97575. addTransformNode(newTransformNode: TransformNode): void;
  97576. /**
  97577. * Remove a transform node for the list of scene's transform nodes
  97578. * @param toRemove defines the transform node to remove
  97579. * @returns the index where the transform node was in the transform node list
  97580. */
  97581. removeTransformNode(toRemove: TransformNode): number;
  97582. /**
  97583. * Remove a skeleton for the list of scene's skeletons
  97584. * @param toRemove defines the skeleton to remove
  97585. * @returns the index where the skeleton was in the skeleton list
  97586. */
  97587. removeSkeleton(toRemove: Skeleton): number;
  97588. /**
  97589. * Remove a morph target for the list of scene's morph targets
  97590. * @param toRemove defines the morph target to remove
  97591. * @returns the index where the morph target was in the morph target list
  97592. */
  97593. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  97594. /**
  97595. * Remove a light for the list of scene's lights
  97596. * @param toRemove defines the light to remove
  97597. * @returns the index where the light was in the light list
  97598. */
  97599. removeLight(toRemove: Light): number;
  97600. /**
  97601. * Remove a camera for the list of scene's cameras
  97602. * @param toRemove defines the camera to remove
  97603. * @returns the index where the camera was in the camera list
  97604. */
  97605. removeCamera(toRemove: Camera): number;
  97606. /**
  97607. * Remove a particle system for the list of scene's particle systems
  97608. * @param toRemove defines the particle system to remove
  97609. * @returns the index where the particle system was in the particle system list
  97610. */
  97611. removeParticleSystem(toRemove: IParticleSystem): number;
  97612. /**
  97613. * Remove a animation for the list of scene's animations
  97614. * @param toRemove defines the animation to remove
  97615. * @returns the index where the animation was in the animation list
  97616. */
  97617. removeAnimation(toRemove: Animation): number;
  97618. /**
  97619. * Will stop the animation of the given target
  97620. * @param target - the target
  97621. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  97622. * @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)
  97623. */
  97624. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  97625. /**
  97626. * Removes the given animation group from this scene.
  97627. * @param toRemove The animation group to remove
  97628. * @returns The index of the removed animation group
  97629. */
  97630. removeAnimationGroup(toRemove: AnimationGroup): number;
  97631. /**
  97632. * Removes the given multi-material from this scene.
  97633. * @param toRemove The multi-material to remove
  97634. * @returns The index of the removed multi-material
  97635. */
  97636. removeMultiMaterial(toRemove: MultiMaterial): number;
  97637. /**
  97638. * Removes the given material from this scene.
  97639. * @param toRemove The material to remove
  97640. * @returns The index of the removed material
  97641. */
  97642. removeMaterial(toRemove: Material): number;
  97643. /**
  97644. * Removes the given action manager from this scene.
  97645. * @param toRemove The action manager to remove
  97646. * @returns The index of the removed action manager
  97647. */
  97648. removeActionManager(toRemove: AbstractActionManager): number;
  97649. /**
  97650. * Removes the given texture from this scene.
  97651. * @param toRemove The texture to remove
  97652. * @returns The index of the removed texture
  97653. */
  97654. removeTexture(toRemove: BaseTexture): number;
  97655. /**
  97656. * Adds the given light to this scene
  97657. * @param newLight The light to add
  97658. */
  97659. addLight(newLight: Light): void;
  97660. /**
  97661. * Sorts the list list based on light priorities
  97662. */
  97663. sortLightsByPriority(): void;
  97664. /**
  97665. * Adds the given camera to this scene
  97666. * @param newCamera The camera to add
  97667. */
  97668. addCamera(newCamera: Camera): void;
  97669. /**
  97670. * Adds the given skeleton to this scene
  97671. * @param newSkeleton The skeleton to add
  97672. */
  97673. addSkeleton(newSkeleton: Skeleton): void;
  97674. /**
  97675. * Adds the given particle system to this scene
  97676. * @param newParticleSystem The particle system to add
  97677. */
  97678. addParticleSystem(newParticleSystem: IParticleSystem): void;
  97679. /**
  97680. * Adds the given animation to this scene
  97681. * @param newAnimation The animation to add
  97682. */
  97683. addAnimation(newAnimation: Animation): void;
  97684. /**
  97685. * Adds the given animation group to this scene.
  97686. * @param newAnimationGroup The animation group to add
  97687. */
  97688. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  97689. /**
  97690. * Adds the given multi-material to this scene
  97691. * @param newMultiMaterial The multi-material to add
  97692. */
  97693. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  97694. /**
  97695. * Adds the given material to this scene
  97696. * @param newMaterial The material to add
  97697. */
  97698. addMaterial(newMaterial: Material): void;
  97699. /**
  97700. * Adds the given morph target to this scene
  97701. * @param newMorphTargetManager The morph target to add
  97702. */
  97703. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  97704. /**
  97705. * Adds the given geometry to this scene
  97706. * @param newGeometry The geometry to add
  97707. */
  97708. addGeometry(newGeometry: Geometry): void;
  97709. /**
  97710. * Adds the given action manager to this scene
  97711. * @param newActionManager The action manager to add
  97712. */
  97713. addActionManager(newActionManager: AbstractActionManager): void;
  97714. /**
  97715. * Adds the given texture to this scene.
  97716. * @param newTexture The texture to add
  97717. */
  97718. addTexture(newTexture: BaseTexture): void;
  97719. /**
  97720. * Switch active camera
  97721. * @param newCamera defines the new active camera
  97722. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  97723. */
  97724. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  97725. /**
  97726. * sets the active camera of the scene using its ID
  97727. * @param id defines the camera's ID
  97728. * @return the new active camera or null if none found.
  97729. */
  97730. setActiveCameraByID(id: string): Nullable<Camera>;
  97731. /**
  97732. * sets the active camera of the scene using its name
  97733. * @param name defines the camera's name
  97734. * @returns the new active camera or null if none found.
  97735. */
  97736. setActiveCameraByName(name: string): Nullable<Camera>;
  97737. /**
  97738. * get an animation group using its name
  97739. * @param name defines the material's name
  97740. * @return the animation group or null if none found.
  97741. */
  97742. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  97743. /**
  97744. * Get a material using its unique id
  97745. * @param uniqueId defines the material's unique id
  97746. * @return the material or null if none found.
  97747. */
  97748. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  97749. /**
  97750. * get a material using its id
  97751. * @param id defines the material's ID
  97752. * @return the material or null if none found.
  97753. */
  97754. getMaterialByID(id: string): Nullable<Material>;
  97755. /**
  97756. * Gets a the last added material using a given id
  97757. * @param id defines the material's ID
  97758. * @return the last material with the given id or null if none found.
  97759. */
  97760. getLastMaterialByID(id: string): Nullable<Material>;
  97761. /**
  97762. * Gets a material using its name
  97763. * @param name defines the material's name
  97764. * @return the material or null if none found.
  97765. */
  97766. getMaterialByName(name: string): Nullable<Material>;
  97767. /**
  97768. * Gets a camera using its id
  97769. * @param id defines the id to look for
  97770. * @returns the camera or null if not found
  97771. */
  97772. getCameraByID(id: string): Nullable<Camera>;
  97773. /**
  97774. * Gets a camera using its unique id
  97775. * @param uniqueId defines the unique id to look for
  97776. * @returns the camera or null if not found
  97777. */
  97778. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  97779. /**
  97780. * Gets a camera using its name
  97781. * @param name defines the camera's name
  97782. * @return the camera or null if none found.
  97783. */
  97784. getCameraByName(name: string): Nullable<Camera>;
  97785. /**
  97786. * Gets a bone using its id
  97787. * @param id defines the bone's id
  97788. * @return the bone or null if not found
  97789. */
  97790. getBoneByID(id: string): Nullable<Bone>;
  97791. /**
  97792. * Gets a bone using its id
  97793. * @param name defines the bone's name
  97794. * @return the bone or null if not found
  97795. */
  97796. getBoneByName(name: string): Nullable<Bone>;
  97797. /**
  97798. * Gets a light node using its name
  97799. * @param name defines the the light's name
  97800. * @return the light or null if none found.
  97801. */
  97802. getLightByName(name: string): Nullable<Light>;
  97803. /**
  97804. * Gets a light node using its id
  97805. * @param id defines the light's id
  97806. * @return the light or null if none found.
  97807. */
  97808. getLightByID(id: string): Nullable<Light>;
  97809. /**
  97810. * Gets a light node using its scene-generated unique ID
  97811. * @param uniqueId defines the light's unique id
  97812. * @return the light or null if none found.
  97813. */
  97814. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  97815. /**
  97816. * Gets a particle system by id
  97817. * @param id defines the particle system id
  97818. * @return the corresponding system or null if none found
  97819. */
  97820. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  97821. /**
  97822. * Gets a geometry using its ID
  97823. * @param id defines the geometry's id
  97824. * @return the geometry or null if none found.
  97825. */
  97826. getGeometryByID(id: string): Nullable<Geometry>;
  97827. private _getGeometryByUniqueID;
  97828. /**
  97829. * Add a new geometry to this scene
  97830. * @param geometry defines the geometry to be added to the scene.
  97831. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  97832. * @return a boolean defining if the geometry was added or not
  97833. */
  97834. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  97835. /**
  97836. * Removes an existing geometry
  97837. * @param geometry defines the geometry to be removed from the scene
  97838. * @return a boolean defining if the geometry was removed or not
  97839. */
  97840. removeGeometry(geometry: Geometry): boolean;
  97841. /**
  97842. * Gets the list of geometries attached to the scene
  97843. * @returns an array of Geometry
  97844. */
  97845. getGeometries(): Geometry[];
  97846. /**
  97847. * Gets the first added mesh found of a given ID
  97848. * @param id defines the id to search for
  97849. * @return the mesh found or null if not found at all
  97850. */
  97851. getMeshByID(id: string): Nullable<AbstractMesh>;
  97852. /**
  97853. * Gets a list of meshes using their id
  97854. * @param id defines the id to search for
  97855. * @returns a list of meshes
  97856. */
  97857. getMeshesByID(id: string): Array<AbstractMesh>;
  97858. /**
  97859. * Gets the first added transform node found of a given ID
  97860. * @param id defines the id to search for
  97861. * @return the found transform node or null if not found at all.
  97862. */
  97863. getTransformNodeByID(id: string): Nullable<TransformNode>;
  97864. /**
  97865. * Gets a transform node with its auto-generated unique id
  97866. * @param uniqueId efines the unique id to search for
  97867. * @return the found transform node or null if not found at all.
  97868. */
  97869. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  97870. /**
  97871. * Gets a list of transform nodes using their id
  97872. * @param id defines the id to search for
  97873. * @returns a list of transform nodes
  97874. */
  97875. getTransformNodesByID(id: string): Array<TransformNode>;
  97876. /**
  97877. * Gets a mesh with its auto-generated unique id
  97878. * @param uniqueId defines the unique id to search for
  97879. * @return the found mesh or null if not found at all.
  97880. */
  97881. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  97882. /**
  97883. * Gets a the last added mesh using a given id
  97884. * @param id defines the id to search for
  97885. * @return the found mesh or null if not found at all.
  97886. */
  97887. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  97888. /**
  97889. * Gets a the last added node (Mesh, Camera, Light) using a given id
  97890. * @param id defines the id to search for
  97891. * @return the found node or null if not found at all
  97892. */
  97893. getLastEntryByID(id: string): Nullable<Node>;
  97894. /**
  97895. * Gets a node (Mesh, Camera, Light) using a given id
  97896. * @param id defines the id to search for
  97897. * @return the found node or null if not found at all
  97898. */
  97899. getNodeByID(id: string): Nullable<Node>;
  97900. /**
  97901. * Gets a node (Mesh, Camera, Light) using a given name
  97902. * @param name defines the name to search for
  97903. * @return the found node or null if not found at all.
  97904. */
  97905. getNodeByName(name: string): Nullable<Node>;
  97906. /**
  97907. * Gets a mesh using a given name
  97908. * @param name defines the name to search for
  97909. * @return the found mesh or null if not found at all.
  97910. */
  97911. getMeshByName(name: string): Nullable<AbstractMesh>;
  97912. /**
  97913. * Gets a transform node using a given name
  97914. * @param name defines the name to search for
  97915. * @return the found transform node or null if not found at all.
  97916. */
  97917. getTransformNodeByName(name: string): Nullable<TransformNode>;
  97918. /**
  97919. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  97920. * @param id defines the id to search for
  97921. * @return the found skeleton or null if not found at all.
  97922. */
  97923. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  97924. /**
  97925. * Gets a skeleton using a given auto generated unique id
  97926. * @param uniqueId defines the unique id to search for
  97927. * @return the found skeleton or null if not found at all.
  97928. */
  97929. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  97930. /**
  97931. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  97932. * @param id defines the id to search for
  97933. * @return the found skeleton or null if not found at all.
  97934. */
  97935. getSkeletonById(id: string): Nullable<Skeleton>;
  97936. /**
  97937. * Gets a skeleton using a given name
  97938. * @param name defines the name to search for
  97939. * @return the found skeleton or null if not found at all.
  97940. */
  97941. getSkeletonByName(name: string): Nullable<Skeleton>;
  97942. /**
  97943. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  97944. * @param id defines the id to search for
  97945. * @return the found morph target manager or null if not found at all.
  97946. */
  97947. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  97948. /**
  97949. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  97950. * @param id defines the id to search for
  97951. * @return the found morph target or null if not found at all.
  97952. */
  97953. getMorphTargetById(id: string): Nullable<MorphTarget>;
  97954. /**
  97955. * Gets a boolean indicating if the given mesh is active
  97956. * @param mesh defines the mesh to look for
  97957. * @returns true if the mesh is in the active list
  97958. */
  97959. isActiveMesh(mesh: AbstractMesh): boolean;
  97960. /**
  97961. * Return a unique id as a string which can serve as an identifier for the scene
  97962. */
  97963. readonly uid: string;
  97964. /**
  97965. * Add an externaly attached data from its key.
  97966. * This method call will fail and return false, if such key already exists.
  97967. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  97968. * @param key the unique key that identifies the data
  97969. * @param data the data object to associate to the key for this Engine instance
  97970. * @return true if no such key were already present and the data was added successfully, false otherwise
  97971. */
  97972. addExternalData<T>(key: string, data: T): boolean;
  97973. /**
  97974. * Get an externaly attached data from its key
  97975. * @param key the unique key that identifies the data
  97976. * @return the associated data, if present (can be null), or undefined if not present
  97977. */
  97978. getExternalData<T>(key: string): Nullable<T>;
  97979. /**
  97980. * Get an externaly attached data from its key, create it using a factory if it's not already present
  97981. * @param key the unique key that identifies the data
  97982. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  97983. * @return the associated data, can be null if the factory returned null.
  97984. */
  97985. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  97986. /**
  97987. * Remove an externaly attached data from the Engine instance
  97988. * @param key the unique key that identifies the data
  97989. * @return true if the data was successfully removed, false if it doesn't exist
  97990. */
  97991. removeExternalData(key: string): boolean;
  97992. private _evaluateSubMesh;
  97993. /**
  97994. * Clear the processed materials smart array preventing retention point in material dispose.
  97995. */
  97996. freeProcessedMaterials(): void;
  97997. private _preventFreeActiveMeshesAndRenderingGroups;
  97998. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  97999. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  98000. * when disposing several meshes in a row or a hierarchy of meshes.
  98001. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  98002. */
  98003. blockfreeActiveMeshesAndRenderingGroups: boolean;
  98004. /**
  98005. * Clear the active meshes smart array preventing retention point in mesh dispose.
  98006. */
  98007. freeActiveMeshes(): void;
  98008. /**
  98009. * Clear the info related to rendering groups preventing retention points during dispose.
  98010. */
  98011. freeRenderingGroups(): void;
  98012. /** @hidden */
  98013. _isInIntermediateRendering(): boolean;
  98014. /**
  98015. * Lambda returning the list of potentially active meshes.
  98016. */
  98017. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  98018. /**
  98019. * Lambda returning the list of potentially active sub meshes.
  98020. */
  98021. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  98022. /**
  98023. * Lambda returning the list of potentially intersecting sub meshes.
  98024. */
  98025. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  98026. /**
  98027. * Lambda returning the list of potentially colliding sub meshes.
  98028. */
  98029. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  98030. private _activeMeshesFrozen;
  98031. /**
  98032. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  98033. * @returns the current scene
  98034. */
  98035. freezeActiveMeshes(): Scene;
  98036. /**
  98037. * Use this function to restart evaluating active meshes on every frame
  98038. * @returns the current scene
  98039. */
  98040. unfreezeActiveMeshes(): Scene;
  98041. private _evaluateActiveMeshes;
  98042. private _activeMesh;
  98043. /**
  98044. * Update the transform matrix to update from the current active camera
  98045. * @param force defines a boolean used to force the update even if cache is up to date
  98046. */
  98047. updateTransformMatrix(force?: boolean): void;
  98048. private _bindFrameBuffer;
  98049. /** @hidden */
  98050. _allowPostProcessClearColor: boolean;
  98051. /** @hidden */
  98052. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  98053. private _processSubCameras;
  98054. private _checkIntersections;
  98055. /** @hidden */
  98056. _advancePhysicsEngineStep(step: number): void;
  98057. /**
  98058. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  98059. */
  98060. getDeterministicFrameTime: () => number;
  98061. /** @hidden */
  98062. _animate(): void;
  98063. /** Execute all animations (for a frame) */
  98064. animate(): void;
  98065. /**
  98066. * Render the scene
  98067. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  98068. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  98069. */
  98070. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  98071. /**
  98072. * Freeze all materials
  98073. * A frozen material will not be updatable but should be faster to render
  98074. */
  98075. freezeMaterials(): void;
  98076. /**
  98077. * Unfreeze all materials
  98078. * A frozen material will not be updatable but should be faster to render
  98079. */
  98080. unfreezeMaterials(): void;
  98081. /**
  98082. * Releases all held ressources
  98083. */
  98084. dispose(): void;
  98085. /**
  98086. * Gets if the scene is already disposed
  98087. */
  98088. readonly isDisposed: boolean;
  98089. /**
  98090. * Call this function to reduce memory footprint of the scene.
  98091. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  98092. */
  98093. clearCachedVertexData(): void;
  98094. /**
  98095. * This function will remove the local cached buffer data from texture.
  98096. * It will save memory but will prevent the texture from being rebuilt
  98097. */
  98098. cleanCachedTextureBuffer(): void;
  98099. /**
  98100. * Get the world extend vectors with an optional filter
  98101. *
  98102. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  98103. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  98104. */
  98105. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  98106. min: Vector3;
  98107. max: Vector3;
  98108. };
  98109. /**
  98110. * Creates a ray that can be used to pick in the scene
  98111. * @param x defines the x coordinate of the origin (on-screen)
  98112. * @param y defines the y coordinate of the origin (on-screen)
  98113. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  98114. * @param camera defines the camera to use for the picking
  98115. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  98116. * @returns a Ray
  98117. */
  98118. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  98119. /**
  98120. * Creates a ray that can be used to pick in the scene
  98121. * @param x defines the x coordinate of the origin (on-screen)
  98122. * @param y defines the y coordinate of the origin (on-screen)
  98123. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  98124. * @param result defines the ray where to store the picking ray
  98125. * @param camera defines the camera to use for the picking
  98126. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  98127. * @returns the current scene
  98128. */
  98129. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  98130. /**
  98131. * Creates a ray that can be used to pick in the scene
  98132. * @param x defines the x coordinate of the origin (on-screen)
  98133. * @param y defines the y coordinate of the origin (on-screen)
  98134. * @param camera defines the camera to use for the picking
  98135. * @returns a Ray
  98136. */
  98137. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  98138. /**
  98139. * Creates a ray that can be used to pick in the scene
  98140. * @param x defines the x coordinate of the origin (on-screen)
  98141. * @param y defines the y coordinate of the origin (on-screen)
  98142. * @param result defines the ray where to store the picking ray
  98143. * @param camera defines the camera to use for the picking
  98144. * @returns the current scene
  98145. */
  98146. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  98147. /** Launch a ray to try to pick a mesh in the scene
  98148. * @param x position on screen
  98149. * @param y position on screen
  98150. * @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
  98151. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  98152. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  98153. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98154. * @returns a PickingInfo
  98155. */
  98156. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  98157. /** Use the given ray to pick a mesh in the scene
  98158. * @param ray The ray to use to pick meshes
  98159. * @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
  98160. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  98161. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98162. * @returns a PickingInfo
  98163. */
  98164. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  98165. /**
  98166. * Launch a ray to try to pick a mesh in the scene
  98167. * @param x X position on screen
  98168. * @param y Y position on screen
  98169. * @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
  98170. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  98171. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98172. * @returns an array of PickingInfo
  98173. */
  98174. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  98175. /**
  98176. * Launch a ray to try to pick a mesh in the scene
  98177. * @param ray Ray to use
  98178. * @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
  98179. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98180. * @returns an array of PickingInfo
  98181. */
  98182. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  98183. /**
  98184. * Force the value of meshUnderPointer
  98185. * @param mesh defines the mesh to use
  98186. */
  98187. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  98188. /**
  98189. * Gets the mesh under the pointer
  98190. * @returns a Mesh or null if no mesh is under the pointer
  98191. */
  98192. getPointerOverMesh(): Nullable<AbstractMesh>;
  98193. /** @hidden */
  98194. _rebuildGeometries(): void;
  98195. /** @hidden */
  98196. _rebuildTextures(): void;
  98197. private _getByTags;
  98198. /**
  98199. * Get a list of meshes by tags
  98200. * @param tagsQuery defines the tags query to use
  98201. * @param forEach defines a predicate used to filter results
  98202. * @returns an array of Mesh
  98203. */
  98204. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  98205. /**
  98206. * Get a list of cameras by tags
  98207. * @param tagsQuery defines the tags query to use
  98208. * @param forEach defines a predicate used to filter results
  98209. * @returns an array of Camera
  98210. */
  98211. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  98212. /**
  98213. * Get a list of lights by tags
  98214. * @param tagsQuery defines the tags query to use
  98215. * @param forEach defines a predicate used to filter results
  98216. * @returns an array of Light
  98217. */
  98218. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  98219. /**
  98220. * Get a list of materials by tags
  98221. * @param tagsQuery defines the tags query to use
  98222. * @param forEach defines a predicate used to filter results
  98223. * @returns an array of Material
  98224. */
  98225. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  98226. /**
  98227. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  98228. * This allowed control for front to back rendering or reversly depending of the special needs.
  98229. *
  98230. * @param renderingGroupId The rendering group id corresponding to its index
  98231. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  98232. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  98233. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  98234. */
  98235. 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;
  98236. /**
  98237. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  98238. *
  98239. * @param renderingGroupId The rendering group id corresponding to its index
  98240. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  98241. * @param depth Automatically clears depth between groups if true and autoClear is true.
  98242. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  98243. */
  98244. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  98245. /**
  98246. * Gets the current auto clear configuration for one rendering group of the rendering
  98247. * manager.
  98248. * @param index the rendering group index to get the information for
  98249. * @returns The auto clear setup for the requested rendering group
  98250. */
  98251. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  98252. private _blockMaterialDirtyMechanism;
  98253. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  98254. blockMaterialDirtyMechanism: boolean;
  98255. /**
  98256. * Will flag all materials as dirty to trigger new shader compilation
  98257. * @param flag defines the flag used to specify which material part must be marked as dirty
  98258. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  98259. */
  98260. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  98261. /** @hidden */
  98262. _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;
  98263. /** @hidden */
  98264. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  98265. }
  98266. }
  98267. declare module BABYLON {
  98268. /**
  98269. * Set of assets to keep when moving a scene into an asset container.
  98270. */
  98271. export class KeepAssets extends AbstractScene {
  98272. }
  98273. /**
  98274. * Container with a set of assets that can be added or removed from a scene.
  98275. */
  98276. export class AssetContainer extends AbstractScene {
  98277. /**
  98278. * The scene the AssetContainer belongs to.
  98279. */
  98280. scene: Scene;
  98281. /**
  98282. * Instantiates an AssetContainer.
  98283. * @param scene The scene the AssetContainer belongs to.
  98284. */
  98285. constructor(scene: Scene);
  98286. /**
  98287. * Adds all the assets from the container to the scene.
  98288. */
  98289. addAllToScene(): void;
  98290. /**
  98291. * Removes all the assets in the container from the scene
  98292. */
  98293. removeAllFromScene(): void;
  98294. /**
  98295. * Disposes all the assets in the container
  98296. */
  98297. dispose(): void;
  98298. private _moveAssets;
  98299. /**
  98300. * Removes all the assets contained in the scene and adds them to the container.
  98301. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  98302. */
  98303. moveAllFromScene(keepAssets?: KeepAssets): void;
  98304. /**
  98305. * 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.
  98306. * @returns the root mesh
  98307. */
  98308. createRootMesh(): Mesh;
  98309. }
  98310. }
  98311. declare module BABYLON {
  98312. /**
  98313. * Defines how the parser contract is defined.
  98314. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  98315. */
  98316. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  98317. /**
  98318. * Defines how the individual parser contract is defined.
  98319. * These parser can parse an individual asset
  98320. */
  98321. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  98322. /**
  98323. * Base class of the scene acting as a container for the different elements composing a scene.
  98324. * This class is dynamically extended by the different components of the scene increasing
  98325. * flexibility and reducing coupling
  98326. */
  98327. export abstract class AbstractScene {
  98328. /**
  98329. * Stores the list of available parsers in the application.
  98330. */
  98331. private static _BabylonFileParsers;
  98332. /**
  98333. * Stores the list of available individual parsers in the application.
  98334. */
  98335. private static _IndividualBabylonFileParsers;
  98336. /**
  98337. * Adds a parser in the list of available ones
  98338. * @param name Defines the name of the parser
  98339. * @param parser Defines the parser to add
  98340. */
  98341. static AddParser(name: string, parser: BabylonFileParser): void;
  98342. /**
  98343. * Gets a general parser from the list of avaialble ones
  98344. * @param name Defines the name of the parser
  98345. * @returns the requested parser or null
  98346. */
  98347. static GetParser(name: string): Nullable<BabylonFileParser>;
  98348. /**
  98349. * Adds n individual parser in the list of available ones
  98350. * @param name Defines the name of the parser
  98351. * @param parser Defines the parser to add
  98352. */
  98353. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  98354. /**
  98355. * Gets an individual parser from the list of avaialble ones
  98356. * @param name Defines the name of the parser
  98357. * @returns the requested parser or null
  98358. */
  98359. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  98360. /**
  98361. * Parser json data and populate both a scene and its associated container object
  98362. * @param jsonData Defines the data to parse
  98363. * @param scene Defines the scene to parse the data for
  98364. * @param container Defines the container attached to the parsing sequence
  98365. * @param rootUrl Defines the root url of the data
  98366. */
  98367. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  98368. /**
  98369. * Gets the list of root nodes (ie. nodes with no parent)
  98370. */
  98371. rootNodes: Node[];
  98372. /** All of the cameras added to this scene
  98373. * @see http://doc.babylonjs.com/babylon101/cameras
  98374. */
  98375. cameras: Camera[];
  98376. /**
  98377. * All of the lights added to this scene
  98378. * @see http://doc.babylonjs.com/babylon101/lights
  98379. */
  98380. lights: Light[];
  98381. /**
  98382. * All of the (abstract) meshes added to this scene
  98383. */
  98384. meshes: AbstractMesh[];
  98385. /**
  98386. * The list of skeletons added to the scene
  98387. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  98388. */
  98389. skeletons: Skeleton[];
  98390. /**
  98391. * All of the particle systems added to this scene
  98392. * @see http://doc.babylonjs.com/babylon101/particles
  98393. */
  98394. particleSystems: IParticleSystem[];
  98395. /**
  98396. * Gets a list of Animations associated with the scene
  98397. */
  98398. animations: Animation[];
  98399. /**
  98400. * All of the animation groups added to this scene
  98401. * @see http://doc.babylonjs.com/how_to/group
  98402. */
  98403. animationGroups: AnimationGroup[];
  98404. /**
  98405. * All of the multi-materials added to this scene
  98406. * @see http://doc.babylonjs.com/how_to/multi_materials
  98407. */
  98408. multiMaterials: MultiMaterial[];
  98409. /**
  98410. * All of the materials added to this scene
  98411. * In the context of a Scene, it is not supposed to be modified manually.
  98412. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  98413. * Note also that the order of the Material wihin the array is not significant and might change.
  98414. * @see http://doc.babylonjs.com/babylon101/materials
  98415. */
  98416. materials: Material[];
  98417. /**
  98418. * The list of morph target managers added to the scene
  98419. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  98420. */
  98421. morphTargetManagers: MorphTargetManager[];
  98422. /**
  98423. * The list of geometries used in the scene.
  98424. */
  98425. geometries: Geometry[];
  98426. /**
  98427. * All of the tranform nodes added to this scene
  98428. * In the context of a Scene, it is not supposed to be modified manually.
  98429. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  98430. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  98431. * @see http://doc.babylonjs.com/how_to/transformnode
  98432. */
  98433. transformNodes: TransformNode[];
  98434. /**
  98435. * ActionManagers available on the scene.
  98436. */
  98437. actionManagers: AbstractActionManager[];
  98438. /**
  98439. * Textures to keep.
  98440. */
  98441. textures: BaseTexture[];
  98442. /**
  98443. * Environment texture for the scene
  98444. */
  98445. environmentTexture: Nullable<BaseTexture>;
  98446. }
  98447. }
  98448. declare module BABYLON {
  98449. /**
  98450. * Interface used to define options for Sound class
  98451. */
  98452. export interface ISoundOptions {
  98453. /**
  98454. * Does the sound autoplay once loaded.
  98455. */
  98456. autoplay?: boolean;
  98457. /**
  98458. * Does the sound loop after it finishes playing once.
  98459. */
  98460. loop?: boolean;
  98461. /**
  98462. * Sound's volume
  98463. */
  98464. volume?: number;
  98465. /**
  98466. * Is it a spatial sound?
  98467. */
  98468. spatialSound?: boolean;
  98469. /**
  98470. * Maximum distance to hear that sound
  98471. */
  98472. maxDistance?: number;
  98473. /**
  98474. * Uses user defined attenuation function
  98475. */
  98476. useCustomAttenuation?: boolean;
  98477. /**
  98478. * Define the roll off factor of spatial sounds.
  98479. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98480. */
  98481. rolloffFactor?: number;
  98482. /**
  98483. * Define the reference distance the sound should be heard perfectly.
  98484. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98485. */
  98486. refDistance?: number;
  98487. /**
  98488. * Define the distance attenuation model the sound will follow.
  98489. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98490. */
  98491. distanceModel?: string;
  98492. /**
  98493. * Defines the playback speed (1 by default)
  98494. */
  98495. playbackRate?: number;
  98496. /**
  98497. * Defines if the sound is from a streaming source
  98498. */
  98499. streaming?: boolean;
  98500. /**
  98501. * Defines an optional length (in seconds) inside the sound file
  98502. */
  98503. length?: number;
  98504. /**
  98505. * Defines an optional offset (in seconds) inside the sound file
  98506. */
  98507. offset?: number;
  98508. /**
  98509. * If true, URLs will not be required to state the audio file codec to use.
  98510. */
  98511. skipCodecCheck?: boolean;
  98512. }
  98513. /**
  98514. * Defines a sound that can be played in the application.
  98515. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  98516. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98517. */
  98518. export class Sound {
  98519. /**
  98520. * The name of the sound in the scene.
  98521. */
  98522. name: string;
  98523. /**
  98524. * Does the sound autoplay once loaded.
  98525. */
  98526. autoplay: boolean;
  98527. /**
  98528. * Does the sound loop after it finishes playing once.
  98529. */
  98530. loop: boolean;
  98531. /**
  98532. * Does the sound use a custom attenuation curve to simulate the falloff
  98533. * happening when the source gets further away from the camera.
  98534. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  98535. */
  98536. useCustomAttenuation: boolean;
  98537. /**
  98538. * The sound track id this sound belongs to.
  98539. */
  98540. soundTrackId: number;
  98541. /**
  98542. * Is this sound currently played.
  98543. */
  98544. isPlaying: boolean;
  98545. /**
  98546. * Is this sound currently paused.
  98547. */
  98548. isPaused: boolean;
  98549. /**
  98550. * Does this sound enables spatial sound.
  98551. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98552. */
  98553. spatialSound: boolean;
  98554. /**
  98555. * Define the reference distance the sound should be heard perfectly.
  98556. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98557. */
  98558. refDistance: number;
  98559. /**
  98560. * Define the roll off factor of spatial sounds.
  98561. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98562. */
  98563. rolloffFactor: number;
  98564. /**
  98565. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  98566. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98567. */
  98568. maxDistance: number;
  98569. /**
  98570. * Define the distance attenuation model the sound will follow.
  98571. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98572. */
  98573. distanceModel: string;
  98574. /**
  98575. * @hidden
  98576. * Back Compat
  98577. **/
  98578. onended: () => any;
  98579. /**
  98580. * Observable event when the current playing sound finishes.
  98581. */
  98582. onEndedObservable: Observable<Sound>;
  98583. private _panningModel;
  98584. private _playbackRate;
  98585. private _streaming;
  98586. private _startTime;
  98587. private _startOffset;
  98588. private _position;
  98589. /** @hidden */
  98590. _positionInEmitterSpace: boolean;
  98591. private _localDirection;
  98592. private _volume;
  98593. private _isReadyToPlay;
  98594. private _isDirectional;
  98595. private _readyToPlayCallback;
  98596. private _audioBuffer;
  98597. private _soundSource;
  98598. private _streamingSource;
  98599. private _soundPanner;
  98600. private _soundGain;
  98601. private _inputAudioNode;
  98602. private _outputAudioNode;
  98603. private _coneInnerAngle;
  98604. private _coneOuterAngle;
  98605. private _coneOuterGain;
  98606. private _scene;
  98607. private _connectedTransformNode;
  98608. private _customAttenuationFunction;
  98609. private _registerFunc;
  98610. private _isOutputConnected;
  98611. private _htmlAudioElement;
  98612. private _urlType;
  98613. private _length?;
  98614. private _offset?;
  98615. /** @hidden */
  98616. static _SceneComponentInitialization: (scene: Scene) => void;
  98617. /**
  98618. * Create a sound and attach it to a scene
  98619. * @param name Name of your sound
  98620. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  98621. * @param scene defines the scene the sound belongs to
  98622. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  98623. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  98624. */
  98625. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  98626. /**
  98627. * Release the sound and its associated resources
  98628. */
  98629. dispose(): void;
  98630. /**
  98631. * Gets if the sounds is ready to be played or not.
  98632. * @returns true if ready, otherwise false
  98633. */
  98634. isReady(): boolean;
  98635. private _soundLoaded;
  98636. /**
  98637. * Sets the data of the sound from an audiobuffer
  98638. * @param audioBuffer The audioBuffer containing the data
  98639. */
  98640. setAudioBuffer(audioBuffer: AudioBuffer): void;
  98641. /**
  98642. * Updates the current sounds options such as maxdistance, loop...
  98643. * @param options A JSON object containing values named as the object properties
  98644. */
  98645. updateOptions(options: ISoundOptions): void;
  98646. private _createSpatialParameters;
  98647. private _updateSpatialParameters;
  98648. /**
  98649. * Switch the panning model to HRTF:
  98650. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  98651. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98652. */
  98653. switchPanningModelToHRTF(): void;
  98654. /**
  98655. * Switch the panning model to Equal Power:
  98656. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  98657. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98658. */
  98659. switchPanningModelToEqualPower(): void;
  98660. private _switchPanningModel;
  98661. /**
  98662. * Connect this sound to a sound track audio node like gain...
  98663. * @param soundTrackAudioNode the sound track audio node to connect to
  98664. */
  98665. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  98666. /**
  98667. * Transform this sound into a directional source
  98668. * @param coneInnerAngle Size of the inner cone in degree
  98669. * @param coneOuterAngle Size of the outer cone in degree
  98670. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  98671. */
  98672. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  98673. /**
  98674. * Gets or sets the inner angle for the directional cone.
  98675. */
  98676. /**
  98677. * Gets or sets the inner angle for the directional cone.
  98678. */
  98679. directionalConeInnerAngle: number;
  98680. /**
  98681. * Gets or sets the outer angle for the directional cone.
  98682. */
  98683. /**
  98684. * Gets or sets the outer angle for the directional cone.
  98685. */
  98686. directionalConeOuterAngle: number;
  98687. /**
  98688. * Sets the position of the emitter if spatial sound is enabled
  98689. * @param newPosition Defines the new posisiton
  98690. */
  98691. setPosition(newPosition: Vector3): void;
  98692. /**
  98693. * Sets the local direction of the emitter if spatial sound is enabled
  98694. * @param newLocalDirection Defines the new local direction
  98695. */
  98696. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  98697. private _updateDirection;
  98698. /** @hidden */
  98699. updateDistanceFromListener(): void;
  98700. /**
  98701. * Sets a new custom attenuation function for the sound.
  98702. * @param callback Defines the function used for the attenuation
  98703. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  98704. */
  98705. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  98706. /**
  98707. * Play the sound
  98708. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  98709. * @param offset (optional) Start the sound at a specific time in seconds
  98710. * @param length (optional) Sound duration (in seconds)
  98711. */
  98712. play(time?: number, offset?: number, length?: number): void;
  98713. private _onended;
  98714. /**
  98715. * Stop the sound
  98716. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  98717. */
  98718. stop(time?: number): void;
  98719. /**
  98720. * Put the sound in pause
  98721. */
  98722. pause(): void;
  98723. /**
  98724. * Sets a dedicated volume for this sounds
  98725. * @param newVolume Define the new volume of the sound
  98726. * @param time Define time for gradual change to new volume
  98727. */
  98728. setVolume(newVolume: number, time?: number): void;
  98729. /**
  98730. * Set the sound play back rate
  98731. * @param newPlaybackRate Define the playback rate the sound should be played at
  98732. */
  98733. setPlaybackRate(newPlaybackRate: number): void;
  98734. /**
  98735. * Gets the volume of the sound.
  98736. * @returns the volume of the sound
  98737. */
  98738. getVolume(): number;
  98739. /**
  98740. * Attach the sound to a dedicated mesh
  98741. * @param transformNode The transform node to connect the sound with
  98742. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  98743. */
  98744. attachToMesh(transformNode: TransformNode): void;
  98745. /**
  98746. * Detach the sound from the previously attached mesh
  98747. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  98748. */
  98749. detachFromMesh(): void;
  98750. private _onRegisterAfterWorldMatrixUpdate;
  98751. /**
  98752. * Clone the current sound in the scene.
  98753. * @returns the new sound clone
  98754. */
  98755. clone(): Nullable<Sound>;
  98756. /**
  98757. * Gets the current underlying audio buffer containing the data
  98758. * @returns the audio buffer
  98759. */
  98760. getAudioBuffer(): Nullable<AudioBuffer>;
  98761. /**
  98762. * Serializes the Sound in a JSON representation
  98763. * @returns the JSON representation of the sound
  98764. */
  98765. serialize(): any;
  98766. /**
  98767. * Parse a JSON representation of a sound to innstantiate in a given scene
  98768. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  98769. * @param scene Define the scene the new parsed sound should be created in
  98770. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  98771. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  98772. * @returns the newly parsed sound
  98773. */
  98774. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  98775. }
  98776. }
  98777. declare module BABYLON {
  98778. /**
  98779. * This defines an action helpful to play a defined sound on a triggered action.
  98780. */
  98781. export class PlaySoundAction extends Action {
  98782. private _sound;
  98783. /**
  98784. * Instantiate the action
  98785. * @param triggerOptions defines the trigger options
  98786. * @param sound defines the sound to play
  98787. * @param condition defines the trigger related conditions
  98788. */
  98789. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  98790. /** @hidden */
  98791. _prepare(): void;
  98792. /**
  98793. * Execute the action and play the sound.
  98794. */
  98795. execute(): void;
  98796. /**
  98797. * Serializes the actions and its related information.
  98798. * @param parent defines the object to serialize in
  98799. * @returns the serialized object
  98800. */
  98801. serialize(parent: any): any;
  98802. }
  98803. /**
  98804. * This defines an action helpful to stop a defined sound on a triggered action.
  98805. */
  98806. export class StopSoundAction extends Action {
  98807. private _sound;
  98808. /**
  98809. * Instantiate the action
  98810. * @param triggerOptions defines the trigger options
  98811. * @param sound defines the sound to stop
  98812. * @param condition defines the trigger related conditions
  98813. */
  98814. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  98815. /** @hidden */
  98816. _prepare(): void;
  98817. /**
  98818. * Execute the action and stop the sound.
  98819. */
  98820. execute(): void;
  98821. /**
  98822. * Serializes the actions and its related information.
  98823. * @param parent defines the object to serialize in
  98824. * @returns the serialized object
  98825. */
  98826. serialize(parent: any): any;
  98827. }
  98828. }
  98829. declare module BABYLON {
  98830. /**
  98831. * This defines an action responsible to change the value of a property
  98832. * by interpolating between its current value and the newly set one once triggered.
  98833. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  98834. */
  98835. export class InterpolateValueAction extends Action {
  98836. /**
  98837. * Defines the path of the property where the value should be interpolated
  98838. */
  98839. propertyPath: string;
  98840. /**
  98841. * Defines the target value at the end of the interpolation.
  98842. */
  98843. value: any;
  98844. /**
  98845. * Defines the time it will take for the property to interpolate to the value.
  98846. */
  98847. duration: number;
  98848. /**
  98849. * Defines if the other scene animations should be stopped when the action has been triggered
  98850. */
  98851. stopOtherAnimations?: boolean;
  98852. /**
  98853. * Defines a callback raised once the interpolation animation has been done.
  98854. */
  98855. onInterpolationDone?: () => void;
  98856. /**
  98857. * Observable triggered once the interpolation animation has been done.
  98858. */
  98859. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  98860. private _target;
  98861. private _effectiveTarget;
  98862. private _property;
  98863. /**
  98864. * Instantiate the action
  98865. * @param triggerOptions defines the trigger options
  98866. * @param target defines the object containing the value to interpolate
  98867. * @param propertyPath defines the path to the property in the target object
  98868. * @param value defines the target value at the end of the interpolation
  98869. * @param duration deines the time it will take for the property to interpolate to the value.
  98870. * @param condition defines the trigger related conditions
  98871. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  98872. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  98873. */
  98874. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  98875. /** @hidden */
  98876. _prepare(): void;
  98877. /**
  98878. * Execute the action starts the value interpolation.
  98879. */
  98880. execute(): void;
  98881. /**
  98882. * Serializes the actions and its related information.
  98883. * @param parent defines the object to serialize in
  98884. * @returns the serialized object
  98885. */
  98886. serialize(parent: any): any;
  98887. }
  98888. }
  98889. declare module BABYLON {
  98890. /**
  98891. * Options allowed during the creation of a sound track.
  98892. */
  98893. export interface ISoundTrackOptions {
  98894. /**
  98895. * The volume the sound track should take during creation
  98896. */
  98897. volume?: number;
  98898. /**
  98899. * Define if the sound track is the main sound track of the scene
  98900. */
  98901. mainTrack?: boolean;
  98902. }
  98903. /**
  98904. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  98905. * It will be also used in a future release to apply effects on a specific track.
  98906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  98907. */
  98908. export class SoundTrack {
  98909. /**
  98910. * The unique identifier of the sound track in the scene.
  98911. */
  98912. id: number;
  98913. /**
  98914. * The list of sounds included in the sound track.
  98915. */
  98916. soundCollection: Array<Sound>;
  98917. private _outputAudioNode;
  98918. private _scene;
  98919. private _isMainTrack;
  98920. private _connectedAnalyser;
  98921. private _options;
  98922. private _isInitialized;
  98923. /**
  98924. * Creates a new sound track.
  98925. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  98926. * @param scene Define the scene the sound track belongs to
  98927. * @param options
  98928. */
  98929. constructor(scene: Scene, options?: ISoundTrackOptions);
  98930. private _initializeSoundTrackAudioGraph;
  98931. /**
  98932. * Release the sound track and its associated resources
  98933. */
  98934. dispose(): void;
  98935. /**
  98936. * Adds a sound to this sound track
  98937. * @param sound define the cound to add
  98938. * @ignoreNaming
  98939. */
  98940. AddSound(sound: Sound): void;
  98941. /**
  98942. * Removes a sound to this sound track
  98943. * @param sound define the cound to remove
  98944. * @ignoreNaming
  98945. */
  98946. RemoveSound(sound: Sound): void;
  98947. /**
  98948. * Set a global volume for the full sound track.
  98949. * @param newVolume Define the new volume of the sound track
  98950. */
  98951. setVolume(newVolume: number): void;
  98952. /**
  98953. * Switch the panning model to HRTF:
  98954. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  98955. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98956. */
  98957. switchPanningModelToHRTF(): void;
  98958. /**
  98959. * Switch the panning model to Equal Power:
  98960. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  98961. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98962. */
  98963. switchPanningModelToEqualPower(): void;
  98964. /**
  98965. * Connect the sound track to an audio analyser allowing some amazing
  98966. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  98967. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  98968. * @param analyser The analyser to connect to the engine
  98969. */
  98970. connectToAnalyser(analyser: Analyser): void;
  98971. }
  98972. }
  98973. declare module BABYLON {
  98974. interface AbstractScene {
  98975. /**
  98976. * The list of sounds used in the scene.
  98977. */
  98978. sounds: Nullable<Array<Sound>>;
  98979. }
  98980. interface Scene {
  98981. /**
  98982. * @hidden
  98983. * Backing field
  98984. */
  98985. _mainSoundTrack: SoundTrack;
  98986. /**
  98987. * The main sound track played by the scene.
  98988. * It cotains your primary collection of sounds.
  98989. */
  98990. mainSoundTrack: SoundTrack;
  98991. /**
  98992. * The list of sound tracks added to the scene
  98993. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98994. */
  98995. soundTracks: Nullable<Array<SoundTrack>>;
  98996. /**
  98997. * Gets a sound using a given name
  98998. * @param name defines the name to search for
  98999. * @return the found sound or null if not found at all.
  99000. */
  99001. getSoundByName(name: string): Nullable<Sound>;
  99002. /**
  99003. * Gets or sets if audio support is enabled
  99004. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99005. */
  99006. audioEnabled: boolean;
  99007. /**
  99008. * Gets or sets if audio will be output to headphones
  99009. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  99010. */
  99011. headphone: boolean;
  99012. }
  99013. /**
  99014. * Defines the sound scene component responsible to manage any sounds
  99015. * in a given scene.
  99016. */
  99017. export class AudioSceneComponent implements ISceneSerializableComponent {
  99018. /**
  99019. * The component name helpfull to identify the component in the list of scene components.
  99020. */
  99021. readonly name: string;
  99022. /**
  99023. * The scene the component belongs to.
  99024. */
  99025. scene: Scene;
  99026. private _audioEnabled;
  99027. /**
  99028. * Gets whether audio is enabled or not.
  99029. * Please use related enable/disable method to switch state.
  99030. */
  99031. readonly audioEnabled: boolean;
  99032. private _headphone;
  99033. /**
  99034. * Gets whether audio is outputing to headphone or not.
  99035. * Please use the according Switch methods to change output.
  99036. */
  99037. readonly headphone: boolean;
  99038. /**
  99039. * Creates a new instance of the component for the given scene
  99040. * @param scene Defines the scene to register the component in
  99041. */
  99042. constructor(scene: Scene);
  99043. /**
  99044. * Registers the component in a given scene
  99045. */
  99046. register(): void;
  99047. /**
  99048. * Rebuilds the elements related to this component in case of
  99049. * context lost for instance.
  99050. */
  99051. rebuild(): void;
  99052. /**
  99053. * Serializes the component data to the specified json object
  99054. * @param serializationObject The object to serialize to
  99055. */
  99056. serialize(serializationObject: any): void;
  99057. /**
  99058. * Adds all the elements from the container to the scene
  99059. * @param container the container holding the elements
  99060. */
  99061. addFromContainer(container: AbstractScene): void;
  99062. /**
  99063. * Removes all the elements in the container from the scene
  99064. * @param container contains the elements to remove
  99065. * @param dispose if the removed element should be disposed (default: false)
  99066. */
  99067. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  99068. /**
  99069. * Disposes the component and the associated ressources.
  99070. */
  99071. dispose(): void;
  99072. /**
  99073. * Disables audio in the associated scene.
  99074. */
  99075. disableAudio(): void;
  99076. /**
  99077. * Enables audio in the associated scene.
  99078. */
  99079. enableAudio(): void;
  99080. /**
  99081. * Switch audio to headphone output.
  99082. */
  99083. switchAudioModeForHeadphones(): void;
  99084. /**
  99085. * Switch audio to normal speakers.
  99086. */
  99087. switchAudioModeForNormalSpeakers(): void;
  99088. private _afterRender;
  99089. }
  99090. }
  99091. declare module BABYLON {
  99092. /**
  99093. * Wraps one or more Sound objects and selects one with random weight for playback.
  99094. */
  99095. export class WeightedSound {
  99096. /** When true a Sound will be selected and played when the current playing Sound completes. */
  99097. loop: boolean;
  99098. private _coneInnerAngle;
  99099. private _coneOuterAngle;
  99100. private _volume;
  99101. /** A Sound is currently playing. */
  99102. isPlaying: boolean;
  99103. /** A Sound is currently paused. */
  99104. isPaused: boolean;
  99105. private _sounds;
  99106. private _weights;
  99107. private _currentIndex?;
  99108. /**
  99109. * Creates a new WeightedSound from the list of sounds given.
  99110. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  99111. * @param sounds Array of Sounds that will be selected from.
  99112. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  99113. */
  99114. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  99115. /**
  99116. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  99117. */
  99118. /**
  99119. * The size of cone in degress for a directional sound in which there will be no attenuation.
  99120. */
  99121. directionalConeInnerAngle: number;
  99122. /**
  99123. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  99124. * Listener angles between innerAngle and outerAngle will falloff linearly.
  99125. */
  99126. /**
  99127. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  99128. * Listener angles between innerAngle and outerAngle will falloff linearly.
  99129. */
  99130. directionalConeOuterAngle: number;
  99131. /**
  99132. * Playback volume.
  99133. */
  99134. /**
  99135. * Playback volume.
  99136. */
  99137. volume: number;
  99138. private _onended;
  99139. /**
  99140. * Suspend playback
  99141. */
  99142. pause(): void;
  99143. /**
  99144. * Stop playback
  99145. */
  99146. stop(): void;
  99147. /**
  99148. * Start playback.
  99149. * @param startOffset Position the clip head at a specific time in seconds.
  99150. */
  99151. play(startOffset?: number): void;
  99152. }
  99153. }
  99154. declare module BABYLON {
  99155. /**
  99156. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  99157. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  99158. */
  99159. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  99160. /**
  99161. * Gets the name of the behavior.
  99162. */
  99163. readonly name: string;
  99164. /**
  99165. * The easing function used by animations
  99166. */
  99167. static EasingFunction: BackEase;
  99168. /**
  99169. * The easing mode used by animations
  99170. */
  99171. static EasingMode: number;
  99172. /**
  99173. * The duration of the animation, in milliseconds
  99174. */
  99175. transitionDuration: number;
  99176. /**
  99177. * Length of the distance animated by the transition when lower radius is reached
  99178. */
  99179. lowerRadiusTransitionRange: number;
  99180. /**
  99181. * Length of the distance animated by the transition when upper radius is reached
  99182. */
  99183. upperRadiusTransitionRange: number;
  99184. private _autoTransitionRange;
  99185. /**
  99186. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  99187. */
  99188. /**
  99189. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  99190. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  99191. */
  99192. autoTransitionRange: boolean;
  99193. private _attachedCamera;
  99194. private _onAfterCheckInputsObserver;
  99195. private _onMeshTargetChangedObserver;
  99196. /**
  99197. * Initializes the behavior.
  99198. */
  99199. init(): void;
  99200. /**
  99201. * Attaches the behavior to its arc rotate camera.
  99202. * @param camera Defines the camera to attach the behavior to
  99203. */
  99204. attach(camera: ArcRotateCamera): void;
  99205. /**
  99206. * Detaches the behavior from its current arc rotate camera.
  99207. */
  99208. detach(): void;
  99209. private _radiusIsAnimating;
  99210. private _radiusBounceTransition;
  99211. private _animatables;
  99212. private _cachedWheelPrecision;
  99213. /**
  99214. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  99215. * @param radiusLimit The limit to check against.
  99216. * @return Bool to indicate if at limit.
  99217. */
  99218. private _isRadiusAtLimit;
  99219. /**
  99220. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  99221. * @param radiusDelta The delta by which to animate to. Can be negative.
  99222. */
  99223. private _applyBoundRadiusAnimation;
  99224. /**
  99225. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  99226. */
  99227. protected _clearAnimationLocks(): void;
  99228. /**
  99229. * Stops and removes all animations that have been applied to the camera
  99230. */
  99231. stopAllAnimations(): void;
  99232. }
  99233. }
  99234. declare module BABYLON {
  99235. /**
  99236. * 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.
  99237. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  99238. */
  99239. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  99240. /**
  99241. * Gets the name of the behavior.
  99242. */
  99243. readonly name: string;
  99244. private _mode;
  99245. private _radiusScale;
  99246. private _positionScale;
  99247. private _defaultElevation;
  99248. private _elevationReturnTime;
  99249. private _elevationReturnWaitTime;
  99250. private _zoomStopsAnimation;
  99251. private _framingTime;
  99252. /**
  99253. * The easing function used by animations
  99254. */
  99255. static EasingFunction: ExponentialEase;
  99256. /**
  99257. * The easing mode used by animations
  99258. */
  99259. static EasingMode: number;
  99260. /**
  99261. * Sets the current mode used by the behavior
  99262. */
  99263. /**
  99264. * Gets current mode used by the behavior.
  99265. */
  99266. mode: number;
  99267. /**
  99268. * Sets the scale applied to the radius (1 by default)
  99269. */
  99270. /**
  99271. * Gets the scale applied to the radius
  99272. */
  99273. radiusScale: number;
  99274. /**
  99275. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  99276. */
  99277. /**
  99278. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  99279. */
  99280. positionScale: number;
  99281. /**
  99282. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  99283. * behaviour is triggered, in radians.
  99284. */
  99285. /**
  99286. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  99287. * behaviour is triggered, in radians.
  99288. */
  99289. defaultElevation: number;
  99290. /**
  99291. * Sets the time (in milliseconds) taken to return to the default beta position.
  99292. * Negative value indicates camera should not return to default.
  99293. */
  99294. /**
  99295. * Gets the time (in milliseconds) taken to return to the default beta position.
  99296. * Negative value indicates camera should not return to default.
  99297. */
  99298. elevationReturnTime: number;
  99299. /**
  99300. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  99301. */
  99302. /**
  99303. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  99304. */
  99305. elevationReturnWaitTime: number;
  99306. /**
  99307. * Sets the flag that indicates if user zooming should stop animation.
  99308. */
  99309. /**
  99310. * Gets the flag that indicates if user zooming should stop animation.
  99311. */
  99312. zoomStopsAnimation: boolean;
  99313. /**
  99314. * Sets the transition time when framing the mesh, in milliseconds
  99315. */
  99316. /**
  99317. * Gets the transition time when framing the mesh, in milliseconds
  99318. */
  99319. framingTime: number;
  99320. /**
  99321. * Define if the behavior should automatically change the configured
  99322. * camera limits and sensibilities.
  99323. */
  99324. autoCorrectCameraLimitsAndSensibility: boolean;
  99325. private _onPrePointerObservableObserver;
  99326. private _onAfterCheckInputsObserver;
  99327. private _onMeshTargetChangedObserver;
  99328. private _attachedCamera;
  99329. private _isPointerDown;
  99330. private _lastInteractionTime;
  99331. /**
  99332. * Initializes the behavior.
  99333. */
  99334. init(): void;
  99335. /**
  99336. * Attaches the behavior to its arc rotate camera.
  99337. * @param camera Defines the camera to attach the behavior to
  99338. */
  99339. attach(camera: ArcRotateCamera): void;
  99340. /**
  99341. * Detaches the behavior from its current arc rotate camera.
  99342. */
  99343. detach(): void;
  99344. private _animatables;
  99345. private _betaIsAnimating;
  99346. private _betaTransition;
  99347. private _radiusTransition;
  99348. private _vectorTransition;
  99349. /**
  99350. * Targets the given mesh and updates zoom level accordingly.
  99351. * @param mesh The mesh to target.
  99352. * @param radius Optional. If a cached radius position already exists, overrides default.
  99353. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  99354. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99355. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99356. */
  99357. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99358. /**
  99359. * Targets the given mesh with its children and updates zoom level accordingly.
  99360. * @param mesh The mesh to target.
  99361. * @param radius Optional. If a cached radius position already exists, overrides default.
  99362. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  99363. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99364. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99365. */
  99366. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99367. /**
  99368. * Targets the given meshes with their children and updates zoom level accordingly.
  99369. * @param meshes The mesh to target.
  99370. * @param radius Optional. If a cached radius position already exists, overrides default.
  99371. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  99372. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99373. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99374. */
  99375. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99376. /**
  99377. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  99378. * @param minimumWorld Determines the smaller position of the bounding box extend
  99379. * @param maximumWorld Determines the bigger position of the bounding box extend
  99380. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99381. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99382. */
  99383. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99384. /**
  99385. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  99386. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  99387. * frustum width.
  99388. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  99389. * to fully enclose the mesh in the viewing frustum.
  99390. */
  99391. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  99392. /**
  99393. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  99394. * is automatically returned to its default position (expected to be above ground plane).
  99395. */
  99396. private _maintainCameraAboveGround;
  99397. /**
  99398. * Returns the frustum slope based on the canvas ratio and camera FOV
  99399. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  99400. */
  99401. private _getFrustumSlope;
  99402. /**
  99403. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  99404. */
  99405. private _clearAnimationLocks;
  99406. /**
  99407. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  99408. */
  99409. private _applyUserInteraction;
  99410. /**
  99411. * Stops and removes all animations that have been applied to the camera
  99412. */
  99413. stopAllAnimations(): void;
  99414. /**
  99415. * Gets a value indicating if the user is moving the camera
  99416. */
  99417. readonly isUserIsMoving: boolean;
  99418. /**
  99419. * The camera can move all the way towards the mesh.
  99420. */
  99421. static IgnoreBoundsSizeMode: number;
  99422. /**
  99423. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  99424. */
  99425. static FitFrustumSidesMode: number;
  99426. }
  99427. }
  99428. declare module BABYLON {
  99429. /**
  99430. * Base class for Camera Pointer Inputs.
  99431. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  99432. * for example usage.
  99433. */
  99434. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  99435. /**
  99436. * Defines the camera the input is attached to.
  99437. */
  99438. abstract camera: Camera;
  99439. /**
  99440. * Whether keyboard modifier keys are pressed at time of last mouse event.
  99441. */
  99442. protected _altKey: boolean;
  99443. protected _ctrlKey: boolean;
  99444. protected _metaKey: boolean;
  99445. protected _shiftKey: boolean;
  99446. /**
  99447. * Which mouse buttons were pressed at time of last mouse event.
  99448. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  99449. */
  99450. protected _buttonsPressed: number;
  99451. /**
  99452. * Defines the buttons associated with the input to handle camera move.
  99453. */
  99454. buttons: number[];
  99455. /**
  99456. * Attach the input controls to a specific dom element to get the input from.
  99457. * @param element Defines the element the controls should be listened from
  99458. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99459. */
  99460. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99461. /**
  99462. * Detach the current controls from the specified dom element.
  99463. * @param element Defines the element to stop listening the inputs from
  99464. */
  99465. detachControl(element: Nullable<HTMLElement>): void;
  99466. /**
  99467. * Gets the class name of the current input.
  99468. * @returns the class name
  99469. */
  99470. getClassName(): string;
  99471. /**
  99472. * Get the friendly name associated with the input class.
  99473. * @returns the input friendly name
  99474. */
  99475. getSimpleName(): string;
  99476. /**
  99477. * Called on pointer POINTERDOUBLETAP event.
  99478. * Override this method to provide functionality on POINTERDOUBLETAP event.
  99479. */
  99480. protected onDoubleTap(type: string): void;
  99481. /**
  99482. * Called on pointer POINTERMOVE event if only a single touch is active.
  99483. * Override this method to provide functionality.
  99484. */
  99485. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  99486. /**
  99487. * Called on pointer POINTERMOVE event if multiple touches are active.
  99488. * Override this method to provide functionality.
  99489. */
  99490. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  99491. /**
  99492. * Called on JS contextmenu event.
  99493. * Override this method to provide functionality.
  99494. */
  99495. protected onContextMenu(evt: PointerEvent): void;
  99496. /**
  99497. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  99498. * press.
  99499. * Override this method to provide functionality.
  99500. */
  99501. protected onButtonDown(evt: PointerEvent): void;
  99502. /**
  99503. * Called each time a new POINTERUP event occurs. Ie, for each button
  99504. * release.
  99505. * Override this method to provide functionality.
  99506. */
  99507. protected onButtonUp(evt: PointerEvent): void;
  99508. /**
  99509. * Called when window becomes inactive.
  99510. * Override this method to provide functionality.
  99511. */
  99512. protected onLostFocus(): void;
  99513. private _pointerInput;
  99514. private _observer;
  99515. private _onLostFocus;
  99516. private pointA;
  99517. private pointB;
  99518. }
  99519. }
  99520. declare module BABYLON {
  99521. /**
  99522. * Manage the pointers inputs to control an arc rotate camera.
  99523. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99524. */
  99525. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  99526. /**
  99527. * Defines the camera the input is attached to.
  99528. */
  99529. camera: ArcRotateCamera;
  99530. /**
  99531. * Gets the class name of the current input.
  99532. * @returns the class name
  99533. */
  99534. getClassName(): string;
  99535. /**
  99536. * Defines the buttons associated with the input to handle camera move.
  99537. */
  99538. buttons: number[];
  99539. /**
  99540. * Defines the pointer angular sensibility along the X axis or how fast is
  99541. * the camera rotating.
  99542. */
  99543. angularSensibilityX: number;
  99544. /**
  99545. * Defines the pointer angular sensibility along the Y axis or how fast is
  99546. * the camera rotating.
  99547. */
  99548. angularSensibilityY: number;
  99549. /**
  99550. * Defines the pointer pinch precision or how fast is the camera zooming.
  99551. */
  99552. pinchPrecision: number;
  99553. /**
  99554. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  99555. * from 0.
  99556. * It defines the percentage of current camera.radius to use as delta when
  99557. * pinch zoom is used.
  99558. */
  99559. pinchDeltaPercentage: number;
  99560. /**
  99561. * Defines the pointer panning sensibility or how fast is the camera moving.
  99562. */
  99563. panningSensibility: number;
  99564. /**
  99565. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  99566. */
  99567. multiTouchPanning: boolean;
  99568. /**
  99569. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  99570. * zoom (pinch) through multitouch.
  99571. */
  99572. multiTouchPanAndZoom: boolean;
  99573. /**
  99574. * Revers pinch action direction.
  99575. */
  99576. pinchInwards: boolean;
  99577. private _isPanClick;
  99578. private _twoFingerActivityCount;
  99579. private _isPinching;
  99580. /**
  99581. * Called on pointer POINTERMOVE event if only a single touch is active.
  99582. */
  99583. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  99584. /**
  99585. * Called on pointer POINTERDOUBLETAP event.
  99586. */
  99587. protected onDoubleTap(type: string): void;
  99588. /**
  99589. * Called on pointer POINTERMOVE event if multiple touches are active.
  99590. */
  99591. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  99592. /**
  99593. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  99594. * press.
  99595. */
  99596. protected onButtonDown(evt: PointerEvent): void;
  99597. /**
  99598. * Called each time a new POINTERUP event occurs. Ie, for each button
  99599. * release.
  99600. */
  99601. protected onButtonUp(evt: PointerEvent): void;
  99602. /**
  99603. * Called when window becomes inactive.
  99604. */
  99605. protected onLostFocus(): void;
  99606. }
  99607. }
  99608. declare module BABYLON {
  99609. /**
  99610. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  99611. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99612. */
  99613. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  99614. /**
  99615. * Defines the camera the input is attached to.
  99616. */
  99617. camera: ArcRotateCamera;
  99618. /**
  99619. * Defines the list of key codes associated with the up action (increase alpha)
  99620. */
  99621. keysUp: number[];
  99622. /**
  99623. * Defines the list of key codes associated with the down action (decrease alpha)
  99624. */
  99625. keysDown: number[];
  99626. /**
  99627. * Defines the list of key codes associated with the left action (increase beta)
  99628. */
  99629. keysLeft: number[];
  99630. /**
  99631. * Defines the list of key codes associated with the right action (decrease beta)
  99632. */
  99633. keysRight: number[];
  99634. /**
  99635. * Defines the list of key codes associated with the reset action.
  99636. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  99637. */
  99638. keysReset: number[];
  99639. /**
  99640. * Defines the panning sensibility of the inputs.
  99641. * (How fast is the camera paning)
  99642. */
  99643. panningSensibility: number;
  99644. /**
  99645. * Defines the zooming sensibility of the inputs.
  99646. * (How fast is the camera zooming)
  99647. */
  99648. zoomingSensibility: number;
  99649. /**
  99650. * Defines wether maintaining the alt key down switch the movement mode from
  99651. * orientation to zoom.
  99652. */
  99653. useAltToZoom: boolean;
  99654. /**
  99655. * Rotation speed of the camera
  99656. */
  99657. angularSpeed: number;
  99658. private _keys;
  99659. private _ctrlPressed;
  99660. private _altPressed;
  99661. private _onCanvasBlurObserver;
  99662. private _onKeyboardObserver;
  99663. private _engine;
  99664. private _scene;
  99665. /**
  99666. * Attach the input controls to a specific dom element to get the input from.
  99667. * @param element Defines the element the controls should be listened from
  99668. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99669. */
  99670. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99671. /**
  99672. * Detach the current controls from the specified dom element.
  99673. * @param element Defines the element to stop listening the inputs from
  99674. */
  99675. detachControl(element: Nullable<HTMLElement>): void;
  99676. /**
  99677. * Update the current camera state depending on the inputs that have been used this frame.
  99678. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99679. */
  99680. checkInputs(): void;
  99681. /**
  99682. * Gets the class name of the current intput.
  99683. * @returns the class name
  99684. */
  99685. getClassName(): string;
  99686. /**
  99687. * Get the friendly name associated with the input class.
  99688. * @returns the input friendly name
  99689. */
  99690. getSimpleName(): string;
  99691. }
  99692. }
  99693. declare module BABYLON {
  99694. /**
  99695. * Manage the mouse wheel inputs to control an arc rotate camera.
  99696. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99697. */
  99698. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  99699. /**
  99700. * Defines the camera the input is attached to.
  99701. */
  99702. camera: ArcRotateCamera;
  99703. /**
  99704. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  99705. */
  99706. wheelPrecision: number;
  99707. /**
  99708. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  99709. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  99710. */
  99711. wheelDeltaPercentage: number;
  99712. private _wheel;
  99713. private _observer;
  99714. private computeDeltaFromMouseWheelLegacyEvent;
  99715. /**
  99716. * Attach the input controls to a specific dom element to get the input from.
  99717. * @param element Defines the element the controls should be listened from
  99718. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99719. */
  99720. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99721. /**
  99722. * Detach the current controls from the specified dom element.
  99723. * @param element Defines the element to stop listening the inputs from
  99724. */
  99725. detachControl(element: Nullable<HTMLElement>): void;
  99726. /**
  99727. * Gets the class name of the current intput.
  99728. * @returns the class name
  99729. */
  99730. getClassName(): string;
  99731. /**
  99732. * Get the friendly name associated with the input class.
  99733. * @returns the input friendly name
  99734. */
  99735. getSimpleName(): string;
  99736. }
  99737. }
  99738. declare module BABYLON {
  99739. /**
  99740. * Default Inputs manager for the ArcRotateCamera.
  99741. * It groups all the default supported inputs for ease of use.
  99742. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99743. */
  99744. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  99745. /**
  99746. * Instantiates a new ArcRotateCameraInputsManager.
  99747. * @param camera Defines the camera the inputs belong to
  99748. */
  99749. constructor(camera: ArcRotateCamera);
  99750. /**
  99751. * Add mouse wheel input support to the input manager.
  99752. * @returns the current input manager
  99753. */
  99754. addMouseWheel(): ArcRotateCameraInputsManager;
  99755. /**
  99756. * Add pointers input support to the input manager.
  99757. * @returns the current input manager
  99758. */
  99759. addPointers(): ArcRotateCameraInputsManager;
  99760. /**
  99761. * Add keyboard input support to the input manager.
  99762. * @returns the current input manager
  99763. */
  99764. addKeyboard(): ArcRotateCameraInputsManager;
  99765. }
  99766. }
  99767. declare module BABYLON {
  99768. /**
  99769. * This represents an orbital type of camera.
  99770. *
  99771. * 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.
  99772. * 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.
  99773. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  99774. */
  99775. export class ArcRotateCamera extends TargetCamera {
  99776. /**
  99777. * Defines the rotation angle of the camera along the longitudinal axis.
  99778. */
  99779. alpha: number;
  99780. /**
  99781. * Defines the rotation angle of the camera along the latitudinal axis.
  99782. */
  99783. beta: number;
  99784. /**
  99785. * Defines the radius of the camera from it s target point.
  99786. */
  99787. radius: number;
  99788. protected _target: Vector3;
  99789. protected _targetHost: Nullable<AbstractMesh>;
  99790. /**
  99791. * Defines the target point of the camera.
  99792. * The camera looks towards it form the radius distance.
  99793. */
  99794. target: Vector3;
  99795. /**
  99796. * Define the current local position of the camera in the scene
  99797. */
  99798. position: Vector3;
  99799. protected _upVector: Vector3;
  99800. protected _upToYMatrix: Matrix;
  99801. protected _YToUpMatrix: Matrix;
  99802. /**
  99803. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  99804. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  99805. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  99806. */
  99807. upVector: Vector3;
  99808. /**
  99809. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  99810. */
  99811. setMatUp(): void;
  99812. /**
  99813. * Current inertia value on the longitudinal axis.
  99814. * The bigger this number the longer it will take for the camera to stop.
  99815. */
  99816. inertialAlphaOffset: number;
  99817. /**
  99818. * Current inertia value on the latitudinal axis.
  99819. * The bigger this number the longer it will take for the camera to stop.
  99820. */
  99821. inertialBetaOffset: number;
  99822. /**
  99823. * Current inertia value on the radius axis.
  99824. * The bigger this number the longer it will take for the camera to stop.
  99825. */
  99826. inertialRadiusOffset: number;
  99827. /**
  99828. * Minimum allowed angle on the longitudinal axis.
  99829. * This can help limiting how the Camera is able to move in the scene.
  99830. */
  99831. lowerAlphaLimit: Nullable<number>;
  99832. /**
  99833. * Maximum allowed angle on the longitudinal axis.
  99834. * This can help limiting how the Camera is able to move in the scene.
  99835. */
  99836. upperAlphaLimit: Nullable<number>;
  99837. /**
  99838. * Minimum allowed angle on the latitudinal axis.
  99839. * This can help limiting how the Camera is able to move in the scene.
  99840. */
  99841. lowerBetaLimit: number;
  99842. /**
  99843. * Maximum allowed angle on the latitudinal axis.
  99844. * This can help limiting how the Camera is able to move in the scene.
  99845. */
  99846. upperBetaLimit: number;
  99847. /**
  99848. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  99849. * This can help limiting how the Camera is able to move in the scene.
  99850. */
  99851. lowerRadiusLimit: Nullable<number>;
  99852. /**
  99853. * Maximum allowed distance of the camera to the target (The camera can not get further).
  99854. * This can help limiting how the Camera is able to move in the scene.
  99855. */
  99856. upperRadiusLimit: Nullable<number>;
  99857. /**
  99858. * Defines the current inertia value used during panning of the camera along the X axis.
  99859. */
  99860. inertialPanningX: number;
  99861. /**
  99862. * Defines the current inertia value used during panning of the camera along the Y axis.
  99863. */
  99864. inertialPanningY: number;
  99865. /**
  99866. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  99867. * Basically if your fingers moves away from more than this distance you will be considered
  99868. * in pinch mode.
  99869. */
  99870. pinchToPanMaxDistance: number;
  99871. /**
  99872. * Defines the maximum distance the camera can pan.
  99873. * This could help keeping the cammera always in your scene.
  99874. */
  99875. panningDistanceLimit: Nullable<number>;
  99876. /**
  99877. * Defines the target of the camera before paning.
  99878. */
  99879. panningOriginTarget: Vector3;
  99880. /**
  99881. * Defines the value of the inertia used during panning.
  99882. * 0 would mean stop inertia and one would mean no decelleration at all.
  99883. */
  99884. panningInertia: number;
  99885. /**
  99886. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  99887. */
  99888. angularSensibilityX: number;
  99889. /**
  99890. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  99891. */
  99892. angularSensibilityY: number;
  99893. /**
  99894. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  99895. */
  99896. pinchPrecision: number;
  99897. /**
  99898. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  99899. * It will be used instead of pinchDeltaPrecision if different from 0.
  99900. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  99901. */
  99902. pinchDeltaPercentage: number;
  99903. /**
  99904. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  99905. */
  99906. panningSensibility: number;
  99907. /**
  99908. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  99909. */
  99910. keysUp: number[];
  99911. /**
  99912. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  99913. */
  99914. keysDown: number[];
  99915. /**
  99916. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  99917. */
  99918. keysLeft: number[];
  99919. /**
  99920. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  99921. */
  99922. keysRight: number[];
  99923. /**
  99924. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  99925. */
  99926. wheelPrecision: number;
  99927. /**
  99928. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  99929. * It will be used instead of pinchDeltaPrecision if different from 0.
  99930. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  99931. */
  99932. wheelDeltaPercentage: number;
  99933. /**
  99934. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  99935. */
  99936. zoomOnFactor: number;
  99937. /**
  99938. * Defines a screen offset for the camera position.
  99939. */
  99940. targetScreenOffset: Vector2;
  99941. /**
  99942. * Allows the camera to be completely reversed.
  99943. * If false the camera can not arrive upside down.
  99944. */
  99945. allowUpsideDown: boolean;
  99946. /**
  99947. * Define if double tap/click is used to restore the previously saved state of the camera.
  99948. */
  99949. useInputToRestoreState: boolean;
  99950. /** @hidden */
  99951. _viewMatrix: Matrix;
  99952. /** @hidden */
  99953. _useCtrlForPanning: boolean;
  99954. /** @hidden */
  99955. _panningMouseButton: number;
  99956. /**
  99957. * Defines the input associated to the camera.
  99958. */
  99959. inputs: ArcRotateCameraInputsManager;
  99960. /** @hidden */
  99961. _reset: () => void;
  99962. /**
  99963. * Defines the allowed panning axis.
  99964. */
  99965. panningAxis: Vector3;
  99966. protected _localDirection: Vector3;
  99967. protected _transformedDirection: Vector3;
  99968. private _bouncingBehavior;
  99969. /**
  99970. * Gets the bouncing behavior of the camera if it has been enabled.
  99971. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  99972. */
  99973. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  99974. /**
  99975. * Defines if the bouncing behavior of the camera is enabled on the camera.
  99976. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  99977. */
  99978. useBouncingBehavior: boolean;
  99979. private _framingBehavior;
  99980. /**
  99981. * Gets the framing behavior of the camera if it has been enabled.
  99982. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  99983. */
  99984. readonly framingBehavior: Nullable<FramingBehavior>;
  99985. /**
  99986. * Defines if the framing behavior of the camera is enabled on the camera.
  99987. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  99988. */
  99989. useFramingBehavior: boolean;
  99990. private _autoRotationBehavior;
  99991. /**
  99992. * Gets the auto rotation behavior of the camera if it has been enabled.
  99993. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  99994. */
  99995. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  99996. /**
  99997. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  99998. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  99999. */
  100000. useAutoRotationBehavior: boolean;
  100001. /**
  100002. * Observable triggered when the mesh target has been changed on the camera.
  100003. */
  100004. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  100005. /**
  100006. * Event raised when the camera is colliding with a mesh.
  100007. */
  100008. onCollide: (collidedMesh: AbstractMesh) => void;
  100009. /**
  100010. * Defines whether the camera should check collision with the objects oh the scene.
  100011. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  100012. */
  100013. checkCollisions: boolean;
  100014. /**
  100015. * Defines the collision radius of the camera.
  100016. * This simulates a sphere around the camera.
  100017. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  100018. */
  100019. collisionRadius: Vector3;
  100020. protected _collider: Collider;
  100021. protected _previousPosition: Vector3;
  100022. protected _collisionVelocity: Vector3;
  100023. protected _newPosition: Vector3;
  100024. protected _previousAlpha: number;
  100025. protected _previousBeta: number;
  100026. protected _previousRadius: number;
  100027. protected _collisionTriggered: boolean;
  100028. protected _targetBoundingCenter: Nullable<Vector3>;
  100029. private _computationVector;
  100030. /**
  100031. * Instantiates a new ArcRotateCamera in a given scene
  100032. * @param name Defines the name of the camera
  100033. * @param alpha Defines the camera rotation along the logitudinal axis
  100034. * @param beta Defines the camera rotation along the latitudinal axis
  100035. * @param radius Defines the camera distance from its target
  100036. * @param target Defines the camera target
  100037. * @param scene Defines the scene the camera belongs to
  100038. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  100039. */
  100040. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  100041. /** @hidden */
  100042. _initCache(): void;
  100043. /** @hidden */
  100044. _updateCache(ignoreParentClass?: boolean): void;
  100045. protected _getTargetPosition(): Vector3;
  100046. private _storedAlpha;
  100047. private _storedBeta;
  100048. private _storedRadius;
  100049. private _storedTarget;
  100050. /**
  100051. * Stores the current state of the camera (alpha, beta, radius and target)
  100052. * @returns the camera itself
  100053. */
  100054. storeState(): Camera;
  100055. /**
  100056. * @hidden
  100057. * Restored camera state. You must call storeState() first
  100058. */
  100059. _restoreStateValues(): boolean;
  100060. /** @hidden */
  100061. _isSynchronizedViewMatrix(): boolean;
  100062. /**
  100063. * Attached controls to the current camera.
  100064. * @param element Defines the element the controls should be listened from
  100065. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100066. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  100067. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  100068. */
  100069. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  100070. /**
  100071. * Detach the current controls from the camera.
  100072. * The camera will stop reacting to inputs.
  100073. * @param element Defines the element to stop listening the inputs from
  100074. */
  100075. detachControl(element: HTMLElement): void;
  100076. /** @hidden */
  100077. _checkInputs(): void;
  100078. protected _checkLimits(): void;
  100079. /**
  100080. * Rebuilds angles (alpha, beta) and radius from the give position and target
  100081. */
  100082. rebuildAnglesAndRadius(): void;
  100083. /**
  100084. * Use a position to define the current camera related information like aplha, beta and radius
  100085. * @param position Defines the position to set the camera at
  100086. */
  100087. setPosition(position: Vector3): void;
  100088. /**
  100089. * Defines the target the camera should look at.
  100090. * This will automatically adapt alpha beta and radius to fit within the new target.
  100091. * @param target Defines the new target as a Vector or a mesh
  100092. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  100093. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  100094. */
  100095. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  100096. /** @hidden */
  100097. _getViewMatrix(): Matrix;
  100098. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  100099. /**
  100100. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  100101. * @param meshes Defines the mesh to zoom on
  100102. * @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)
  100103. */
  100104. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  100105. /**
  100106. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  100107. * The target will be changed but the radius
  100108. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  100109. * @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)
  100110. */
  100111. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  100112. min: Vector3;
  100113. max: Vector3;
  100114. distance: number;
  100115. }, doNotUpdateMaxZ?: boolean): void;
  100116. /**
  100117. * @override
  100118. * Override Camera.createRigCamera
  100119. */
  100120. createRigCamera(name: string, cameraIndex: number): Camera;
  100121. /**
  100122. * @hidden
  100123. * @override
  100124. * Override Camera._updateRigCameras
  100125. */
  100126. _updateRigCameras(): void;
  100127. /**
  100128. * Destroy the camera and release the current resources hold by it.
  100129. */
  100130. dispose(): void;
  100131. /**
  100132. * Gets the current object class name.
  100133. * @return the class name
  100134. */
  100135. getClassName(): string;
  100136. }
  100137. }
  100138. declare module BABYLON {
  100139. /**
  100140. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  100141. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  100142. */
  100143. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  100144. /**
  100145. * Gets the name of the behavior.
  100146. */
  100147. readonly name: string;
  100148. private _zoomStopsAnimation;
  100149. private _idleRotationSpeed;
  100150. private _idleRotationWaitTime;
  100151. private _idleRotationSpinupTime;
  100152. /**
  100153. * Sets the flag that indicates if user zooming should stop animation.
  100154. */
  100155. /**
  100156. * Gets the flag that indicates if user zooming should stop animation.
  100157. */
  100158. zoomStopsAnimation: boolean;
  100159. /**
  100160. * Sets the default speed at which the camera rotates around the model.
  100161. */
  100162. /**
  100163. * Gets the default speed at which the camera rotates around the model.
  100164. */
  100165. idleRotationSpeed: number;
  100166. /**
  100167. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  100168. */
  100169. /**
  100170. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  100171. */
  100172. idleRotationWaitTime: number;
  100173. /**
  100174. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  100175. */
  100176. /**
  100177. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  100178. */
  100179. idleRotationSpinupTime: number;
  100180. /**
  100181. * Gets a value indicating if the camera is currently rotating because of this behavior
  100182. */
  100183. readonly rotationInProgress: boolean;
  100184. private _onPrePointerObservableObserver;
  100185. private _onAfterCheckInputsObserver;
  100186. private _attachedCamera;
  100187. private _isPointerDown;
  100188. private _lastFrameTime;
  100189. private _lastInteractionTime;
  100190. private _cameraRotationSpeed;
  100191. /**
  100192. * Initializes the behavior.
  100193. */
  100194. init(): void;
  100195. /**
  100196. * Attaches the behavior to its arc rotate camera.
  100197. * @param camera Defines the camera to attach the behavior to
  100198. */
  100199. attach(camera: ArcRotateCamera): void;
  100200. /**
  100201. * Detaches the behavior from its current arc rotate camera.
  100202. */
  100203. detach(): void;
  100204. /**
  100205. * Returns true if user is scrolling.
  100206. * @return true if user is scrolling.
  100207. */
  100208. private _userIsZooming;
  100209. private _lastFrameRadius;
  100210. private _shouldAnimationStopForInteraction;
  100211. /**
  100212. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  100213. */
  100214. private _applyUserInteraction;
  100215. private _userIsMoving;
  100216. }
  100217. }
  100218. declare module BABYLON {
  100219. /**
  100220. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  100221. */
  100222. export class AttachToBoxBehavior implements Behavior<Mesh> {
  100223. private ui;
  100224. /**
  100225. * The name of the behavior
  100226. */
  100227. name: string;
  100228. /**
  100229. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  100230. */
  100231. distanceAwayFromFace: number;
  100232. /**
  100233. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  100234. */
  100235. distanceAwayFromBottomOfFace: number;
  100236. private _faceVectors;
  100237. private _target;
  100238. private _scene;
  100239. private _onRenderObserver;
  100240. private _tmpMatrix;
  100241. private _tmpVector;
  100242. /**
  100243. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  100244. * @param ui The transform node that should be attched to the mesh
  100245. */
  100246. constructor(ui: TransformNode);
  100247. /**
  100248. * Initializes the behavior
  100249. */
  100250. init(): void;
  100251. private _closestFace;
  100252. private _zeroVector;
  100253. private _lookAtTmpMatrix;
  100254. private _lookAtToRef;
  100255. /**
  100256. * Attaches the AttachToBoxBehavior to the passed in mesh
  100257. * @param target The mesh that the specified node will be attached to
  100258. */
  100259. attach(target: Mesh): void;
  100260. /**
  100261. * Detaches the behavior from the mesh
  100262. */
  100263. detach(): void;
  100264. }
  100265. }
  100266. declare module BABYLON {
  100267. /**
  100268. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  100269. */
  100270. export class FadeInOutBehavior implements Behavior<Mesh> {
  100271. /**
  100272. * Time in milliseconds to delay before fading in (Default: 0)
  100273. */
  100274. delay: number;
  100275. /**
  100276. * Time in milliseconds for the mesh to fade in (Default: 300)
  100277. */
  100278. fadeInTime: number;
  100279. private _millisecondsPerFrame;
  100280. private _hovered;
  100281. private _hoverValue;
  100282. private _ownerNode;
  100283. /**
  100284. * Instatiates the FadeInOutBehavior
  100285. */
  100286. constructor();
  100287. /**
  100288. * The name of the behavior
  100289. */
  100290. readonly name: string;
  100291. /**
  100292. * Initializes the behavior
  100293. */
  100294. init(): void;
  100295. /**
  100296. * Attaches the fade behavior on the passed in mesh
  100297. * @param ownerNode The mesh that will be faded in/out once attached
  100298. */
  100299. attach(ownerNode: Mesh): void;
  100300. /**
  100301. * Detaches the behavior from the mesh
  100302. */
  100303. detach(): void;
  100304. /**
  100305. * Triggers the mesh to begin fading in or out
  100306. * @param value if the object should fade in or out (true to fade in)
  100307. */
  100308. fadeIn(value: boolean): void;
  100309. private _update;
  100310. private _setAllVisibility;
  100311. }
  100312. }
  100313. declare module BABYLON {
  100314. /**
  100315. * Class containing a set of static utilities functions for managing Pivots
  100316. * @hidden
  100317. */
  100318. export class PivotTools {
  100319. private static _PivotCached;
  100320. private static _OldPivotPoint;
  100321. private static _PivotTranslation;
  100322. private static _PivotTmpVector;
  100323. /** @hidden */
  100324. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  100325. /** @hidden */
  100326. static _RestorePivotPoint(mesh: AbstractMesh): void;
  100327. }
  100328. }
  100329. declare module BABYLON {
  100330. /**
  100331. * Class containing static functions to help procedurally build meshes
  100332. */
  100333. export class PlaneBuilder {
  100334. /**
  100335. * Creates a plane mesh
  100336. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  100337. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  100338. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  100339. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100340. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100342. * @param name defines the name of the mesh
  100343. * @param options defines the options used to create the mesh
  100344. * @param scene defines the hosting scene
  100345. * @returns the plane mesh
  100346. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  100347. */
  100348. static CreatePlane(name: string, options: {
  100349. size?: number;
  100350. width?: number;
  100351. height?: number;
  100352. sideOrientation?: number;
  100353. frontUVs?: Vector4;
  100354. backUVs?: Vector4;
  100355. updatable?: boolean;
  100356. sourcePlane?: Plane;
  100357. }, scene?: Nullable<Scene>): Mesh;
  100358. }
  100359. }
  100360. declare module BABYLON {
  100361. /**
  100362. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  100363. */
  100364. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  100365. private static _AnyMouseID;
  100366. /**
  100367. * Abstract mesh the behavior is set on
  100368. */
  100369. attachedNode: AbstractMesh;
  100370. private _dragPlane;
  100371. private _scene;
  100372. private _pointerObserver;
  100373. private _beforeRenderObserver;
  100374. private static _planeScene;
  100375. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  100376. /**
  100377. * 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)
  100378. */
  100379. maxDragAngle: number;
  100380. /**
  100381. * @hidden
  100382. */
  100383. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  100384. /**
  100385. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  100386. */
  100387. currentDraggingPointerID: number;
  100388. /**
  100389. * The last position where the pointer hit the drag plane in world space
  100390. */
  100391. lastDragPosition: Vector3;
  100392. /**
  100393. * If the behavior is currently in a dragging state
  100394. */
  100395. dragging: boolean;
  100396. /**
  100397. * 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)
  100398. */
  100399. dragDeltaRatio: number;
  100400. /**
  100401. * If the drag plane orientation should be updated during the dragging (Default: true)
  100402. */
  100403. updateDragPlane: boolean;
  100404. private _debugMode;
  100405. private _moving;
  100406. /**
  100407. * Fires each time the attached mesh is dragged with the pointer
  100408. * * delta between last drag position and current drag position in world space
  100409. * * dragDistance along the drag axis
  100410. * * dragPlaneNormal normal of the current drag plane used during the drag
  100411. * * dragPlanePoint in world space where the drag intersects the drag plane
  100412. */
  100413. onDragObservable: Observable<{
  100414. delta: Vector3;
  100415. dragPlanePoint: Vector3;
  100416. dragPlaneNormal: Vector3;
  100417. dragDistance: number;
  100418. pointerId: number;
  100419. }>;
  100420. /**
  100421. * Fires each time a drag begins (eg. mouse down on mesh)
  100422. */
  100423. onDragStartObservable: Observable<{
  100424. dragPlanePoint: Vector3;
  100425. pointerId: number;
  100426. }>;
  100427. /**
  100428. * Fires each time a drag ends (eg. mouse release after drag)
  100429. */
  100430. onDragEndObservable: Observable<{
  100431. dragPlanePoint: Vector3;
  100432. pointerId: number;
  100433. }>;
  100434. /**
  100435. * If the attached mesh should be moved when dragged
  100436. */
  100437. moveAttached: boolean;
  100438. /**
  100439. * If the drag behavior will react to drag events (Default: true)
  100440. */
  100441. enabled: boolean;
  100442. /**
  100443. * If pointer events should start and release the drag (Default: true)
  100444. */
  100445. startAndReleaseDragOnPointerEvents: boolean;
  100446. /**
  100447. * If camera controls should be detached during the drag
  100448. */
  100449. detachCameraControls: boolean;
  100450. /**
  100451. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  100452. */
  100453. useObjectOrienationForDragging: boolean;
  100454. private _options;
  100455. /**
  100456. * Creates a pointer drag behavior that can be attached to a mesh
  100457. * @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)
  100458. */
  100459. constructor(options?: {
  100460. dragAxis?: Vector3;
  100461. dragPlaneNormal?: Vector3;
  100462. });
  100463. /**
  100464. * Predicate to determine if it is valid to move the object to a new position when it is moved
  100465. */
  100466. validateDrag: (targetPosition: Vector3) => boolean;
  100467. /**
  100468. * The name of the behavior
  100469. */
  100470. readonly name: string;
  100471. /**
  100472. * Initializes the behavior
  100473. */
  100474. init(): void;
  100475. private _tmpVector;
  100476. private _alternatePickedPoint;
  100477. private _worldDragAxis;
  100478. private _targetPosition;
  100479. private _attachedElement;
  100480. /**
  100481. * Attaches the drag behavior the passed in mesh
  100482. * @param ownerNode The mesh that will be dragged around once attached
  100483. */
  100484. attach(ownerNode: AbstractMesh): void;
  100485. /**
  100486. * Force relase the drag action by code.
  100487. */
  100488. releaseDrag(): void;
  100489. private _startDragRay;
  100490. private _lastPointerRay;
  100491. /**
  100492. * Simulates the start of a pointer drag event on the behavior
  100493. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  100494. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  100495. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  100496. */
  100497. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  100498. private _startDrag;
  100499. private _dragDelta;
  100500. private _moveDrag;
  100501. private _pickWithRayOnDragPlane;
  100502. private _pointA;
  100503. private _pointB;
  100504. private _pointC;
  100505. private _lineA;
  100506. private _lineB;
  100507. private _localAxis;
  100508. private _lookAt;
  100509. private _updateDragPlanePosition;
  100510. /**
  100511. * Detaches the behavior from the mesh
  100512. */
  100513. detach(): void;
  100514. }
  100515. }
  100516. declare module BABYLON {
  100517. /**
  100518. * A behavior that when attached to a mesh will allow the mesh to be scaled
  100519. */
  100520. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  100521. private _dragBehaviorA;
  100522. private _dragBehaviorB;
  100523. private _startDistance;
  100524. private _initialScale;
  100525. private _targetScale;
  100526. private _ownerNode;
  100527. private _sceneRenderObserver;
  100528. /**
  100529. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  100530. */
  100531. constructor();
  100532. /**
  100533. * The name of the behavior
  100534. */
  100535. readonly name: string;
  100536. /**
  100537. * Initializes the behavior
  100538. */
  100539. init(): void;
  100540. private _getCurrentDistance;
  100541. /**
  100542. * Attaches the scale behavior the passed in mesh
  100543. * @param ownerNode The mesh that will be scaled around once attached
  100544. */
  100545. attach(ownerNode: Mesh): void;
  100546. /**
  100547. * Detaches the behavior from the mesh
  100548. */
  100549. detach(): void;
  100550. }
  100551. }
  100552. declare module BABYLON {
  100553. /**
  100554. * 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
  100555. */
  100556. export class SixDofDragBehavior implements Behavior<Mesh> {
  100557. private static _virtualScene;
  100558. private _ownerNode;
  100559. private _sceneRenderObserver;
  100560. private _scene;
  100561. private _targetPosition;
  100562. private _virtualOriginMesh;
  100563. private _virtualDragMesh;
  100564. private _pointerObserver;
  100565. private _moving;
  100566. private _startingOrientation;
  100567. /**
  100568. * 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)
  100569. */
  100570. private zDragFactor;
  100571. /**
  100572. * If the object should rotate to face the drag origin
  100573. */
  100574. rotateDraggedObject: boolean;
  100575. /**
  100576. * If the behavior is currently in a dragging state
  100577. */
  100578. dragging: boolean;
  100579. /**
  100580. * 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)
  100581. */
  100582. dragDeltaRatio: number;
  100583. /**
  100584. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  100585. */
  100586. currentDraggingPointerID: number;
  100587. /**
  100588. * If camera controls should be detached during the drag
  100589. */
  100590. detachCameraControls: boolean;
  100591. /**
  100592. * Fires each time a drag starts
  100593. */
  100594. onDragStartObservable: Observable<{}>;
  100595. /**
  100596. * Fires each time a drag ends (eg. mouse release after drag)
  100597. */
  100598. onDragEndObservable: Observable<{}>;
  100599. /**
  100600. * 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
  100601. */
  100602. constructor();
  100603. /**
  100604. * The name of the behavior
  100605. */
  100606. readonly name: string;
  100607. /**
  100608. * Initializes the behavior
  100609. */
  100610. init(): void;
  100611. /**
  100612. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  100613. */
  100614. private readonly _pointerCamera;
  100615. /**
  100616. * Attaches the scale behavior the passed in mesh
  100617. * @param ownerNode The mesh that will be scaled around once attached
  100618. */
  100619. attach(ownerNode: Mesh): void;
  100620. /**
  100621. * Detaches the behavior from the mesh
  100622. */
  100623. detach(): void;
  100624. }
  100625. }
  100626. declare module BABYLON {
  100627. /**
  100628. * Class used to apply inverse kinematics to bones
  100629. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  100630. */
  100631. export class BoneIKController {
  100632. private static _tmpVecs;
  100633. private static _tmpQuat;
  100634. private static _tmpMats;
  100635. /**
  100636. * Gets or sets the target mesh
  100637. */
  100638. targetMesh: AbstractMesh;
  100639. /** Gets or sets the mesh used as pole */
  100640. poleTargetMesh: AbstractMesh;
  100641. /**
  100642. * Gets or sets the bone used as pole
  100643. */
  100644. poleTargetBone: Nullable<Bone>;
  100645. /**
  100646. * Gets or sets the target position
  100647. */
  100648. targetPosition: Vector3;
  100649. /**
  100650. * Gets or sets the pole target position
  100651. */
  100652. poleTargetPosition: Vector3;
  100653. /**
  100654. * Gets or sets the pole target local offset
  100655. */
  100656. poleTargetLocalOffset: Vector3;
  100657. /**
  100658. * Gets or sets the pole angle
  100659. */
  100660. poleAngle: number;
  100661. /**
  100662. * Gets or sets the mesh associated with the controller
  100663. */
  100664. mesh: AbstractMesh;
  100665. /**
  100666. * 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)
  100667. */
  100668. slerpAmount: number;
  100669. private _bone1Quat;
  100670. private _bone1Mat;
  100671. private _bone2Ang;
  100672. private _bone1;
  100673. private _bone2;
  100674. private _bone1Length;
  100675. private _bone2Length;
  100676. private _maxAngle;
  100677. private _maxReach;
  100678. private _rightHandedSystem;
  100679. private _bendAxis;
  100680. private _slerping;
  100681. private _adjustRoll;
  100682. /**
  100683. * Gets or sets maximum allowed angle
  100684. */
  100685. maxAngle: number;
  100686. /**
  100687. * Creates a new BoneIKController
  100688. * @param mesh defines the mesh to control
  100689. * @param bone defines the bone to control
  100690. * @param options defines options to set up the controller
  100691. */
  100692. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  100693. targetMesh?: AbstractMesh;
  100694. poleTargetMesh?: AbstractMesh;
  100695. poleTargetBone?: Bone;
  100696. poleTargetLocalOffset?: Vector3;
  100697. poleAngle?: number;
  100698. bendAxis?: Vector3;
  100699. maxAngle?: number;
  100700. slerpAmount?: number;
  100701. });
  100702. private _setMaxAngle;
  100703. /**
  100704. * Force the controller to update the bones
  100705. */
  100706. update(): void;
  100707. }
  100708. }
  100709. declare module BABYLON {
  100710. /**
  100711. * Class used to make a bone look toward a point in space
  100712. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  100713. */
  100714. export class BoneLookController {
  100715. private static _tmpVecs;
  100716. private static _tmpQuat;
  100717. private static _tmpMats;
  100718. /**
  100719. * The target Vector3 that the bone will look at
  100720. */
  100721. target: Vector3;
  100722. /**
  100723. * The mesh that the bone is attached to
  100724. */
  100725. mesh: AbstractMesh;
  100726. /**
  100727. * The bone that will be looking to the target
  100728. */
  100729. bone: Bone;
  100730. /**
  100731. * The up axis of the coordinate system that is used when the bone is rotated
  100732. */
  100733. upAxis: Vector3;
  100734. /**
  100735. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  100736. */
  100737. upAxisSpace: Space;
  100738. /**
  100739. * Used to make an adjustment to the yaw of the bone
  100740. */
  100741. adjustYaw: number;
  100742. /**
  100743. * Used to make an adjustment to the pitch of the bone
  100744. */
  100745. adjustPitch: number;
  100746. /**
  100747. * Used to make an adjustment to the roll of the bone
  100748. */
  100749. adjustRoll: number;
  100750. /**
  100751. * 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)
  100752. */
  100753. slerpAmount: number;
  100754. private _minYaw;
  100755. private _maxYaw;
  100756. private _minPitch;
  100757. private _maxPitch;
  100758. private _minYawSin;
  100759. private _minYawCos;
  100760. private _maxYawSin;
  100761. private _maxYawCos;
  100762. private _midYawConstraint;
  100763. private _minPitchTan;
  100764. private _maxPitchTan;
  100765. private _boneQuat;
  100766. private _slerping;
  100767. private _transformYawPitch;
  100768. private _transformYawPitchInv;
  100769. private _firstFrameSkipped;
  100770. private _yawRange;
  100771. private _fowardAxis;
  100772. /**
  100773. * Gets or sets the minimum yaw angle that the bone can look to
  100774. */
  100775. minYaw: number;
  100776. /**
  100777. * Gets or sets the maximum yaw angle that the bone can look to
  100778. */
  100779. maxYaw: number;
  100780. /**
  100781. * Gets or sets the minimum pitch angle that the bone can look to
  100782. */
  100783. minPitch: number;
  100784. /**
  100785. * Gets or sets the maximum pitch angle that the bone can look to
  100786. */
  100787. maxPitch: number;
  100788. /**
  100789. * Create a BoneLookController
  100790. * @param mesh the mesh that the bone belongs to
  100791. * @param bone the bone that will be looking to the target
  100792. * @param target the target Vector3 to look at
  100793. * @param options optional settings:
  100794. * * maxYaw: the maximum angle the bone will yaw to
  100795. * * minYaw: the minimum angle the bone will yaw to
  100796. * * maxPitch: the maximum angle the bone will pitch to
  100797. * * minPitch: the minimum angle the bone will yaw to
  100798. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  100799. * * upAxis: the up axis of the coordinate system
  100800. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  100801. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  100802. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  100803. * * adjustYaw: used to make an adjustment to the yaw of the bone
  100804. * * adjustPitch: used to make an adjustment to the pitch of the bone
  100805. * * adjustRoll: used to make an adjustment to the roll of the bone
  100806. **/
  100807. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  100808. maxYaw?: number;
  100809. minYaw?: number;
  100810. maxPitch?: number;
  100811. minPitch?: number;
  100812. slerpAmount?: number;
  100813. upAxis?: Vector3;
  100814. upAxisSpace?: Space;
  100815. yawAxis?: Vector3;
  100816. pitchAxis?: Vector3;
  100817. adjustYaw?: number;
  100818. adjustPitch?: number;
  100819. adjustRoll?: number;
  100820. });
  100821. /**
  100822. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  100823. */
  100824. update(): void;
  100825. private _getAngleDiff;
  100826. private _getAngleBetween;
  100827. private _isAngleBetween;
  100828. }
  100829. }
  100830. declare module BABYLON {
  100831. /**
  100832. * Manage the gamepad inputs to control an arc rotate camera.
  100833. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100834. */
  100835. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  100836. /**
  100837. * Defines the camera the input is attached to.
  100838. */
  100839. camera: ArcRotateCamera;
  100840. /**
  100841. * Defines the gamepad the input is gathering event from.
  100842. */
  100843. gamepad: Nullable<Gamepad>;
  100844. /**
  100845. * Defines the gamepad rotation sensiblity.
  100846. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100847. */
  100848. gamepadRotationSensibility: number;
  100849. /**
  100850. * Defines the gamepad move sensiblity.
  100851. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100852. */
  100853. gamepadMoveSensibility: number;
  100854. private _onGamepadConnectedObserver;
  100855. private _onGamepadDisconnectedObserver;
  100856. /**
  100857. * Attach the input controls to a specific dom element to get the input from.
  100858. * @param element Defines the element the controls should be listened from
  100859. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100860. */
  100861. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100862. /**
  100863. * Detach the current controls from the specified dom element.
  100864. * @param element Defines the element to stop listening the inputs from
  100865. */
  100866. detachControl(element: Nullable<HTMLElement>): void;
  100867. /**
  100868. * Update the current camera state depending on the inputs that have been used this frame.
  100869. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100870. */
  100871. checkInputs(): void;
  100872. /**
  100873. * Gets the class name of the current intput.
  100874. * @returns the class name
  100875. */
  100876. getClassName(): string;
  100877. /**
  100878. * Get the friendly name associated with the input class.
  100879. * @returns the input friendly name
  100880. */
  100881. getSimpleName(): string;
  100882. }
  100883. }
  100884. declare module BABYLON {
  100885. interface ArcRotateCameraInputsManager {
  100886. /**
  100887. * Add orientation input support to the input manager.
  100888. * @returns the current input manager
  100889. */
  100890. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  100891. }
  100892. /**
  100893. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  100894. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100895. */
  100896. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  100897. /**
  100898. * Defines the camera the input is attached to.
  100899. */
  100900. camera: ArcRotateCamera;
  100901. /**
  100902. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  100903. */
  100904. alphaCorrection: number;
  100905. /**
  100906. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  100907. */
  100908. gammaCorrection: number;
  100909. private _alpha;
  100910. private _gamma;
  100911. private _dirty;
  100912. private _deviceOrientationHandler;
  100913. /**
  100914. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  100915. */
  100916. constructor();
  100917. /**
  100918. * Attach the input controls to a specific dom element to get the input from.
  100919. * @param element Defines the element the controls should be listened from
  100920. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100921. */
  100922. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100923. /** @hidden */
  100924. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  100925. /**
  100926. * Update the current camera state depending on the inputs that have been used this frame.
  100927. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100928. */
  100929. checkInputs(): void;
  100930. /**
  100931. * Detach the current controls from the specified dom element.
  100932. * @param element Defines the element to stop listening the inputs from
  100933. */
  100934. detachControl(element: Nullable<HTMLElement>): void;
  100935. /**
  100936. * Gets the class name of the current intput.
  100937. * @returns the class name
  100938. */
  100939. getClassName(): string;
  100940. /**
  100941. * Get the friendly name associated with the input class.
  100942. * @returns the input friendly name
  100943. */
  100944. getSimpleName(): string;
  100945. }
  100946. }
  100947. declare module BABYLON {
  100948. /**
  100949. * Listen to mouse events to control the camera.
  100950. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100951. */
  100952. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  100953. /**
  100954. * Defines the camera the input is attached to.
  100955. */
  100956. camera: FlyCamera;
  100957. /**
  100958. * Defines if touch is enabled. (Default is true.)
  100959. */
  100960. touchEnabled: boolean;
  100961. /**
  100962. * Defines the buttons associated with the input to handle camera rotation.
  100963. */
  100964. buttons: number[];
  100965. /**
  100966. * Assign buttons for Yaw control.
  100967. */
  100968. buttonsYaw: number[];
  100969. /**
  100970. * Assign buttons for Pitch control.
  100971. */
  100972. buttonsPitch: number[];
  100973. /**
  100974. * Assign buttons for Roll control.
  100975. */
  100976. buttonsRoll: number[];
  100977. /**
  100978. * Detect if any button is being pressed while mouse is moved.
  100979. * -1 = Mouse locked.
  100980. * 0 = Left button.
  100981. * 1 = Middle Button.
  100982. * 2 = Right Button.
  100983. */
  100984. activeButton: number;
  100985. /**
  100986. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  100987. * Higher values reduce its sensitivity.
  100988. */
  100989. angularSensibility: number;
  100990. private _mousemoveCallback;
  100991. private _observer;
  100992. private _rollObserver;
  100993. private previousPosition;
  100994. private noPreventDefault;
  100995. private element;
  100996. /**
  100997. * Listen to mouse events to control the camera.
  100998. * @param touchEnabled Define if touch is enabled. (Default is true.)
  100999. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101000. */
  101001. constructor(touchEnabled?: boolean);
  101002. /**
  101003. * Attach the mouse control to the HTML DOM element.
  101004. * @param element Defines the element that listens to the input events.
  101005. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  101006. */
  101007. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101008. /**
  101009. * Detach the current controls from the specified dom element.
  101010. * @param element Defines the element to stop listening the inputs from
  101011. */
  101012. detachControl(element: Nullable<HTMLElement>): void;
  101013. /**
  101014. * Gets the class name of the current input.
  101015. * @returns the class name.
  101016. */
  101017. getClassName(): string;
  101018. /**
  101019. * Get the friendly name associated with the input class.
  101020. * @returns the input's friendly name.
  101021. */
  101022. getSimpleName(): string;
  101023. private _pointerInput;
  101024. private _onMouseMove;
  101025. /**
  101026. * Rotate camera by mouse offset.
  101027. */
  101028. private rotateCamera;
  101029. }
  101030. }
  101031. declare module BABYLON {
  101032. /**
  101033. * Default Inputs manager for the FlyCamera.
  101034. * It groups all the default supported inputs for ease of use.
  101035. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101036. */
  101037. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  101038. /**
  101039. * Instantiates a new FlyCameraInputsManager.
  101040. * @param camera Defines the camera the inputs belong to.
  101041. */
  101042. constructor(camera: FlyCamera);
  101043. /**
  101044. * Add keyboard input support to the input manager.
  101045. * @returns the new FlyCameraKeyboardMoveInput().
  101046. */
  101047. addKeyboard(): FlyCameraInputsManager;
  101048. /**
  101049. * Add mouse input support to the input manager.
  101050. * @param touchEnabled Enable touch screen support.
  101051. * @returns the new FlyCameraMouseInput().
  101052. */
  101053. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  101054. }
  101055. }
  101056. declare module BABYLON {
  101057. /**
  101058. * This is a flying camera, designed for 3D movement and rotation in all directions,
  101059. * such as in a 3D Space Shooter or a Flight Simulator.
  101060. */
  101061. export class FlyCamera extends TargetCamera {
  101062. /**
  101063. * Define the collision ellipsoid of the camera.
  101064. * This is helpful for simulating a camera body, like a player's body.
  101065. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  101066. */
  101067. ellipsoid: Vector3;
  101068. /**
  101069. * Define an offset for the position of the ellipsoid around the camera.
  101070. * This can be helpful if the camera is attached away from the player's body center,
  101071. * such as at its head.
  101072. */
  101073. ellipsoidOffset: Vector3;
  101074. /**
  101075. * Enable or disable collisions of the camera with the rest of the scene objects.
  101076. */
  101077. checkCollisions: boolean;
  101078. /**
  101079. * Enable or disable gravity on the camera.
  101080. */
  101081. applyGravity: boolean;
  101082. /**
  101083. * Define the current direction the camera is moving to.
  101084. */
  101085. cameraDirection: Vector3;
  101086. /**
  101087. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  101088. * This overrides and empties cameraRotation.
  101089. */
  101090. rotationQuaternion: Quaternion;
  101091. /**
  101092. * Track Roll to maintain the wanted Rolling when looking around.
  101093. */
  101094. _trackRoll: number;
  101095. /**
  101096. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  101097. */
  101098. rollCorrect: number;
  101099. /**
  101100. * Mimic a banked turn, Rolling the camera when Yawing.
  101101. * It's recommended to use rollCorrect = 10 for faster banking correction.
  101102. */
  101103. bankedTurn: boolean;
  101104. /**
  101105. * Limit in radians for how much Roll banking will add. (Default: 90°)
  101106. */
  101107. bankedTurnLimit: number;
  101108. /**
  101109. * Value of 0 disables the banked Roll.
  101110. * Value of 1 is equal to the Yaw angle in radians.
  101111. */
  101112. bankedTurnMultiplier: number;
  101113. /**
  101114. * The inputs manager loads all the input sources, such as keyboard and mouse.
  101115. */
  101116. inputs: FlyCameraInputsManager;
  101117. /**
  101118. * Gets the input sensibility for mouse input.
  101119. * Higher values reduce sensitivity.
  101120. */
  101121. /**
  101122. * Sets the input sensibility for a mouse input.
  101123. * Higher values reduce sensitivity.
  101124. */
  101125. angularSensibility: number;
  101126. /**
  101127. * Get the keys for camera movement forward.
  101128. */
  101129. /**
  101130. * Set the keys for camera movement forward.
  101131. */
  101132. keysForward: number[];
  101133. /**
  101134. * Get the keys for camera movement backward.
  101135. */
  101136. keysBackward: number[];
  101137. /**
  101138. * Get the keys for camera movement up.
  101139. */
  101140. /**
  101141. * Set the keys for camera movement up.
  101142. */
  101143. keysUp: number[];
  101144. /**
  101145. * Get the keys for camera movement down.
  101146. */
  101147. /**
  101148. * Set the keys for camera movement down.
  101149. */
  101150. keysDown: number[];
  101151. /**
  101152. * Get the keys for camera movement left.
  101153. */
  101154. /**
  101155. * Set the keys for camera movement left.
  101156. */
  101157. keysLeft: number[];
  101158. /**
  101159. * Set the keys for camera movement right.
  101160. */
  101161. /**
  101162. * Set the keys for camera movement right.
  101163. */
  101164. keysRight: number[];
  101165. /**
  101166. * Event raised when the camera collides with a mesh in the scene.
  101167. */
  101168. onCollide: (collidedMesh: AbstractMesh) => void;
  101169. private _collider;
  101170. private _needMoveForGravity;
  101171. private _oldPosition;
  101172. private _diffPosition;
  101173. private _newPosition;
  101174. /** @hidden */
  101175. _localDirection: Vector3;
  101176. /** @hidden */
  101177. _transformedDirection: Vector3;
  101178. /**
  101179. * Instantiates a FlyCamera.
  101180. * This is a flying camera, designed for 3D movement and rotation in all directions,
  101181. * such as in a 3D Space Shooter or a Flight Simulator.
  101182. * @param name Define the name of the camera in the scene.
  101183. * @param position Define the starting position of the camera in the scene.
  101184. * @param scene Define the scene the camera belongs to.
  101185. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  101186. */
  101187. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  101188. /**
  101189. * Attach a control to the HTML DOM element.
  101190. * @param element Defines the element that listens to the input events.
  101191. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  101192. */
  101193. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101194. /**
  101195. * Detach a control from the HTML DOM element.
  101196. * The camera will stop reacting to that input.
  101197. * @param element Defines the element that listens to the input events.
  101198. */
  101199. detachControl(element: HTMLElement): void;
  101200. private _collisionMask;
  101201. /**
  101202. * Get the mask that the camera ignores in collision events.
  101203. */
  101204. /**
  101205. * Set the mask that the camera ignores in collision events.
  101206. */
  101207. collisionMask: number;
  101208. /** @hidden */
  101209. _collideWithWorld(displacement: Vector3): void;
  101210. /** @hidden */
  101211. private _onCollisionPositionChange;
  101212. /** @hidden */
  101213. _checkInputs(): void;
  101214. /** @hidden */
  101215. _decideIfNeedsToMove(): boolean;
  101216. /** @hidden */
  101217. _updatePosition(): void;
  101218. /**
  101219. * Restore the Roll to its target value at the rate specified.
  101220. * @param rate - Higher means slower restoring.
  101221. * @hidden
  101222. */
  101223. restoreRoll(rate: number): void;
  101224. /**
  101225. * Destroy the camera and release the current resources held by it.
  101226. */
  101227. dispose(): void;
  101228. /**
  101229. * Get the current object class name.
  101230. * @returns the class name.
  101231. */
  101232. getClassName(): string;
  101233. }
  101234. }
  101235. declare module BABYLON {
  101236. /**
  101237. * Listen to keyboard events to control the camera.
  101238. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101239. */
  101240. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  101241. /**
  101242. * Defines the camera the input is attached to.
  101243. */
  101244. camera: FlyCamera;
  101245. /**
  101246. * The list of keyboard keys used to control the forward move of the camera.
  101247. */
  101248. keysForward: number[];
  101249. /**
  101250. * The list of keyboard keys used to control the backward move of the camera.
  101251. */
  101252. keysBackward: number[];
  101253. /**
  101254. * The list of keyboard keys used to control the forward move of the camera.
  101255. */
  101256. keysUp: number[];
  101257. /**
  101258. * The list of keyboard keys used to control the backward move of the camera.
  101259. */
  101260. keysDown: number[];
  101261. /**
  101262. * The list of keyboard keys used to control the right strafe move of the camera.
  101263. */
  101264. keysRight: number[];
  101265. /**
  101266. * The list of keyboard keys used to control the left strafe move of the camera.
  101267. */
  101268. keysLeft: number[];
  101269. private _keys;
  101270. private _onCanvasBlurObserver;
  101271. private _onKeyboardObserver;
  101272. private _engine;
  101273. private _scene;
  101274. /**
  101275. * Attach the input controls to a specific dom element to get the input from.
  101276. * @param element Defines the element the controls should be listened from
  101277. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101278. */
  101279. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101280. /**
  101281. * Detach the current controls from the specified dom element.
  101282. * @param element Defines the element to stop listening the inputs from
  101283. */
  101284. detachControl(element: Nullable<HTMLElement>): void;
  101285. /**
  101286. * Gets the class name of the current intput.
  101287. * @returns the class name
  101288. */
  101289. getClassName(): string;
  101290. /** @hidden */
  101291. _onLostFocus(e: FocusEvent): void;
  101292. /**
  101293. * Get the friendly name associated with the input class.
  101294. * @returns the input friendly name
  101295. */
  101296. getSimpleName(): string;
  101297. /**
  101298. * Update the current camera state depending on the inputs that have been used this frame.
  101299. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101300. */
  101301. checkInputs(): void;
  101302. }
  101303. }
  101304. declare module BABYLON {
  101305. /**
  101306. * Manage the mouse wheel inputs to control a follow camera.
  101307. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101308. */
  101309. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  101310. /**
  101311. * Defines the camera the input is attached to.
  101312. */
  101313. camera: FollowCamera;
  101314. /**
  101315. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  101316. */
  101317. axisControlRadius: boolean;
  101318. /**
  101319. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  101320. */
  101321. axisControlHeight: boolean;
  101322. /**
  101323. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  101324. */
  101325. axisControlRotation: boolean;
  101326. /**
  101327. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  101328. * relation to mouseWheel events.
  101329. */
  101330. wheelPrecision: number;
  101331. /**
  101332. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  101333. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  101334. */
  101335. wheelDeltaPercentage: number;
  101336. private _wheel;
  101337. private _observer;
  101338. /**
  101339. * Attach the input controls to a specific dom element to get the input from.
  101340. * @param element Defines the element the controls should be listened from
  101341. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101342. */
  101343. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101344. /**
  101345. * Detach the current controls from the specified dom element.
  101346. * @param element Defines the element to stop listening the inputs from
  101347. */
  101348. detachControl(element: Nullable<HTMLElement>): void;
  101349. /**
  101350. * Gets the class name of the current intput.
  101351. * @returns the class name
  101352. */
  101353. getClassName(): string;
  101354. /**
  101355. * Get the friendly name associated with the input class.
  101356. * @returns the input friendly name
  101357. */
  101358. getSimpleName(): string;
  101359. }
  101360. }
  101361. declare module BABYLON {
  101362. /**
  101363. * Manage the pointers inputs to control an follow camera.
  101364. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101365. */
  101366. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  101367. /**
  101368. * Defines the camera the input is attached to.
  101369. */
  101370. camera: FollowCamera;
  101371. /**
  101372. * Gets the class name of the current input.
  101373. * @returns the class name
  101374. */
  101375. getClassName(): string;
  101376. /**
  101377. * Defines the pointer angular sensibility along the X axis or how fast is
  101378. * the camera rotating.
  101379. * A negative number will reverse the axis direction.
  101380. */
  101381. angularSensibilityX: number;
  101382. /**
  101383. * Defines the pointer angular sensibility along the Y axis or how fast is
  101384. * the camera rotating.
  101385. * A negative number will reverse the axis direction.
  101386. */
  101387. angularSensibilityY: number;
  101388. /**
  101389. * Defines the pointer pinch precision or how fast is the camera zooming.
  101390. * A negative number will reverse the axis direction.
  101391. */
  101392. pinchPrecision: number;
  101393. /**
  101394. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  101395. * from 0.
  101396. * It defines the percentage of current camera.radius to use as delta when
  101397. * pinch zoom is used.
  101398. */
  101399. pinchDeltaPercentage: number;
  101400. /**
  101401. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  101402. */
  101403. axisXControlRadius: boolean;
  101404. /**
  101405. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  101406. */
  101407. axisXControlHeight: boolean;
  101408. /**
  101409. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  101410. */
  101411. axisXControlRotation: boolean;
  101412. /**
  101413. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  101414. */
  101415. axisYControlRadius: boolean;
  101416. /**
  101417. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  101418. */
  101419. axisYControlHeight: boolean;
  101420. /**
  101421. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  101422. */
  101423. axisYControlRotation: boolean;
  101424. /**
  101425. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  101426. */
  101427. axisPinchControlRadius: boolean;
  101428. /**
  101429. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  101430. */
  101431. axisPinchControlHeight: boolean;
  101432. /**
  101433. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  101434. */
  101435. axisPinchControlRotation: boolean;
  101436. /**
  101437. * Log error messages if basic misconfiguration has occurred.
  101438. */
  101439. warningEnable: boolean;
  101440. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101441. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101442. private _warningCounter;
  101443. private _warning;
  101444. }
  101445. }
  101446. declare module BABYLON {
  101447. /**
  101448. * Default Inputs manager for the FollowCamera.
  101449. * It groups all the default supported inputs for ease of use.
  101450. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101451. */
  101452. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  101453. /**
  101454. * Instantiates a new FollowCameraInputsManager.
  101455. * @param camera Defines the camera the inputs belong to
  101456. */
  101457. constructor(camera: FollowCamera);
  101458. /**
  101459. * Add keyboard input support to the input manager.
  101460. * @returns the current input manager
  101461. */
  101462. addKeyboard(): FollowCameraInputsManager;
  101463. /**
  101464. * Add mouse wheel input support to the input manager.
  101465. * @returns the current input manager
  101466. */
  101467. addMouseWheel(): FollowCameraInputsManager;
  101468. /**
  101469. * Add pointers input support to the input manager.
  101470. * @returns the current input manager
  101471. */
  101472. addPointers(): FollowCameraInputsManager;
  101473. /**
  101474. * Add orientation input support to the input manager.
  101475. * @returns the current input manager
  101476. */
  101477. addVRDeviceOrientation(): FollowCameraInputsManager;
  101478. }
  101479. }
  101480. declare module BABYLON {
  101481. /**
  101482. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  101483. * an arc rotate version arcFollowCamera are available.
  101484. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101485. */
  101486. export class FollowCamera extends TargetCamera {
  101487. /**
  101488. * Distance the follow camera should follow an object at
  101489. */
  101490. radius: number;
  101491. /**
  101492. * Minimum allowed distance of the camera to the axis of rotation
  101493. * (The camera can not get closer).
  101494. * This can help limiting how the Camera is able to move in the scene.
  101495. */
  101496. lowerRadiusLimit: Nullable<number>;
  101497. /**
  101498. * Maximum allowed distance of the camera to the axis of rotation
  101499. * (The camera can not get further).
  101500. * This can help limiting how the Camera is able to move in the scene.
  101501. */
  101502. upperRadiusLimit: Nullable<number>;
  101503. /**
  101504. * Define a rotation offset between the camera and the object it follows
  101505. */
  101506. rotationOffset: number;
  101507. /**
  101508. * Minimum allowed angle to camera position relative to target object.
  101509. * This can help limiting how the Camera is able to move in the scene.
  101510. */
  101511. lowerRotationOffsetLimit: Nullable<number>;
  101512. /**
  101513. * Maximum allowed angle to camera position relative to target object.
  101514. * This can help limiting how the Camera is able to move in the scene.
  101515. */
  101516. upperRotationOffsetLimit: Nullable<number>;
  101517. /**
  101518. * Define a height offset between the camera and the object it follows.
  101519. * It can help following an object from the top (like a car chaing a plane)
  101520. */
  101521. heightOffset: number;
  101522. /**
  101523. * Minimum allowed height of camera position relative to target object.
  101524. * This can help limiting how the Camera is able to move in the scene.
  101525. */
  101526. lowerHeightOffsetLimit: Nullable<number>;
  101527. /**
  101528. * Maximum allowed height of camera position relative to target object.
  101529. * This can help limiting how the Camera is able to move in the scene.
  101530. */
  101531. upperHeightOffsetLimit: Nullable<number>;
  101532. /**
  101533. * Define how fast the camera can accelerate to follow it s target.
  101534. */
  101535. cameraAcceleration: number;
  101536. /**
  101537. * Define the speed limit of the camera following an object.
  101538. */
  101539. maxCameraSpeed: number;
  101540. /**
  101541. * Define the target of the camera.
  101542. */
  101543. lockedTarget: Nullable<AbstractMesh>;
  101544. /**
  101545. * Defines the input associated with the camera.
  101546. */
  101547. inputs: FollowCameraInputsManager;
  101548. /**
  101549. * Instantiates the follow camera.
  101550. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101551. * @param name Define the name of the camera in the scene
  101552. * @param position Define the position of the camera
  101553. * @param scene Define the scene the camera belong to
  101554. * @param lockedTarget Define the target of the camera
  101555. */
  101556. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  101557. private _follow;
  101558. /**
  101559. * Attached controls to the current camera.
  101560. * @param element Defines the element the controls should be listened from
  101561. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101562. */
  101563. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101564. /**
  101565. * Detach the current controls from the camera.
  101566. * The camera will stop reacting to inputs.
  101567. * @param element Defines the element to stop listening the inputs from
  101568. */
  101569. detachControl(element: HTMLElement): void;
  101570. /** @hidden */
  101571. _checkInputs(): void;
  101572. private _checkLimits;
  101573. /**
  101574. * Gets the camera class name.
  101575. * @returns the class name
  101576. */
  101577. getClassName(): string;
  101578. }
  101579. /**
  101580. * Arc Rotate version of the follow camera.
  101581. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  101582. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101583. */
  101584. export class ArcFollowCamera extends TargetCamera {
  101585. /** The longitudinal angle of the camera */
  101586. alpha: number;
  101587. /** The latitudinal angle of the camera */
  101588. beta: number;
  101589. /** The radius of the camera from its target */
  101590. radius: number;
  101591. /** Define the camera target (the messh it should follow) */
  101592. target: Nullable<AbstractMesh>;
  101593. private _cartesianCoordinates;
  101594. /**
  101595. * Instantiates a new ArcFollowCamera
  101596. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101597. * @param name Define the name of the camera
  101598. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  101599. * @param beta Define the rotation angle of the camera around the elevation axis
  101600. * @param radius Define the radius of the camera from its target point
  101601. * @param target Define the target of the camera
  101602. * @param scene Define the scene the camera belongs to
  101603. */
  101604. constructor(name: string,
  101605. /** The longitudinal angle of the camera */
  101606. alpha: number,
  101607. /** The latitudinal angle of the camera */
  101608. beta: number,
  101609. /** The radius of the camera from its target */
  101610. radius: number,
  101611. /** Define the camera target (the messh it should follow) */
  101612. target: Nullable<AbstractMesh>, scene: Scene);
  101613. private _follow;
  101614. /** @hidden */
  101615. _checkInputs(): void;
  101616. /**
  101617. * Returns the class name of the object.
  101618. * It is mostly used internally for serialization purposes.
  101619. */
  101620. getClassName(): string;
  101621. }
  101622. }
  101623. declare module BABYLON {
  101624. /**
  101625. * Manage the keyboard inputs to control the movement of a follow camera.
  101626. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101627. */
  101628. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  101629. /**
  101630. * Defines the camera the input is attached to.
  101631. */
  101632. camera: FollowCamera;
  101633. /**
  101634. * Defines the list of key codes associated with the up action (increase heightOffset)
  101635. */
  101636. keysHeightOffsetIncr: number[];
  101637. /**
  101638. * Defines the list of key codes associated with the down action (decrease heightOffset)
  101639. */
  101640. keysHeightOffsetDecr: number[];
  101641. /**
  101642. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  101643. */
  101644. keysHeightOffsetModifierAlt: boolean;
  101645. /**
  101646. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  101647. */
  101648. keysHeightOffsetModifierCtrl: boolean;
  101649. /**
  101650. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  101651. */
  101652. keysHeightOffsetModifierShift: boolean;
  101653. /**
  101654. * Defines the list of key codes associated with the left action (increase rotationOffset)
  101655. */
  101656. keysRotationOffsetIncr: number[];
  101657. /**
  101658. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  101659. */
  101660. keysRotationOffsetDecr: number[];
  101661. /**
  101662. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  101663. */
  101664. keysRotationOffsetModifierAlt: boolean;
  101665. /**
  101666. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  101667. */
  101668. keysRotationOffsetModifierCtrl: boolean;
  101669. /**
  101670. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  101671. */
  101672. keysRotationOffsetModifierShift: boolean;
  101673. /**
  101674. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  101675. */
  101676. keysRadiusIncr: number[];
  101677. /**
  101678. * Defines the list of key codes associated with the zoom-out action (increase radius)
  101679. */
  101680. keysRadiusDecr: number[];
  101681. /**
  101682. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  101683. */
  101684. keysRadiusModifierAlt: boolean;
  101685. /**
  101686. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  101687. */
  101688. keysRadiusModifierCtrl: boolean;
  101689. /**
  101690. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  101691. */
  101692. keysRadiusModifierShift: boolean;
  101693. /**
  101694. * Defines the rate of change of heightOffset.
  101695. */
  101696. heightSensibility: number;
  101697. /**
  101698. * Defines the rate of change of rotationOffset.
  101699. */
  101700. rotationSensibility: number;
  101701. /**
  101702. * Defines the rate of change of radius.
  101703. */
  101704. radiusSensibility: number;
  101705. private _keys;
  101706. private _ctrlPressed;
  101707. private _altPressed;
  101708. private _shiftPressed;
  101709. private _onCanvasBlurObserver;
  101710. private _onKeyboardObserver;
  101711. private _engine;
  101712. private _scene;
  101713. /**
  101714. * Attach the input controls to a specific dom element to get the input from.
  101715. * @param element Defines the element the controls should be listened from
  101716. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101717. */
  101718. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101719. /**
  101720. * Detach the current controls from the specified dom element.
  101721. * @param element Defines the element to stop listening the inputs from
  101722. */
  101723. detachControl(element: Nullable<HTMLElement>): void;
  101724. /**
  101725. * Update the current camera state depending on the inputs that have been used this frame.
  101726. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101727. */
  101728. checkInputs(): void;
  101729. /**
  101730. * Gets the class name of the current input.
  101731. * @returns the class name
  101732. */
  101733. getClassName(): string;
  101734. /**
  101735. * Get the friendly name associated with the input class.
  101736. * @returns the input friendly name
  101737. */
  101738. getSimpleName(): string;
  101739. /**
  101740. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  101741. * allow modification of the heightOffset value.
  101742. */
  101743. private _modifierHeightOffset;
  101744. /**
  101745. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  101746. * allow modification of the rotationOffset value.
  101747. */
  101748. private _modifierRotationOffset;
  101749. /**
  101750. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  101751. * allow modification of the radius value.
  101752. */
  101753. private _modifierRadius;
  101754. }
  101755. }
  101756. declare module BABYLON {
  101757. interface FreeCameraInputsManager {
  101758. /**
  101759. * @hidden
  101760. */
  101761. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  101762. /**
  101763. * Add orientation input support to the input manager.
  101764. * @returns the current input manager
  101765. */
  101766. addDeviceOrientation(): FreeCameraInputsManager;
  101767. }
  101768. /**
  101769. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  101770. * Screen rotation is taken into account.
  101771. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101772. */
  101773. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  101774. private _camera;
  101775. private _screenOrientationAngle;
  101776. private _constantTranform;
  101777. private _screenQuaternion;
  101778. private _alpha;
  101779. private _beta;
  101780. private _gamma;
  101781. /**
  101782. * Can be used to detect if a device orientation sensor is availible on a device
  101783. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  101784. * @returns a promise that will resolve on orientation change
  101785. */
  101786. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  101787. /**
  101788. * @hidden
  101789. */
  101790. _onDeviceOrientationChangedObservable: Observable<void>;
  101791. /**
  101792. * Instantiates a new input
  101793. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101794. */
  101795. constructor();
  101796. /**
  101797. * Define the camera controlled by the input.
  101798. */
  101799. camera: FreeCamera;
  101800. /**
  101801. * Attach the input controls to a specific dom element to get the input from.
  101802. * @param element Defines the element the controls should be listened from
  101803. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101804. */
  101805. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101806. private _orientationChanged;
  101807. private _deviceOrientation;
  101808. /**
  101809. * Detach the current controls from the specified dom element.
  101810. * @param element Defines the element to stop listening the inputs from
  101811. */
  101812. detachControl(element: Nullable<HTMLElement>): void;
  101813. /**
  101814. * Update the current camera state depending on the inputs that have been used this frame.
  101815. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101816. */
  101817. checkInputs(): void;
  101818. /**
  101819. * Gets the class name of the current intput.
  101820. * @returns the class name
  101821. */
  101822. getClassName(): string;
  101823. /**
  101824. * Get the friendly name associated with the input class.
  101825. * @returns the input friendly name
  101826. */
  101827. getSimpleName(): string;
  101828. }
  101829. }
  101830. declare module BABYLON {
  101831. /**
  101832. * Manage the gamepad inputs to control a free camera.
  101833. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101834. */
  101835. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  101836. /**
  101837. * Define the camera the input is attached to.
  101838. */
  101839. camera: FreeCamera;
  101840. /**
  101841. * Define the Gamepad controlling the input
  101842. */
  101843. gamepad: Nullable<Gamepad>;
  101844. /**
  101845. * Defines the gamepad rotation sensiblity.
  101846. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  101847. */
  101848. gamepadAngularSensibility: number;
  101849. /**
  101850. * Defines the gamepad move sensiblity.
  101851. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  101852. */
  101853. gamepadMoveSensibility: number;
  101854. private _onGamepadConnectedObserver;
  101855. private _onGamepadDisconnectedObserver;
  101856. private _cameraTransform;
  101857. private _deltaTransform;
  101858. private _vector3;
  101859. private _vector2;
  101860. /**
  101861. * Attach the input controls to a specific dom element to get the input from.
  101862. * @param element Defines the element the controls should be listened from
  101863. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101864. */
  101865. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101866. /**
  101867. * Detach the current controls from the specified dom element.
  101868. * @param element Defines the element to stop listening the inputs from
  101869. */
  101870. detachControl(element: Nullable<HTMLElement>): void;
  101871. /**
  101872. * Update the current camera state depending on the inputs that have been used this frame.
  101873. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101874. */
  101875. checkInputs(): void;
  101876. /**
  101877. * Gets the class name of the current intput.
  101878. * @returns the class name
  101879. */
  101880. getClassName(): string;
  101881. /**
  101882. * Get the friendly name associated with the input class.
  101883. * @returns the input friendly name
  101884. */
  101885. getSimpleName(): string;
  101886. }
  101887. }
  101888. declare module BABYLON {
  101889. /**
  101890. * Defines the potential axis of a Joystick
  101891. */
  101892. export enum JoystickAxis {
  101893. /** X axis */
  101894. X = 0,
  101895. /** Y axis */
  101896. Y = 1,
  101897. /** Z axis */
  101898. Z = 2
  101899. }
  101900. /**
  101901. * Class used to define virtual joystick (used in touch mode)
  101902. */
  101903. export class VirtualJoystick {
  101904. /**
  101905. * Gets or sets a boolean indicating that left and right values must be inverted
  101906. */
  101907. reverseLeftRight: boolean;
  101908. /**
  101909. * Gets or sets a boolean indicating that up and down values must be inverted
  101910. */
  101911. reverseUpDown: boolean;
  101912. /**
  101913. * Gets the offset value for the position (ie. the change of the position value)
  101914. */
  101915. deltaPosition: Vector3;
  101916. /**
  101917. * Gets a boolean indicating if the virtual joystick was pressed
  101918. */
  101919. pressed: boolean;
  101920. /**
  101921. * Canvas the virtual joystick will render onto, default z-index of this is 5
  101922. */
  101923. static Canvas: Nullable<HTMLCanvasElement>;
  101924. private static _globalJoystickIndex;
  101925. private static vjCanvasContext;
  101926. private static vjCanvasWidth;
  101927. private static vjCanvasHeight;
  101928. private static halfWidth;
  101929. private _action;
  101930. private _axisTargetedByLeftAndRight;
  101931. private _axisTargetedByUpAndDown;
  101932. private _joystickSensibility;
  101933. private _inversedSensibility;
  101934. private _joystickPointerID;
  101935. private _joystickColor;
  101936. private _joystickPointerPos;
  101937. private _joystickPreviousPointerPos;
  101938. private _joystickPointerStartPos;
  101939. private _deltaJoystickVector;
  101940. private _leftJoystick;
  101941. private _touches;
  101942. private _onPointerDownHandlerRef;
  101943. private _onPointerMoveHandlerRef;
  101944. private _onPointerUpHandlerRef;
  101945. private _onResize;
  101946. /**
  101947. * Creates a new virtual joystick
  101948. * @param leftJoystick defines that the joystick is for left hand (false by default)
  101949. */
  101950. constructor(leftJoystick?: boolean);
  101951. /**
  101952. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  101953. * @param newJoystickSensibility defines the new sensibility
  101954. */
  101955. setJoystickSensibility(newJoystickSensibility: number): void;
  101956. private _onPointerDown;
  101957. private _onPointerMove;
  101958. private _onPointerUp;
  101959. /**
  101960. * Change the color of the virtual joystick
  101961. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  101962. */
  101963. setJoystickColor(newColor: string): void;
  101964. /**
  101965. * Defines a callback to call when the joystick is touched
  101966. * @param action defines the callback
  101967. */
  101968. setActionOnTouch(action: () => any): void;
  101969. /**
  101970. * Defines which axis you'd like to control for left & right
  101971. * @param axis defines the axis to use
  101972. */
  101973. setAxisForLeftRight(axis: JoystickAxis): void;
  101974. /**
  101975. * Defines which axis you'd like to control for up & down
  101976. * @param axis defines the axis to use
  101977. */
  101978. setAxisForUpDown(axis: JoystickAxis): void;
  101979. private _drawVirtualJoystick;
  101980. /**
  101981. * Release internal HTML canvas
  101982. */
  101983. releaseCanvas(): void;
  101984. }
  101985. }
  101986. declare module BABYLON {
  101987. interface FreeCameraInputsManager {
  101988. /**
  101989. * Add virtual joystick input support to the input manager.
  101990. * @returns the current input manager
  101991. */
  101992. addVirtualJoystick(): FreeCameraInputsManager;
  101993. }
  101994. /**
  101995. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  101996. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101997. */
  101998. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  101999. /**
  102000. * Defines the camera the input is attached to.
  102001. */
  102002. camera: FreeCamera;
  102003. private _leftjoystick;
  102004. private _rightjoystick;
  102005. /**
  102006. * Gets the left stick of the virtual joystick.
  102007. * @returns The virtual Joystick
  102008. */
  102009. getLeftJoystick(): VirtualJoystick;
  102010. /**
  102011. * Gets the right stick of the virtual joystick.
  102012. * @returns The virtual Joystick
  102013. */
  102014. getRightJoystick(): VirtualJoystick;
  102015. /**
  102016. * Update the current camera state depending on the inputs that have been used this frame.
  102017. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102018. */
  102019. checkInputs(): void;
  102020. /**
  102021. * Attach the input controls to a specific dom element to get the input from.
  102022. * @param element Defines the element the controls should be listened from
  102023. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102024. */
  102025. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102026. /**
  102027. * Detach the current controls from the specified dom element.
  102028. * @param element Defines the element to stop listening the inputs from
  102029. */
  102030. detachControl(element: Nullable<HTMLElement>): void;
  102031. /**
  102032. * Gets the class name of the current intput.
  102033. * @returns the class name
  102034. */
  102035. getClassName(): string;
  102036. /**
  102037. * Get the friendly name associated with the input class.
  102038. * @returns the input friendly name
  102039. */
  102040. getSimpleName(): string;
  102041. }
  102042. }
  102043. declare module BABYLON {
  102044. /**
  102045. * This represents a FPS type of camera controlled by touch.
  102046. * This is like a universal camera minus the Gamepad controls.
  102047. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102048. */
  102049. export class TouchCamera extends FreeCamera {
  102050. /**
  102051. * Defines the touch sensibility for rotation.
  102052. * The higher the faster.
  102053. */
  102054. touchAngularSensibility: number;
  102055. /**
  102056. * Defines the touch sensibility for move.
  102057. * The higher the faster.
  102058. */
  102059. touchMoveSensibility: number;
  102060. /**
  102061. * Instantiates a new touch camera.
  102062. * This represents a FPS type of camera controlled by touch.
  102063. * This is like a universal camera minus the Gamepad controls.
  102064. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102065. * @param name Define the name of the camera in the scene
  102066. * @param position Define the start position of the camera in the scene
  102067. * @param scene Define the scene the camera belongs to
  102068. */
  102069. constructor(name: string, position: Vector3, scene: Scene);
  102070. /**
  102071. * Gets the current object class name.
  102072. * @return the class name
  102073. */
  102074. getClassName(): string;
  102075. /** @hidden */
  102076. _setupInputs(): void;
  102077. }
  102078. }
  102079. declare module BABYLON {
  102080. /**
  102081. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  102082. * being tilted forward or back and left or right.
  102083. */
  102084. export class DeviceOrientationCamera extends FreeCamera {
  102085. private _initialQuaternion;
  102086. private _quaternionCache;
  102087. private _tmpDragQuaternion;
  102088. /**
  102089. * Creates a new device orientation camera
  102090. * @param name The name of the camera
  102091. * @param position The start position camera
  102092. * @param scene The scene the camera belongs to
  102093. */
  102094. constructor(name: string, position: Vector3, scene: Scene);
  102095. /**
  102096. * @hidden
  102097. * Disabled pointer input on first orientation sensor update (Default: true)
  102098. */
  102099. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  102100. private _dragFactor;
  102101. /**
  102102. * Enabled turning on the y axis when the orientation sensor is active
  102103. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  102104. */
  102105. enableHorizontalDragging(dragFactor?: number): void;
  102106. /**
  102107. * Gets the current instance class name ("DeviceOrientationCamera").
  102108. * This helps avoiding instanceof at run time.
  102109. * @returns the class name
  102110. */
  102111. getClassName(): string;
  102112. /**
  102113. * @hidden
  102114. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  102115. */
  102116. _checkInputs(): void;
  102117. /**
  102118. * Reset the camera to its default orientation on the specified axis only.
  102119. * @param axis The axis to reset
  102120. */
  102121. resetToCurrentRotation(axis?: Axis): void;
  102122. }
  102123. }
  102124. declare module BABYLON {
  102125. /**
  102126. * Defines supported buttons for XBox360 compatible gamepads
  102127. */
  102128. export enum Xbox360Button {
  102129. /** A */
  102130. A = 0,
  102131. /** B */
  102132. B = 1,
  102133. /** X */
  102134. X = 2,
  102135. /** Y */
  102136. Y = 3,
  102137. /** Start */
  102138. Start = 4,
  102139. /** Back */
  102140. Back = 5,
  102141. /** Left button */
  102142. LB = 6,
  102143. /** Right button */
  102144. RB = 7,
  102145. /** Left stick */
  102146. LeftStick = 8,
  102147. /** Right stick */
  102148. RightStick = 9
  102149. }
  102150. /** Defines values for XBox360 DPad */
  102151. export enum Xbox360Dpad {
  102152. /** Up */
  102153. Up = 0,
  102154. /** Down */
  102155. Down = 1,
  102156. /** Left */
  102157. Left = 2,
  102158. /** Right */
  102159. Right = 3
  102160. }
  102161. /**
  102162. * Defines a XBox360 gamepad
  102163. */
  102164. export class Xbox360Pad extends Gamepad {
  102165. private _leftTrigger;
  102166. private _rightTrigger;
  102167. private _onlefttriggerchanged;
  102168. private _onrighttriggerchanged;
  102169. private _onbuttondown;
  102170. private _onbuttonup;
  102171. private _ondpaddown;
  102172. private _ondpadup;
  102173. /** Observable raised when a button is pressed */
  102174. onButtonDownObservable: Observable<Xbox360Button>;
  102175. /** Observable raised when a button is released */
  102176. onButtonUpObservable: Observable<Xbox360Button>;
  102177. /** Observable raised when a pad is pressed */
  102178. onPadDownObservable: Observable<Xbox360Dpad>;
  102179. /** Observable raised when a pad is released */
  102180. onPadUpObservable: Observable<Xbox360Dpad>;
  102181. private _buttonA;
  102182. private _buttonB;
  102183. private _buttonX;
  102184. private _buttonY;
  102185. private _buttonBack;
  102186. private _buttonStart;
  102187. private _buttonLB;
  102188. private _buttonRB;
  102189. private _buttonLeftStick;
  102190. private _buttonRightStick;
  102191. private _dPadUp;
  102192. private _dPadDown;
  102193. private _dPadLeft;
  102194. private _dPadRight;
  102195. private _isXboxOnePad;
  102196. /**
  102197. * Creates a new XBox360 gamepad object
  102198. * @param id defines the id of this gamepad
  102199. * @param index defines its index
  102200. * @param gamepad defines the internal HTML gamepad object
  102201. * @param xboxOne defines if it is a XBox One gamepad
  102202. */
  102203. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  102204. /**
  102205. * Defines the callback to call when left trigger is pressed
  102206. * @param callback defines the callback to use
  102207. */
  102208. onlefttriggerchanged(callback: (value: number) => void): void;
  102209. /**
  102210. * Defines the callback to call when right trigger is pressed
  102211. * @param callback defines the callback to use
  102212. */
  102213. onrighttriggerchanged(callback: (value: number) => void): void;
  102214. /**
  102215. * Gets the left trigger value
  102216. */
  102217. /**
  102218. * Sets the left trigger value
  102219. */
  102220. leftTrigger: number;
  102221. /**
  102222. * Gets the right trigger value
  102223. */
  102224. /**
  102225. * Sets the right trigger value
  102226. */
  102227. rightTrigger: number;
  102228. /**
  102229. * Defines the callback to call when a button is pressed
  102230. * @param callback defines the callback to use
  102231. */
  102232. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  102233. /**
  102234. * Defines the callback to call when a button is released
  102235. * @param callback defines the callback to use
  102236. */
  102237. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  102238. /**
  102239. * Defines the callback to call when a pad is pressed
  102240. * @param callback defines the callback to use
  102241. */
  102242. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  102243. /**
  102244. * Defines the callback to call when a pad is released
  102245. * @param callback defines the callback to use
  102246. */
  102247. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  102248. private _setButtonValue;
  102249. private _setDPadValue;
  102250. /**
  102251. * Gets the value of the `A` button
  102252. */
  102253. /**
  102254. * Sets the value of the `A` button
  102255. */
  102256. buttonA: number;
  102257. /**
  102258. * Gets the value of the `B` button
  102259. */
  102260. /**
  102261. * Sets the value of the `B` button
  102262. */
  102263. buttonB: number;
  102264. /**
  102265. * Gets the value of the `X` button
  102266. */
  102267. /**
  102268. * Sets the value of the `X` button
  102269. */
  102270. buttonX: number;
  102271. /**
  102272. * Gets the value of the `Y` button
  102273. */
  102274. /**
  102275. * Sets the value of the `Y` button
  102276. */
  102277. buttonY: number;
  102278. /**
  102279. * Gets the value of the `Start` button
  102280. */
  102281. /**
  102282. * Sets the value of the `Start` button
  102283. */
  102284. buttonStart: number;
  102285. /**
  102286. * Gets the value of the `Back` button
  102287. */
  102288. /**
  102289. * Sets the value of the `Back` button
  102290. */
  102291. buttonBack: number;
  102292. /**
  102293. * Gets the value of the `Left` button
  102294. */
  102295. /**
  102296. * Sets the value of the `Left` button
  102297. */
  102298. buttonLB: number;
  102299. /**
  102300. * Gets the value of the `Right` button
  102301. */
  102302. /**
  102303. * Sets the value of the `Right` button
  102304. */
  102305. buttonRB: number;
  102306. /**
  102307. * Gets the value of the Left joystick
  102308. */
  102309. /**
  102310. * Sets the value of the Left joystick
  102311. */
  102312. buttonLeftStick: number;
  102313. /**
  102314. * Gets the value of the Right joystick
  102315. */
  102316. /**
  102317. * Sets the value of the Right joystick
  102318. */
  102319. buttonRightStick: number;
  102320. /**
  102321. * Gets the value of D-pad up
  102322. */
  102323. /**
  102324. * Sets the value of D-pad up
  102325. */
  102326. dPadUp: number;
  102327. /**
  102328. * Gets the value of D-pad down
  102329. */
  102330. /**
  102331. * Sets the value of D-pad down
  102332. */
  102333. dPadDown: number;
  102334. /**
  102335. * Gets the value of D-pad left
  102336. */
  102337. /**
  102338. * Sets the value of D-pad left
  102339. */
  102340. dPadLeft: number;
  102341. /**
  102342. * Gets the value of D-pad right
  102343. */
  102344. /**
  102345. * Sets the value of D-pad right
  102346. */
  102347. dPadRight: number;
  102348. /**
  102349. * Force the gamepad to synchronize with device values
  102350. */
  102351. update(): void;
  102352. /**
  102353. * Disposes the gamepad
  102354. */
  102355. dispose(): void;
  102356. }
  102357. }
  102358. declare module BABYLON {
  102359. /**
  102360. * Manager for handling gamepads
  102361. */
  102362. export class GamepadManager {
  102363. private _scene?;
  102364. private _babylonGamepads;
  102365. private _oneGamepadConnected;
  102366. /** @hidden */
  102367. _isMonitoring: boolean;
  102368. private _gamepadEventSupported;
  102369. private _gamepadSupport;
  102370. /**
  102371. * observable to be triggered when the gamepad controller has been connected
  102372. */
  102373. onGamepadConnectedObservable: Observable<Gamepad>;
  102374. /**
  102375. * observable to be triggered when the gamepad controller has been disconnected
  102376. */
  102377. onGamepadDisconnectedObservable: Observable<Gamepad>;
  102378. private _onGamepadConnectedEvent;
  102379. private _onGamepadDisconnectedEvent;
  102380. /**
  102381. * Initializes the gamepad manager
  102382. * @param _scene BabylonJS scene
  102383. */
  102384. constructor(_scene?: Scene | undefined);
  102385. /**
  102386. * The gamepads in the game pad manager
  102387. */
  102388. readonly gamepads: Gamepad[];
  102389. /**
  102390. * Get the gamepad controllers based on type
  102391. * @param type The type of gamepad controller
  102392. * @returns Nullable gamepad
  102393. */
  102394. getGamepadByType(type?: number): Nullable<Gamepad>;
  102395. /**
  102396. * Disposes the gamepad manager
  102397. */
  102398. dispose(): void;
  102399. private _addNewGamepad;
  102400. private _startMonitoringGamepads;
  102401. private _stopMonitoringGamepads;
  102402. /** @hidden */
  102403. _checkGamepadsStatus(): void;
  102404. private _updateGamepadObjects;
  102405. }
  102406. }
  102407. declare module BABYLON {
  102408. interface Scene {
  102409. /** @hidden */
  102410. _gamepadManager: Nullable<GamepadManager>;
  102411. /**
  102412. * Gets the gamepad manager associated with the scene
  102413. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  102414. */
  102415. gamepadManager: GamepadManager;
  102416. }
  102417. /**
  102418. * Interface representing a free camera inputs manager
  102419. */
  102420. interface FreeCameraInputsManager {
  102421. /**
  102422. * Adds gamepad input support to the FreeCameraInputsManager.
  102423. * @returns the FreeCameraInputsManager
  102424. */
  102425. addGamepad(): FreeCameraInputsManager;
  102426. }
  102427. /**
  102428. * Interface representing an arc rotate camera inputs manager
  102429. */
  102430. interface ArcRotateCameraInputsManager {
  102431. /**
  102432. * Adds gamepad input support to the ArcRotateCamera InputManager.
  102433. * @returns the camera inputs manager
  102434. */
  102435. addGamepad(): ArcRotateCameraInputsManager;
  102436. }
  102437. /**
  102438. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  102439. */
  102440. export class GamepadSystemSceneComponent implements ISceneComponent {
  102441. /**
  102442. * The component name helpfull to identify the component in the list of scene components.
  102443. */
  102444. readonly name: string;
  102445. /**
  102446. * The scene the component belongs to.
  102447. */
  102448. scene: Scene;
  102449. /**
  102450. * Creates a new instance of the component for the given scene
  102451. * @param scene Defines the scene to register the component in
  102452. */
  102453. constructor(scene: Scene);
  102454. /**
  102455. * Registers the component in a given scene
  102456. */
  102457. register(): void;
  102458. /**
  102459. * Rebuilds the elements related to this component in case of
  102460. * context lost for instance.
  102461. */
  102462. rebuild(): void;
  102463. /**
  102464. * Disposes the component and the associated ressources
  102465. */
  102466. dispose(): void;
  102467. private _beforeCameraUpdate;
  102468. }
  102469. }
  102470. declare module BABYLON {
  102471. /**
  102472. * 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,
  102473. * which still works and will still be found in many Playgrounds.
  102474. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102475. */
  102476. export class UniversalCamera extends TouchCamera {
  102477. /**
  102478. * Defines the gamepad rotation sensiblity.
  102479. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  102480. */
  102481. gamepadAngularSensibility: number;
  102482. /**
  102483. * Defines the gamepad move sensiblity.
  102484. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  102485. */
  102486. gamepadMoveSensibility: number;
  102487. /**
  102488. * 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,
  102489. * which still works and will still be found in many Playgrounds.
  102490. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102491. * @param name Define the name of the camera in the scene
  102492. * @param position Define the start position of the camera in the scene
  102493. * @param scene Define the scene the camera belongs to
  102494. */
  102495. constructor(name: string, position: Vector3, scene: Scene);
  102496. /**
  102497. * Gets the current object class name.
  102498. * @return the class name
  102499. */
  102500. getClassName(): string;
  102501. }
  102502. }
  102503. declare module BABYLON {
  102504. /**
  102505. * This represents a FPS type of camera. This is only here for back compat purpose.
  102506. * Please use the UniversalCamera instead as both are identical.
  102507. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102508. */
  102509. export class GamepadCamera extends UniversalCamera {
  102510. /**
  102511. * Instantiates a new Gamepad Camera
  102512. * This represents a FPS type of camera. This is only here for back compat purpose.
  102513. * Please use the UniversalCamera instead as both are identical.
  102514. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102515. * @param name Define the name of the camera in the scene
  102516. * @param position Define the start position of the camera in the scene
  102517. * @param scene Define the scene the camera belongs to
  102518. */
  102519. constructor(name: string, position: Vector3, scene: Scene);
  102520. /**
  102521. * Gets the current object class name.
  102522. * @return the class name
  102523. */
  102524. getClassName(): string;
  102525. }
  102526. }
  102527. declare module BABYLON {
  102528. /** @hidden */
  102529. export var passPixelShader: {
  102530. name: string;
  102531. shader: string;
  102532. };
  102533. }
  102534. declare module BABYLON {
  102535. /** @hidden */
  102536. export var passCubePixelShader: {
  102537. name: string;
  102538. shader: string;
  102539. };
  102540. }
  102541. declare module BABYLON {
  102542. /**
  102543. * PassPostProcess which produces an output the same as it's input
  102544. */
  102545. export class PassPostProcess extends PostProcess {
  102546. /**
  102547. * Creates the PassPostProcess
  102548. * @param name The name of the effect.
  102549. * @param options The required width/height ratio to downsize to before computing the render pass.
  102550. * @param camera The camera to apply the render pass to.
  102551. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102552. * @param engine The engine which the post process will be applied. (default: current engine)
  102553. * @param reusable If the post process can be reused on the same frame. (default: false)
  102554. * @param textureType The type of texture to be used when performing the post processing.
  102555. * @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)
  102556. */
  102557. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  102558. }
  102559. /**
  102560. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  102561. */
  102562. export class PassCubePostProcess extends PostProcess {
  102563. private _face;
  102564. /**
  102565. * Gets or sets the cube face to display.
  102566. * * 0 is +X
  102567. * * 1 is -X
  102568. * * 2 is +Y
  102569. * * 3 is -Y
  102570. * * 4 is +Z
  102571. * * 5 is -Z
  102572. */
  102573. face: number;
  102574. /**
  102575. * Creates the PassCubePostProcess
  102576. * @param name The name of the effect.
  102577. * @param options The required width/height ratio to downsize to before computing the render pass.
  102578. * @param camera The camera to apply the render pass to.
  102579. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102580. * @param engine The engine which the post process will be applied. (default: current engine)
  102581. * @param reusable If the post process can be reused on the same frame. (default: false)
  102582. * @param textureType The type of texture to be used when performing the post processing.
  102583. * @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)
  102584. */
  102585. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  102586. }
  102587. }
  102588. declare module BABYLON {
  102589. /** @hidden */
  102590. export var anaglyphPixelShader: {
  102591. name: string;
  102592. shader: string;
  102593. };
  102594. }
  102595. declare module BABYLON {
  102596. /**
  102597. * Postprocess used to generate anaglyphic rendering
  102598. */
  102599. export class AnaglyphPostProcess extends PostProcess {
  102600. private _passedProcess;
  102601. /**
  102602. * Creates a new AnaglyphPostProcess
  102603. * @param name defines postprocess name
  102604. * @param options defines creation options or target ratio scale
  102605. * @param rigCameras defines cameras using this postprocess
  102606. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  102607. * @param engine defines hosting engine
  102608. * @param reusable defines if the postprocess will be reused multiple times per frame
  102609. */
  102610. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  102611. }
  102612. }
  102613. declare module BABYLON {
  102614. /**
  102615. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  102616. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  102617. */
  102618. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  102619. /**
  102620. * Creates a new AnaglyphArcRotateCamera
  102621. * @param name defines camera name
  102622. * @param alpha defines alpha angle (in radians)
  102623. * @param beta defines beta angle (in radians)
  102624. * @param radius defines radius
  102625. * @param target defines camera target
  102626. * @param interaxialDistance defines distance between each color axis
  102627. * @param scene defines the hosting scene
  102628. */
  102629. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  102630. /**
  102631. * Gets camera class name
  102632. * @returns AnaglyphArcRotateCamera
  102633. */
  102634. getClassName(): string;
  102635. }
  102636. }
  102637. declare module BABYLON {
  102638. /**
  102639. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  102640. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  102641. */
  102642. export class AnaglyphFreeCamera extends FreeCamera {
  102643. /**
  102644. * Creates a new AnaglyphFreeCamera
  102645. * @param name defines camera name
  102646. * @param position defines initial position
  102647. * @param interaxialDistance defines distance between each color axis
  102648. * @param scene defines the hosting scene
  102649. */
  102650. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  102651. /**
  102652. * Gets camera class name
  102653. * @returns AnaglyphFreeCamera
  102654. */
  102655. getClassName(): string;
  102656. }
  102657. }
  102658. declare module BABYLON {
  102659. /**
  102660. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  102661. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  102662. */
  102663. export class AnaglyphGamepadCamera extends GamepadCamera {
  102664. /**
  102665. * Creates a new AnaglyphGamepadCamera
  102666. * @param name defines camera name
  102667. * @param position defines initial position
  102668. * @param interaxialDistance defines distance between each color axis
  102669. * @param scene defines the hosting scene
  102670. */
  102671. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  102672. /**
  102673. * Gets camera class name
  102674. * @returns AnaglyphGamepadCamera
  102675. */
  102676. getClassName(): string;
  102677. }
  102678. }
  102679. declare module BABYLON {
  102680. /**
  102681. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  102682. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  102683. */
  102684. export class AnaglyphUniversalCamera extends UniversalCamera {
  102685. /**
  102686. * Creates a new AnaglyphUniversalCamera
  102687. * @param name defines camera name
  102688. * @param position defines initial position
  102689. * @param interaxialDistance defines distance between each color axis
  102690. * @param scene defines the hosting scene
  102691. */
  102692. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  102693. /**
  102694. * Gets camera class name
  102695. * @returns AnaglyphUniversalCamera
  102696. */
  102697. getClassName(): string;
  102698. }
  102699. }
  102700. declare module BABYLON {
  102701. /** @hidden */
  102702. export var stereoscopicInterlacePixelShader: {
  102703. name: string;
  102704. shader: string;
  102705. };
  102706. }
  102707. declare module BABYLON {
  102708. /**
  102709. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  102710. */
  102711. export class StereoscopicInterlacePostProcess extends PostProcess {
  102712. private _stepSize;
  102713. private _passedProcess;
  102714. /**
  102715. * Initializes a StereoscopicInterlacePostProcess
  102716. * @param name The name of the effect.
  102717. * @param rigCameras The rig cameras to be appled to the post process
  102718. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  102719. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102720. * @param engine The engine which the post process will be applied. (default: current engine)
  102721. * @param reusable If the post process can be reused on the same frame. (default: false)
  102722. */
  102723. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  102724. }
  102725. }
  102726. declare module BABYLON {
  102727. /**
  102728. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  102729. * @see http://doc.babylonjs.com/features/cameras
  102730. */
  102731. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  102732. /**
  102733. * Creates a new StereoscopicArcRotateCamera
  102734. * @param name defines camera name
  102735. * @param alpha defines alpha angle (in radians)
  102736. * @param beta defines beta angle (in radians)
  102737. * @param radius defines radius
  102738. * @param target defines camera target
  102739. * @param interaxialDistance defines distance between each color axis
  102740. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  102741. * @param scene defines the hosting scene
  102742. */
  102743. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  102744. /**
  102745. * Gets camera class name
  102746. * @returns StereoscopicArcRotateCamera
  102747. */
  102748. getClassName(): string;
  102749. }
  102750. }
  102751. declare module BABYLON {
  102752. /**
  102753. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  102754. * @see http://doc.babylonjs.com/features/cameras
  102755. */
  102756. export class StereoscopicFreeCamera extends FreeCamera {
  102757. /**
  102758. * Creates a new StereoscopicFreeCamera
  102759. * @param name defines camera name
  102760. * @param position defines initial position
  102761. * @param interaxialDistance defines distance between each color axis
  102762. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  102763. * @param scene defines the hosting scene
  102764. */
  102765. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  102766. /**
  102767. * Gets camera class name
  102768. * @returns StereoscopicFreeCamera
  102769. */
  102770. getClassName(): string;
  102771. }
  102772. }
  102773. declare module BABYLON {
  102774. /**
  102775. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  102776. * @see http://doc.babylonjs.com/features/cameras
  102777. */
  102778. export class StereoscopicGamepadCamera extends GamepadCamera {
  102779. /**
  102780. * Creates a new StereoscopicGamepadCamera
  102781. * @param name defines camera name
  102782. * @param position defines initial position
  102783. * @param interaxialDistance defines distance between each color axis
  102784. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  102785. * @param scene defines the hosting scene
  102786. */
  102787. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  102788. /**
  102789. * Gets camera class name
  102790. * @returns StereoscopicGamepadCamera
  102791. */
  102792. getClassName(): string;
  102793. }
  102794. }
  102795. declare module BABYLON {
  102796. /**
  102797. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  102798. * @see http://doc.babylonjs.com/features/cameras
  102799. */
  102800. export class StereoscopicUniversalCamera extends UniversalCamera {
  102801. /**
  102802. * Creates a new StereoscopicUniversalCamera
  102803. * @param name defines camera name
  102804. * @param position defines initial position
  102805. * @param interaxialDistance defines distance between each color axis
  102806. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  102807. * @param scene defines the hosting scene
  102808. */
  102809. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  102810. /**
  102811. * Gets camera class name
  102812. * @returns StereoscopicUniversalCamera
  102813. */
  102814. getClassName(): string;
  102815. }
  102816. }
  102817. declare module BABYLON {
  102818. /**
  102819. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  102820. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  102821. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  102822. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  102823. */
  102824. export class VirtualJoysticksCamera extends FreeCamera {
  102825. /**
  102826. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  102827. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  102828. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  102829. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  102830. * @param name Define the name of the camera in the scene
  102831. * @param position Define the start position of the camera in the scene
  102832. * @param scene Define the scene the camera belongs to
  102833. */
  102834. constructor(name: string, position: Vector3, scene: Scene);
  102835. /**
  102836. * Gets the current object class name.
  102837. * @return the class name
  102838. */
  102839. getClassName(): string;
  102840. }
  102841. }
  102842. declare module BABYLON {
  102843. /**
  102844. * This represents all the required metrics to create a VR camera.
  102845. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  102846. */
  102847. export class VRCameraMetrics {
  102848. /**
  102849. * Define the horizontal resolution off the screen.
  102850. */
  102851. hResolution: number;
  102852. /**
  102853. * Define the vertical resolution off the screen.
  102854. */
  102855. vResolution: number;
  102856. /**
  102857. * Define the horizontal screen size.
  102858. */
  102859. hScreenSize: number;
  102860. /**
  102861. * Define the vertical screen size.
  102862. */
  102863. vScreenSize: number;
  102864. /**
  102865. * Define the vertical screen center position.
  102866. */
  102867. vScreenCenter: number;
  102868. /**
  102869. * Define the distance of the eyes to the screen.
  102870. */
  102871. eyeToScreenDistance: number;
  102872. /**
  102873. * Define the distance between both lenses
  102874. */
  102875. lensSeparationDistance: number;
  102876. /**
  102877. * Define the distance between both viewer's eyes.
  102878. */
  102879. interpupillaryDistance: number;
  102880. /**
  102881. * Define the distortion factor of the VR postprocess.
  102882. * Please, touch with care.
  102883. */
  102884. distortionK: number[];
  102885. /**
  102886. * Define the chromatic aberration correction factors for the VR post process.
  102887. */
  102888. chromaAbCorrection: number[];
  102889. /**
  102890. * Define the scale factor of the post process.
  102891. * The smaller the better but the slower.
  102892. */
  102893. postProcessScaleFactor: number;
  102894. /**
  102895. * Define an offset for the lens center.
  102896. */
  102897. lensCenterOffset: number;
  102898. /**
  102899. * Define if the current vr camera should compensate the distortion of the lense or not.
  102900. */
  102901. compensateDistortion: boolean;
  102902. /**
  102903. * Defines if multiview should be enabled when rendering (Default: false)
  102904. */
  102905. multiviewEnabled: boolean;
  102906. /**
  102907. * Gets the rendering aspect ratio based on the provided resolutions.
  102908. */
  102909. readonly aspectRatio: number;
  102910. /**
  102911. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  102912. */
  102913. readonly aspectRatioFov: number;
  102914. /**
  102915. * @hidden
  102916. */
  102917. readonly leftHMatrix: Matrix;
  102918. /**
  102919. * @hidden
  102920. */
  102921. readonly rightHMatrix: Matrix;
  102922. /**
  102923. * @hidden
  102924. */
  102925. readonly leftPreViewMatrix: Matrix;
  102926. /**
  102927. * @hidden
  102928. */
  102929. readonly rightPreViewMatrix: Matrix;
  102930. /**
  102931. * Get the default VRMetrics based on the most generic setup.
  102932. * @returns the default vr metrics
  102933. */
  102934. static GetDefault(): VRCameraMetrics;
  102935. }
  102936. }
  102937. declare module BABYLON {
  102938. /** @hidden */
  102939. export var vrDistortionCorrectionPixelShader: {
  102940. name: string;
  102941. shader: string;
  102942. };
  102943. }
  102944. declare module BABYLON {
  102945. /**
  102946. * VRDistortionCorrectionPostProcess used for mobile VR
  102947. */
  102948. export class VRDistortionCorrectionPostProcess extends PostProcess {
  102949. private _isRightEye;
  102950. private _distortionFactors;
  102951. private _postProcessScaleFactor;
  102952. private _lensCenterOffset;
  102953. private _scaleIn;
  102954. private _scaleFactor;
  102955. private _lensCenter;
  102956. /**
  102957. * Initializes the VRDistortionCorrectionPostProcess
  102958. * @param name The name of the effect.
  102959. * @param camera The camera to apply the render pass to.
  102960. * @param isRightEye If this is for the right eye distortion
  102961. * @param vrMetrics All the required metrics for the VR camera
  102962. */
  102963. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  102964. }
  102965. }
  102966. declare module BABYLON {
  102967. /**
  102968. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  102969. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  102970. */
  102971. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  102972. /**
  102973. * Creates a new VRDeviceOrientationArcRotateCamera
  102974. * @param name defines camera name
  102975. * @param alpha defines the camera rotation along the logitudinal axis
  102976. * @param beta defines the camera rotation along the latitudinal axis
  102977. * @param radius defines the camera distance from its target
  102978. * @param target defines the camera target
  102979. * @param scene defines the scene the camera belongs to
  102980. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  102981. * @param vrCameraMetrics defines the vr metrics associated to the camera
  102982. */
  102983. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  102984. /**
  102985. * Gets camera class name
  102986. * @returns VRDeviceOrientationArcRotateCamera
  102987. */
  102988. getClassName(): string;
  102989. }
  102990. }
  102991. declare module BABYLON {
  102992. /**
  102993. * Camera used to simulate VR rendering (based on FreeCamera)
  102994. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  102995. */
  102996. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  102997. /**
  102998. * Creates a new VRDeviceOrientationFreeCamera
  102999. * @param name defines camera name
  103000. * @param position defines the start position of the camera
  103001. * @param scene defines the scene the camera belongs to
  103002. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  103003. * @param vrCameraMetrics defines the vr metrics associated to the camera
  103004. */
  103005. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  103006. /**
  103007. * Gets camera class name
  103008. * @returns VRDeviceOrientationFreeCamera
  103009. */
  103010. getClassName(): string;
  103011. }
  103012. }
  103013. declare module BABYLON {
  103014. /**
  103015. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  103016. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  103017. */
  103018. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  103019. /**
  103020. * Creates a new VRDeviceOrientationGamepadCamera
  103021. * @param name defines camera name
  103022. * @param position defines the start position of the camera
  103023. * @param scene defines the scene the camera belongs to
  103024. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  103025. * @param vrCameraMetrics defines the vr metrics associated to the camera
  103026. */
  103027. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  103028. /**
  103029. * Gets camera class name
  103030. * @returns VRDeviceOrientationGamepadCamera
  103031. */
  103032. getClassName(): string;
  103033. }
  103034. }
  103035. declare module BABYLON {
  103036. /**
  103037. * Base class of materials working in push mode in babylon JS
  103038. * @hidden
  103039. */
  103040. export class PushMaterial extends Material {
  103041. protected _activeEffect: Effect;
  103042. protected _normalMatrix: Matrix;
  103043. /**
  103044. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  103045. * This means that the material can keep using a previous shader while a new one is being compiled.
  103046. * This is mostly used when shader parallel compilation is supported (true by default)
  103047. */
  103048. allowShaderHotSwapping: boolean;
  103049. constructor(name: string, scene: Scene);
  103050. getEffect(): Effect;
  103051. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  103052. /**
  103053. * Binds the given world matrix to the active effect
  103054. *
  103055. * @param world the matrix to bind
  103056. */
  103057. bindOnlyWorldMatrix(world: Matrix): void;
  103058. /**
  103059. * Binds the given normal matrix to the active effect
  103060. *
  103061. * @param normalMatrix the matrix to bind
  103062. */
  103063. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  103064. bind(world: Matrix, mesh?: Mesh): void;
  103065. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  103066. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  103067. }
  103068. }
  103069. declare module BABYLON {
  103070. /**
  103071. * This groups all the flags used to control the materials channel.
  103072. */
  103073. export class MaterialFlags {
  103074. private static _DiffuseTextureEnabled;
  103075. /**
  103076. * Are diffuse textures enabled in the application.
  103077. */
  103078. static DiffuseTextureEnabled: boolean;
  103079. private static _AmbientTextureEnabled;
  103080. /**
  103081. * Are ambient textures enabled in the application.
  103082. */
  103083. static AmbientTextureEnabled: boolean;
  103084. private static _OpacityTextureEnabled;
  103085. /**
  103086. * Are opacity textures enabled in the application.
  103087. */
  103088. static OpacityTextureEnabled: boolean;
  103089. private static _ReflectionTextureEnabled;
  103090. /**
  103091. * Are reflection textures enabled in the application.
  103092. */
  103093. static ReflectionTextureEnabled: boolean;
  103094. private static _EmissiveTextureEnabled;
  103095. /**
  103096. * Are emissive textures enabled in the application.
  103097. */
  103098. static EmissiveTextureEnabled: boolean;
  103099. private static _SpecularTextureEnabled;
  103100. /**
  103101. * Are specular textures enabled in the application.
  103102. */
  103103. static SpecularTextureEnabled: boolean;
  103104. private static _BumpTextureEnabled;
  103105. /**
  103106. * Are bump textures enabled in the application.
  103107. */
  103108. static BumpTextureEnabled: boolean;
  103109. private static _LightmapTextureEnabled;
  103110. /**
  103111. * Are lightmap textures enabled in the application.
  103112. */
  103113. static LightmapTextureEnabled: boolean;
  103114. private static _RefractionTextureEnabled;
  103115. /**
  103116. * Are refraction textures enabled in the application.
  103117. */
  103118. static RefractionTextureEnabled: boolean;
  103119. private static _ColorGradingTextureEnabled;
  103120. /**
  103121. * Are color grading textures enabled in the application.
  103122. */
  103123. static ColorGradingTextureEnabled: boolean;
  103124. private static _FresnelEnabled;
  103125. /**
  103126. * Are fresnels enabled in the application.
  103127. */
  103128. static FresnelEnabled: boolean;
  103129. private static _ClearCoatTextureEnabled;
  103130. /**
  103131. * Are clear coat textures enabled in the application.
  103132. */
  103133. static ClearCoatTextureEnabled: boolean;
  103134. private static _ClearCoatBumpTextureEnabled;
  103135. /**
  103136. * Are clear coat bump textures enabled in the application.
  103137. */
  103138. static ClearCoatBumpTextureEnabled: boolean;
  103139. private static _ClearCoatTintTextureEnabled;
  103140. /**
  103141. * Are clear coat tint textures enabled in the application.
  103142. */
  103143. static ClearCoatTintTextureEnabled: boolean;
  103144. private static _SheenTextureEnabled;
  103145. /**
  103146. * Are sheen textures enabled in the application.
  103147. */
  103148. static SheenTextureEnabled: boolean;
  103149. private static _AnisotropicTextureEnabled;
  103150. /**
  103151. * Are anisotropic textures enabled in the application.
  103152. */
  103153. static AnisotropicTextureEnabled: boolean;
  103154. private static _ThicknessTextureEnabled;
  103155. /**
  103156. * Are thickness textures enabled in the application.
  103157. */
  103158. static ThicknessTextureEnabled: boolean;
  103159. }
  103160. }
  103161. declare module BABYLON {
  103162. /** @hidden */
  103163. export var defaultFragmentDeclaration: {
  103164. name: string;
  103165. shader: string;
  103166. };
  103167. }
  103168. declare module BABYLON {
  103169. /** @hidden */
  103170. export var defaultUboDeclaration: {
  103171. name: string;
  103172. shader: string;
  103173. };
  103174. }
  103175. declare module BABYLON {
  103176. /** @hidden */
  103177. export var lightFragmentDeclaration: {
  103178. name: string;
  103179. shader: string;
  103180. };
  103181. }
  103182. declare module BABYLON {
  103183. /** @hidden */
  103184. export var lightUboDeclaration: {
  103185. name: string;
  103186. shader: string;
  103187. };
  103188. }
  103189. declare module BABYLON {
  103190. /** @hidden */
  103191. export var lightsFragmentFunctions: {
  103192. name: string;
  103193. shader: string;
  103194. };
  103195. }
  103196. declare module BABYLON {
  103197. /** @hidden */
  103198. export var shadowsFragmentFunctions: {
  103199. name: string;
  103200. shader: string;
  103201. };
  103202. }
  103203. declare module BABYLON {
  103204. /** @hidden */
  103205. export var fresnelFunction: {
  103206. name: string;
  103207. shader: string;
  103208. };
  103209. }
  103210. declare module BABYLON {
  103211. /** @hidden */
  103212. export var reflectionFunction: {
  103213. name: string;
  103214. shader: string;
  103215. };
  103216. }
  103217. declare module BABYLON {
  103218. /** @hidden */
  103219. export var bumpFragmentFunctions: {
  103220. name: string;
  103221. shader: string;
  103222. };
  103223. }
  103224. declare module BABYLON {
  103225. /** @hidden */
  103226. export var logDepthDeclaration: {
  103227. name: string;
  103228. shader: string;
  103229. };
  103230. }
  103231. declare module BABYLON {
  103232. /** @hidden */
  103233. export var bumpFragment: {
  103234. name: string;
  103235. shader: string;
  103236. };
  103237. }
  103238. declare module BABYLON {
  103239. /** @hidden */
  103240. export var depthPrePass: {
  103241. name: string;
  103242. shader: string;
  103243. };
  103244. }
  103245. declare module BABYLON {
  103246. /** @hidden */
  103247. export var lightFragment: {
  103248. name: string;
  103249. shader: string;
  103250. };
  103251. }
  103252. declare module BABYLON {
  103253. /** @hidden */
  103254. export var logDepthFragment: {
  103255. name: string;
  103256. shader: string;
  103257. };
  103258. }
  103259. declare module BABYLON {
  103260. /** @hidden */
  103261. export var defaultPixelShader: {
  103262. name: string;
  103263. shader: string;
  103264. };
  103265. }
  103266. declare module BABYLON {
  103267. /** @hidden */
  103268. export var defaultVertexDeclaration: {
  103269. name: string;
  103270. shader: string;
  103271. };
  103272. }
  103273. declare module BABYLON {
  103274. /** @hidden */
  103275. export var bumpVertexDeclaration: {
  103276. name: string;
  103277. shader: string;
  103278. };
  103279. }
  103280. declare module BABYLON {
  103281. /** @hidden */
  103282. export var bumpVertex: {
  103283. name: string;
  103284. shader: string;
  103285. };
  103286. }
  103287. declare module BABYLON {
  103288. /** @hidden */
  103289. export var fogVertex: {
  103290. name: string;
  103291. shader: string;
  103292. };
  103293. }
  103294. declare module BABYLON {
  103295. /** @hidden */
  103296. export var shadowsVertex: {
  103297. name: string;
  103298. shader: string;
  103299. };
  103300. }
  103301. declare module BABYLON {
  103302. /** @hidden */
  103303. export var pointCloudVertex: {
  103304. name: string;
  103305. shader: string;
  103306. };
  103307. }
  103308. declare module BABYLON {
  103309. /** @hidden */
  103310. export var logDepthVertex: {
  103311. name: string;
  103312. shader: string;
  103313. };
  103314. }
  103315. declare module BABYLON {
  103316. /** @hidden */
  103317. export var defaultVertexShader: {
  103318. name: string;
  103319. shader: string;
  103320. };
  103321. }
  103322. declare module BABYLON {
  103323. /** @hidden */
  103324. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  103325. MAINUV1: boolean;
  103326. MAINUV2: boolean;
  103327. DIFFUSE: boolean;
  103328. DIFFUSEDIRECTUV: number;
  103329. AMBIENT: boolean;
  103330. AMBIENTDIRECTUV: number;
  103331. OPACITY: boolean;
  103332. OPACITYDIRECTUV: number;
  103333. OPACITYRGB: boolean;
  103334. REFLECTION: boolean;
  103335. EMISSIVE: boolean;
  103336. EMISSIVEDIRECTUV: number;
  103337. SPECULAR: boolean;
  103338. SPECULARDIRECTUV: number;
  103339. BUMP: boolean;
  103340. BUMPDIRECTUV: number;
  103341. PARALLAX: boolean;
  103342. PARALLAXOCCLUSION: boolean;
  103343. SPECULAROVERALPHA: boolean;
  103344. CLIPPLANE: boolean;
  103345. CLIPPLANE2: boolean;
  103346. CLIPPLANE3: boolean;
  103347. CLIPPLANE4: boolean;
  103348. ALPHATEST: boolean;
  103349. DEPTHPREPASS: boolean;
  103350. ALPHAFROMDIFFUSE: boolean;
  103351. POINTSIZE: boolean;
  103352. FOG: boolean;
  103353. SPECULARTERM: boolean;
  103354. DIFFUSEFRESNEL: boolean;
  103355. OPACITYFRESNEL: boolean;
  103356. REFLECTIONFRESNEL: boolean;
  103357. REFRACTIONFRESNEL: boolean;
  103358. EMISSIVEFRESNEL: boolean;
  103359. FRESNEL: boolean;
  103360. NORMAL: boolean;
  103361. UV1: boolean;
  103362. UV2: boolean;
  103363. VERTEXCOLOR: boolean;
  103364. VERTEXALPHA: boolean;
  103365. NUM_BONE_INFLUENCERS: number;
  103366. BonesPerMesh: number;
  103367. BONETEXTURE: boolean;
  103368. INSTANCES: boolean;
  103369. GLOSSINESS: boolean;
  103370. ROUGHNESS: boolean;
  103371. EMISSIVEASILLUMINATION: boolean;
  103372. LINKEMISSIVEWITHDIFFUSE: boolean;
  103373. REFLECTIONFRESNELFROMSPECULAR: boolean;
  103374. LIGHTMAP: boolean;
  103375. LIGHTMAPDIRECTUV: number;
  103376. OBJECTSPACE_NORMALMAP: boolean;
  103377. USELIGHTMAPASSHADOWMAP: boolean;
  103378. REFLECTIONMAP_3D: boolean;
  103379. REFLECTIONMAP_SPHERICAL: boolean;
  103380. REFLECTIONMAP_PLANAR: boolean;
  103381. REFLECTIONMAP_CUBIC: boolean;
  103382. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  103383. REFLECTIONMAP_PROJECTION: boolean;
  103384. REFLECTIONMAP_SKYBOX: boolean;
  103385. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  103386. REFLECTIONMAP_EXPLICIT: boolean;
  103387. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  103388. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  103389. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  103390. INVERTCUBICMAP: boolean;
  103391. LOGARITHMICDEPTH: boolean;
  103392. REFRACTION: boolean;
  103393. REFRACTIONMAP_3D: boolean;
  103394. REFLECTIONOVERALPHA: boolean;
  103395. TWOSIDEDLIGHTING: boolean;
  103396. SHADOWFLOAT: boolean;
  103397. MORPHTARGETS: boolean;
  103398. MORPHTARGETS_NORMAL: boolean;
  103399. MORPHTARGETS_TANGENT: boolean;
  103400. MORPHTARGETS_UV: boolean;
  103401. NUM_MORPH_INFLUENCERS: number;
  103402. NONUNIFORMSCALING: boolean;
  103403. PREMULTIPLYALPHA: boolean;
  103404. IMAGEPROCESSING: boolean;
  103405. VIGNETTE: boolean;
  103406. VIGNETTEBLENDMODEMULTIPLY: boolean;
  103407. VIGNETTEBLENDMODEOPAQUE: boolean;
  103408. TONEMAPPING: boolean;
  103409. TONEMAPPING_ACES: boolean;
  103410. CONTRAST: boolean;
  103411. COLORCURVES: boolean;
  103412. COLORGRADING: boolean;
  103413. COLORGRADING3D: boolean;
  103414. SAMPLER3DGREENDEPTH: boolean;
  103415. SAMPLER3DBGRMAP: boolean;
  103416. IMAGEPROCESSINGPOSTPROCESS: boolean;
  103417. MULTIVIEW: boolean;
  103418. /**
  103419. * If the reflection texture on this material is in linear color space
  103420. * @hidden
  103421. */
  103422. IS_REFLECTION_LINEAR: boolean;
  103423. /**
  103424. * If the refraction texture on this material is in linear color space
  103425. * @hidden
  103426. */
  103427. IS_REFRACTION_LINEAR: boolean;
  103428. EXPOSURE: boolean;
  103429. constructor();
  103430. setReflectionMode(modeToEnable: string): void;
  103431. }
  103432. /**
  103433. * This is the default material used in Babylon. It is the best trade off between quality
  103434. * and performances.
  103435. * @see http://doc.babylonjs.com/babylon101/materials
  103436. */
  103437. export class StandardMaterial extends PushMaterial {
  103438. private _diffuseTexture;
  103439. /**
  103440. * The basic texture of the material as viewed under a light.
  103441. */
  103442. diffuseTexture: Nullable<BaseTexture>;
  103443. private _ambientTexture;
  103444. /**
  103445. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  103446. */
  103447. ambientTexture: Nullable<BaseTexture>;
  103448. private _opacityTexture;
  103449. /**
  103450. * Define the transparency of the material from a texture.
  103451. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  103452. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  103453. */
  103454. opacityTexture: Nullable<BaseTexture>;
  103455. private _reflectionTexture;
  103456. /**
  103457. * Define the texture used to display the reflection.
  103458. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103459. */
  103460. reflectionTexture: Nullable<BaseTexture>;
  103461. private _emissiveTexture;
  103462. /**
  103463. * Define texture of the material as if self lit.
  103464. * This will be mixed in the final result even in the absence of light.
  103465. */
  103466. emissiveTexture: Nullable<BaseTexture>;
  103467. private _specularTexture;
  103468. /**
  103469. * Define how the color and intensity of the highlight given by the light in the material.
  103470. */
  103471. specularTexture: Nullable<BaseTexture>;
  103472. private _bumpTexture;
  103473. /**
  103474. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  103475. * 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.
  103476. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  103477. */
  103478. bumpTexture: Nullable<BaseTexture>;
  103479. private _lightmapTexture;
  103480. /**
  103481. * Complex lighting can be computationally expensive to compute at runtime.
  103482. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  103483. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  103484. */
  103485. lightmapTexture: Nullable<BaseTexture>;
  103486. private _refractionTexture;
  103487. /**
  103488. * Define the texture used to display the refraction.
  103489. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103490. */
  103491. refractionTexture: Nullable<BaseTexture>;
  103492. /**
  103493. * The color of the material lit by the environmental background lighting.
  103494. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  103495. */
  103496. ambientColor: Color3;
  103497. /**
  103498. * The basic color of the material as viewed under a light.
  103499. */
  103500. diffuseColor: Color3;
  103501. /**
  103502. * Define how the color and intensity of the highlight given by the light in the material.
  103503. */
  103504. specularColor: Color3;
  103505. /**
  103506. * Define the color of the material as if self lit.
  103507. * This will be mixed in the final result even in the absence of light.
  103508. */
  103509. emissiveColor: Color3;
  103510. /**
  103511. * Defines how sharp are the highlights in the material.
  103512. * The bigger the value the sharper giving a more glossy feeling to the result.
  103513. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  103514. */
  103515. specularPower: number;
  103516. private _useAlphaFromDiffuseTexture;
  103517. /**
  103518. * Does the transparency come from the diffuse texture alpha channel.
  103519. */
  103520. useAlphaFromDiffuseTexture: boolean;
  103521. private _useEmissiveAsIllumination;
  103522. /**
  103523. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  103524. */
  103525. useEmissiveAsIllumination: boolean;
  103526. private _linkEmissiveWithDiffuse;
  103527. /**
  103528. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  103529. * the emissive level when the final color is close to one.
  103530. */
  103531. linkEmissiveWithDiffuse: boolean;
  103532. private _useSpecularOverAlpha;
  103533. /**
  103534. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  103535. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  103536. */
  103537. useSpecularOverAlpha: boolean;
  103538. private _useReflectionOverAlpha;
  103539. /**
  103540. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  103541. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  103542. */
  103543. useReflectionOverAlpha: boolean;
  103544. private _disableLighting;
  103545. /**
  103546. * Does lights from the scene impacts this material.
  103547. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  103548. */
  103549. disableLighting: boolean;
  103550. private _useObjectSpaceNormalMap;
  103551. /**
  103552. * Allows using an object space normal map (instead of tangent space).
  103553. */
  103554. useObjectSpaceNormalMap: boolean;
  103555. private _useParallax;
  103556. /**
  103557. * Is parallax enabled or not.
  103558. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  103559. */
  103560. useParallax: boolean;
  103561. private _useParallaxOcclusion;
  103562. /**
  103563. * Is parallax occlusion enabled or not.
  103564. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  103565. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  103566. */
  103567. useParallaxOcclusion: boolean;
  103568. /**
  103569. * 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.
  103570. */
  103571. parallaxScaleBias: number;
  103572. private _roughness;
  103573. /**
  103574. * Helps to define how blurry the reflections should appears in the material.
  103575. */
  103576. roughness: number;
  103577. /**
  103578. * In case of refraction, define the value of the index of refraction.
  103579. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103580. */
  103581. indexOfRefraction: number;
  103582. /**
  103583. * Invert the refraction texture alongside the y axis.
  103584. * It can be useful with procedural textures or probe for instance.
  103585. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103586. */
  103587. invertRefractionY: boolean;
  103588. /**
  103589. * Defines the alpha limits in alpha test mode.
  103590. */
  103591. alphaCutOff: number;
  103592. private _useLightmapAsShadowmap;
  103593. /**
  103594. * In case of light mapping, define whether the map contains light or shadow informations.
  103595. */
  103596. useLightmapAsShadowmap: boolean;
  103597. private _diffuseFresnelParameters;
  103598. /**
  103599. * Define the diffuse fresnel parameters of the material.
  103600. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103601. */
  103602. diffuseFresnelParameters: FresnelParameters;
  103603. private _opacityFresnelParameters;
  103604. /**
  103605. * Define the opacity fresnel parameters of the material.
  103606. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103607. */
  103608. opacityFresnelParameters: FresnelParameters;
  103609. private _reflectionFresnelParameters;
  103610. /**
  103611. * Define the reflection fresnel parameters of the material.
  103612. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103613. */
  103614. reflectionFresnelParameters: FresnelParameters;
  103615. private _refractionFresnelParameters;
  103616. /**
  103617. * Define the refraction fresnel parameters of the material.
  103618. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103619. */
  103620. refractionFresnelParameters: FresnelParameters;
  103621. private _emissiveFresnelParameters;
  103622. /**
  103623. * Define the emissive fresnel parameters of the material.
  103624. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103625. */
  103626. emissiveFresnelParameters: FresnelParameters;
  103627. private _useReflectionFresnelFromSpecular;
  103628. /**
  103629. * If true automatically deducts the fresnels values from the material specularity.
  103630. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103631. */
  103632. useReflectionFresnelFromSpecular: boolean;
  103633. private _useGlossinessFromSpecularMapAlpha;
  103634. /**
  103635. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  103636. */
  103637. useGlossinessFromSpecularMapAlpha: boolean;
  103638. private _maxSimultaneousLights;
  103639. /**
  103640. * Defines the maximum number of lights that can be used in the material
  103641. */
  103642. maxSimultaneousLights: number;
  103643. private _invertNormalMapX;
  103644. /**
  103645. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  103646. */
  103647. invertNormalMapX: boolean;
  103648. private _invertNormalMapY;
  103649. /**
  103650. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  103651. */
  103652. invertNormalMapY: boolean;
  103653. private _twoSidedLighting;
  103654. /**
  103655. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  103656. */
  103657. twoSidedLighting: boolean;
  103658. /**
  103659. * Default configuration related to image processing available in the standard Material.
  103660. */
  103661. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103662. /**
  103663. * Gets the image processing configuration used either in this material.
  103664. */
  103665. /**
  103666. * Sets the Default image processing configuration used either in the this material.
  103667. *
  103668. * If sets to null, the scene one is in use.
  103669. */
  103670. imageProcessingConfiguration: ImageProcessingConfiguration;
  103671. /**
  103672. * Keep track of the image processing observer to allow dispose and replace.
  103673. */
  103674. private _imageProcessingObserver;
  103675. /**
  103676. * Attaches a new image processing configuration to the Standard Material.
  103677. * @param configuration
  103678. */
  103679. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103680. /**
  103681. * Gets wether the color curves effect is enabled.
  103682. */
  103683. /**
  103684. * Sets wether the color curves effect is enabled.
  103685. */
  103686. cameraColorCurvesEnabled: boolean;
  103687. /**
  103688. * Gets wether the color grading effect is enabled.
  103689. */
  103690. /**
  103691. * Gets wether the color grading effect is enabled.
  103692. */
  103693. cameraColorGradingEnabled: boolean;
  103694. /**
  103695. * Gets wether tonemapping is enabled or not.
  103696. */
  103697. /**
  103698. * Sets wether tonemapping is enabled or not
  103699. */
  103700. cameraToneMappingEnabled: boolean;
  103701. /**
  103702. * The camera exposure used on this material.
  103703. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103704. * This corresponds to a photographic exposure.
  103705. */
  103706. /**
  103707. * The camera exposure used on this material.
  103708. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103709. * This corresponds to a photographic exposure.
  103710. */
  103711. cameraExposure: number;
  103712. /**
  103713. * Gets The camera contrast used on this material.
  103714. */
  103715. /**
  103716. * Sets The camera contrast used on this material.
  103717. */
  103718. cameraContrast: number;
  103719. /**
  103720. * Gets the Color Grading 2D Lookup Texture.
  103721. */
  103722. /**
  103723. * Sets the Color Grading 2D Lookup Texture.
  103724. */
  103725. cameraColorGradingTexture: Nullable<BaseTexture>;
  103726. /**
  103727. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103728. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103729. * 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;
  103730. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103731. */
  103732. /**
  103733. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103734. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103735. * 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;
  103736. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103737. */
  103738. cameraColorCurves: Nullable<ColorCurves>;
  103739. /**
  103740. * Custom callback helping to override the default shader used in the material.
  103741. */
  103742. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  103743. protected _renderTargets: SmartArray<RenderTargetTexture>;
  103744. protected _worldViewProjectionMatrix: Matrix;
  103745. protected _globalAmbientColor: Color3;
  103746. protected _useLogarithmicDepth: boolean;
  103747. /**
  103748. * Instantiates a new standard material.
  103749. * This is the default material used in Babylon. It is the best trade off between quality
  103750. * and performances.
  103751. * @see http://doc.babylonjs.com/babylon101/materials
  103752. * @param name Define the name of the material in the scene
  103753. * @param scene Define the scene the material belong to
  103754. */
  103755. constructor(name: string, scene: Scene);
  103756. /**
  103757. * Gets a boolean indicating that current material needs to register RTT
  103758. */
  103759. readonly hasRenderTargetTextures: boolean;
  103760. /**
  103761. * Gets the current class name of the material e.g. "StandardMaterial"
  103762. * Mainly use in serialization.
  103763. * @returns the class name
  103764. */
  103765. getClassName(): string;
  103766. /**
  103767. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  103768. * You can try switching to logarithmic depth.
  103769. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  103770. */
  103771. useLogarithmicDepth: boolean;
  103772. /**
  103773. * Specifies if the material will require alpha blending
  103774. * @returns a boolean specifying if alpha blending is needed
  103775. */
  103776. needAlphaBlending(): boolean;
  103777. /**
  103778. * Specifies if this material should be rendered in alpha test mode
  103779. * @returns a boolean specifying if an alpha test is needed.
  103780. */
  103781. needAlphaTesting(): boolean;
  103782. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  103783. /**
  103784. * Get the texture used for alpha test purpose.
  103785. * @returns the diffuse texture in case of the standard material.
  103786. */
  103787. getAlphaTestTexture(): Nullable<BaseTexture>;
  103788. /**
  103789. * Get if the submesh is ready to be used and all its information available.
  103790. * Child classes can use it to update shaders
  103791. * @param mesh defines the mesh to check
  103792. * @param subMesh defines which submesh to check
  103793. * @param useInstances specifies that instances should be used
  103794. * @returns a boolean indicating that the submesh is ready or not
  103795. */
  103796. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103797. /**
  103798. * Builds the material UBO layouts.
  103799. * Used internally during the effect preparation.
  103800. */
  103801. buildUniformLayout(): void;
  103802. /**
  103803. * Unbinds the material from the mesh
  103804. */
  103805. unbind(): void;
  103806. /**
  103807. * Binds the submesh to this material by preparing the effect and shader to draw
  103808. * @param world defines the world transformation matrix
  103809. * @param mesh defines the mesh containing the submesh
  103810. * @param subMesh defines the submesh to bind the material to
  103811. */
  103812. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103813. /**
  103814. * Get the list of animatables in the material.
  103815. * @returns the list of animatables object used in the material
  103816. */
  103817. getAnimatables(): IAnimatable[];
  103818. /**
  103819. * Gets the active textures from the material
  103820. * @returns an array of textures
  103821. */
  103822. getActiveTextures(): BaseTexture[];
  103823. /**
  103824. * Specifies if the material uses a texture
  103825. * @param texture defines the texture to check against the material
  103826. * @returns a boolean specifying if the material uses the texture
  103827. */
  103828. hasTexture(texture: BaseTexture): boolean;
  103829. /**
  103830. * Disposes the material
  103831. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103832. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103833. */
  103834. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103835. /**
  103836. * Makes a duplicate of the material, and gives it a new name
  103837. * @param name defines the new name for the duplicated material
  103838. * @returns the cloned material
  103839. */
  103840. clone(name: string): StandardMaterial;
  103841. /**
  103842. * Serializes this material in a JSON representation
  103843. * @returns the serialized material object
  103844. */
  103845. serialize(): any;
  103846. /**
  103847. * Creates a standard material from parsed material data
  103848. * @param source defines the JSON representation of the material
  103849. * @param scene defines the hosting scene
  103850. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103851. * @returns a new standard material
  103852. */
  103853. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  103854. /**
  103855. * Are diffuse textures enabled in the application.
  103856. */
  103857. static DiffuseTextureEnabled: boolean;
  103858. /**
  103859. * Are ambient textures enabled in the application.
  103860. */
  103861. static AmbientTextureEnabled: boolean;
  103862. /**
  103863. * Are opacity textures enabled in the application.
  103864. */
  103865. static OpacityTextureEnabled: boolean;
  103866. /**
  103867. * Are reflection textures enabled in the application.
  103868. */
  103869. static ReflectionTextureEnabled: boolean;
  103870. /**
  103871. * Are emissive textures enabled in the application.
  103872. */
  103873. static EmissiveTextureEnabled: boolean;
  103874. /**
  103875. * Are specular textures enabled in the application.
  103876. */
  103877. static SpecularTextureEnabled: boolean;
  103878. /**
  103879. * Are bump textures enabled in the application.
  103880. */
  103881. static BumpTextureEnabled: boolean;
  103882. /**
  103883. * Are lightmap textures enabled in the application.
  103884. */
  103885. static LightmapTextureEnabled: boolean;
  103886. /**
  103887. * Are refraction textures enabled in the application.
  103888. */
  103889. static RefractionTextureEnabled: boolean;
  103890. /**
  103891. * Are color grading textures enabled in the application.
  103892. */
  103893. static ColorGradingTextureEnabled: boolean;
  103894. /**
  103895. * Are fresnels enabled in the application.
  103896. */
  103897. static FresnelEnabled: boolean;
  103898. }
  103899. }
  103900. declare module BABYLON {
  103901. /**
  103902. * A class extending Texture allowing drawing on a texture
  103903. * @see http://doc.babylonjs.com/how_to/dynamictexture
  103904. */
  103905. export class DynamicTexture extends Texture {
  103906. private _generateMipMaps;
  103907. private _canvas;
  103908. private _context;
  103909. private _engine;
  103910. /**
  103911. * Creates a DynamicTexture
  103912. * @param name defines the name of the texture
  103913. * @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
  103914. * @param scene defines the scene where you want the texture
  103915. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  103916. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  103917. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  103918. */
  103919. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  103920. /**
  103921. * Get the current class name of the texture useful for serialization or dynamic coding.
  103922. * @returns "DynamicTexture"
  103923. */
  103924. getClassName(): string;
  103925. /**
  103926. * Gets the current state of canRescale
  103927. */
  103928. readonly canRescale: boolean;
  103929. private _recreate;
  103930. /**
  103931. * Scales the texture
  103932. * @param ratio the scale factor to apply to both width and height
  103933. */
  103934. scale(ratio: number): void;
  103935. /**
  103936. * Resizes the texture
  103937. * @param width the new width
  103938. * @param height the new height
  103939. */
  103940. scaleTo(width: number, height: number): void;
  103941. /**
  103942. * Gets the context of the canvas used by the texture
  103943. * @returns the canvas context of the dynamic texture
  103944. */
  103945. getContext(): CanvasRenderingContext2D;
  103946. /**
  103947. * Clears the texture
  103948. */
  103949. clear(): void;
  103950. /**
  103951. * Updates the texture
  103952. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  103953. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  103954. */
  103955. update(invertY?: boolean, premulAlpha?: boolean): void;
  103956. /**
  103957. * Draws text onto the texture
  103958. * @param text defines the text to be drawn
  103959. * @param x defines the placement of the text from the left
  103960. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  103961. * @param font defines the font to be used with font-style, font-size, font-name
  103962. * @param color defines the color used for the text
  103963. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  103964. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  103965. * @param update defines whether texture is immediately update (default is true)
  103966. */
  103967. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  103968. /**
  103969. * Clones the texture
  103970. * @returns the clone of the texture.
  103971. */
  103972. clone(): DynamicTexture;
  103973. /**
  103974. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  103975. * @returns a serialized dynamic texture object
  103976. */
  103977. serialize(): any;
  103978. /** @hidden */
  103979. _rebuild(): void;
  103980. }
  103981. }
  103982. declare module BABYLON {
  103983. /** @hidden */
  103984. export var imageProcessingPixelShader: {
  103985. name: string;
  103986. shader: string;
  103987. };
  103988. }
  103989. declare module BABYLON {
  103990. /**
  103991. * ImageProcessingPostProcess
  103992. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  103993. */
  103994. export class ImageProcessingPostProcess extends PostProcess {
  103995. /**
  103996. * Default configuration related to image processing available in the PBR Material.
  103997. */
  103998. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103999. /**
  104000. * Gets the image processing configuration used either in this material.
  104001. */
  104002. /**
  104003. * Sets the Default image processing configuration used either in the this material.
  104004. *
  104005. * If sets to null, the scene one is in use.
  104006. */
  104007. imageProcessingConfiguration: ImageProcessingConfiguration;
  104008. /**
  104009. * Keep track of the image processing observer to allow dispose and replace.
  104010. */
  104011. private _imageProcessingObserver;
  104012. /**
  104013. * Attaches a new image processing configuration to the PBR Material.
  104014. * @param configuration
  104015. */
  104016. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  104017. /**
  104018. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104019. */
  104020. /**
  104021. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104022. */
  104023. colorCurves: Nullable<ColorCurves>;
  104024. /**
  104025. * Gets wether the color curves effect is enabled.
  104026. */
  104027. /**
  104028. * Sets wether the color curves effect is enabled.
  104029. */
  104030. colorCurvesEnabled: boolean;
  104031. /**
  104032. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104033. */
  104034. /**
  104035. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104036. */
  104037. colorGradingTexture: Nullable<BaseTexture>;
  104038. /**
  104039. * Gets wether the color grading effect is enabled.
  104040. */
  104041. /**
  104042. * Gets wether the color grading effect is enabled.
  104043. */
  104044. colorGradingEnabled: boolean;
  104045. /**
  104046. * Gets exposure used in the effect.
  104047. */
  104048. /**
  104049. * Sets exposure used in the effect.
  104050. */
  104051. exposure: number;
  104052. /**
  104053. * Gets wether tonemapping is enabled or not.
  104054. */
  104055. /**
  104056. * Sets wether tonemapping is enabled or not
  104057. */
  104058. toneMappingEnabled: boolean;
  104059. /**
  104060. * Gets the type of tone mapping effect.
  104061. */
  104062. /**
  104063. * Sets the type of tone mapping effect.
  104064. */
  104065. toneMappingType: number;
  104066. /**
  104067. * Gets contrast used in the effect.
  104068. */
  104069. /**
  104070. * Sets contrast used in the effect.
  104071. */
  104072. contrast: number;
  104073. /**
  104074. * Gets Vignette stretch size.
  104075. */
  104076. /**
  104077. * Sets Vignette stretch size.
  104078. */
  104079. vignetteStretch: number;
  104080. /**
  104081. * Gets Vignette centre X Offset.
  104082. */
  104083. /**
  104084. * Sets Vignette centre X Offset.
  104085. */
  104086. vignetteCentreX: number;
  104087. /**
  104088. * Gets Vignette centre Y Offset.
  104089. */
  104090. /**
  104091. * Sets Vignette centre Y Offset.
  104092. */
  104093. vignetteCentreY: number;
  104094. /**
  104095. * Gets Vignette weight or intensity of the vignette effect.
  104096. */
  104097. /**
  104098. * Sets Vignette weight or intensity of the vignette effect.
  104099. */
  104100. vignetteWeight: number;
  104101. /**
  104102. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104103. * if vignetteEnabled is set to true.
  104104. */
  104105. /**
  104106. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104107. * if vignetteEnabled is set to true.
  104108. */
  104109. vignetteColor: Color4;
  104110. /**
  104111. * Gets Camera field of view used by the Vignette effect.
  104112. */
  104113. /**
  104114. * Sets Camera field of view used by the Vignette effect.
  104115. */
  104116. vignetteCameraFov: number;
  104117. /**
  104118. * Gets the vignette blend mode allowing different kind of effect.
  104119. */
  104120. /**
  104121. * Sets the vignette blend mode allowing different kind of effect.
  104122. */
  104123. vignetteBlendMode: number;
  104124. /**
  104125. * Gets wether the vignette effect is enabled.
  104126. */
  104127. /**
  104128. * Sets wether the vignette effect is enabled.
  104129. */
  104130. vignetteEnabled: boolean;
  104131. private _fromLinearSpace;
  104132. /**
  104133. * Gets wether the input of the processing is in Gamma or Linear Space.
  104134. */
  104135. /**
  104136. * Sets wether the input of the processing is in Gamma or Linear Space.
  104137. */
  104138. fromLinearSpace: boolean;
  104139. /**
  104140. * Defines cache preventing GC.
  104141. */
  104142. private _defines;
  104143. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  104144. /**
  104145. * "ImageProcessingPostProcess"
  104146. * @returns "ImageProcessingPostProcess"
  104147. */
  104148. getClassName(): string;
  104149. protected _updateParameters(): void;
  104150. dispose(camera?: Camera): void;
  104151. }
  104152. }
  104153. declare module BABYLON {
  104154. /**
  104155. * Class containing static functions to help procedurally build meshes
  104156. */
  104157. export class GroundBuilder {
  104158. /**
  104159. * Creates a ground mesh
  104160. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  104161. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  104162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104163. * @param name defines the name of the mesh
  104164. * @param options defines the options used to create the mesh
  104165. * @param scene defines the hosting scene
  104166. * @returns the ground mesh
  104167. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  104168. */
  104169. static CreateGround(name: string, options: {
  104170. width?: number;
  104171. height?: number;
  104172. subdivisions?: number;
  104173. subdivisionsX?: number;
  104174. subdivisionsY?: number;
  104175. updatable?: boolean;
  104176. }, scene: any): Mesh;
  104177. /**
  104178. * Creates a tiled ground mesh
  104179. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  104180. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  104181. * * 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
  104182. * * 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
  104183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104184. * @param name defines the name of the mesh
  104185. * @param options defines the options used to create the mesh
  104186. * @param scene defines the hosting scene
  104187. * @returns the tiled ground mesh
  104188. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  104189. */
  104190. static CreateTiledGround(name: string, options: {
  104191. xmin: number;
  104192. zmin: number;
  104193. xmax: number;
  104194. zmax: number;
  104195. subdivisions?: {
  104196. w: number;
  104197. h: number;
  104198. };
  104199. precision?: {
  104200. w: number;
  104201. h: number;
  104202. };
  104203. updatable?: boolean;
  104204. }, scene?: Nullable<Scene>): Mesh;
  104205. /**
  104206. * Creates a ground mesh from a height map
  104207. * * The parameter `url` sets the URL of the height map image resource.
  104208. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  104209. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  104210. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  104211. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  104212. * * 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.
  104213. * * 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).
  104214. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  104215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104216. * @param name defines the name of the mesh
  104217. * @param url defines the url to the height map
  104218. * @param options defines the options used to create the mesh
  104219. * @param scene defines the hosting scene
  104220. * @returns the ground mesh
  104221. * @see https://doc.babylonjs.com/babylon101/height_map
  104222. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  104223. */
  104224. static CreateGroundFromHeightMap(name: string, url: string, options: {
  104225. width?: number;
  104226. height?: number;
  104227. subdivisions?: number;
  104228. minHeight?: number;
  104229. maxHeight?: number;
  104230. colorFilter?: Color3;
  104231. alphaFilter?: number;
  104232. updatable?: boolean;
  104233. onReady?: (mesh: GroundMesh) => void;
  104234. }, scene?: Nullable<Scene>): GroundMesh;
  104235. }
  104236. }
  104237. declare module BABYLON {
  104238. /**
  104239. * Class containing static functions to help procedurally build meshes
  104240. */
  104241. export class TorusBuilder {
  104242. /**
  104243. * Creates a torus mesh
  104244. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  104245. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  104246. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  104247. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104248. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104249. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104250. * @param name defines the name of the mesh
  104251. * @param options defines the options used to create the mesh
  104252. * @param scene defines the hosting scene
  104253. * @returns the torus mesh
  104254. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  104255. */
  104256. static CreateTorus(name: string, options: {
  104257. diameter?: number;
  104258. thickness?: number;
  104259. tessellation?: number;
  104260. updatable?: boolean;
  104261. sideOrientation?: number;
  104262. frontUVs?: Vector4;
  104263. backUVs?: Vector4;
  104264. }, scene: any): Mesh;
  104265. }
  104266. }
  104267. declare module BABYLON {
  104268. /**
  104269. * Class containing static functions to help procedurally build meshes
  104270. */
  104271. export class CylinderBuilder {
  104272. /**
  104273. * Creates a cylinder or a cone mesh
  104274. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  104275. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  104276. * * 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.
  104277. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  104278. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  104279. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  104280. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  104281. * * 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).
  104282. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  104283. * * 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).
  104284. * * 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
  104285. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  104286. * * 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
  104287. * * 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.
  104288. * * If `enclose` is false, a ring surface is one element.
  104289. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  104290. * * 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
  104291. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104292. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104294. * @param name defines the name of the mesh
  104295. * @param options defines the options used to create the mesh
  104296. * @param scene defines the hosting scene
  104297. * @returns the cylinder mesh
  104298. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  104299. */
  104300. static CreateCylinder(name: string, options: {
  104301. height?: number;
  104302. diameterTop?: number;
  104303. diameterBottom?: number;
  104304. diameter?: number;
  104305. tessellation?: number;
  104306. subdivisions?: number;
  104307. arc?: number;
  104308. faceColors?: Color4[];
  104309. faceUV?: Vector4[];
  104310. updatable?: boolean;
  104311. hasRings?: boolean;
  104312. enclose?: boolean;
  104313. cap?: number;
  104314. sideOrientation?: number;
  104315. frontUVs?: Vector4;
  104316. backUVs?: Vector4;
  104317. }, scene: any): Mesh;
  104318. }
  104319. }
  104320. declare module BABYLON {
  104321. /**
  104322. * Options to modify the vr teleportation behavior.
  104323. */
  104324. export interface VRTeleportationOptions {
  104325. /**
  104326. * The name of the mesh which should be used as the teleportation floor. (default: null)
  104327. */
  104328. floorMeshName?: string;
  104329. /**
  104330. * A list of meshes to be used as the teleportation floor. (default: empty)
  104331. */
  104332. floorMeshes?: Mesh[];
  104333. }
  104334. /**
  104335. * Options to modify the vr experience helper's behavior.
  104336. */
  104337. export interface VRExperienceHelperOptions extends WebVROptions {
  104338. /**
  104339. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  104340. */
  104341. createDeviceOrientationCamera?: boolean;
  104342. /**
  104343. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  104344. */
  104345. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  104346. /**
  104347. * Uses the main button on the controller to toggle the laser casted. (default: true)
  104348. */
  104349. laserToggle?: boolean;
  104350. /**
  104351. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  104352. */
  104353. floorMeshes?: Mesh[];
  104354. /**
  104355. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  104356. */
  104357. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  104358. }
  104359. /**
  104360. * Event containing information after VR has been entered
  104361. */
  104362. export class OnAfterEnteringVRObservableEvent {
  104363. /**
  104364. * If entering vr was successful
  104365. */
  104366. success: boolean;
  104367. }
  104368. /**
  104369. * Helps to quickly add VR support to an existing scene.
  104370. * See http://doc.babylonjs.com/how_to/webvr_helper
  104371. */
  104372. export class VRExperienceHelper {
  104373. /** Options to modify the vr experience helper's behavior. */
  104374. webVROptions: VRExperienceHelperOptions;
  104375. private _scene;
  104376. private _position;
  104377. private _btnVR;
  104378. private _btnVRDisplayed;
  104379. private _webVRsupported;
  104380. private _webVRready;
  104381. private _webVRrequesting;
  104382. private _webVRpresenting;
  104383. private _hasEnteredVR;
  104384. private _fullscreenVRpresenting;
  104385. private _canvas;
  104386. private _webVRCamera;
  104387. private _vrDeviceOrientationCamera;
  104388. private _deviceOrientationCamera;
  104389. private _existingCamera;
  104390. private _onKeyDown;
  104391. private _onVrDisplayPresentChange;
  104392. private _onVRDisplayChanged;
  104393. private _onVRRequestPresentStart;
  104394. private _onVRRequestPresentComplete;
  104395. /**
  104396. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  104397. */
  104398. enableGazeEvenWhenNoPointerLock: boolean;
  104399. /**
  104400. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  104401. */
  104402. exitVROnDoubleTap: boolean;
  104403. /**
  104404. * Observable raised right before entering VR.
  104405. */
  104406. onEnteringVRObservable: Observable<VRExperienceHelper>;
  104407. /**
  104408. * Observable raised when entering VR has completed.
  104409. */
  104410. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  104411. /**
  104412. * Observable raised when exiting VR.
  104413. */
  104414. onExitingVRObservable: Observable<VRExperienceHelper>;
  104415. /**
  104416. * Observable raised when controller mesh is loaded.
  104417. */
  104418. onControllerMeshLoadedObservable: Observable<WebVRController>;
  104419. /** Return this.onEnteringVRObservable
  104420. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  104421. */
  104422. readonly onEnteringVR: Observable<VRExperienceHelper>;
  104423. /** Return this.onExitingVRObservable
  104424. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  104425. */
  104426. readonly onExitingVR: Observable<VRExperienceHelper>;
  104427. /** Return this.onControllerMeshLoadedObservable
  104428. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  104429. */
  104430. readonly onControllerMeshLoaded: Observable<WebVRController>;
  104431. private _rayLength;
  104432. private _useCustomVRButton;
  104433. private _teleportationRequested;
  104434. private _teleportActive;
  104435. private _floorMeshName;
  104436. private _floorMeshesCollection;
  104437. private _rotationAllowed;
  104438. private _teleportBackwardsVector;
  104439. private _teleportationTarget;
  104440. private _isDefaultTeleportationTarget;
  104441. private _postProcessMove;
  104442. private _teleportationFillColor;
  104443. private _teleportationBorderColor;
  104444. private _rotationAngle;
  104445. private _haloCenter;
  104446. private _cameraGazer;
  104447. private _padSensibilityUp;
  104448. private _padSensibilityDown;
  104449. private _leftController;
  104450. private _rightController;
  104451. /**
  104452. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  104453. */
  104454. onNewMeshSelected: Observable<AbstractMesh>;
  104455. /**
  104456. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  104457. */
  104458. onNewMeshPicked: Observable<PickingInfo>;
  104459. private _circleEase;
  104460. /**
  104461. * Observable raised before camera teleportation
  104462. */
  104463. onBeforeCameraTeleport: Observable<Vector3>;
  104464. /**
  104465. * Observable raised after camera teleportation
  104466. */
  104467. onAfterCameraTeleport: Observable<Vector3>;
  104468. /**
  104469. * Observable raised when current selected mesh gets unselected
  104470. */
  104471. onSelectedMeshUnselected: Observable<AbstractMesh>;
  104472. private _raySelectionPredicate;
  104473. /**
  104474. * To be optionaly changed by user to define custom ray selection
  104475. */
  104476. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  104477. /**
  104478. * To be optionaly changed by user to define custom selection logic (after ray selection)
  104479. */
  104480. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  104481. /**
  104482. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  104483. */
  104484. teleportationEnabled: boolean;
  104485. private _defaultHeight;
  104486. private _teleportationInitialized;
  104487. private _interactionsEnabled;
  104488. private _interactionsRequested;
  104489. private _displayGaze;
  104490. private _displayLaserPointer;
  104491. /**
  104492. * The mesh used to display where the user is going to teleport.
  104493. */
  104494. /**
  104495. * Sets the mesh to be used to display where the user is going to teleport.
  104496. */
  104497. teleportationTarget: Mesh;
  104498. /**
  104499. * 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
  104500. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  104501. * See http://doc.babylonjs.com/resources/baking_transformations
  104502. */
  104503. gazeTrackerMesh: Mesh;
  104504. /**
  104505. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  104506. */
  104507. updateGazeTrackerScale: boolean;
  104508. /**
  104509. * If the gaze trackers color should be updated when selecting meshes
  104510. */
  104511. updateGazeTrackerColor: boolean;
  104512. /**
  104513. * The gaze tracking mesh corresponding to the left controller
  104514. */
  104515. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  104516. /**
  104517. * The gaze tracking mesh corresponding to the right controller
  104518. */
  104519. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  104520. /**
  104521. * If the ray of the gaze should be displayed.
  104522. */
  104523. /**
  104524. * Sets if the ray of the gaze should be displayed.
  104525. */
  104526. displayGaze: boolean;
  104527. /**
  104528. * If the ray of the LaserPointer should be displayed.
  104529. */
  104530. /**
  104531. * Sets if the ray of the LaserPointer should be displayed.
  104532. */
  104533. displayLaserPointer: boolean;
  104534. /**
  104535. * The deviceOrientationCamera used as the camera when not in VR.
  104536. */
  104537. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  104538. /**
  104539. * Based on the current WebVR support, returns the current VR camera used.
  104540. */
  104541. readonly currentVRCamera: Nullable<Camera>;
  104542. /**
  104543. * The webVRCamera which is used when in VR.
  104544. */
  104545. readonly webVRCamera: WebVRFreeCamera;
  104546. /**
  104547. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  104548. */
  104549. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  104550. /**
  104551. * The html button that is used to trigger entering into VR.
  104552. */
  104553. readonly vrButton: Nullable<HTMLButtonElement>;
  104554. private readonly _teleportationRequestInitiated;
  104555. /**
  104556. * Defines wether or not Pointer lock should be requested when switching to
  104557. * full screen.
  104558. */
  104559. requestPointerLockOnFullScreen: boolean;
  104560. /**
  104561. * Instantiates a VRExperienceHelper.
  104562. * Helps to quickly add VR support to an existing scene.
  104563. * @param scene The scene the VRExperienceHelper belongs to.
  104564. * @param webVROptions Options to modify the vr experience helper's behavior.
  104565. */
  104566. constructor(scene: Scene,
  104567. /** Options to modify the vr experience helper's behavior. */
  104568. webVROptions?: VRExperienceHelperOptions);
  104569. private _onDefaultMeshLoaded;
  104570. private _onResize;
  104571. private _onFullscreenChange;
  104572. /**
  104573. * Gets a value indicating if we are currently in VR mode.
  104574. */
  104575. readonly isInVRMode: boolean;
  104576. private onVrDisplayPresentChange;
  104577. private onVRDisplayChanged;
  104578. private moveButtonToBottomRight;
  104579. private displayVRButton;
  104580. private updateButtonVisibility;
  104581. private _cachedAngularSensibility;
  104582. /**
  104583. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  104584. * Otherwise, will use the fullscreen API.
  104585. */
  104586. enterVR(): void;
  104587. /**
  104588. * Attempt to exit VR, or fullscreen.
  104589. */
  104590. exitVR(): void;
  104591. /**
  104592. * The position of the vr experience helper.
  104593. */
  104594. /**
  104595. * Sets the position of the vr experience helper.
  104596. */
  104597. position: Vector3;
  104598. /**
  104599. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  104600. */
  104601. enableInteractions(): void;
  104602. private readonly _noControllerIsActive;
  104603. private beforeRender;
  104604. private _isTeleportationFloor;
  104605. /**
  104606. * Adds a floor mesh to be used for teleportation.
  104607. * @param floorMesh the mesh to be used for teleportation.
  104608. */
  104609. addFloorMesh(floorMesh: Mesh): void;
  104610. /**
  104611. * Removes a floor mesh from being used for teleportation.
  104612. * @param floorMesh the mesh to be removed.
  104613. */
  104614. removeFloorMesh(floorMesh: Mesh): void;
  104615. /**
  104616. * Enables interactions and teleportation using the VR controllers and gaze.
  104617. * @param vrTeleportationOptions options to modify teleportation behavior.
  104618. */
  104619. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  104620. private _onNewGamepadConnected;
  104621. private _tryEnableInteractionOnController;
  104622. private _onNewGamepadDisconnected;
  104623. private _enableInteractionOnController;
  104624. private _checkTeleportWithRay;
  104625. private _checkRotate;
  104626. private _checkTeleportBackwards;
  104627. private _enableTeleportationOnController;
  104628. private _createTeleportationCircles;
  104629. private _displayTeleportationTarget;
  104630. private _hideTeleportationTarget;
  104631. private _rotateCamera;
  104632. private _moveTeleportationSelectorTo;
  104633. private _workingVector;
  104634. private _workingQuaternion;
  104635. private _workingMatrix;
  104636. /**
  104637. * Teleports the users feet to the desired location
  104638. * @param location The location where the user's feet should be placed
  104639. */
  104640. teleportCamera(location: Vector3): void;
  104641. private _convertNormalToDirectionOfRay;
  104642. private _castRayAndSelectObject;
  104643. private _notifySelectedMeshUnselected;
  104644. /**
  104645. * Sets the color of the laser ray from the vr controllers.
  104646. * @param color new color for the ray.
  104647. */
  104648. changeLaserColor(color: Color3): void;
  104649. /**
  104650. * Sets the color of the ray from the vr headsets gaze.
  104651. * @param color new color for the ray.
  104652. */
  104653. changeGazeColor(color: Color3): void;
  104654. /**
  104655. * Exits VR and disposes of the vr experience helper
  104656. */
  104657. dispose(): void;
  104658. /**
  104659. * Gets the name of the VRExperienceHelper class
  104660. * @returns "VRExperienceHelper"
  104661. */
  104662. getClassName(): string;
  104663. }
  104664. }
  104665. declare module BABYLON {
  104666. /**
  104667. * Manages an XRSession to work with Babylon's engine
  104668. * @see https://doc.babylonjs.com/how_to/webxr
  104669. */
  104670. export class WebXRSessionManager implements IDisposable {
  104671. private scene;
  104672. /**
  104673. * Fires every time a new xrFrame arrives which can be used to update the camera
  104674. */
  104675. onXRFrameObservable: Observable<any>;
  104676. /**
  104677. * Fires when the xr session is ended either by the device or manually done
  104678. */
  104679. onXRSessionEnded: Observable<any>;
  104680. /**
  104681. * Underlying xr session
  104682. */
  104683. session: XRSession;
  104684. /**
  104685. * Type of reference space used when creating the session
  104686. */
  104687. referenceSpace: XRReferenceSpace;
  104688. /** @hidden */
  104689. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  104690. /**
  104691. * Current XR frame
  104692. */
  104693. currentFrame: Nullable<XRFrame>;
  104694. private _xrNavigator;
  104695. private baseLayer;
  104696. /**
  104697. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  104698. * @param scene The scene which the session should be created for
  104699. */
  104700. constructor(scene: Scene);
  104701. /**
  104702. * Initializes the manager
  104703. * After initialization enterXR can be called to start an XR session
  104704. * @returns Promise which resolves after it is initialized
  104705. */
  104706. initializeAsync(): Promise<void>;
  104707. /**
  104708. * Initializes an xr session
  104709. * @param xrSessionMode mode to initialize
  104710. * @returns a promise which will resolve once the session has been initialized
  104711. */
  104712. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  104713. /**
  104714. * Sets the reference space on the xr session
  104715. * @param referenceSpace space to set
  104716. * @returns a promise that will resolve once the reference space has been set
  104717. */
  104718. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  104719. /**
  104720. * Updates the render state of the session
  104721. * @param state state to set
  104722. * @returns a promise that resolves once the render state has been updated
  104723. */
  104724. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  104725. /**
  104726. * Starts rendering to the xr layer
  104727. * @returns a promise that will resolve once rendering has started
  104728. */
  104729. startRenderingToXRAsync(): Promise<void>;
  104730. /**
  104731. * Stops the xrSession and restores the renderloop
  104732. * @returns Promise which resolves after it exits XR
  104733. */
  104734. exitXRAsync(): Promise<unknown>;
  104735. /**
  104736. * Checks if a session would be supported for the creation options specified
  104737. * @param sessionMode session mode to check if supported eg. immersive-vr
  104738. * @returns true if supported
  104739. */
  104740. supportsSessionAsync(sessionMode: XRSessionMode): any;
  104741. /**
  104742. * @hidden
  104743. * Converts the render layer of xrSession to a render target
  104744. * @param session session to create render target for
  104745. * @param scene scene the new render target should be created for
  104746. */
  104747. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  104748. /**
  104749. * Disposes of the session manager
  104750. */
  104751. dispose(): void;
  104752. }
  104753. }
  104754. declare module BABYLON {
  104755. /**
  104756. * WebXR Camera which holds the views for the xrSession
  104757. * @see https://doc.babylonjs.com/how_to/webxr
  104758. */
  104759. export class WebXRCamera extends FreeCamera {
  104760. private static _TmpMatrix;
  104761. /**
  104762. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  104763. * @param name the name of the camera
  104764. * @param scene the scene to add the camera to
  104765. */
  104766. constructor(name: string, scene: Scene);
  104767. private _updateNumberOfRigCameras;
  104768. /** @hidden */
  104769. _updateForDualEyeDebugging(pupilDistance?: number): void;
  104770. /**
  104771. * Updates the cameras position from the current pose information of the XR session
  104772. * @param xrSessionManager the session containing pose information
  104773. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  104774. */
  104775. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  104776. }
  104777. }
  104778. declare module BABYLON {
  104779. /**
  104780. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  104781. */
  104782. export class WebXRManagedOutputCanvas implements IDisposable {
  104783. private helper;
  104784. private _canvas;
  104785. /**
  104786. * xrpresent context of the canvas which can be used to display/mirror xr content
  104787. */
  104788. canvasContext: WebGLRenderingContext;
  104789. /**
  104790. * xr layer for the canvas
  104791. */
  104792. xrLayer: Nullable<XRWebGLLayer>;
  104793. /**
  104794. * Initializes the xr layer for the session
  104795. * @param xrSession xr session
  104796. * @returns a promise that will resolve once the XR Layer has been created
  104797. */
  104798. initializeXRLayerAsync(xrSession: any): any;
  104799. /**
  104800. * Initializes the canvas to be added/removed upon entering/exiting xr
  104801. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  104802. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  104803. */
  104804. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  104805. /**
  104806. * Disposes of the object
  104807. */
  104808. dispose(): void;
  104809. private _setManagedOutputCanvas;
  104810. private _addCanvas;
  104811. private _removeCanvas;
  104812. }
  104813. }
  104814. declare module BABYLON {
  104815. /**
  104816. * States of the webXR experience
  104817. */
  104818. export enum WebXRState {
  104819. /**
  104820. * Transitioning to being in XR mode
  104821. */
  104822. ENTERING_XR = 0,
  104823. /**
  104824. * Transitioning to non XR mode
  104825. */
  104826. EXITING_XR = 1,
  104827. /**
  104828. * In XR mode and presenting
  104829. */
  104830. IN_XR = 2,
  104831. /**
  104832. * Not entered XR mode
  104833. */
  104834. NOT_IN_XR = 3
  104835. }
  104836. /**
  104837. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  104838. * @see https://doc.babylonjs.com/how_to/webxr
  104839. */
  104840. export class WebXRExperienceHelper implements IDisposable {
  104841. private scene;
  104842. /**
  104843. * 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
  104844. */
  104845. container: AbstractMesh;
  104846. /**
  104847. * Camera used to render xr content
  104848. */
  104849. camera: WebXRCamera;
  104850. /**
  104851. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  104852. */
  104853. state: WebXRState;
  104854. private _setState;
  104855. private static _TmpVector;
  104856. /**
  104857. * Fires when the state of the experience helper has changed
  104858. */
  104859. onStateChangedObservable: Observable<WebXRState>;
  104860. /** Session manager used to keep track of xr session */
  104861. sessionManager: WebXRSessionManager;
  104862. private _nonVRCamera;
  104863. private _originalSceneAutoClear;
  104864. private _supported;
  104865. /**
  104866. * Creates the experience helper
  104867. * @param scene the scene to attach the experience helper to
  104868. * @returns a promise for the experience helper
  104869. */
  104870. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  104871. /**
  104872. * Creates a WebXRExperienceHelper
  104873. * @param scene The scene the helper should be created in
  104874. */
  104875. private constructor();
  104876. /**
  104877. * Exits XR mode and returns the scene to its original state
  104878. * @returns promise that resolves after xr mode has exited
  104879. */
  104880. exitXRAsync(): Promise<unknown>;
  104881. /**
  104882. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  104883. * @param sessionCreationOptions options for the XR session
  104884. * @param referenceSpaceType frame of reference of the XR session
  104885. * @param outputCanvas the output canvas that will be used to enter XR mode
  104886. * @returns promise that resolves after xr mode has entered
  104887. */
  104888. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  104889. /**
  104890. * Updates the global position of the camera by moving the camera's container
  104891. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  104892. * @param position The desired global position of the camera
  104893. */
  104894. setPositionOfCameraUsingContainer(position: Vector3): void;
  104895. /**
  104896. * Rotates the xr camera by rotating the camera's container around the camera's position
  104897. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  104898. * @param rotation the desired quaternion rotation to apply to the camera
  104899. */
  104900. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  104901. /**
  104902. * Disposes of the experience helper
  104903. */
  104904. dispose(): void;
  104905. }
  104906. }
  104907. declare module BABYLON {
  104908. /**
  104909. * Button which can be used to enter a different mode of XR
  104910. */
  104911. export class WebXREnterExitUIButton {
  104912. /** button element */
  104913. element: HTMLElement;
  104914. /** XR initialization options for the button */
  104915. sessionMode: XRSessionMode;
  104916. /** Reference space type */
  104917. referenceSpaceType: XRReferenceSpaceType;
  104918. /**
  104919. * Creates a WebXREnterExitUIButton
  104920. * @param element button element
  104921. * @param sessionMode XR initialization session mode
  104922. * @param referenceSpaceType the type of reference space to be used
  104923. */
  104924. constructor(
  104925. /** button element */
  104926. element: HTMLElement,
  104927. /** XR initialization options for the button */
  104928. sessionMode: XRSessionMode,
  104929. /** Reference space type */
  104930. referenceSpaceType: XRReferenceSpaceType);
  104931. /**
  104932. * Overwritable function which can be used to update the button's visuals when the state changes
  104933. * @param activeButton the current active button in the UI
  104934. */
  104935. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  104936. }
  104937. /**
  104938. * Options to create the webXR UI
  104939. */
  104940. export class WebXREnterExitUIOptions {
  104941. /**
  104942. * Context to enter xr with
  104943. */
  104944. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  104945. /**
  104946. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  104947. */
  104948. customButtons?: Array<WebXREnterExitUIButton>;
  104949. }
  104950. /**
  104951. * UI to allow the user to enter/exit XR mode
  104952. */
  104953. export class WebXREnterExitUI implements IDisposable {
  104954. private scene;
  104955. private _overlay;
  104956. private _buttons;
  104957. private _activeButton;
  104958. /**
  104959. * Fired every time the active button is changed.
  104960. *
  104961. * When xr is entered via a button that launches xr that button will be the callback parameter
  104962. *
  104963. * When exiting xr the callback parameter will be null)
  104964. */
  104965. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  104966. /**
  104967. * Creates UI to allow the user to enter/exit XR mode
  104968. * @param scene the scene to add the ui to
  104969. * @param helper the xr experience helper to enter/exit xr with
  104970. * @param options options to configure the UI
  104971. * @returns the created ui
  104972. */
  104973. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  104974. private constructor();
  104975. private _updateButtons;
  104976. /**
  104977. * Disposes of the object
  104978. */
  104979. dispose(): void;
  104980. }
  104981. }
  104982. declare module BABYLON {
  104983. /**
  104984. * Represents an XR input
  104985. */
  104986. export class WebXRController {
  104987. private scene;
  104988. /** The underlying input source for the controller */
  104989. inputSource: XRInputSource;
  104990. private parentContainer;
  104991. /**
  104992. * 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
  104993. */
  104994. grip?: AbstractMesh;
  104995. /**
  104996. * Pointer which can be used to select objects or attach a visible laser to
  104997. */
  104998. pointer: AbstractMesh;
  104999. /**
  105000. * Event that fires when the controller is removed/disposed
  105001. */
  105002. onDisposeObservable: Observable<{}>;
  105003. private _tmpMatrix;
  105004. private _tmpQuaternion;
  105005. private _tmpVector;
  105006. /**
  105007. * Creates the controller
  105008. * @see https://doc.babylonjs.com/how_to/webxr
  105009. * @param scene the scene which the controller should be associated to
  105010. * @param inputSource the underlying input source for the controller
  105011. * @param parentContainer parent that the controller meshes should be children of
  105012. */
  105013. constructor(scene: Scene,
  105014. /** The underlying input source for the controller */
  105015. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  105016. /**
  105017. * Updates the controller pose based on the given XRFrame
  105018. * @param xrFrame xr frame to update the pose with
  105019. * @param referenceSpace reference space to use
  105020. */
  105021. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  105022. /**
  105023. * Gets a world space ray coming from the controller
  105024. * @param result the resulting ray
  105025. */
  105026. getWorldPointerRayToRef(result: Ray): void;
  105027. /**
  105028. * Disposes of the object
  105029. */
  105030. dispose(): void;
  105031. }
  105032. }
  105033. declare module BABYLON {
  105034. /**
  105035. * XR input used to track XR inputs such as controllers/rays
  105036. */
  105037. export class WebXRInput implements IDisposable {
  105038. /**
  105039. * Base experience the input listens to
  105040. */
  105041. baseExperience: WebXRExperienceHelper;
  105042. /**
  105043. * XR controllers being tracked
  105044. */
  105045. controllers: Array<WebXRController>;
  105046. private _frameObserver;
  105047. private _stateObserver;
  105048. /**
  105049. * Event when a controller has been connected/added
  105050. */
  105051. onControllerAddedObservable: Observable<WebXRController>;
  105052. /**
  105053. * Event when a controller has been removed/disconnected
  105054. */
  105055. onControllerRemovedObservable: Observable<WebXRController>;
  105056. /**
  105057. * Initializes the WebXRInput
  105058. * @param baseExperience experience helper which the input should be created for
  105059. */
  105060. constructor(
  105061. /**
  105062. * Base experience the input listens to
  105063. */
  105064. baseExperience: WebXRExperienceHelper);
  105065. private _onInputSourcesChange;
  105066. private _addAndRemoveControllers;
  105067. /**
  105068. * Disposes of the object
  105069. */
  105070. dispose(): void;
  105071. }
  105072. }
  105073. declare module BABYLON {
  105074. /**
  105075. * Enables teleportation
  105076. */
  105077. export class WebXRControllerTeleportation {
  105078. private _teleportationFillColor;
  105079. private _teleportationBorderColor;
  105080. private _tmpRay;
  105081. private _tmpVector;
  105082. /**
  105083. * Creates a WebXRControllerTeleportation
  105084. * @param input input manager to add teleportation to
  105085. * @param floorMeshes floormeshes which can be teleported to
  105086. */
  105087. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  105088. }
  105089. }
  105090. declare module BABYLON {
  105091. /**
  105092. * Handles pointer input automatically for the pointer of XR controllers
  105093. */
  105094. export class WebXRControllerPointerSelection {
  105095. private static _idCounter;
  105096. private _tmpRay;
  105097. /**
  105098. * Creates a WebXRControllerPointerSelection
  105099. * @param input input manager to setup pointer selection
  105100. */
  105101. constructor(input: WebXRInput);
  105102. private _convertNormalToDirectionOfRay;
  105103. private _updatePointerDistance;
  105104. }
  105105. }
  105106. declare module BABYLON {
  105107. /**
  105108. * Class used to represent data loading progression
  105109. */
  105110. export class SceneLoaderProgressEvent {
  105111. /** defines if data length to load can be evaluated */
  105112. readonly lengthComputable: boolean;
  105113. /** defines the loaded data length */
  105114. readonly loaded: number;
  105115. /** defines the data length to load */
  105116. readonly total: number;
  105117. /**
  105118. * Create a new progress event
  105119. * @param lengthComputable defines if data length to load can be evaluated
  105120. * @param loaded defines the loaded data length
  105121. * @param total defines the data length to load
  105122. */
  105123. constructor(
  105124. /** defines if data length to load can be evaluated */
  105125. lengthComputable: boolean,
  105126. /** defines the loaded data length */
  105127. loaded: number,
  105128. /** defines the data length to load */
  105129. total: number);
  105130. /**
  105131. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  105132. * @param event defines the source event
  105133. * @returns a new SceneLoaderProgressEvent
  105134. */
  105135. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  105136. }
  105137. /**
  105138. * Interface used by SceneLoader plugins to define supported file extensions
  105139. */
  105140. export interface ISceneLoaderPluginExtensions {
  105141. /**
  105142. * Defines the list of supported extensions
  105143. */
  105144. [extension: string]: {
  105145. isBinary: boolean;
  105146. };
  105147. }
  105148. /**
  105149. * Interface used by SceneLoader plugin factory
  105150. */
  105151. export interface ISceneLoaderPluginFactory {
  105152. /**
  105153. * Defines the name of the factory
  105154. */
  105155. name: string;
  105156. /**
  105157. * Function called to create a new plugin
  105158. * @return the new plugin
  105159. */
  105160. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  105161. /**
  105162. * Boolean indicating if the plugin can direct load specific data
  105163. */
  105164. canDirectLoad?: (data: string) => boolean;
  105165. }
  105166. /**
  105167. * Interface used to define a SceneLoader plugin
  105168. */
  105169. export interface ISceneLoaderPlugin {
  105170. /**
  105171. * The friendly name of this plugin.
  105172. */
  105173. name: string;
  105174. /**
  105175. * The file extensions supported by this plugin.
  105176. */
  105177. extensions: string | ISceneLoaderPluginExtensions;
  105178. /**
  105179. * Import meshes into a scene.
  105180. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105181. * @param scene The scene to import into
  105182. * @param data The data to import
  105183. * @param rootUrl The root url for scene and resources
  105184. * @param meshes The meshes array to import into
  105185. * @param particleSystems The particle systems array to import into
  105186. * @param skeletons The skeletons array to import into
  105187. * @param onError The callback when import fails
  105188. * @returns True if successful or false otherwise
  105189. */
  105190. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  105191. /**
  105192. * Load into a scene.
  105193. * @param scene The scene to load into
  105194. * @param data The data to import
  105195. * @param rootUrl The root url for scene and resources
  105196. * @param onError The callback when import fails
  105197. * @returns true if successful or false otherwise
  105198. */
  105199. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  105200. /**
  105201. * The callback that returns true if the data can be directly loaded.
  105202. */
  105203. canDirectLoad?: (data: string) => boolean;
  105204. /**
  105205. * The callback that allows custom handling of the root url based on the response url.
  105206. */
  105207. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105208. /**
  105209. * Load into an asset container.
  105210. * @param scene The scene to load into
  105211. * @param data The data to import
  105212. * @param rootUrl The root url for scene and resources
  105213. * @param onError The callback when import fails
  105214. * @returns The loaded asset container
  105215. */
  105216. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  105217. }
  105218. /**
  105219. * Interface used to define an async SceneLoader plugin
  105220. */
  105221. export interface ISceneLoaderPluginAsync {
  105222. /**
  105223. * The friendly name of this plugin.
  105224. */
  105225. name: string;
  105226. /**
  105227. * The file extensions supported by this plugin.
  105228. */
  105229. extensions: string | ISceneLoaderPluginExtensions;
  105230. /**
  105231. * Import meshes into a scene.
  105232. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105233. * @param scene The scene to import into
  105234. * @param data The data to import
  105235. * @param rootUrl The root url for scene and resources
  105236. * @param onProgress The callback when the load progresses
  105237. * @param fileName Defines the name of the file to load
  105238. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  105239. */
  105240. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  105241. meshes: AbstractMesh[];
  105242. particleSystems: IParticleSystem[];
  105243. skeletons: Skeleton[];
  105244. animationGroups: AnimationGroup[];
  105245. }>;
  105246. /**
  105247. * Load into a scene.
  105248. * @param scene The scene to load into
  105249. * @param data The data to import
  105250. * @param rootUrl The root url for scene and resources
  105251. * @param onProgress The callback when the load progresses
  105252. * @param fileName Defines the name of the file to load
  105253. * @returns Nothing
  105254. */
  105255. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  105256. /**
  105257. * The callback that returns true if the data can be directly loaded.
  105258. */
  105259. canDirectLoad?: (data: string) => boolean;
  105260. /**
  105261. * The callback that allows custom handling of the root url based on the response url.
  105262. */
  105263. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105264. /**
  105265. * Load into an asset container.
  105266. * @param scene The scene to load into
  105267. * @param data The data to import
  105268. * @param rootUrl The root url for scene and resources
  105269. * @param onProgress The callback when the load progresses
  105270. * @param fileName Defines the name of the file to load
  105271. * @returns The loaded asset container
  105272. */
  105273. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  105274. }
  105275. /**
  105276. * Class used to load scene from various file formats using registered plugins
  105277. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  105278. */
  105279. export class SceneLoader {
  105280. /**
  105281. * No logging while loading
  105282. */
  105283. static readonly NO_LOGGING: number;
  105284. /**
  105285. * Minimal logging while loading
  105286. */
  105287. static readonly MINIMAL_LOGGING: number;
  105288. /**
  105289. * Summary logging while loading
  105290. */
  105291. static readonly SUMMARY_LOGGING: number;
  105292. /**
  105293. * Detailled logging while loading
  105294. */
  105295. static readonly DETAILED_LOGGING: number;
  105296. /**
  105297. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105298. */
  105299. static ForceFullSceneLoadingForIncremental: boolean;
  105300. /**
  105301. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105302. */
  105303. static ShowLoadingScreen: boolean;
  105304. /**
  105305. * Defines the current logging level (while loading the scene)
  105306. * @ignorenaming
  105307. */
  105308. static loggingLevel: number;
  105309. /**
  105310. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105311. */
  105312. static CleanBoneMatrixWeights: boolean;
  105313. /**
  105314. * Event raised when a plugin is used to load a scene
  105315. */
  105316. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  105317. private static _registeredPlugins;
  105318. private static _getDefaultPlugin;
  105319. private static _getPluginForExtension;
  105320. private static _getPluginForDirectLoad;
  105321. private static _getPluginForFilename;
  105322. private static _getDirectLoad;
  105323. private static _loadData;
  105324. private static _getFileInfo;
  105325. /**
  105326. * Gets a plugin that can load the given extension
  105327. * @param extension defines the extension to load
  105328. * @returns a plugin or null if none works
  105329. */
  105330. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  105331. /**
  105332. * Gets a boolean indicating that the given extension can be loaded
  105333. * @param extension defines the extension to load
  105334. * @returns true if the extension is supported
  105335. */
  105336. static IsPluginForExtensionAvailable(extension: string): boolean;
  105337. /**
  105338. * Adds a new plugin to the list of registered plugins
  105339. * @param plugin defines the plugin to add
  105340. */
  105341. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  105342. /**
  105343. * Import meshes into a scene
  105344. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105345. * @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)
  105346. * @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)
  105347. * @param scene the instance of BABYLON.Scene to append to
  105348. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  105349. * @param onProgress a callback with a progress event for each file being loaded
  105350. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105351. * @param pluginExtension the extension used to determine the plugin
  105352. * @returns The loaded plugin
  105353. */
  105354. 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>;
  105355. /**
  105356. * Import meshes into a scene
  105357. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105358. * @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)
  105359. * @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)
  105360. * @param scene the instance of BABYLON.Scene to append to
  105361. * @param onProgress a callback with a progress event for each file being loaded
  105362. * @param pluginExtension the extension used to determine the plugin
  105363. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  105364. */
  105365. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  105366. meshes: AbstractMesh[];
  105367. particleSystems: IParticleSystem[];
  105368. skeletons: Skeleton[];
  105369. animationGroups: AnimationGroup[];
  105370. }>;
  105371. /**
  105372. * Load a scene
  105373. * @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)
  105374. * @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)
  105375. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105376. * @param onSuccess a callback with the scene when import succeeds
  105377. * @param onProgress a callback with a progress event for each file being loaded
  105378. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105379. * @param pluginExtension the extension used to determine the plugin
  105380. * @returns The loaded plugin
  105381. */
  105382. 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>;
  105383. /**
  105384. * Load a scene
  105385. * @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)
  105386. * @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)
  105387. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105388. * @param onProgress a callback with a progress event for each file being loaded
  105389. * @param pluginExtension the extension used to determine the plugin
  105390. * @returns The loaded scene
  105391. */
  105392. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105393. /**
  105394. * Append a scene
  105395. * @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)
  105396. * @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)
  105397. * @param scene is the instance of BABYLON.Scene to append to
  105398. * @param onSuccess a callback with the scene when import succeeds
  105399. * @param onProgress a callback with a progress event for each file being loaded
  105400. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105401. * @param pluginExtension the extension used to determine the plugin
  105402. * @returns The loaded plugin
  105403. */
  105404. 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>;
  105405. /**
  105406. * Append a scene
  105407. * @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)
  105408. * @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)
  105409. * @param scene is the instance of BABYLON.Scene to append to
  105410. * @param onProgress a callback with a progress event for each file being loaded
  105411. * @param pluginExtension the extension used to determine the plugin
  105412. * @returns The given scene
  105413. */
  105414. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105415. /**
  105416. * Load a scene into an asset container
  105417. * @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)
  105418. * @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)
  105419. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  105420. * @param onSuccess a callback with the scene when import succeeds
  105421. * @param onProgress a callback with a progress event for each file being loaded
  105422. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105423. * @param pluginExtension the extension used to determine the plugin
  105424. * @returns The loaded plugin
  105425. */
  105426. 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>;
  105427. /**
  105428. * Load a scene into an asset container
  105429. * @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)
  105430. * @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)
  105431. * @param scene is the instance of Scene to append to
  105432. * @param onProgress a callback with a progress event for each file being loaded
  105433. * @param pluginExtension the extension used to determine the plugin
  105434. * @returns The loaded asset container
  105435. */
  105436. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  105437. }
  105438. }
  105439. declare module BABYLON {
  105440. /**
  105441. * Generic Controller
  105442. */
  105443. export class GenericController extends WebVRController {
  105444. /**
  105445. * Base Url for the controller model.
  105446. */
  105447. static readonly MODEL_BASE_URL: string;
  105448. /**
  105449. * File name for the controller model.
  105450. */
  105451. static readonly MODEL_FILENAME: string;
  105452. /**
  105453. * Creates a new GenericController from a gamepad
  105454. * @param vrGamepad the gamepad that the controller should be created from
  105455. */
  105456. constructor(vrGamepad: any);
  105457. /**
  105458. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105459. * @param scene scene in which to add meshes
  105460. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105461. */
  105462. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105463. /**
  105464. * Called once for each button that changed state since the last frame
  105465. * @param buttonIdx Which button index changed
  105466. * @param state New state of the button
  105467. * @param changes Which properties on the state changed since last frame
  105468. */
  105469. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105470. }
  105471. }
  105472. declare module BABYLON {
  105473. /**
  105474. * Defines the WindowsMotionController object that the state of the windows motion controller
  105475. */
  105476. export class WindowsMotionController extends WebVRController {
  105477. /**
  105478. * The base url used to load the left and right controller models
  105479. */
  105480. static MODEL_BASE_URL: string;
  105481. /**
  105482. * The name of the left controller model file
  105483. */
  105484. static MODEL_LEFT_FILENAME: string;
  105485. /**
  105486. * The name of the right controller model file
  105487. */
  105488. static MODEL_RIGHT_FILENAME: string;
  105489. /**
  105490. * The controller name prefix for this controller type
  105491. */
  105492. static readonly GAMEPAD_ID_PREFIX: string;
  105493. /**
  105494. * The controller id pattern for this controller type
  105495. */
  105496. private static readonly GAMEPAD_ID_PATTERN;
  105497. private _loadedMeshInfo;
  105498. private readonly _mapping;
  105499. /**
  105500. * Fired when the trackpad on this controller is clicked
  105501. */
  105502. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  105503. /**
  105504. * Fired when the trackpad on this controller is modified
  105505. */
  105506. onTrackpadValuesChangedObservable: Observable<StickValues>;
  105507. /**
  105508. * The current x and y values of this controller's trackpad
  105509. */
  105510. trackpad: StickValues;
  105511. /**
  105512. * Creates a new WindowsMotionController from a gamepad
  105513. * @param vrGamepad the gamepad that the controller should be created from
  105514. */
  105515. constructor(vrGamepad: any);
  105516. /**
  105517. * Fired when the trigger on this controller is modified
  105518. */
  105519. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105520. /**
  105521. * Fired when the menu button on this controller is modified
  105522. */
  105523. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105524. /**
  105525. * Fired when the grip button on this controller is modified
  105526. */
  105527. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105528. /**
  105529. * Fired when the thumbstick button on this controller is modified
  105530. */
  105531. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105532. /**
  105533. * Fired when the touchpad button on this controller is modified
  105534. */
  105535. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105536. /**
  105537. * Fired when the touchpad values on this controller are modified
  105538. */
  105539. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  105540. private _updateTrackpad;
  105541. /**
  105542. * Called once per frame by the engine.
  105543. */
  105544. update(): void;
  105545. /**
  105546. * Called once for each button that changed state since the last frame
  105547. * @param buttonIdx Which button index changed
  105548. * @param state New state of the button
  105549. * @param changes Which properties on the state changed since last frame
  105550. */
  105551. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105552. /**
  105553. * Moves the buttons on the controller mesh based on their current state
  105554. * @param buttonName the name of the button to move
  105555. * @param buttonValue the value of the button which determines the buttons new position
  105556. */
  105557. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  105558. /**
  105559. * Moves the axis on the controller mesh based on its current state
  105560. * @param axis the index of the axis
  105561. * @param axisValue the value of the axis which determines the meshes new position
  105562. * @hidden
  105563. */
  105564. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  105565. /**
  105566. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105567. * @param scene scene in which to add meshes
  105568. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105569. */
  105570. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  105571. /**
  105572. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  105573. * can be transformed by button presses and axes values, based on this._mapping.
  105574. *
  105575. * @param scene scene in which the meshes exist
  105576. * @param meshes list of meshes that make up the controller model to process
  105577. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  105578. */
  105579. private processModel;
  105580. private createMeshInfo;
  105581. /**
  105582. * Gets the ray of the controller in the direction the controller is pointing
  105583. * @param length the length the resulting ray should be
  105584. * @returns a ray in the direction the controller is pointing
  105585. */
  105586. getForwardRay(length?: number): Ray;
  105587. /**
  105588. * Disposes of the controller
  105589. */
  105590. dispose(): void;
  105591. }
  105592. }
  105593. declare module BABYLON {
  105594. /**
  105595. * Oculus Touch Controller
  105596. */
  105597. export class OculusTouchController extends WebVRController {
  105598. /**
  105599. * Base Url for the controller model.
  105600. */
  105601. static MODEL_BASE_URL: string;
  105602. /**
  105603. * File name for the left controller model.
  105604. */
  105605. static MODEL_LEFT_FILENAME: string;
  105606. /**
  105607. * File name for the right controller model.
  105608. */
  105609. static MODEL_RIGHT_FILENAME: string;
  105610. /**
  105611. * Base Url for the Quest controller model.
  105612. */
  105613. static QUEST_MODEL_BASE_URL: string;
  105614. /**
  105615. * @hidden
  105616. * If the controllers are running on a device that needs the updated Quest controller models
  105617. */
  105618. static _IsQuest: boolean;
  105619. /**
  105620. * Fired when the secondary trigger on this controller is modified
  105621. */
  105622. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  105623. /**
  105624. * Fired when the thumb rest on this controller is modified
  105625. */
  105626. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  105627. /**
  105628. * Creates a new OculusTouchController from a gamepad
  105629. * @param vrGamepad the gamepad that the controller should be created from
  105630. */
  105631. constructor(vrGamepad: any);
  105632. /**
  105633. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105634. * @param scene scene in which to add meshes
  105635. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105636. */
  105637. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105638. /**
  105639. * Fired when the A button on this controller is modified
  105640. */
  105641. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105642. /**
  105643. * Fired when the B button on this controller is modified
  105644. */
  105645. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105646. /**
  105647. * Fired when the X button on this controller is modified
  105648. */
  105649. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105650. /**
  105651. * Fired when the Y button on this controller is modified
  105652. */
  105653. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105654. /**
  105655. * Called once for each button that changed state since the last frame
  105656. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  105657. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  105658. * 2) secondary trigger (same)
  105659. * 3) A (right) X (left), touch, pressed = value
  105660. * 4) B / Y
  105661. * 5) thumb rest
  105662. * @param buttonIdx Which button index changed
  105663. * @param state New state of the button
  105664. * @param changes Which properties on the state changed since last frame
  105665. */
  105666. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105667. }
  105668. }
  105669. declare module BABYLON {
  105670. /**
  105671. * Vive Controller
  105672. */
  105673. export class ViveController extends WebVRController {
  105674. /**
  105675. * Base Url for the controller model.
  105676. */
  105677. static MODEL_BASE_URL: string;
  105678. /**
  105679. * File name for the controller model.
  105680. */
  105681. static MODEL_FILENAME: string;
  105682. /**
  105683. * Creates a new ViveController from a gamepad
  105684. * @param vrGamepad the gamepad that the controller should be created from
  105685. */
  105686. constructor(vrGamepad: any);
  105687. /**
  105688. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105689. * @param scene scene in which to add meshes
  105690. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105691. */
  105692. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105693. /**
  105694. * Fired when the left button on this controller is modified
  105695. */
  105696. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105697. /**
  105698. * Fired when the right button on this controller is modified
  105699. */
  105700. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105701. /**
  105702. * Fired when the menu button on this controller is modified
  105703. */
  105704. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105705. /**
  105706. * Called once for each button that changed state since the last frame
  105707. * Vive mapping:
  105708. * 0: touchpad
  105709. * 1: trigger
  105710. * 2: left AND right buttons
  105711. * 3: menu button
  105712. * @param buttonIdx Which button index changed
  105713. * @param state New state of the button
  105714. * @param changes Which properties on the state changed since last frame
  105715. */
  105716. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105717. }
  105718. }
  105719. declare module BABYLON {
  105720. /**
  105721. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  105722. */
  105723. export class WebXRControllerModelLoader {
  105724. /**
  105725. * Creates the WebXRControllerModelLoader
  105726. * @param input xr input that creates the controllers
  105727. */
  105728. constructor(input: WebXRInput);
  105729. }
  105730. }
  105731. declare module BABYLON {
  105732. /**
  105733. * Contains an array of blocks representing the octree
  105734. */
  105735. export interface IOctreeContainer<T> {
  105736. /**
  105737. * Blocks within the octree
  105738. */
  105739. blocks: Array<OctreeBlock<T>>;
  105740. }
  105741. /**
  105742. * Class used to store a cell in an octree
  105743. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105744. */
  105745. export class OctreeBlock<T> {
  105746. /**
  105747. * Gets the content of the current block
  105748. */
  105749. entries: T[];
  105750. /**
  105751. * Gets the list of block children
  105752. */
  105753. blocks: Array<OctreeBlock<T>>;
  105754. private _depth;
  105755. private _maxDepth;
  105756. private _capacity;
  105757. private _minPoint;
  105758. private _maxPoint;
  105759. private _boundingVectors;
  105760. private _creationFunc;
  105761. /**
  105762. * Creates a new block
  105763. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  105764. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  105765. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  105766. * @param depth defines the current depth of this block in the octree
  105767. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  105768. * @param creationFunc defines a callback to call when an element is added to the block
  105769. */
  105770. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  105771. /**
  105772. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  105773. */
  105774. readonly capacity: number;
  105775. /**
  105776. * Gets the minimum vector (in world space) of the block's bounding box
  105777. */
  105778. readonly minPoint: Vector3;
  105779. /**
  105780. * Gets the maximum vector (in world space) of the block's bounding box
  105781. */
  105782. readonly maxPoint: Vector3;
  105783. /**
  105784. * Add a new element to this block
  105785. * @param entry defines the element to add
  105786. */
  105787. addEntry(entry: T): void;
  105788. /**
  105789. * Remove an element from this block
  105790. * @param entry defines the element to remove
  105791. */
  105792. removeEntry(entry: T): void;
  105793. /**
  105794. * Add an array of elements to this block
  105795. * @param entries defines the array of elements to add
  105796. */
  105797. addEntries(entries: T[]): void;
  105798. /**
  105799. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  105800. * @param frustumPlanes defines the frustum planes to test
  105801. * @param selection defines the array to store current content if selection is positive
  105802. * @param allowDuplicate defines if the selection array can contains duplicated entries
  105803. */
  105804. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  105805. /**
  105806. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  105807. * @param sphereCenter defines the bounding sphere center
  105808. * @param sphereRadius defines the bounding sphere radius
  105809. * @param selection defines the array to store current content if selection is positive
  105810. * @param allowDuplicate defines if the selection array can contains duplicated entries
  105811. */
  105812. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  105813. /**
  105814. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  105815. * @param ray defines the ray to test with
  105816. * @param selection defines the array to store current content if selection is positive
  105817. */
  105818. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  105819. /**
  105820. * Subdivide the content into child blocks (this block will then be empty)
  105821. */
  105822. createInnerBlocks(): void;
  105823. /**
  105824. * @hidden
  105825. */
  105826. 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;
  105827. }
  105828. }
  105829. declare module BABYLON {
  105830. /**
  105831. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  105832. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105833. */
  105834. export class Octree<T> {
  105835. /** 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.) */
  105836. maxDepth: number;
  105837. /**
  105838. * Blocks within the octree containing objects
  105839. */
  105840. blocks: Array<OctreeBlock<T>>;
  105841. /**
  105842. * Content stored in the octree
  105843. */
  105844. dynamicContent: T[];
  105845. private _maxBlockCapacity;
  105846. private _selectionContent;
  105847. private _creationFunc;
  105848. /**
  105849. * Creates a octree
  105850. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105851. * @param creationFunc function to be used to instatiate the octree
  105852. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  105853. * @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.)
  105854. */
  105855. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  105856. /** 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.) */
  105857. maxDepth?: number);
  105858. /**
  105859. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  105860. * @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);
  105861. * @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);
  105862. * @param entries meshes to be added to the octree blocks
  105863. */
  105864. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  105865. /**
  105866. * Adds a mesh to the octree
  105867. * @param entry Mesh to add to the octree
  105868. */
  105869. addMesh(entry: T): void;
  105870. /**
  105871. * Remove an element from the octree
  105872. * @param entry defines the element to remove
  105873. */
  105874. removeMesh(entry: T): void;
  105875. /**
  105876. * Selects an array of meshes within the frustum
  105877. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  105878. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  105879. * @returns array of meshes within the frustum
  105880. */
  105881. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  105882. /**
  105883. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  105884. * @param sphereCenter defines the bounding sphere center
  105885. * @param sphereRadius defines the bounding sphere radius
  105886. * @param allowDuplicate defines if the selection array can contains duplicated entries
  105887. * @returns an array of objects that intersect the sphere
  105888. */
  105889. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  105890. /**
  105891. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  105892. * @param ray defines the ray to test with
  105893. * @returns array of intersected objects
  105894. */
  105895. intersectsRay(ray: Ray): SmartArray<T>;
  105896. /**
  105897. * Adds a mesh into the octree block if it intersects the block
  105898. */
  105899. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  105900. /**
  105901. * Adds a submesh into the octree block if it intersects the block
  105902. */
  105903. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  105904. }
  105905. }
  105906. declare module BABYLON {
  105907. interface Scene {
  105908. /**
  105909. * @hidden
  105910. * Backing Filed
  105911. */
  105912. _selectionOctree: Octree<AbstractMesh>;
  105913. /**
  105914. * Gets the octree used to boost mesh selection (picking)
  105915. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105916. */
  105917. selectionOctree: Octree<AbstractMesh>;
  105918. /**
  105919. * Creates or updates the octree used to boost selection (picking)
  105920. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105921. * @param maxCapacity defines the maximum capacity per leaf
  105922. * @param maxDepth defines the maximum depth of the octree
  105923. * @returns an octree of AbstractMesh
  105924. */
  105925. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  105926. }
  105927. interface AbstractMesh {
  105928. /**
  105929. * @hidden
  105930. * Backing Field
  105931. */
  105932. _submeshesOctree: Octree<SubMesh>;
  105933. /**
  105934. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  105935. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  105936. * @param maxCapacity defines the maximum size of each block (64 by default)
  105937. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  105938. * @returns the new octree
  105939. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  105940. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105941. */
  105942. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  105943. }
  105944. /**
  105945. * Defines the octree scene component responsible to manage any octrees
  105946. * in a given scene.
  105947. */
  105948. export class OctreeSceneComponent {
  105949. /**
  105950. * The component name help to identify the component in the list of scene components.
  105951. */
  105952. readonly name: string;
  105953. /**
  105954. * The scene the component belongs to.
  105955. */
  105956. scene: Scene;
  105957. /**
  105958. * Indicates if the meshes have been checked to make sure they are isEnabled()
  105959. */
  105960. readonly checksIsEnabled: boolean;
  105961. /**
  105962. * Creates a new instance of the component for the given scene
  105963. * @param scene Defines the scene to register the component in
  105964. */
  105965. constructor(scene: Scene);
  105966. /**
  105967. * Registers the component in a given scene
  105968. */
  105969. register(): void;
  105970. /**
  105971. * Return the list of active meshes
  105972. * @returns the list of active meshes
  105973. */
  105974. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  105975. /**
  105976. * Return the list of active sub meshes
  105977. * @param mesh The mesh to get the candidates sub meshes from
  105978. * @returns the list of active sub meshes
  105979. */
  105980. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  105981. private _tempRay;
  105982. /**
  105983. * Return the list of sub meshes intersecting with a given local ray
  105984. * @param mesh defines the mesh to find the submesh for
  105985. * @param localRay defines the ray in local space
  105986. * @returns the list of intersecting sub meshes
  105987. */
  105988. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  105989. /**
  105990. * Return the list of sub meshes colliding with a collider
  105991. * @param mesh defines the mesh to find the submesh for
  105992. * @param collider defines the collider to evaluate the collision against
  105993. * @returns the list of colliding sub meshes
  105994. */
  105995. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  105996. /**
  105997. * Rebuilds the elements related to this component in case of
  105998. * context lost for instance.
  105999. */
  106000. rebuild(): void;
  106001. /**
  106002. * Disposes the component and the associated ressources.
  106003. */
  106004. dispose(): void;
  106005. }
  106006. }
  106007. declare module BABYLON {
  106008. /**
  106009. * Renders a layer on top of an existing scene
  106010. */
  106011. export class UtilityLayerRenderer implements IDisposable {
  106012. /** the original scene that will be rendered on top of */
  106013. originalScene: Scene;
  106014. private _pointerCaptures;
  106015. private _lastPointerEvents;
  106016. private static _DefaultUtilityLayer;
  106017. private static _DefaultKeepDepthUtilityLayer;
  106018. private _sharedGizmoLight;
  106019. private _renderCamera;
  106020. /**
  106021. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  106022. * @returns the camera that is used when rendering the utility layer
  106023. */
  106024. getRenderCamera(): Nullable<Camera>;
  106025. /**
  106026. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  106027. * @param cam the camera that should be used when rendering the utility layer
  106028. */
  106029. setRenderCamera(cam: Nullable<Camera>): void;
  106030. /**
  106031. * @hidden
  106032. * Light which used by gizmos to get light shading
  106033. */
  106034. _getSharedGizmoLight(): HemisphericLight;
  106035. /**
  106036. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  106037. */
  106038. pickUtilitySceneFirst: boolean;
  106039. /**
  106040. * 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)
  106041. */
  106042. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  106043. /**
  106044. * 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)
  106045. */
  106046. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  106047. /**
  106048. * The scene that is rendered on top of the original scene
  106049. */
  106050. utilityLayerScene: Scene;
  106051. /**
  106052. * If the utility layer should automatically be rendered on top of existing scene
  106053. */
  106054. shouldRender: boolean;
  106055. /**
  106056. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  106057. */
  106058. onlyCheckPointerDownEvents: boolean;
  106059. /**
  106060. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  106061. */
  106062. processAllEvents: boolean;
  106063. /**
  106064. * Observable raised when the pointer move from the utility layer scene to the main scene
  106065. */
  106066. onPointerOutObservable: Observable<number>;
  106067. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  106068. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  106069. private _afterRenderObserver;
  106070. private _sceneDisposeObserver;
  106071. private _originalPointerObserver;
  106072. /**
  106073. * Instantiates a UtilityLayerRenderer
  106074. * @param originalScene the original scene that will be rendered on top of
  106075. * @param handleEvents boolean indicating if the utility layer should handle events
  106076. */
  106077. constructor(
  106078. /** the original scene that will be rendered on top of */
  106079. originalScene: Scene, handleEvents?: boolean);
  106080. private _notifyObservers;
  106081. /**
  106082. * Renders the utility layers scene on top of the original scene
  106083. */
  106084. render(): void;
  106085. /**
  106086. * Disposes of the renderer
  106087. */
  106088. dispose(): void;
  106089. private _updateCamera;
  106090. }
  106091. }
  106092. declare module BABYLON {
  106093. /**
  106094. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  106095. */
  106096. export class Gizmo implements IDisposable {
  106097. /** The utility layer the gizmo will be added to */
  106098. gizmoLayer: UtilityLayerRenderer;
  106099. /**
  106100. * The root mesh of the gizmo
  106101. */
  106102. _rootMesh: Mesh;
  106103. private _attachedMesh;
  106104. /**
  106105. * Ratio for the scale of the gizmo (Default: 1)
  106106. */
  106107. scaleRatio: number;
  106108. /**
  106109. * If a custom mesh has been set (Default: false)
  106110. */
  106111. protected _customMeshSet: boolean;
  106112. /**
  106113. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  106114. * * When set, interactions will be enabled
  106115. */
  106116. attachedMesh: Nullable<AbstractMesh>;
  106117. /**
  106118. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  106119. * @param mesh The mesh to replace the default mesh of the gizmo
  106120. */
  106121. setCustomMesh(mesh: Mesh): void;
  106122. /**
  106123. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  106124. */
  106125. updateGizmoRotationToMatchAttachedMesh: boolean;
  106126. /**
  106127. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  106128. */
  106129. updateGizmoPositionToMatchAttachedMesh: boolean;
  106130. /**
  106131. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  106132. */
  106133. updateScale: boolean;
  106134. protected _interactionsEnabled: boolean;
  106135. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106136. private _beforeRenderObserver;
  106137. private _tempVector;
  106138. /**
  106139. * Creates a gizmo
  106140. * @param gizmoLayer The utility layer the gizmo will be added to
  106141. */
  106142. constructor(
  106143. /** The utility layer the gizmo will be added to */
  106144. gizmoLayer?: UtilityLayerRenderer);
  106145. /**
  106146. * Updates the gizmo to match the attached mesh's position/rotation
  106147. */
  106148. protected _update(): void;
  106149. /**
  106150. * Disposes of the gizmo
  106151. */
  106152. dispose(): void;
  106153. }
  106154. }
  106155. declare module BABYLON {
  106156. /**
  106157. * Single plane drag gizmo
  106158. */
  106159. export class PlaneDragGizmo extends Gizmo {
  106160. /**
  106161. * Drag behavior responsible for the gizmos dragging interactions
  106162. */
  106163. dragBehavior: PointerDragBehavior;
  106164. private _pointerObserver;
  106165. /**
  106166. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106167. */
  106168. snapDistance: number;
  106169. /**
  106170. * Event that fires each time the gizmo snaps to a new location.
  106171. * * snapDistance is the the change in distance
  106172. */
  106173. onSnapObservable: Observable<{
  106174. snapDistance: number;
  106175. }>;
  106176. private _plane;
  106177. private _coloredMaterial;
  106178. private _hoverMaterial;
  106179. private _isEnabled;
  106180. private _parent;
  106181. /** @hidden */
  106182. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  106183. /** @hidden */
  106184. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  106185. /**
  106186. * Creates a PlaneDragGizmo
  106187. * @param gizmoLayer The utility layer the gizmo will be added to
  106188. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  106189. * @param color The color of the gizmo
  106190. */
  106191. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  106192. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106193. /**
  106194. * If the gizmo is enabled
  106195. */
  106196. isEnabled: boolean;
  106197. /**
  106198. * Disposes of the gizmo
  106199. */
  106200. dispose(): void;
  106201. }
  106202. }
  106203. declare module BABYLON {
  106204. /**
  106205. * Gizmo that enables dragging a mesh along 3 axis
  106206. */
  106207. export class PositionGizmo extends Gizmo {
  106208. /**
  106209. * Internal gizmo used for interactions on the x axis
  106210. */
  106211. xGizmo: AxisDragGizmo;
  106212. /**
  106213. * Internal gizmo used for interactions on the y axis
  106214. */
  106215. yGizmo: AxisDragGizmo;
  106216. /**
  106217. * Internal gizmo used for interactions on the z axis
  106218. */
  106219. zGizmo: AxisDragGizmo;
  106220. /**
  106221. * Internal gizmo used for interactions on the yz plane
  106222. */
  106223. xPlaneGizmo: PlaneDragGizmo;
  106224. /**
  106225. * Internal gizmo used for interactions on the xz plane
  106226. */
  106227. yPlaneGizmo: PlaneDragGizmo;
  106228. /**
  106229. * Internal gizmo used for interactions on the xy plane
  106230. */
  106231. zPlaneGizmo: PlaneDragGizmo;
  106232. /**
  106233. * private variables
  106234. */
  106235. private _meshAttached;
  106236. private _updateGizmoRotationToMatchAttachedMesh;
  106237. private _snapDistance;
  106238. private _scaleRatio;
  106239. /** Fires an event when any of it's sub gizmos are dragged */
  106240. onDragStartObservable: Observable<unknown>;
  106241. /** Fires an event when any of it's sub gizmos are released from dragging */
  106242. onDragEndObservable: Observable<unknown>;
  106243. /**
  106244. * If set to true, planar drag is enabled
  106245. */
  106246. private _planarGizmoEnabled;
  106247. attachedMesh: Nullable<AbstractMesh>;
  106248. /**
  106249. * Creates a PositionGizmo
  106250. * @param gizmoLayer The utility layer the gizmo will be added to
  106251. */
  106252. constructor(gizmoLayer?: UtilityLayerRenderer);
  106253. /**
  106254. * If the planar drag gizmo is enabled
  106255. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  106256. */
  106257. planarGizmoEnabled: boolean;
  106258. updateGizmoRotationToMatchAttachedMesh: boolean;
  106259. /**
  106260. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106261. */
  106262. snapDistance: number;
  106263. /**
  106264. * Ratio for the scale of the gizmo (Default: 1)
  106265. */
  106266. scaleRatio: number;
  106267. /**
  106268. * Disposes of the gizmo
  106269. */
  106270. dispose(): void;
  106271. /**
  106272. * CustomMeshes are not supported by this gizmo
  106273. * @param mesh The mesh to replace the default mesh of the gizmo
  106274. */
  106275. setCustomMesh(mesh: Mesh): void;
  106276. }
  106277. }
  106278. declare module BABYLON {
  106279. /**
  106280. * Single axis drag gizmo
  106281. */
  106282. export class AxisDragGizmo extends Gizmo {
  106283. /**
  106284. * Drag behavior responsible for the gizmos dragging interactions
  106285. */
  106286. dragBehavior: PointerDragBehavior;
  106287. private _pointerObserver;
  106288. /**
  106289. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106290. */
  106291. snapDistance: number;
  106292. /**
  106293. * Event that fires each time the gizmo snaps to a new location.
  106294. * * snapDistance is the the change in distance
  106295. */
  106296. onSnapObservable: Observable<{
  106297. snapDistance: number;
  106298. }>;
  106299. private _isEnabled;
  106300. private _parent;
  106301. private _arrow;
  106302. private _coloredMaterial;
  106303. private _hoverMaterial;
  106304. /** @hidden */
  106305. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  106306. /** @hidden */
  106307. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  106308. /**
  106309. * Creates an AxisDragGizmo
  106310. * @param gizmoLayer The utility layer the gizmo will be added to
  106311. * @param dragAxis The axis which the gizmo will be able to drag on
  106312. * @param color The color of the gizmo
  106313. */
  106314. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  106315. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106316. /**
  106317. * If the gizmo is enabled
  106318. */
  106319. isEnabled: boolean;
  106320. /**
  106321. * Disposes of the gizmo
  106322. */
  106323. dispose(): void;
  106324. }
  106325. }
  106326. declare module BABYLON.Debug {
  106327. /**
  106328. * The Axes viewer will show 3 axes in a specific point in space
  106329. */
  106330. export class AxesViewer {
  106331. private _xAxis;
  106332. private _yAxis;
  106333. private _zAxis;
  106334. private _scaleLinesFactor;
  106335. private _instanced;
  106336. /**
  106337. * Gets the hosting scene
  106338. */
  106339. scene: Scene;
  106340. /**
  106341. * Gets or sets a number used to scale line length
  106342. */
  106343. scaleLines: number;
  106344. /** Gets the node hierarchy used to render x-axis */
  106345. readonly xAxis: TransformNode;
  106346. /** Gets the node hierarchy used to render y-axis */
  106347. readonly yAxis: TransformNode;
  106348. /** Gets the node hierarchy used to render z-axis */
  106349. readonly zAxis: TransformNode;
  106350. /**
  106351. * Creates a new AxesViewer
  106352. * @param scene defines the hosting scene
  106353. * @param scaleLines defines a number used to scale line length (1 by default)
  106354. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  106355. * @param xAxis defines the node hierarchy used to render the x-axis
  106356. * @param yAxis defines the node hierarchy used to render the y-axis
  106357. * @param zAxis defines the node hierarchy used to render the z-axis
  106358. */
  106359. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  106360. /**
  106361. * Force the viewer to update
  106362. * @param position defines the position of the viewer
  106363. * @param xaxis defines the x axis of the viewer
  106364. * @param yaxis defines the y axis of the viewer
  106365. * @param zaxis defines the z axis of the viewer
  106366. */
  106367. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  106368. /**
  106369. * Creates an instance of this axes viewer.
  106370. * @returns a new axes viewer with instanced meshes
  106371. */
  106372. createInstance(): AxesViewer;
  106373. /** Releases resources */
  106374. dispose(): void;
  106375. private static _SetRenderingGroupId;
  106376. }
  106377. }
  106378. declare module BABYLON.Debug {
  106379. /**
  106380. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  106381. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  106382. */
  106383. export class BoneAxesViewer extends AxesViewer {
  106384. /**
  106385. * Gets or sets the target mesh where to display the axes viewer
  106386. */
  106387. mesh: Nullable<Mesh>;
  106388. /**
  106389. * Gets or sets the target bone where to display the axes viewer
  106390. */
  106391. bone: Nullable<Bone>;
  106392. /** Gets current position */
  106393. pos: Vector3;
  106394. /** Gets direction of X axis */
  106395. xaxis: Vector3;
  106396. /** Gets direction of Y axis */
  106397. yaxis: Vector3;
  106398. /** Gets direction of Z axis */
  106399. zaxis: Vector3;
  106400. /**
  106401. * Creates a new BoneAxesViewer
  106402. * @param scene defines the hosting scene
  106403. * @param bone defines the target bone
  106404. * @param mesh defines the target mesh
  106405. * @param scaleLines defines a scaling factor for line length (1 by default)
  106406. */
  106407. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  106408. /**
  106409. * Force the viewer to update
  106410. */
  106411. update(): void;
  106412. /** Releases resources */
  106413. dispose(): void;
  106414. }
  106415. }
  106416. declare module BABYLON {
  106417. /**
  106418. * Interface used to define scene explorer extensibility option
  106419. */
  106420. export interface IExplorerExtensibilityOption {
  106421. /**
  106422. * Define the option label
  106423. */
  106424. label: string;
  106425. /**
  106426. * Defines the action to execute on click
  106427. */
  106428. action: (entity: any) => void;
  106429. }
  106430. /**
  106431. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  106432. */
  106433. export interface IExplorerExtensibilityGroup {
  106434. /**
  106435. * Defines a predicate to test if a given type mut be extended
  106436. */
  106437. predicate: (entity: any) => boolean;
  106438. /**
  106439. * Gets the list of options added to a type
  106440. */
  106441. entries: IExplorerExtensibilityOption[];
  106442. }
  106443. /**
  106444. * Interface used to define the options to use to create the Inspector
  106445. */
  106446. export interface IInspectorOptions {
  106447. /**
  106448. * Display in overlay mode (default: false)
  106449. */
  106450. overlay?: boolean;
  106451. /**
  106452. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  106453. */
  106454. globalRoot?: HTMLElement;
  106455. /**
  106456. * Display the Scene explorer
  106457. */
  106458. showExplorer?: boolean;
  106459. /**
  106460. * Display the property inspector
  106461. */
  106462. showInspector?: boolean;
  106463. /**
  106464. * Display in embed mode (both panes on the right)
  106465. */
  106466. embedMode?: boolean;
  106467. /**
  106468. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  106469. */
  106470. handleResize?: boolean;
  106471. /**
  106472. * Allow the panes to popup (default: true)
  106473. */
  106474. enablePopup?: boolean;
  106475. /**
  106476. * Allow the panes to be closed by users (default: true)
  106477. */
  106478. enableClose?: boolean;
  106479. /**
  106480. * Optional list of extensibility entries
  106481. */
  106482. explorerExtensibility?: IExplorerExtensibilityGroup[];
  106483. /**
  106484. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  106485. */
  106486. inspectorURL?: string;
  106487. }
  106488. interface Scene {
  106489. /**
  106490. * @hidden
  106491. * Backing field
  106492. */
  106493. _debugLayer: DebugLayer;
  106494. /**
  106495. * Gets the debug layer (aka Inspector) associated with the scene
  106496. * @see http://doc.babylonjs.com/features/playground_debuglayer
  106497. */
  106498. debugLayer: DebugLayer;
  106499. }
  106500. /**
  106501. * The debug layer (aka Inspector) is the go to tool in order to better understand
  106502. * what is happening in your scene
  106503. * @see http://doc.babylonjs.com/features/playground_debuglayer
  106504. */
  106505. export class DebugLayer {
  106506. /**
  106507. * Define the url to get the inspector script from.
  106508. * By default it uses the babylonjs CDN.
  106509. * @ignoreNaming
  106510. */
  106511. static InspectorURL: string;
  106512. private _scene;
  106513. private BJSINSPECTOR;
  106514. private _onPropertyChangedObservable?;
  106515. /**
  106516. * Observable triggered when a property is changed through the inspector.
  106517. */
  106518. readonly onPropertyChangedObservable: any;
  106519. /**
  106520. * Instantiates a new debug layer.
  106521. * The debug layer (aka Inspector) is the go to tool in order to better understand
  106522. * what is happening in your scene
  106523. * @see http://doc.babylonjs.com/features/playground_debuglayer
  106524. * @param scene Defines the scene to inspect
  106525. */
  106526. constructor(scene: Scene);
  106527. /** Creates the inspector window. */
  106528. private _createInspector;
  106529. /**
  106530. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  106531. * @param entity defines the entity to select
  106532. * @param lineContainerTitle defines the specific block to highlight
  106533. */
  106534. select(entity: any, lineContainerTitle?: string): void;
  106535. /** Get the inspector from bundle or global */
  106536. private _getGlobalInspector;
  106537. /**
  106538. * Get if the inspector is visible or not.
  106539. * @returns true if visible otherwise, false
  106540. */
  106541. isVisible(): boolean;
  106542. /**
  106543. * Hide the inspector and close its window.
  106544. */
  106545. hide(): void;
  106546. /**
  106547. * Launch the debugLayer.
  106548. * @param config Define the configuration of the inspector
  106549. * @return a promise fulfilled when the debug layer is visible
  106550. */
  106551. show(config?: IInspectorOptions): Promise<DebugLayer>;
  106552. }
  106553. }
  106554. declare module BABYLON {
  106555. /**
  106556. * Class containing static functions to help procedurally build meshes
  106557. */
  106558. export class BoxBuilder {
  106559. /**
  106560. * Creates a box mesh
  106561. * * The parameter `size` sets the size (float) of each box side (default 1)
  106562. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  106563. * * 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)
  106564. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  106565. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106566. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106568. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  106569. * @param name defines the name of the mesh
  106570. * @param options defines the options used to create the mesh
  106571. * @param scene defines the hosting scene
  106572. * @returns the box mesh
  106573. */
  106574. static CreateBox(name: string, options: {
  106575. size?: number;
  106576. width?: number;
  106577. height?: number;
  106578. depth?: number;
  106579. faceUV?: Vector4[];
  106580. faceColors?: Color4[];
  106581. sideOrientation?: number;
  106582. frontUVs?: Vector4;
  106583. backUVs?: Vector4;
  106584. wrap?: boolean;
  106585. topBaseAt?: number;
  106586. bottomBaseAt?: number;
  106587. updatable?: boolean;
  106588. }, scene?: Nullable<Scene>): Mesh;
  106589. }
  106590. }
  106591. declare module BABYLON {
  106592. /**
  106593. * Class containing static functions to help procedurally build meshes
  106594. */
  106595. export class SphereBuilder {
  106596. /**
  106597. * Creates a sphere mesh
  106598. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  106599. * * 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`)
  106600. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  106601. * * 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
  106602. * * 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)
  106603. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106604. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106606. * @param name defines the name of the mesh
  106607. * @param options defines the options used to create the mesh
  106608. * @param scene defines the hosting scene
  106609. * @returns the sphere mesh
  106610. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  106611. */
  106612. static CreateSphere(name: string, options: {
  106613. segments?: number;
  106614. diameter?: number;
  106615. diameterX?: number;
  106616. diameterY?: number;
  106617. diameterZ?: number;
  106618. arc?: number;
  106619. slice?: number;
  106620. sideOrientation?: number;
  106621. frontUVs?: Vector4;
  106622. backUVs?: Vector4;
  106623. updatable?: boolean;
  106624. }, scene: any): Mesh;
  106625. }
  106626. }
  106627. declare module BABYLON.Debug {
  106628. /**
  106629. * Used to show the physics impostor around the specific mesh
  106630. */
  106631. export class PhysicsViewer {
  106632. /** @hidden */
  106633. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  106634. /** @hidden */
  106635. protected _meshes: Array<Nullable<AbstractMesh>>;
  106636. /** @hidden */
  106637. protected _scene: Nullable<Scene>;
  106638. /** @hidden */
  106639. protected _numMeshes: number;
  106640. /** @hidden */
  106641. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  106642. private _renderFunction;
  106643. private _utilityLayer;
  106644. private _debugBoxMesh;
  106645. private _debugSphereMesh;
  106646. private _debugCylinderMesh;
  106647. private _debugMaterial;
  106648. private _debugMeshMeshes;
  106649. /**
  106650. * Creates a new PhysicsViewer
  106651. * @param scene defines the hosting scene
  106652. */
  106653. constructor(scene: Scene);
  106654. /** @hidden */
  106655. protected _updateDebugMeshes(): void;
  106656. /**
  106657. * Renders a specified physic impostor
  106658. * @param impostor defines the impostor to render
  106659. * @param targetMesh defines the mesh represented by the impostor
  106660. * @returns the new debug mesh used to render the impostor
  106661. */
  106662. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  106663. /**
  106664. * Hides a specified physic impostor
  106665. * @param impostor defines the impostor to hide
  106666. */
  106667. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  106668. private _getDebugMaterial;
  106669. private _getDebugBoxMesh;
  106670. private _getDebugSphereMesh;
  106671. private _getDebugCylinderMesh;
  106672. private _getDebugMeshMesh;
  106673. private _getDebugMesh;
  106674. /** Releases all resources */
  106675. dispose(): void;
  106676. }
  106677. }
  106678. declare module BABYLON {
  106679. /**
  106680. * Class containing static functions to help procedurally build meshes
  106681. */
  106682. export class LinesBuilder {
  106683. /**
  106684. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  106685. * * 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
  106686. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  106687. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  106688. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  106689. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  106690. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  106691. * * 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
  106692. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  106693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106694. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  106695. * @param name defines the name of the new line system
  106696. * @param options defines the options used to create the line system
  106697. * @param scene defines the hosting scene
  106698. * @returns a new line system mesh
  106699. */
  106700. static CreateLineSystem(name: string, options: {
  106701. lines: Vector3[][];
  106702. updatable?: boolean;
  106703. instance?: Nullable<LinesMesh>;
  106704. colors?: Nullable<Color4[][]>;
  106705. useVertexAlpha?: boolean;
  106706. }, scene: Nullable<Scene>): LinesMesh;
  106707. /**
  106708. * Creates a line mesh
  106709. * 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
  106710. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  106711. * * The parameter `points` is an array successive Vector3
  106712. * * 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
  106713. * * The optional parameter `colors` is an array of successive Color4, one per line point
  106714. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  106715. * * When updating an instance, remember that only point positions can change, not the number of points
  106716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106717. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  106718. * @param name defines the name of the new line system
  106719. * @param options defines the options used to create the line system
  106720. * @param scene defines the hosting scene
  106721. * @returns a new line mesh
  106722. */
  106723. static CreateLines(name: string, options: {
  106724. points: Vector3[];
  106725. updatable?: boolean;
  106726. instance?: Nullable<LinesMesh>;
  106727. colors?: Color4[];
  106728. useVertexAlpha?: boolean;
  106729. }, scene?: Nullable<Scene>): LinesMesh;
  106730. /**
  106731. * Creates a dashed line mesh
  106732. * * 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
  106733. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  106734. * * The parameter `points` is an array successive Vector3
  106735. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  106736. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  106737. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  106738. * * 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
  106739. * * When updating an instance, remember that only point positions can change, not the number of points
  106740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106741. * @param name defines the name of the mesh
  106742. * @param options defines the options used to create the mesh
  106743. * @param scene defines the hosting scene
  106744. * @returns the dashed line mesh
  106745. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  106746. */
  106747. static CreateDashedLines(name: string, options: {
  106748. points: Vector3[];
  106749. dashSize?: number;
  106750. gapSize?: number;
  106751. dashNb?: number;
  106752. updatable?: boolean;
  106753. instance?: LinesMesh;
  106754. }, scene?: Nullable<Scene>): LinesMesh;
  106755. }
  106756. }
  106757. declare module BABYLON {
  106758. /**
  106759. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  106760. * in order to better appreciate the issue one might have.
  106761. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  106762. */
  106763. export class RayHelper {
  106764. /**
  106765. * Defines the ray we are currently tryin to visualize.
  106766. */
  106767. ray: Nullable<Ray>;
  106768. private _renderPoints;
  106769. private _renderLine;
  106770. private _renderFunction;
  106771. private _scene;
  106772. private _updateToMeshFunction;
  106773. private _attachedToMesh;
  106774. private _meshSpaceDirection;
  106775. private _meshSpaceOrigin;
  106776. /**
  106777. * Helper function to create a colored helper in a scene in one line.
  106778. * @param ray Defines the ray we are currently tryin to visualize
  106779. * @param scene Defines the scene the ray is used in
  106780. * @param color Defines the color we want to see the ray in
  106781. * @returns The newly created ray helper.
  106782. */
  106783. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  106784. /**
  106785. * Instantiate a new ray helper.
  106786. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  106787. * in order to better appreciate the issue one might have.
  106788. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  106789. * @param ray Defines the ray we are currently tryin to visualize
  106790. */
  106791. constructor(ray: Ray);
  106792. /**
  106793. * Shows the ray we are willing to debug.
  106794. * @param scene Defines the scene the ray needs to be rendered in
  106795. * @param color Defines the color the ray needs to be rendered in
  106796. */
  106797. show(scene: Scene, color?: Color3): void;
  106798. /**
  106799. * Hides the ray we are debugging.
  106800. */
  106801. hide(): void;
  106802. private _render;
  106803. /**
  106804. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  106805. * @param mesh Defines the mesh we want the helper attached to
  106806. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  106807. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  106808. * @param length Defines the length of the ray
  106809. */
  106810. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  106811. /**
  106812. * Detach the ray helper from the mesh it has previously been attached to.
  106813. */
  106814. detachFromMesh(): void;
  106815. private _updateToMesh;
  106816. /**
  106817. * Dispose the helper and release its associated resources.
  106818. */
  106819. dispose(): void;
  106820. }
  106821. }
  106822. declare module BABYLON.Debug {
  106823. /**
  106824. * Class used to render a debug view of a given skeleton
  106825. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  106826. */
  106827. export class SkeletonViewer {
  106828. /** defines the skeleton to render */
  106829. skeleton: Skeleton;
  106830. /** defines the mesh attached to the skeleton */
  106831. mesh: AbstractMesh;
  106832. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  106833. autoUpdateBonesMatrices: boolean;
  106834. /** defines the rendering group id to use with the viewer */
  106835. renderingGroupId: number;
  106836. /** Gets or sets the color used to render the skeleton */
  106837. color: Color3;
  106838. private _scene;
  106839. private _debugLines;
  106840. private _debugMesh;
  106841. private _isEnabled;
  106842. private _renderFunction;
  106843. private _utilityLayer;
  106844. /**
  106845. * Returns the mesh used to render the bones
  106846. */
  106847. readonly debugMesh: Nullable<LinesMesh>;
  106848. /**
  106849. * Creates a new SkeletonViewer
  106850. * @param skeleton defines the skeleton to render
  106851. * @param mesh defines the mesh attached to the skeleton
  106852. * @param scene defines the hosting scene
  106853. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  106854. * @param renderingGroupId defines the rendering group id to use with the viewer
  106855. */
  106856. constructor(
  106857. /** defines the skeleton to render */
  106858. skeleton: Skeleton,
  106859. /** defines the mesh attached to the skeleton */
  106860. mesh: AbstractMesh, scene: Scene,
  106861. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  106862. autoUpdateBonesMatrices?: boolean,
  106863. /** defines the rendering group id to use with the viewer */
  106864. renderingGroupId?: number);
  106865. /** Gets or sets a boolean indicating if the viewer is enabled */
  106866. isEnabled: boolean;
  106867. private _getBonePosition;
  106868. private _getLinesForBonesWithLength;
  106869. private _getLinesForBonesNoLength;
  106870. /** Update the viewer to sync with current skeleton state */
  106871. update(): void;
  106872. /** Release associated resources */
  106873. dispose(): void;
  106874. }
  106875. }
  106876. declare module BABYLON {
  106877. /**
  106878. * Options to create the null engine
  106879. */
  106880. export class NullEngineOptions {
  106881. /**
  106882. * Render width (Default: 512)
  106883. */
  106884. renderWidth: number;
  106885. /**
  106886. * Render height (Default: 256)
  106887. */
  106888. renderHeight: number;
  106889. /**
  106890. * Texture size (Default: 512)
  106891. */
  106892. textureSize: number;
  106893. /**
  106894. * If delta time between frames should be constant
  106895. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106896. */
  106897. deterministicLockstep: boolean;
  106898. /**
  106899. * Maximum about of steps between frames (Default: 4)
  106900. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106901. */
  106902. lockstepMaxSteps: number;
  106903. }
  106904. /**
  106905. * The null engine class provides support for headless version of babylon.js.
  106906. * This can be used in server side scenario or for testing purposes
  106907. */
  106908. export class NullEngine extends Engine {
  106909. private _options;
  106910. /**
  106911. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106912. */
  106913. isDeterministicLockStep(): boolean;
  106914. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  106915. getLockstepMaxSteps(): number;
  106916. /**
  106917. * Sets hardware scaling, used to save performance if needed
  106918. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  106919. */
  106920. getHardwareScalingLevel(): number;
  106921. constructor(options?: NullEngineOptions);
  106922. createVertexBuffer(vertices: FloatArray): DataBuffer;
  106923. createIndexBuffer(indices: IndicesArray): DataBuffer;
  106924. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  106925. getRenderWidth(useScreen?: boolean): number;
  106926. getRenderHeight(useScreen?: boolean): number;
  106927. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  106928. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  106929. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  106930. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  106931. bindSamplers(effect: Effect): void;
  106932. enableEffect(effect: Effect): void;
  106933. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  106934. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  106935. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  106936. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  106937. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  106938. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  106939. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  106940. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  106941. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  106942. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  106943. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  106944. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  106945. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  106946. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  106947. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  106948. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  106949. setFloat(uniform: WebGLUniformLocation, value: number): void;
  106950. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  106951. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  106952. setBool(uniform: WebGLUniformLocation, bool: number): void;
  106953. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  106954. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  106955. bindBuffers(vertexBuffers: {
  106956. [key: string]: VertexBuffer;
  106957. }, indexBuffer: DataBuffer, effect: Effect): void;
  106958. wipeCaches(bruteForce?: boolean): void;
  106959. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  106960. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  106961. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  106962. /** @hidden */
  106963. _createTexture(): WebGLTexture;
  106964. /** @hidden */
  106965. _releaseTexture(texture: InternalTexture): void;
  106966. 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;
  106967. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  106968. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  106969. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  106970. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  106971. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  106972. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  106973. areAllEffectsReady(): boolean;
  106974. /**
  106975. * @hidden
  106976. * Get the current error code of the webGL context
  106977. * @returns the error code
  106978. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  106979. */
  106980. getError(): number;
  106981. /** @hidden */
  106982. _getUnpackAlignement(): number;
  106983. /** @hidden */
  106984. _unpackFlipY(value: boolean): void;
  106985. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  106986. /**
  106987. * Updates a dynamic vertex buffer.
  106988. * @param vertexBuffer the vertex buffer to update
  106989. * @param data the data used to update the vertex buffer
  106990. * @param byteOffset the byte offset of the data (optional)
  106991. * @param byteLength the byte length of the data (optional)
  106992. */
  106993. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  106994. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  106995. /** @hidden */
  106996. _bindTexture(channel: number, texture: InternalTexture): void;
  106997. /** @hidden */
  106998. _releaseBuffer(buffer: DataBuffer): boolean;
  106999. releaseEffects(): void;
  107000. displayLoadingUI(): void;
  107001. hideLoadingUI(): void;
  107002. /** @hidden */
  107003. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  107004. /** @hidden */
  107005. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  107006. /** @hidden */
  107007. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  107008. /** @hidden */
  107009. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  107010. }
  107011. }
  107012. declare module BABYLON {
  107013. /** @hidden */
  107014. export class _OcclusionDataStorage {
  107015. /** @hidden */
  107016. occlusionInternalRetryCounter: number;
  107017. /** @hidden */
  107018. isOcclusionQueryInProgress: boolean;
  107019. /** @hidden */
  107020. isOccluded: boolean;
  107021. /** @hidden */
  107022. occlusionRetryCount: number;
  107023. /** @hidden */
  107024. occlusionType: number;
  107025. /** @hidden */
  107026. occlusionQueryAlgorithmType: number;
  107027. }
  107028. interface Engine {
  107029. /**
  107030. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  107031. * @return the new query
  107032. */
  107033. createQuery(): WebGLQuery;
  107034. /**
  107035. * Delete and release a webGL query
  107036. * @param query defines the query to delete
  107037. * @return the current engine
  107038. */
  107039. deleteQuery(query: WebGLQuery): Engine;
  107040. /**
  107041. * Check if a given query has resolved and got its value
  107042. * @param query defines the query to check
  107043. * @returns true if the query got its value
  107044. */
  107045. isQueryResultAvailable(query: WebGLQuery): boolean;
  107046. /**
  107047. * Gets the value of a given query
  107048. * @param query defines the query to check
  107049. * @returns the value of the query
  107050. */
  107051. getQueryResult(query: WebGLQuery): number;
  107052. /**
  107053. * Initiates an occlusion query
  107054. * @param algorithmType defines the algorithm to use
  107055. * @param query defines the query to use
  107056. * @returns the current engine
  107057. * @see http://doc.babylonjs.com/features/occlusionquery
  107058. */
  107059. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  107060. /**
  107061. * Ends an occlusion query
  107062. * @see http://doc.babylonjs.com/features/occlusionquery
  107063. * @param algorithmType defines the algorithm to use
  107064. * @returns the current engine
  107065. */
  107066. endOcclusionQuery(algorithmType: number): Engine;
  107067. /**
  107068. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  107069. * Please note that only one query can be issued at a time
  107070. * @returns a time token used to track the time span
  107071. */
  107072. startTimeQuery(): Nullable<_TimeToken>;
  107073. /**
  107074. * Ends a time query
  107075. * @param token defines the token used to measure the time span
  107076. * @returns the time spent (in ns)
  107077. */
  107078. endTimeQuery(token: _TimeToken): int;
  107079. /** @hidden */
  107080. _currentNonTimestampToken: Nullable<_TimeToken>;
  107081. /** @hidden */
  107082. _createTimeQuery(): WebGLQuery;
  107083. /** @hidden */
  107084. _deleteTimeQuery(query: WebGLQuery): void;
  107085. /** @hidden */
  107086. _getGlAlgorithmType(algorithmType: number): number;
  107087. /** @hidden */
  107088. _getTimeQueryResult(query: WebGLQuery): any;
  107089. /** @hidden */
  107090. _getTimeQueryAvailability(query: WebGLQuery): any;
  107091. }
  107092. interface AbstractMesh {
  107093. /**
  107094. * Backing filed
  107095. * @hidden
  107096. */
  107097. __occlusionDataStorage: _OcclusionDataStorage;
  107098. /**
  107099. * Access property
  107100. * @hidden
  107101. */
  107102. _occlusionDataStorage: _OcclusionDataStorage;
  107103. /**
  107104. * 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.
  107105. * The default value is -1 which means don't break the query and wait till the result
  107106. * @see http://doc.babylonjs.com/features/occlusionquery
  107107. */
  107108. occlusionRetryCount: number;
  107109. /**
  107110. * 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:
  107111. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  107112. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  107113. * * 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.
  107114. * @see http://doc.babylonjs.com/features/occlusionquery
  107115. */
  107116. occlusionType: number;
  107117. /**
  107118. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  107119. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  107120. * * 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.
  107121. * @see http://doc.babylonjs.com/features/occlusionquery
  107122. */
  107123. occlusionQueryAlgorithmType: number;
  107124. /**
  107125. * 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
  107126. * @see http://doc.babylonjs.com/features/occlusionquery
  107127. */
  107128. isOccluded: boolean;
  107129. /**
  107130. * Flag to check the progress status of the query
  107131. * @see http://doc.babylonjs.com/features/occlusionquery
  107132. */
  107133. isOcclusionQueryInProgress: boolean;
  107134. }
  107135. }
  107136. declare module BABYLON {
  107137. /** @hidden */
  107138. export var _forceTransformFeedbackToBundle: boolean;
  107139. interface Engine {
  107140. /**
  107141. * Creates a webGL transform feedback object
  107142. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  107143. * @returns the webGL transform feedback object
  107144. */
  107145. createTransformFeedback(): WebGLTransformFeedback;
  107146. /**
  107147. * Delete a webGL transform feedback object
  107148. * @param value defines the webGL transform feedback object to delete
  107149. */
  107150. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  107151. /**
  107152. * Bind a webGL transform feedback object to the webgl context
  107153. * @param value defines the webGL transform feedback object to bind
  107154. */
  107155. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  107156. /**
  107157. * Begins a transform feedback operation
  107158. * @param usePoints defines if points or triangles must be used
  107159. */
  107160. beginTransformFeedback(usePoints: boolean): void;
  107161. /**
  107162. * Ends a transform feedback operation
  107163. */
  107164. endTransformFeedback(): void;
  107165. /**
  107166. * Specify the varyings to use with transform feedback
  107167. * @param program defines the associated webGL program
  107168. * @param value defines the list of strings representing the varying names
  107169. */
  107170. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  107171. /**
  107172. * Bind a webGL buffer for a transform feedback operation
  107173. * @param value defines the webGL buffer to bind
  107174. */
  107175. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  107176. }
  107177. }
  107178. declare module BABYLON {
  107179. /**
  107180. * Creation options of the multi render target texture.
  107181. */
  107182. export interface IMultiRenderTargetOptions {
  107183. /**
  107184. * Define if the texture needs to create mip maps after render.
  107185. */
  107186. generateMipMaps?: boolean;
  107187. /**
  107188. * Define the types of all the draw buffers we want to create
  107189. */
  107190. types?: number[];
  107191. /**
  107192. * Define the sampling modes of all the draw buffers we want to create
  107193. */
  107194. samplingModes?: number[];
  107195. /**
  107196. * Define if a depth buffer is required
  107197. */
  107198. generateDepthBuffer?: boolean;
  107199. /**
  107200. * Define if a stencil buffer is required
  107201. */
  107202. generateStencilBuffer?: boolean;
  107203. /**
  107204. * Define if a depth texture is required instead of a depth buffer
  107205. */
  107206. generateDepthTexture?: boolean;
  107207. /**
  107208. * Define the number of desired draw buffers
  107209. */
  107210. textureCount?: number;
  107211. /**
  107212. * Define if aspect ratio should be adapted to the texture or stay the scene one
  107213. */
  107214. doNotChangeAspectRatio?: boolean;
  107215. /**
  107216. * Define the default type of the buffers we are creating
  107217. */
  107218. defaultType?: number;
  107219. }
  107220. /**
  107221. * A multi render target, like a render target provides the ability to render to a texture.
  107222. * Unlike the render target, it can render to several draw buffers in one draw.
  107223. * This is specially interesting in deferred rendering or for any effects requiring more than
  107224. * just one color from a single pass.
  107225. */
  107226. export class MultiRenderTarget extends RenderTargetTexture {
  107227. private _internalTextures;
  107228. private _textures;
  107229. private _multiRenderTargetOptions;
  107230. /**
  107231. * Get if draw buffers are currently supported by the used hardware and browser.
  107232. */
  107233. readonly isSupported: boolean;
  107234. /**
  107235. * Get the list of textures generated by the multi render target.
  107236. */
  107237. readonly textures: Texture[];
  107238. /**
  107239. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  107240. */
  107241. readonly depthTexture: Texture;
  107242. /**
  107243. * Set the wrapping mode on U of all the textures we are rendering to.
  107244. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  107245. */
  107246. wrapU: number;
  107247. /**
  107248. * Set the wrapping mode on V of all the textures we are rendering to.
  107249. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  107250. */
  107251. wrapV: number;
  107252. /**
  107253. * Instantiate a new multi render target texture.
  107254. * A multi render target, like a render target provides the ability to render to a texture.
  107255. * Unlike the render target, it can render to several draw buffers in one draw.
  107256. * This is specially interesting in deferred rendering or for any effects requiring more than
  107257. * just one color from a single pass.
  107258. * @param name Define the name of the texture
  107259. * @param size Define the size of the buffers to render to
  107260. * @param count Define the number of target we are rendering into
  107261. * @param scene Define the scene the texture belongs to
  107262. * @param options Define the options used to create the multi render target
  107263. */
  107264. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  107265. /** @hidden */
  107266. _rebuild(): void;
  107267. private _createInternalTextures;
  107268. private _createTextures;
  107269. /**
  107270. * Define the number of samples used if MSAA is enabled.
  107271. */
  107272. samples: number;
  107273. /**
  107274. * Resize all the textures in the multi render target.
  107275. * Be carrefull as it will recreate all the data in the new texture.
  107276. * @param size Define the new size
  107277. */
  107278. resize(size: any): void;
  107279. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  107280. /**
  107281. * Dispose the render targets and their associated resources
  107282. */
  107283. dispose(): void;
  107284. /**
  107285. * Release all the underlying texture used as draw buffers.
  107286. */
  107287. releaseInternalTextures(): void;
  107288. }
  107289. }
  107290. declare module BABYLON {
  107291. interface Engine {
  107292. /**
  107293. * Unbind a list of render target textures from the webGL context
  107294. * This is used only when drawBuffer extension or webGL2 are active
  107295. * @param textures defines the render target textures to unbind
  107296. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  107297. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  107298. */
  107299. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  107300. /**
  107301. * Create a multi render target texture
  107302. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  107303. * @param size defines the size of the texture
  107304. * @param options defines the creation options
  107305. * @returns the cube texture as an InternalTexture
  107306. */
  107307. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  107308. /**
  107309. * Update the sample count for a given multiple render target texture
  107310. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  107311. * @param textures defines the textures to update
  107312. * @param samples defines the sample count to set
  107313. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  107314. */
  107315. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  107316. }
  107317. }
  107318. declare module BABYLON {
  107319. /**
  107320. * Gather the list of clipboard event types as constants.
  107321. */
  107322. export class ClipboardEventTypes {
  107323. /**
  107324. * The clipboard event is fired when a copy command is active (pressed).
  107325. */
  107326. static readonly COPY: number;
  107327. /**
  107328. * The clipboard event is fired when a cut command is active (pressed).
  107329. */
  107330. static readonly CUT: number;
  107331. /**
  107332. * The clipboard event is fired when a paste command is active (pressed).
  107333. */
  107334. static readonly PASTE: number;
  107335. }
  107336. /**
  107337. * This class is used to store clipboard related info for the onClipboardObservable event.
  107338. */
  107339. export class ClipboardInfo {
  107340. /**
  107341. * Defines the type of event (BABYLON.ClipboardEventTypes)
  107342. */
  107343. type: number;
  107344. /**
  107345. * Defines the related dom event
  107346. */
  107347. event: ClipboardEvent;
  107348. /**
  107349. *Creates an instance of ClipboardInfo.
  107350. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  107351. * @param event Defines the related dom event
  107352. */
  107353. constructor(
  107354. /**
  107355. * Defines the type of event (BABYLON.ClipboardEventTypes)
  107356. */
  107357. type: number,
  107358. /**
  107359. * Defines the related dom event
  107360. */
  107361. event: ClipboardEvent);
  107362. /**
  107363. * Get the clipboard event's type from the keycode.
  107364. * @param keyCode Defines the keyCode for the current keyboard event.
  107365. * @return {number}
  107366. */
  107367. static GetTypeFromCharacter(keyCode: number): number;
  107368. }
  107369. }
  107370. declare module BABYLON {
  107371. /**
  107372. * Google Daydream controller
  107373. */
  107374. export class DaydreamController extends WebVRController {
  107375. /**
  107376. * Base Url for the controller model.
  107377. */
  107378. static MODEL_BASE_URL: string;
  107379. /**
  107380. * File name for the controller model.
  107381. */
  107382. static MODEL_FILENAME: string;
  107383. /**
  107384. * Gamepad Id prefix used to identify Daydream Controller.
  107385. */
  107386. static readonly GAMEPAD_ID_PREFIX: string;
  107387. /**
  107388. * Creates a new DaydreamController from a gamepad
  107389. * @param vrGamepad the gamepad that the controller should be created from
  107390. */
  107391. constructor(vrGamepad: any);
  107392. /**
  107393. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107394. * @param scene scene in which to add meshes
  107395. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107396. */
  107397. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107398. /**
  107399. * Called once for each button that changed state since the last frame
  107400. * @param buttonIdx Which button index changed
  107401. * @param state New state of the button
  107402. * @param changes Which properties on the state changed since last frame
  107403. */
  107404. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107405. }
  107406. }
  107407. declare module BABYLON {
  107408. /**
  107409. * Gear VR Controller
  107410. */
  107411. export class GearVRController extends WebVRController {
  107412. /**
  107413. * Base Url for the controller model.
  107414. */
  107415. static MODEL_BASE_URL: string;
  107416. /**
  107417. * File name for the controller model.
  107418. */
  107419. static MODEL_FILENAME: string;
  107420. /**
  107421. * Gamepad Id prefix used to identify this controller.
  107422. */
  107423. static readonly GAMEPAD_ID_PREFIX: string;
  107424. private readonly _buttonIndexToObservableNameMap;
  107425. /**
  107426. * Creates a new GearVRController from a gamepad
  107427. * @param vrGamepad the gamepad that the controller should be created from
  107428. */
  107429. constructor(vrGamepad: any);
  107430. /**
  107431. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107432. * @param scene scene in which to add meshes
  107433. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107434. */
  107435. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107436. /**
  107437. * Called once for each button that changed state since the last frame
  107438. * @param buttonIdx Which button index changed
  107439. * @param state New state of the button
  107440. * @param changes Which properties on the state changed since last frame
  107441. */
  107442. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107443. }
  107444. }
  107445. declare module BABYLON {
  107446. /**
  107447. * Class containing static functions to help procedurally build meshes
  107448. */
  107449. export class PolyhedronBuilder {
  107450. /**
  107451. * Creates a polyhedron mesh
  107452. * * 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
  107453. * * The parameter `size` (positive float, default 1) sets the polygon size
  107454. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  107455. * * 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`
  107456. * * 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
  107457. * * 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)`)
  107458. * * 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
  107459. * * 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
  107460. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107461. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107463. * @param name defines the name of the mesh
  107464. * @param options defines the options used to create the mesh
  107465. * @param scene defines the hosting scene
  107466. * @returns the polyhedron mesh
  107467. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  107468. */
  107469. static CreatePolyhedron(name: string, options: {
  107470. type?: number;
  107471. size?: number;
  107472. sizeX?: number;
  107473. sizeY?: number;
  107474. sizeZ?: number;
  107475. custom?: any;
  107476. faceUV?: Vector4[];
  107477. faceColors?: Color4[];
  107478. flat?: boolean;
  107479. updatable?: boolean;
  107480. sideOrientation?: number;
  107481. frontUVs?: Vector4;
  107482. backUVs?: Vector4;
  107483. }, scene?: Nullable<Scene>): Mesh;
  107484. }
  107485. }
  107486. declare module BABYLON {
  107487. /**
  107488. * Gizmo that enables scaling a mesh along 3 axis
  107489. */
  107490. export class ScaleGizmo extends Gizmo {
  107491. /**
  107492. * Internal gizmo used for interactions on the x axis
  107493. */
  107494. xGizmo: AxisScaleGizmo;
  107495. /**
  107496. * Internal gizmo used for interactions on the y axis
  107497. */
  107498. yGizmo: AxisScaleGizmo;
  107499. /**
  107500. * Internal gizmo used for interactions on the z axis
  107501. */
  107502. zGizmo: AxisScaleGizmo;
  107503. /**
  107504. * Internal gizmo used to scale all axis equally
  107505. */
  107506. uniformScaleGizmo: AxisScaleGizmo;
  107507. private _meshAttached;
  107508. private _updateGizmoRotationToMatchAttachedMesh;
  107509. private _snapDistance;
  107510. private _scaleRatio;
  107511. private _uniformScalingMesh;
  107512. private _octahedron;
  107513. /** Fires an event when any of it's sub gizmos are dragged */
  107514. onDragStartObservable: Observable<unknown>;
  107515. /** Fires an event when any of it's sub gizmos are released from dragging */
  107516. onDragEndObservable: Observable<unknown>;
  107517. attachedMesh: Nullable<AbstractMesh>;
  107518. /**
  107519. * Creates a ScaleGizmo
  107520. * @param gizmoLayer The utility layer the gizmo will be added to
  107521. */
  107522. constructor(gizmoLayer?: UtilityLayerRenderer);
  107523. updateGizmoRotationToMatchAttachedMesh: boolean;
  107524. /**
  107525. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107526. */
  107527. snapDistance: number;
  107528. /**
  107529. * Ratio for the scale of the gizmo (Default: 1)
  107530. */
  107531. scaleRatio: number;
  107532. /**
  107533. * Disposes of the gizmo
  107534. */
  107535. dispose(): void;
  107536. }
  107537. }
  107538. declare module BABYLON {
  107539. /**
  107540. * Single axis scale gizmo
  107541. */
  107542. export class AxisScaleGizmo extends Gizmo {
  107543. /**
  107544. * Drag behavior responsible for the gizmos dragging interactions
  107545. */
  107546. dragBehavior: PointerDragBehavior;
  107547. private _pointerObserver;
  107548. /**
  107549. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107550. */
  107551. snapDistance: number;
  107552. /**
  107553. * Event that fires each time the gizmo snaps to a new location.
  107554. * * snapDistance is the the change in distance
  107555. */
  107556. onSnapObservable: Observable<{
  107557. snapDistance: number;
  107558. }>;
  107559. /**
  107560. * If the scaling operation should be done on all axis (default: false)
  107561. */
  107562. uniformScaling: boolean;
  107563. private _isEnabled;
  107564. private _parent;
  107565. private _arrow;
  107566. private _coloredMaterial;
  107567. private _hoverMaterial;
  107568. /**
  107569. * Creates an AxisScaleGizmo
  107570. * @param gizmoLayer The utility layer the gizmo will be added to
  107571. * @param dragAxis The axis which the gizmo will be able to scale on
  107572. * @param color The color of the gizmo
  107573. */
  107574. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  107575. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107576. /**
  107577. * If the gizmo is enabled
  107578. */
  107579. isEnabled: boolean;
  107580. /**
  107581. * Disposes of the gizmo
  107582. */
  107583. dispose(): void;
  107584. /**
  107585. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  107586. * @param mesh The mesh to replace the default mesh of the gizmo
  107587. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  107588. */
  107589. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  107590. }
  107591. }
  107592. declare module BABYLON {
  107593. /**
  107594. * Bounding box gizmo
  107595. */
  107596. export class BoundingBoxGizmo extends Gizmo {
  107597. private _lineBoundingBox;
  107598. private _rotateSpheresParent;
  107599. private _scaleBoxesParent;
  107600. private _boundingDimensions;
  107601. private _renderObserver;
  107602. private _pointerObserver;
  107603. private _scaleDragSpeed;
  107604. private _tmpQuaternion;
  107605. private _tmpVector;
  107606. private _tmpRotationMatrix;
  107607. /**
  107608. * 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)
  107609. */
  107610. ignoreChildren: boolean;
  107611. /**
  107612. * 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)
  107613. */
  107614. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  107615. /**
  107616. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  107617. */
  107618. rotationSphereSize: number;
  107619. /**
  107620. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  107621. */
  107622. scaleBoxSize: number;
  107623. /**
  107624. * 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)
  107625. */
  107626. fixedDragMeshScreenSize: boolean;
  107627. /**
  107628. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  107629. */
  107630. fixedDragMeshScreenSizeDistanceFactor: number;
  107631. /**
  107632. * Fired when a rotation sphere or scale box is dragged
  107633. */
  107634. onDragStartObservable: Observable<{}>;
  107635. /**
  107636. * Fired when a scale box is dragged
  107637. */
  107638. onScaleBoxDragObservable: Observable<{}>;
  107639. /**
  107640. * Fired when a scale box drag is ended
  107641. */
  107642. onScaleBoxDragEndObservable: Observable<{}>;
  107643. /**
  107644. * Fired when a rotation sphere is dragged
  107645. */
  107646. onRotationSphereDragObservable: Observable<{}>;
  107647. /**
  107648. * Fired when a rotation sphere drag is ended
  107649. */
  107650. onRotationSphereDragEndObservable: Observable<{}>;
  107651. /**
  107652. * 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)
  107653. */
  107654. scalePivot: Nullable<Vector3>;
  107655. /**
  107656. * Mesh used as a pivot to rotate the attached mesh
  107657. */
  107658. private _anchorMesh;
  107659. private _existingMeshScale;
  107660. private _dragMesh;
  107661. private pointerDragBehavior;
  107662. private coloredMaterial;
  107663. private hoverColoredMaterial;
  107664. /**
  107665. * Sets the color of the bounding box gizmo
  107666. * @param color the color to set
  107667. */
  107668. setColor(color: Color3): void;
  107669. /**
  107670. * Creates an BoundingBoxGizmo
  107671. * @param gizmoLayer The utility layer the gizmo will be added to
  107672. * @param color The color of the gizmo
  107673. */
  107674. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  107675. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107676. private _selectNode;
  107677. /**
  107678. * Updates the bounding box information for the Gizmo
  107679. */
  107680. updateBoundingBox(): void;
  107681. private _updateRotationSpheres;
  107682. private _updateScaleBoxes;
  107683. /**
  107684. * Enables rotation on the specified axis and disables rotation on the others
  107685. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  107686. */
  107687. setEnabledRotationAxis(axis: string): void;
  107688. /**
  107689. * Enables/disables scaling
  107690. * @param enable if scaling should be enabled
  107691. */
  107692. setEnabledScaling(enable: boolean): void;
  107693. private _updateDummy;
  107694. /**
  107695. * Enables a pointer drag behavior on the bounding box of the gizmo
  107696. */
  107697. enableDragBehavior(): void;
  107698. /**
  107699. * Disposes of the gizmo
  107700. */
  107701. dispose(): void;
  107702. /**
  107703. * 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)
  107704. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  107705. * @returns the bounding box mesh with the passed in mesh as a child
  107706. */
  107707. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  107708. /**
  107709. * CustomMeshes are not supported by this gizmo
  107710. * @param mesh The mesh to replace the default mesh of the gizmo
  107711. */
  107712. setCustomMesh(mesh: Mesh): void;
  107713. }
  107714. }
  107715. declare module BABYLON {
  107716. /**
  107717. * Single plane rotation gizmo
  107718. */
  107719. export class PlaneRotationGizmo extends Gizmo {
  107720. /**
  107721. * Drag behavior responsible for the gizmos dragging interactions
  107722. */
  107723. dragBehavior: PointerDragBehavior;
  107724. private _pointerObserver;
  107725. /**
  107726. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  107727. */
  107728. snapDistance: number;
  107729. /**
  107730. * Event that fires each time the gizmo snaps to a new location.
  107731. * * snapDistance is the the change in distance
  107732. */
  107733. onSnapObservable: Observable<{
  107734. snapDistance: number;
  107735. }>;
  107736. private _isEnabled;
  107737. private _parent;
  107738. /**
  107739. * Creates a PlaneRotationGizmo
  107740. * @param gizmoLayer The utility layer the gizmo will be added to
  107741. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  107742. * @param color The color of the gizmo
  107743. * @param tessellation Amount of tessellation to be used when creating rotation circles
  107744. */
  107745. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  107746. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107747. /**
  107748. * If the gizmo is enabled
  107749. */
  107750. isEnabled: boolean;
  107751. /**
  107752. * Disposes of the gizmo
  107753. */
  107754. dispose(): void;
  107755. }
  107756. }
  107757. declare module BABYLON {
  107758. /**
  107759. * Gizmo that enables rotating a mesh along 3 axis
  107760. */
  107761. export class RotationGizmo extends Gizmo {
  107762. /**
  107763. * Internal gizmo used for interactions on the x axis
  107764. */
  107765. xGizmo: PlaneRotationGizmo;
  107766. /**
  107767. * Internal gizmo used for interactions on the y axis
  107768. */
  107769. yGizmo: PlaneRotationGizmo;
  107770. /**
  107771. * Internal gizmo used for interactions on the z axis
  107772. */
  107773. zGizmo: PlaneRotationGizmo;
  107774. /** Fires an event when any of it's sub gizmos are dragged */
  107775. onDragStartObservable: Observable<unknown>;
  107776. /** Fires an event when any of it's sub gizmos are released from dragging */
  107777. onDragEndObservable: Observable<unknown>;
  107778. private _meshAttached;
  107779. attachedMesh: Nullable<AbstractMesh>;
  107780. /**
  107781. * Creates a RotationGizmo
  107782. * @param gizmoLayer The utility layer the gizmo will be added to
  107783. * @param tessellation Amount of tessellation to be used when creating rotation circles
  107784. */
  107785. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  107786. updateGizmoRotationToMatchAttachedMesh: boolean;
  107787. /**
  107788. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107789. */
  107790. snapDistance: number;
  107791. /**
  107792. * Ratio for the scale of the gizmo (Default: 1)
  107793. */
  107794. scaleRatio: number;
  107795. /**
  107796. * Disposes of the gizmo
  107797. */
  107798. dispose(): void;
  107799. /**
  107800. * CustomMeshes are not supported by this gizmo
  107801. * @param mesh The mesh to replace the default mesh of the gizmo
  107802. */
  107803. setCustomMesh(mesh: Mesh): void;
  107804. }
  107805. }
  107806. declare module BABYLON {
  107807. /**
  107808. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  107809. */
  107810. export class GizmoManager implements IDisposable {
  107811. private scene;
  107812. /**
  107813. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  107814. */
  107815. gizmos: {
  107816. positionGizmo: Nullable<PositionGizmo>;
  107817. rotationGizmo: Nullable<RotationGizmo>;
  107818. scaleGizmo: Nullable<ScaleGizmo>;
  107819. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  107820. };
  107821. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  107822. clearGizmoOnEmptyPointerEvent: boolean;
  107823. /** Fires an event when the manager is attached to a mesh */
  107824. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  107825. private _gizmosEnabled;
  107826. private _pointerObserver;
  107827. private _attachedMesh;
  107828. private _boundingBoxColor;
  107829. private _defaultUtilityLayer;
  107830. private _defaultKeepDepthUtilityLayer;
  107831. /**
  107832. * When bounding box gizmo is enabled, this can be used to track drag/end events
  107833. */
  107834. boundingBoxDragBehavior: SixDofDragBehavior;
  107835. /**
  107836. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  107837. */
  107838. attachableMeshes: Nullable<Array<AbstractMesh>>;
  107839. /**
  107840. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  107841. */
  107842. usePointerToAttachGizmos: boolean;
  107843. /**
  107844. * Utility layer that the bounding box gizmo belongs to
  107845. */
  107846. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  107847. /**
  107848. * Utility layer that all gizmos besides bounding box belong to
  107849. */
  107850. readonly utilityLayer: UtilityLayerRenderer;
  107851. /**
  107852. * Instatiates a gizmo manager
  107853. * @param scene the scene to overlay the gizmos on top of
  107854. */
  107855. constructor(scene: Scene);
  107856. /**
  107857. * Attaches a set of gizmos to the specified mesh
  107858. * @param mesh The mesh the gizmo's should be attached to
  107859. */
  107860. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  107861. /**
  107862. * If the position gizmo is enabled
  107863. */
  107864. positionGizmoEnabled: boolean;
  107865. /**
  107866. * If the rotation gizmo is enabled
  107867. */
  107868. rotationGizmoEnabled: boolean;
  107869. /**
  107870. * If the scale gizmo is enabled
  107871. */
  107872. scaleGizmoEnabled: boolean;
  107873. /**
  107874. * If the boundingBox gizmo is enabled
  107875. */
  107876. boundingBoxGizmoEnabled: boolean;
  107877. /**
  107878. * Disposes of the gizmo manager
  107879. */
  107880. dispose(): void;
  107881. }
  107882. }
  107883. declare module BABYLON {
  107884. /**
  107885. * A directional light is defined by a direction (what a surprise!).
  107886. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  107887. * 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.
  107888. * Documentation: https://doc.babylonjs.com/babylon101/lights
  107889. */
  107890. export class DirectionalLight extends ShadowLight {
  107891. private _shadowFrustumSize;
  107892. /**
  107893. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  107894. */
  107895. /**
  107896. * Specifies a fix frustum size for the shadow generation.
  107897. */
  107898. shadowFrustumSize: number;
  107899. private _shadowOrthoScale;
  107900. /**
  107901. * Gets the shadow projection scale against the optimal computed one.
  107902. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  107903. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  107904. */
  107905. /**
  107906. * Sets the shadow projection scale against the optimal computed one.
  107907. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  107908. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  107909. */
  107910. shadowOrthoScale: number;
  107911. /**
  107912. * Automatically compute the projection matrix to best fit (including all the casters)
  107913. * on each frame.
  107914. */
  107915. autoUpdateExtends: boolean;
  107916. private _orthoLeft;
  107917. private _orthoRight;
  107918. private _orthoTop;
  107919. private _orthoBottom;
  107920. /**
  107921. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  107922. * The directional light is emitted from everywhere in the given direction.
  107923. * It can cast shadows.
  107924. * Documentation : https://doc.babylonjs.com/babylon101/lights
  107925. * @param name The friendly name of the light
  107926. * @param direction The direction of the light
  107927. * @param scene The scene the light belongs to
  107928. */
  107929. constructor(name: string, direction: Vector3, scene: Scene);
  107930. /**
  107931. * Returns the string "DirectionalLight".
  107932. * @return The class name
  107933. */
  107934. getClassName(): string;
  107935. /**
  107936. * Returns the integer 1.
  107937. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  107938. */
  107939. getTypeID(): number;
  107940. /**
  107941. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  107942. * Returns the DirectionalLight Shadow projection matrix.
  107943. */
  107944. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  107945. /**
  107946. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  107947. * Returns the DirectionalLight Shadow projection matrix.
  107948. */
  107949. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  107950. /**
  107951. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  107952. * Returns the DirectionalLight Shadow projection matrix.
  107953. */
  107954. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  107955. protected _buildUniformLayout(): void;
  107956. /**
  107957. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  107958. * @param effect The effect to update
  107959. * @param lightIndex The index of the light in the effect to update
  107960. * @returns The directional light
  107961. */
  107962. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  107963. /**
  107964. * Gets the minZ used for shadow according to both the scene and the light.
  107965. *
  107966. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  107967. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  107968. * @param activeCamera The camera we are returning the min for
  107969. * @returns the depth min z
  107970. */
  107971. getDepthMinZ(activeCamera: Camera): number;
  107972. /**
  107973. * Gets the maxZ used for shadow according to both the scene and the light.
  107974. *
  107975. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  107976. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  107977. * @param activeCamera The camera we are returning the max for
  107978. * @returns the depth max z
  107979. */
  107980. getDepthMaxZ(activeCamera: Camera): number;
  107981. /**
  107982. * Prepares the list of defines specific to the light type.
  107983. * @param defines the list of defines
  107984. * @param lightIndex defines the index of the light for the effect
  107985. */
  107986. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  107987. }
  107988. }
  107989. declare module BABYLON {
  107990. /**
  107991. * Class containing static functions to help procedurally build meshes
  107992. */
  107993. export class HemisphereBuilder {
  107994. /**
  107995. * Creates a hemisphere mesh
  107996. * @param name defines the name of the mesh
  107997. * @param options defines the options used to create the mesh
  107998. * @param scene defines the hosting scene
  107999. * @returns the hemisphere mesh
  108000. */
  108001. static CreateHemisphere(name: string, options: {
  108002. segments?: number;
  108003. diameter?: number;
  108004. sideOrientation?: number;
  108005. }, scene: any): Mesh;
  108006. }
  108007. }
  108008. declare module BABYLON {
  108009. /**
  108010. * A spot light is defined by a position, a direction, an angle, and an exponent.
  108011. * These values define a cone of light starting from the position, emitting toward the direction.
  108012. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  108013. * and the exponent defines the speed of the decay of the light with distance (reach).
  108014. * Documentation: https://doc.babylonjs.com/babylon101/lights
  108015. */
  108016. export class SpotLight extends ShadowLight {
  108017. private _angle;
  108018. private _innerAngle;
  108019. private _cosHalfAngle;
  108020. private _lightAngleScale;
  108021. private _lightAngleOffset;
  108022. /**
  108023. * Gets the cone angle of the spot light in Radians.
  108024. */
  108025. /**
  108026. * Sets the cone angle of the spot light in Radians.
  108027. */
  108028. angle: number;
  108029. /**
  108030. * Only used in gltf falloff mode, this defines the angle where
  108031. * the directional falloff will start before cutting at angle which could be seen
  108032. * as outer angle.
  108033. */
  108034. /**
  108035. * Only used in gltf falloff mode, this defines the angle where
  108036. * the directional falloff will start before cutting at angle which could be seen
  108037. * as outer angle.
  108038. */
  108039. innerAngle: number;
  108040. private _shadowAngleScale;
  108041. /**
  108042. * Allows scaling the angle of the light for shadow generation only.
  108043. */
  108044. /**
  108045. * Allows scaling the angle of the light for shadow generation only.
  108046. */
  108047. shadowAngleScale: number;
  108048. /**
  108049. * The light decay speed with the distance from the emission spot.
  108050. */
  108051. exponent: number;
  108052. private _projectionTextureMatrix;
  108053. /**
  108054. * Allows reading the projecton texture
  108055. */
  108056. readonly projectionTextureMatrix: Matrix;
  108057. protected _projectionTextureLightNear: number;
  108058. /**
  108059. * Gets the near clip of the Spotlight for texture projection.
  108060. */
  108061. /**
  108062. * Sets the near clip of the Spotlight for texture projection.
  108063. */
  108064. projectionTextureLightNear: number;
  108065. protected _projectionTextureLightFar: number;
  108066. /**
  108067. * Gets the far clip of the Spotlight for texture projection.
  108068. */
  108069. /**
  108070. * Sets the far clip of the Spotlight for texture projection.
  108071. */
  108072. projectionTextureLightFar: number;
  108073. protected _projectionTextureUpDirection: Vector3;
  108074. /**
  108075. * Gets the Up vector of the Spotlight for texture projection.
  108076. */
  108077. /**
  108078. * Sets the Up vector of the Spotlight for texture projection.
  108079. */
  108080. projectionTextureUpDirection: Vector3;
  108081. private _projectionTexture;
  108082. /**
  108083. * Gets the projection texture of the light.
  108084. */
  108085. /**
  108086. * Sets the projection texture of the light.
  108087. */
  108088. projectionTexture: Nullable<BaseTexture>;
  108089. private _projectionTextureViewLightDirty;
  108090. private _projectionTextureProjectionLightDirty;
  108091. private _projectionTextureDirty;
  108092. private _projectionTextureViewTargetVector;
  108093. private _projectionTextureViewLightMatrix;
  108094. private _projectionTextureProjectionLightMatrix;
  108095. private _projectionTextureScalingMatrix;
  108096. /**
  108097. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  108098. * It can cast shadows.
  108099. * Documentation : https://doc.babylonjs.com/babylon101/lights
  108100. * @param name The light friendly name
  108101. * @param position The position of the spot light in the scene
  108102. * @param direction The direction of the light in the scene
  108103. * @param angle The cone angle of the light in Radians
  108104. * @param exponent The light decay speed with the distance from the emission spot
  108105. * @param scene The scene the lights belongs to
  108106. */
  108107. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  108108. /**
  108109. * Returns the string "SpotLight".
  108110. * @returns the class name
  108111. */
  108112. getClassName(): string;
  108113. /**
  108114. * Returns the integer 2.
  108115. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  108116. */
  108117. getTypeID(): number;
  108118. /**
  108119. * Overrides the direction setter to recompute the projection texture view light Matrix.
  108120. */
  108121. protected _setDirection(value: Vector3): void;
  108122. /**
  108123. * Overrides the position setter to recompute the projection texture view light Matrix.
  108124. */
  108125. protected _setPosition(value: Vector3): void;
  108126. /**
  108127. * 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.
  108128. * Returns the SpotLight.
  108129. */
  108130. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  108131. protected _computeProjectionTextureViewLightMatrix(): void;
  108132. protected _computeProjectionTextureProjectionLightMatrix(): void;
  108133. /**
  108134. * Main function for light texture projection matrix computing.
  108135. */
  108136. protected _computeProjectionTextureMatrix(): void;
  108137. protected _buildUniformLayout(): void;
  108138. private _computeAngleValues;
  108139. /**
  108140. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  108141. * @param effect The effect to update
  108142. * @param lightIndex The index of the light in the effect to update
  108143. * @returns The spot light
  108144. */
  108145. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  108146. /**
  108147. * Disposes the light and the associated resources.
  108148. */
  108149. dispose(): void;
  108150. /**
  108151. * Prepares the list of defines specific to the light type.
  108152. * @param defines the list of defines
  108153. * @param lightIndex defines the index of the light for the effect
  108154. */
  108155. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  108156. }
  108157. }
  108158. declare module BABYLON {
  108159. /**
  108160. * Gizmo that enables viewing a light
  108161. */
  108162. export class LightGizmo extends Gizmo {
  108163. private _lightMesh;
  108164. private _material;
  108165. private cachedPosition;
  108166. private cachedForward;
  108167. /**
  108168. * Creates a LightGizmo
  108169. * @param gizmoLayer The utility layer the gizmo will be added to
  108170. */
  108171. constructor(gizmoLayer?: UtilityLayerRenderer);
  108172. private _light;
  108173. /**
  108174. * The light that the gizmo is attached to
  108175. */
  108176. light: Nullable<Light>;
  108177. /**
  108178. * @hidden
  108179. * Updates the gizmo to match the attached mesh's position/rotation
  108180. */
  108181. protected _update(): void;
  108182. private static _Scale;
  108183. /**
  108184. * Creates the lines for a light mesh
  108185. */
  108186. private static _createLightLines;
  108187. /**
  108188. * Disposes of the light gizmo
  108189. */
  108190. dispose(): void;
  108191. private static _CreateHemisphericLightMesh;
  108192. private static _CreatePointLightMesh;
  108193. private static _CreateSpotLightMesh;
  108194. private static _CreateDirectionalLightMesh;
  108195. }
  108196. }
  108197. declare module BABYLON {
  108198. /** @hidden */
  108199. export var backgroundFragmentDeclaration: {
  108200. name: string;
  108201. shader: string;
  108202. };
  108203. }
  108204. declare module BABYLON {
  108205. /** @hidden */
  108206. export var backgroundUboDeclaration: {
  108207. name: string;
  108208. shader: string;
  108209. };
  108210. }
  108211. declare module BABYLON {
  108212. /** @hidden */
  108213. export var backgroundPixelShader: {
  108214. name: string;
  108215. shader: string;
  108216. };
  108217. }
  108218. declare module BABYLON {
  108219. /** @hidden */
  108220. export var backgroundVertexDeclaration: {
  108221. name: string;
  108222. shader: string;
  108223. };
  108224. }
  108225. declare module BABYLON {
  108226. /** @hidden */
  108227. export var backgroundVertexShader: {
  108228. name: string;
  108229. shader: string;
  108230. };
  108231. }
  108232. declare module BABYLON {
  108233. /**
  108234. * Background material used to create an efficient environement around your scene.
  108235. */
  108236. export class BackgroundMaterial extends PushMaterial {
  108237. /**
  108238. * Standard reflectance value at parallel view angle.
  108239. */
  108240. static StandardReflectance0: number;
  108241. /**
  108242. * Standard reflectance value at grazing angle.
  108243. */
  108244. static StandardReflectance90: number;
  108245. protected _primaryColor: Color3;
  108246. /**
  108247. * Key light Color (multiply against the environement texture)
  108248. */
  108249. primaryColor: Color3;
  108250. protected __perceptualColor: Nullable<Color3>;
  108251. /**
  108252. * Experimental Internal Use Only.
  108253. *
  108254. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  108255. * This acts as a helper to set the primary color to a more "human friendly" value.
  108256. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  108257. * output color as close as possible from the chosen value.
  108258. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  108259. * part of lighting setup.)
  108260. */
  108261. _perceptualColor: Nullable<Color3>;
  108262. protected _primaryColorShadowLevel: float;
  108263. /**
  108264. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  108265. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  108266. */
  108267. primaryColorShadowLevel: float;
  108268. protected _primaryColorHighlightLevel: float;
  108269. /**
  108270. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  108271. * The primary color is used at the level chosen to define what the white area would look.
  108272. */
  108273. primaryColorHighlightLevel: float;
  108274. protected _reflectionTexture: Nullable<BaseTexture>;
  108275. /**
  108276. * Reflection Texture used in the material.
  108277. * Should be author in a specific way for the best result (refer to the documentation).
  108278. */
  108279. reflectionTexture: Nullable<BaseTexture>;
  108280. protected _reflectionBlur: float;
  108281. /**
  108282. * Reflection Texture level of blur.
  108283. *
  108284. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  108285. * texture twice.
  108286. */
  108287. reflectionBlur: float;
  108288. protected _diffuseTexture: Nullable<BaseTexture>;
  108289. /**
  108290. * Diffuse Texture used in the material.
  108291. * Should be author in a specific way for the best result (refer to the documentation).
  108292. */
  108293. diffuseTexture: Nullable<BaseTexture>;
  108294. protected _shadowLights: Nullable<IShadowLight[]>;
  108295. /**
  108296. * Specify the list of lights casting shadow on the material.
  108297. * All scene shadow lights will be included if null.
  108298. */
  108299. shadowLights: Nullable<IShadowLight[]>;
  108300. protected _shadowLevel: float;
  108301. /**
  108302. * Helps adjusting the shadow to a softer level if required.
  108303. * 0 means black shadows and 1 means no shadows.
  108304. */
  108305. shadowLevel: float;
  108306. protected _sceneCenter: Vector3;
  108307. /**
  108308. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  108309. * It is usually zero but might be interesting to modify according to your setup.
  108310. */
  108311. sceneCenter: Vector3;
  108312. protected _opacityFresnel: boolean;
  108313. /**
  108314. * This helps specifying that the material is falling off to the sky box at grazing angle.
  108315. * This helps ensuring a nice transition when the camera goes under the ground.
  108316. */
  108317. opacityFresnel: boolean;
  108318. protected _reflectionFresnel: boolean;
  108319. /**
  108320. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  108321. * This helps adding a mirror texture on the ground.
  108322. */
  108323. reflectionFresnel: boolean;
  108324. protected _reflectionFalloffDistance: number;
  108325. /**
  108326. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  108327. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  108328. */
  108329. reflectionFalloffDistance: number;
  108330. protected _reflectionAmount: number;
  108331. /**
  108332. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  108333. */
  108334. reflectionAmount: number;
  108335. protected _reflectionReflectance0: number;
  108336. /**
  108337. * This specifies the weight of the reflection at grazing angle.
  108338. */
  108339. reflectionReflectance0: number;
  108340. protected _reflectionReflectance90: number;
  108341. /**
  108342. * This specifies the weight of the reflection at a perpendicular point of view.
  108343. */
  108344. reflectionReflectance90: number;
  108345. /**
  108346. * Sets the reflection reflectance fresnel values according to the default standard
  108347. * empirically know to work well :-)
  108348. */
  108349. reflectionStandardFresnelWeight: number;
  108350. protected _useRGBColor: boolean;
  108351. /**
  108352. * Helps to directly use the maps channels instead of their level.
  108353. */
  108354. useRGBColor: boolean;
  108355. protected _enableNoise: boolean;
  108356. /**
  108357. * This helps reducing the banding effect that could occur on the background.
  108358. */
  108359. enableNoise: boolean;
  108360. /**
  108361. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  108362. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  108363. * Recommended to be keep at 1.0 except for special cases.
  108364. */
  108365. fovMultiplier: number;
  108366. private _fovMultiplier;
  108367. /**
  108368. * Enable the FOV adjustment feature controlled by fovMultiplier.
  108369. */
  108370. useEquirectangularFOV: boolean;
  108371. private _maxSimultaneousLights;
  108372. /**
  108373. * Number of Simultaneous lights allowed on the material.
  108374. */
  108375. maxSimultaneousLights: int;
  108376. /**
  108377. * Default configuration related to image processing available in the Background Material.
  108378. */
  108379. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108380. /**
  108381. * Keep track of the image processing observer to allow dispose and replace.
  108382. */
  108383. private _imageProcessingObserver;
  108384. /**
  108385. * Attaches a new image processing configuration to the PBR Material.
  108386. * @param configuration (if null the scene configuration will be use)
  108387. */
  108388. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108389. /**
  108390. * Gets the image processing configuration used either in this material.
  108391. */
  108392. /**
  108393. * Sets the Default image processing configuration used either in the this material.
  108394. *
  108395. * If sets to null, the scene one is in use.
  108396. */
  108397. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  108398. /**
  108399. * Gets wether the color curves effect is enabled.
  108400. */
  108401. /**
  108402. * Sets wether the color curves effect is enabled.
  108403. */
  108404. cameraColorCurvesEnabled: boolean;
  108405. /**
  108406. * Gets wether the color grading effect is enabled.
  108407. */
  108408. /**
  108409. * Gets wether the color grading effect is enabled.
  108410. */
  108411. cameraColorGradingEnabled: boolean;
  108412. /**
  108413. * Gets wether tonemapping is enabled or not.
  108414. */
  108415. /**
  108416. * Sets wether tonemapping is enabled or not
  108417. */
  108418. cameraToneMappingEnabled: boolean;
  108419. /**
  108420. * The camera exposure used on this material.
  108421. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108422. * This corresponds to a photographic exposure.
  108423. */
  108424. /**
  108425. * The camera exposure used on this material.
  108426. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108427. * This corresponds to a photographic exposure.
  108428. */
  108429. cameraExposure: float;
  108430. /**
  108431. * Gets The camera contrast used on this material.
  108432. */
  108433. /**
  108434. * Sets The camera contrast used on this material.
  108435. */
  108436. cameraContrast: float;
  108437. /**
  108438. * Gets the Color Grading 2D Lookup Texture.
  108439. */
  108440. /**
  108441. * Sets the Color Grading 2D Lookup Texture.
  108442. */
  108443. cameraColorGradingTexture: Nullable<BaseTexture>;
  108444. /**
  108445. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108446. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108447. * 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;
  108448. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108449. */
  108450. /**
  108451. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108452. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108453. * 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;
  108454. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108455. */
  108456. cameraColorCurves: Nullable<ColorCurves>;
  108457. /**
  108458. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  108459. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  108460. */
  108461. switchToBGR: boolean;
  108462. private _renderTargets;
  108463. private _reflectionControls;
  108464. private _white;
  108465. private _primaryShadowColor;
  108466. private _primaryHighlightColor;
  108467. /**
  108468. * Instantiates a Background Material in the given scene
  108469. * @param name The friendly name of the material
  108470. * @param scene The scene to add the material to
  108471. */
  108472. constructor(name: string, scene: Scene);
  108473. /**
  108474. * Gets a boolean indicating that current material needs to register RTT
  108475. */
  108476. readonly hasRenderTargetTextures: boolean;
  108477. /**
  108478. * The entire material has been created in order to prevent overdraw.
  108479. * @returns false
  108480. */
  108481. needAlphaTesting(): boolean;
  108482. /**
  108483. * The entire material has been created in order to prevent overdraw.
  108484. * @returns true if blending is enable
  108485. */
  108486. needAlphaBlending(): boolean;
  108487. /**
  108488. * Checks wether the material is ready to be rendered for a given mesh.
  108489. * @param mesh The mesh to render
  108490. * @param subMesh The submesh to check against
  108491. * @param useInstances Specify wether or not the material is used with instances
  108492. * @returns true if all the dependencies are ready (Textures, Effects...)
  108493. */
  108494. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108495. /**
  108496. * Compute the primary color according to the chosen perceptual color.
  108497. */
  108498. private _computePrimaryColorFromPerceptualColor;
  108499. /**
  108500. * Compute the highlights and shadow colors according to their chosen levels.
  108501. */
  108502. private _computePrimaryColors;
  108503. /**
  108504. * Build the uniform buffer used in the material.
  108505. */
  108506. buildUniformLayout(): void;
  108507. /**
  108508. * Unbind the material.
  108509. */
  108510. unbind(): void;
  108511. /**
  108512. * Bind only the world matrix to the material.
  108513. * @param world The world matrix to bind.
  108514. */
  108515. bindOnlyWorldMatrix(world: Matrix): void;
  108516. /**
  108517. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  108518. * @param world The world matrix to bind.
  108519. * @param subMesh The submesh to bind for.
  108520. */
  108521. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108522. /**
  108523. * Dispose the material.
  108524. * @param forceDisposeEffect Force disposal of the associated effect.
  108525. * @param forceDisposeTextures Force disposal of the associated textures.
  108526. */
  108527. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108528. /**
  108529. * Clones the material.
  108530. * @param name The cloned name.
  108531. * @returns The cloned material.
  108532. */
  108533. clone(name: string): BackgroundMaterial;
  108534. /**
  108535. * Serializes the current material to its JSON representation.
  108536. * @returns The JSON representation.
  108537. */
  108538. serialize(): any;
  108539. /**
  108540. * Gets the class name of the material
  108541. * @returns "BackgroundMaterial"
  108542. */
  108543. getClassName(): string;
  108544. /**
  108545. * Parse a JSON input to create back a background material.
  108546. * @param source The JSON data to parse
  108547. * @param scene The scene to create the parsed material in
  108548. * @param rootUrl The root url of the assets the material depends upon
  108549. * @returns the instantiated BackgroundMaterial.
  108550. */
  108551. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  108552. }
  108553. }
  108554. declare module BABYLON {
  108555. /**
  108556. * Represents the different options available during the creation of
  108557. * a Environment helper.
  108558. *
  108559. * This can control the default ground, skybox and image processing setup of your scene.
  108560. */
  108561. export interface IEnvironmentHelperOptions {
  108562. /**
  108563. * Specifies wether or not to create a ground.
  108564. * True by default.
  108565. */
  108566. createGround: boolean;
  108567. /**
  108568. * Specifies the ground size.
  108569. * 15 by default.
  108570. */
  108571. groundSize: number;
  108572. /**
  108573. * The texture used on the ground for the main color.
  108574. * Comes from the BabylonJS CDN by default.
  108575. *
  108576. * Remarks: Can be either a texture or a url.
  108577. */
  108578. groundTexture: string | BaseTexture;
  108579. /**
  108580. * The color mixed in the ground texture by default.
  108581. * BabylonJS clearColor by default.
  108582. */
  108583. groundColor: Color3;
  108584. /**
  108585. * Specifies the ground opacity.
  108586. * 1 by default.
  108587. */
  108588. groundOpacity: number;
  108589. /**
  108590. * Enables the ground to receive shadows.
  108591. * True by default.
  108592. */
  108593. enableGroundShadow: boolean;
  108594. /**
  108595. * Helps preventing the shadow to be fully black on the ground.
  108596. * 0.5 by default.
  108597. */
  108598. groundShadowLevel: number;
  108599. /**
  108600. * Creates a mirror texture attach to the ground.
  108601. * false by default.
  108602. */
  108603. enableGroundMirror: boolean;
  108604. /**
  108605. * Specifies the ground mirror size ratio.
  108606. * 0.3 by default as the default kernel is 64.
  108607. */
  108608. groundMirrorSizeRatio: number;
  108609. /**
  108610. * Specifies the ground mirror blur kernel size.
  108611. * 64 by default.
  108612. */
  108613. groundMirrorBlurKernel: number;
  108614. /**
  108615. * Specifies the ground mirror visibility amount.
  108616. * 1 by default
  108617. */
  108618. groundMirrorAmount: number;
  108619. /**
  108620. * Specifies the ground mirror reflectance weight.
  108621. * This uses the standard weight of the background material to setup the fresnel effect
  108622. * of the mirror.
  108623. * 1 by default.
  108624. */
  108625. groundMirrorFresnelWeight: number;
  108626. /**
  108627. * Specifies the ground mirror Falloff distance.
  108628. * This can helps reducing the size of the reflection.
  108629. * 0 by Default.
  108630. */
  108631. groundMirrorFallOffDistance: number;
  108632. /**
  108633. * Specifies the ground mirror texture type.
  108634. * Unsigned Int by Default.
  108635. */
  108636. groundMirrorTextureType: number;
  108637. /**
  108638. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  108639. * the shown objects.
  108640. */
  108641. groundYBias: number;
  108642. /**
  108643. * Specifies wether or not to create a skybox.
  108644. * True by default.
  108645. */
  108646. createSkybox: boolean;
  108647. /**
  108648. * Specifies the skybox size.
  108649. * 20 by default.
  108650. */
  108651. skyboxSize: number;
  108652. /**
  108653. * The texture used on the skybox for the main color.
  108654. * Comes from the BabylonJS CDN by default.
  108655. *
  108656. * Remarks: Can be either a texture or a url.
  108657. */
  108658. skyboxTexture: string | BaseTexture;
  108659. /**
  108660. * The color mixed in the skybox texture by default.
  108661. * BabylonJS clearColor by default.
  108662. */
  108663. skyboxColor: Color3;
  108664. /**
  108665. * The background rotation around the Y axis of the scene.
  108666. * This helps aligning the key lights of your scene with the background.
  108667. * 0 by default.
  108668. */
  108669. backgroundYRotation: number;
  108670. /**
  108671. * Compute automatically the size of the elements to best fit with the scene.
  108672. */
  108673. sizeAuto: boolean;
  108674. /**
  108675. * Default position of the rootMesh if autoSize is not true.
  108676. */
  108677. rootPosition: Vector3;
  108678. /**
  108679. * Sets up the image processing in the scene.
  108680. * true by default.
  108681. */
  108682. setupImageProcessing: boolean;
  108683. /**
  108684. * The texture used as your environment texture in the scene.
  108685. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  108686. *
  108687. * Remarks: Can be either a texture or a url.
  108688. */
  108689. environmentTexture: string | BaseTexture;
  108690. /**
  108691. * The value of the exposure to apply to the scene.
  108692. * 0.6 by default if setupImageProcessing is true.
  108693. */
  108694. cameraExposure: number;
  108695. /**
  108696. * The value of the contrast to apply to the scene.
  108697. * 1.6 by default if setupImageProcessing is true.
  108698. */
  108699. cameraContrast: number;
  108700. /**
  108701. * Specifies wether or not tonemapping should be enabled in the scene.
  108702. * true by default if setupImageProcessing is true.
  108703. */
  108704. toneMappingEnabled: boolean;
  108705. }
  108706. /**
  108707. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  108708. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  108709. * It also helps with the default setup of your imageProcessing configuration.
  108710. */
  108711. export class EnvironmentHelper {
  108712. /**
  108713. * Default ground texture URL.
  108714. */
  108715. private static _groundTextureCDNUrl;
  108716. /**
  108717. * Default skybox texture URL.
  108718. */
  108719. private static _skyboxTextureCDNUrl;
  108720. /**
  108721. * Default environment texture URL.
  108722. */
  108723. private static _environmentTextureCDNUrl;
  108724. /**
  108725. * Creates the default options for the helper.
  108726. */
  108727. private static _getDefaultOptions;
  108728. private _rootMesh;
  108729. /**
  108730. * Gets the root mesh created by the helper.
  108731. */
  108732. readonly rootMesh: Mesh;
  108733. private _skybox;
  108734. /**
  108735. * Gets the skybox created by the helper.
  108736. */
  108737. readonly skybox: Nullable<Mesh>;
  108738. private _skyboxTexture;
  108739. /**
  108740. * Gets the skybox texture created by the helper.
  108741. */
  108742. readonly skyboxTexture: Nullable<BaseTexture>;
  108743. private _skyboxMaterial;
  108744. /**
  108745. * Gets the skybox material created by the helper.
  108746. */
  108747. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  108748. private _ground;
  108749. /**
  108750. * Gets the ground mesh created by the helper.
  108751. */
  108752. readonly ground: Nullable<Mesh>;
  108753. private _groundTexture;
  108754. /**
  108755. * Gets the ground texture created by the helper.
  108756. */
  108757. readonly groundTexture: Nullable<BaseTexture>;
  108758. private _groundMirror;
  108759. /**
  108760. * Gets the ground mirror created by the helper.
  108761. */
  108762. readonly groundMirror: Nullable<MirrorTexture>;
  108763. /**
  108764. * Gets the ground mirror render list to helps pushing the meshes
  108765. * you wish in the ground reflection.
  108766. */
  108767. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  108768. private _groundMaterial;
  108769. /**
  108770. * Gets the ground material created by the helper.
  108771. */
  108772. readonly groundMaterial: Nullable<BackgroundMaterial>;
  108773. /**
  108774. * Stores the creation options.
  108775. */
  108776. private readonly _scene;
  108777. private _options;
  108778. /**
  108779. * This observable will be notified with any error during the creation of the environment,
  108780. * mainly texture creation errors.
  108781. */
  108782. onErrorObservable: Observable<{
  108783. message?: string;
  108784. exception?: any;
  108785. }>;
  108786. /**
  108787. * constructor
  108788. * @param options Defines the options we want to customize the helper
  108789. * @param scene The scene to add the material to
  108790. */
  108791. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  108792. /**
  108793. * Updates the background according to the new options
  108794. * @param options
  108795. */
  108796. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  108797. /**
  108798. * Sets the primary color of all the available elements.
  108799. * @param color the main color to affect to the ground and the background
  108800. */
  108801. setMainColor(color: Color3): void;
  108802. /**
  108803. * Setup the image processing according to the specified options.
  108804. */
  108805. private _setupImageProcessing;
  108806. /**
  108807. * Setup the environment texture according to the specified options.
  108808. */
  108809. private _setupEnvironmentTexture;
  108810. /**
  108811. * Setup the background according to the specified options.
  108812. */
  108813. private _setupBackground;
  108814. /**
  108815. * Get the scene sizes according to the setup.
  108816. */
  108817. private _getSceneSize;
  108818. /**
  108819. * Setup the ground according to the specified options.
  108820. */
  108821. private _setupGround;
  108822. /**
  108823. * Setup the ground material according to the specified options.
  108824. */
  108825. private _setupGroundMaterial;
  108826. /**
  108827. * Setup the ground diffuse texture according to the specified options.
  108828. */
  108829. private _setupGroundDiffuseTexture;
  108830. /**
  108831. * Setup the ground mirror texture according to the specified options.
  108832. */
  108833. private _setupGroundMirrorTexture;
  108834. /**
  108835. * Setup the ground to receive the mirror texture.
  108836. */
  108837. private _setupMirrorInGroundMaterial;
  108838. /**
  108839. * Setup the skybox according to the specified options.
  108840. */
  108841. private _setupSkybox;
  108842. /**
  108843. * Setup the skybox material according to the specified options.
  108844. */
  108845. private _setupSkyboxMaterial;
  108846. /**
  108847. * Setup the skybox reflection texture according to the specified options.
  108848. */
  108849. private _setupSkyboxReflectionTexture;
  108850. private _errorHandler;
  108851. /**
  108852. * Dispose all the elements created by the Helper.
  108853. */
  108854. dispose(): void;
  108855. }
  108856. }
  108857. declare module BABYLON {
  108858. /**
  108859. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  108860. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  108861. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  108862. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  108863. */
  108864. export class PhotoDome extends TransformNode {
  108865. /**
  108866. * Define the image as a Monoscopic panoramic 360 image.
  108867. */
  108868. static readonly MODE_MONOSCOPIC: number;
  108869. /**
  108870. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  108871. */
  108872. static readonly MODE_TOPBOTTOM: number;
  108873. /**
  108874. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  108875. */
  108876. static readonly MODE_SIDEBYSIDE: number;
  108877. private _useDirectMapping;
  108878. /**
  108879. * The texture being displayed on the sphere
  108880. */
  108881. protected _photoTexture: Texture;
  108882. /**
  108883. * Gets or sets the texture being displayed on the sphere
  108884. */
  108885. photoTexture: Texture;
  108886. /**
  108887. * Observable raised when an error occured while loading the 360 image
  108888. */
  108889. onLoadErrorObservable: Observable<string>;
  108890. /**
  108891. * The skybox material
  108892. */
  108893. protected _material: BackgroundMaterial;
  108894. /**
  108895. * The surface used for the skybox
  108896. */
  108897. protected _mesh: Mesh;
  108898. /**
  108899. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  108900. * Also see the options.resolution property.
  108901. */
  108902. fovMultiplier: number;
  108903. private _imageMode;
  108904. /**
  108905. * Gets or set the current video mode for the video. It can be:
  108906. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  108907. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  108908. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  108909. */
  108910. imageMode: number;
  108911. /**
  108912. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  108913. * @param name Element's name, child elements will append suffixes for their own names.
  108914. * @param urlsOfPhoto defines the url of the photo to display
  108915. * @param options defines an object containing optional or exposed sub element properties
  108916. * @param onError defines a callback called when an error occured while loading the texture
  108917. */
  108918. constructor(name: string, urlOfPhoto: string, options: {
  108919. resolution?: number;
  108920. size?: number;
  108921. useDirectMapping?: boolean;
  108922. faceForward?: boolean;
  108923. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  108924. private _onBeforeCameraRenderObserver;
  108925. private _changeImageMode;
  108926. /**
  108927. * Releases resources associated with this node.
  108928. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108929. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108930. */
  108931. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108932. }
  108933. }
  108934. declare module BABYLON {
  108935. /** @hidden */
  108936. export var rgbdDecodePixelShader: {
  108937. name: string;
  108938. shader: string;
  108939. };
  108940. }
  108941. declare module BABYLON {
  108942. /**
  108943. * Class used to host texture specific utilities
  108944. */
  108945. export class BRDFTextureTools {
  108946. /**
  108947. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  108948. * @param texture the texture to expand.
  108949. */
  108950. private static _ExpandDefaultBRDFTexture;
  108951. /**
  108952. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  108953. * @param scene defines the hosting scene
  108954. * @returns the environment BRDF texture
  108955. */
  108956. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  108957. private static _environmentBRDFBase64Texture;
  108958. }
  108959. }
  108960. declare module BABYLON {
  108961. /**
  108962. * @hidden
  108963. */
  108964. export interface IMaterialClearCoatDefines {
  108965. CLEARCOAT: boolean;
  108966. CLEARCOAT_DEFAULTIOR: boolean;
  108967. CLEARCOAT_TEXTURE: boolean;
  108968. CLEARCOAT_TEXTUREDIRECTUV: number;
  108969. CLEARCOAT_BUMP: boolean;
  108970. CLEARCOAT_BUMPDIRECTUV: number;
  108971. CLEARCOAT_TINT: boolean;
  108972. CLEARCOAT_TINT_TEXTURE: boolean;
  108973. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  108974. /** @hidden */
  108975. _areTexturesDirty: boolean;
  108976. }
  108977. /**
  108978. * Define the code related to the clear coat parameters of the pbr material.
  108979. */
  108980. export class PBRClearCoatConfiguration {
  108981. /**
  108982. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  108983. * The default fits with a polyurethane material.
  108984. */
  108985. private static readonly _DefaultIndexOfRefraction;
  108986. private _isEnabled;
  108987. /**
  108988. * Defines if the clear coat is enabled in the material.
  108989. */
  108990. isEnabled: boolean;
  108991. /**
  108992. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  108993. */
  108994. intensity: number;
  108995. /**
  108996. * Defines the clear coat layer roughness.
  108997. */
  108998. roughness: number;
  108999. private _indexOfRefraction;
  109000. /**
  109001. * Defines the index of refraction of the clear coat.
  109002. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  109003. * The default fits with a polyurethane material.
  109004. * Changing the default value is more performance intensive.
  109005. */
  109006. indexOfRefraction: number;
  109007. private _texture;
  109008. /**
  109009. * Stores the clear coat values in a texture.
  109010. */
  109011. texture: Nullable<BaseTexture>;
  109012. private _bumpTexture;
  109013. /**
  109014. * Define the clear coat specific bump texture.
  109015. */
  109016. bumpTexture: Nullable<BaseTexture>;
  109017. private _isTintEnabled;
  109018. /**
  109019. * Defines if the clear coat tint is enabled in the material.
  109020. */
  109021. isTintEnabled: boolean;
  109022. /**
  109023. * Defines the clear coat tint of the material.
  109024. * This is only use if tint is enabled
  109025. */
  109026. tintColor: Color3;
  109027. /**
  109028. * Defines the distance at which the tint color should be found in the
  109029. * clear coat media.
  109030. * This is only use if tint is enabled
  109031. */
  109032. tintColorAtDistance: number;
  109033. /**
  109034. * Defines the clear coat layer thickness.
  109035. * This is only use if tint is enabled
  109036. */
  109037. tintThickness: number;
  109038. private _tintTexture;
  109039. /**
  109040. * Stores the clear tint values in a texture.
  109041. * rgb is tint
  109042. * a is a thickness factor
  109043. */
  109044. tintTexture: Nullable<BaseTexture>;
  109045. /** @hidden */
  109046. private _internalMarkAllSubMeshesAsTexturesDirty;
  109047. /** @hidden */
  109048. _markAllSubMeshesAsTexturesDirty(): void;
  109049. /**
  109050. * Instantiate a new istance of clear coat configuration.
  109051. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109052. */
  109053. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109054. /**
  109055. * Gets wehter the submesh is ready to be used or not.
  109056. * @param defines the list of "defines" to update.
  109057. * @param scene defines the scene the material belongs to.
  109058. * @param engine defines the engine the material belongs to.
  109059. * @param disableBumpMap defines wether the material disables bump or not.
  109060. * @returns - boolean indicating that the submesh is ready or not.
  109061. */
  109062. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  109063. /**
  109064. * Checks to see if a texture is used in the material.
  109065. * @param defines the list of "defines" to update.
  109066. * @param scene defines the scene to the material belongs to.
  109067. */
  109068. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  109069. /**
  109070. * Binds the material data.
  109071. * @param uniformBuffer defines the Uniform buffer to fill in.
  109072. * @param scene defines the scene the material belongs to.
  109073. * @param engine defines the engine the material belongs to.
  109074. * @param disableBumpMap defines wether the material disables bump or not.
  109075. * @param isFrozen defines wether the material is frozen or not.
  109076. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  109077. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  109078. */
  109079. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  109080. /**
  109081. * Checks to see if a texture is used in the material.
  109082. * @param texture - Base texture to use.
  109083. * @returns - Boolean specifying if a texture is used in the material.
  109084. */
  109085. hasTexture(texture: BaseTexture): boolean;
  109086. /**
  109087. * Returns an array of the actively used textures.
  109088. * @param activeTextures Array of BaseTextures
  109089. */
  109090. getActiveTextures(activeTextures: BaseTexture[]): void;
  109091. /**
  109092. * Returns the animatable textures.
  109093. * @param animatables Array of animatable textures.
  109094. */
  109095. getAnimatables(animatables: IAnimatable[]): void;
  109096. /**
  109097. * Disposes the resources of the material.
  109098. * @param forceDisposeTextures - Forces the disposal of all textures.
  109099. */
  109100. dispose(forceDisposeTextures?: boolean): void;
  109101. /**
  109102. * Get the current class name of the texture useful for serialization or dynamic coding.
  109103. * @returns "PBRClearCoatConfiguration"
  109104. */
  109105. getClassName(): string;
  109106. /**
  109107. * Add fallbacks to the effect fallbacks list.
  109108. * @param defines defines the Base texture to use.
  109109. * @param fallbacks defines the current fallback list.
  109110. * @param currentRank defines the current fallback rank.
  109111. * @returns the new fallback rank.
  109112. */
  109113. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  109114. /**
  109115. * Add the required uniforms to the current list.
  109116. * @param uniforms defines the current uniform list.
  109117. */
  109118. static AddUniforms(uniforms: string[]): void;
  109119. /**
  109120. * Add the required samplers to the current list.
  109121. * @param samplers defines the current sampler list.
  109122. */
  109123. static AddSamplers(samplers: string[]): void;
  109124. /**
  109125. * Add the required uniforms to the current buffer.
  109126. * @param uniformBuffer defines the current uniform buffer.
  109127. */
  109128. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109129. /**
  109130. * Makes a duplicate of the current configuration into another one.
  109131. * @param clearCoatConfiguration define the config where to copy the info
  109132. */
  109133. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  109134. /**
  109135. * Serializes this clear coat configuration.
  109136. * @returns - An object with the serialized config.
  109137. */
  109138. serialize(): any;
  109139. /**
  109140. * Parses a anisotropy Configuration from a serialized object.
  109141. * @param source - Serialized object.
  109142. * @param scene Defines the scene we are parsing for
  109143. * @param rootUrl Defines the rootUrl to load from
  109144. */
  109145. parse(source: any, scene: Scene, rootUrl: string): void;
  109146. }
  109147. }
  109148. declare module BABYLON {
  109149. /**
  109150. * @hidden
  109151. */
  109152. export interface IMaterialAnisotropicDefines {
  109153. ANISOTROPIC: boolean;
  109154. ANISOTROPIC_TEXTURE: boolean;
  109155. ANISOTROPIC_TEXTUREDIRECTUV: number;
  109156. MAINUV1: boolean;
  109157. _areTexturesDirty: boolean;
  109158. _needUVs: boolean;
  109159. }
  109160. /**
  109161. * Define the code related to the anisotropic parameters of the pbr material.
  109162. */
  109163. export class PBRAnisotropicConfiguration {
  109164. private _isEnabled;
  109165. /**
  109166. * Defines if the anisotropy is enabled in the material.
  109167. */
  109168. isEnabled: boolean;
  109169. /**
  109170. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  109171. */
  109172. intensity: number;
  109173. /**
  109174. * Defines if the effect is along the tangents, bitangents or in between.
  109175. * By default, the effect is "strectching" the highlights along the tangents.
  109176. */
  109177. direction: Vector2;
  109178. private _texture;
  109179. /**
  109180. * Stores the anisotropy values in a texture.
  109181. * rg is direction (like normal from -1 to 1)
  109182. * b is a intensity
  109183. */
  109184. texture: Nullable<BaseTexture>;
  109185. /** @hidden */
  109186. private _internalMarkAllSubMeshesAsTexturesDirty;
  109187. /** @hidden */
  109188. _markAllSubMeshesAsTexturesDirty(): void;
  109189. /**
  109190. * Instantiate a new istance of anisotropy configuration.
  109191. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109192. */
  109193. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109194. /**
  109195. * Specifies that the submesh is ready to be used.
  109196. * @param defines the list of "defines" to update.
  109197. * @param scene defines the scene the material belongs to.
  109198. * @returns - boolean indicating that the submesh is ready or not.
  109199. */
  109200. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  109201. /**
  109202. * Checks to see if a texture is used in the material.
  109203. * @param defines the list of "defines" to update.
  109204. * @param mesh the mesh we are preparing the defines for.
  109205. * @param scene defines the scene the material belongs to.
  109206. */
  109207. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  109208. /**
  109209. * Binds the material data.
  109210. * @param uniformBuffer defines the Uniform buffer to fill in.
  109211. * @param scene defines the scene the material belongs to.
  109212. * @param isFrozen defines wether the material is frozen or not.
  109213. */
  109214. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  109215. /**
  109216. * Checks to see if a texture is used in the material.
  109217. * @param texture - Base texture to use.
  109218. * @returns - Boolean specifying if a texture is used in the material.
  109219. */
  109220. hasTexture(texture: BaseTexture): boolean;
  109221. /**
  109222. * Returns an array of the actively used textures.
  109223. * @param activeTextures Array of BaseTextures
  109224. */
  109225. getActiveTextures(activeTextures: BaseTexture[]): void;
  109226. /**
  109227. * Returns the animatable textures.
  109228. * @param animatables Array of animatable textures.
  109229. */
  109230. getAnimatables(animatables: IAnimatable[]): void;
  109231. /**
  109232. * Disposes the resources of the material.
  109233. * @param forceDisposeTextures - Forces the disposal of all textures.
  109234. */
  109235. dispose(forceDisposeTextures?: boolean): void;
  109236. /**
  109237. * Get the current class name of the texture useful for serialization or dynamic coding.
  109238. * @returns "PBRAnisotropicConfiguration"
  109239. */
  109240. getClassName(): string;
  109241. /**
  109242. * Add fallbacks to the effect fallbacks list.
  109243. * @param defines defines the Base texture to use.
  109244. * @param fallbacks defines the current fallback list.
  109245. * @param currentRank defines the current fallback rank.
  109246. * @returns the new fallback rank.
  109247. */
  109248. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  109249. /**
  109250. * Add the required uniforms to the current list.
  109251. * @param uniforms defines the current uniform list.
  109252. */
  109253. static AddUniforms(uniforms: string[]): void;
  109254. /**
  109255. * Add the required uniforms to the current buffer.
  109256. * @param uniformBuffer defines the current uniform buffer.
  109257. */
  109258. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109259. /**
  109260. * Add the required samplers to the current list.
  109261. * @param samplers defines the current sampler list.
  109262. */
  109263. static AddSamplers(samplers: string[]): void;
  109264. /**
  109265. * Makes a duplicate of the current configuration into another one.
  109266. * @param anisotropicConfiguration define the config where to copy the info
  109267. */
  109268. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  109269. /**
  109270. * Serializes this anisotropy configuration.
  109271. * @returns - An object with the serialized config.
  109272. */
  109273. serialize(): any;
  109274. /**
  109275. * Parses a anisotropy Configuration from a serialized object.
  109276. * @param source - Serialized object.
  109277. * @param scene Defines the scene we are parsing for
  109278. * @param rootUrl Defines the rootUrl to load from
  109279. */
  109280. parse(source: any, scene: Scene, rootUrl: string): void;
  109281. }
  109282. }
  109283. declare module BABYLON {
  109284. /**
  109285. * @hidden
  109286. */
  109287. export interface IMaterialBRDFDefines {
  109288. BRDF_V_HEIGHT_CORRELATED: boolean;
  109289. MS_BRDF_ENERGY_CONSERVATION: boolean;
  109290. SPHERICAL_HARMONICS: boolean;
  109291. /** @hidden */
  109292. _areMiscDirty: boolean;
  109293. }
  109294. /**
  109295. * Define the code related to the BRDF parameters of the pbr material.
  109296. */
  109297. export class PBRBRDFConfiguration {
  109298. /**
  109299. * Default value used for the energy conservation.
  109300. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  109301. */
  109302. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  109303. /**
  109304. * Default value used for the Smith Visibility Height Correlated mode.
  109305. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  109306. */
  109307. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  109308. /**
  109309. * Default value used for the IBL diffuse part.
  109310. * This can help switching back to the polynomials mode globally which is a tiny bit
  109311. * less GPU intensive at the drawback of a lower quality.
  109312. */
  109313. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  109314. private _useEnergyConservation;
  109315. /**
  109316. * Defines if the material uses energy conservation.
  109317. */
  109318. useEnergyConservation: boolean;
  109319. private _useSmithVisibilityHeightCorrelated;
  109320. /**
  109321. * LEGACY Mode set to false
  109322. * Defines if the material uses height smith correlated visibility term.
  109323. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  109324. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  109325. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  109326. * Not relying on height correlated will also disable energy conservation.
  109327. */
  109328. useSmithVisibilityHeightCorrelated: boolean;
  109329. private _useSphericalHarmonics;
  109330. /**
  109331. * LEGACY Mode set to false
  109332. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  109333. * diffuse part of the IBL.
  109334. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  109335. * to the ground truth.
  109336. */
  109337. useSphericalHarmonics: boolean;
  109338. /** @hidden */
  109339. private _internalMarkAllSubMeshesAsMiscDirty;
  109340. /** @hidden */
  109341. _markAllSubMeshesAsMiscDirty(): void;
  109342. /**
  109343. * Instantiate a new istance of clear coat configuration.
  109344. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  109345. */
  109346. constructor(markAllSubMeshesAsMiscDirty: () => void);
  109347. /**
  109348. * Checks to see if a texture is used in the material.
  109349. * @param defines the list of "defines" to update.
  109350. */
  109351. prepareDefines(defines: IMaterialBRDFDefines): void;
  109352. /**
  109353. * Get the current class name of the texture useful for serialization or dynamic coding.
  109354. * @returns "PBRClearCoatConfiguration"
  109355. */
  109356. getClassName(): string;
  109357. /**
  109358. * Makes a duplicate of the current configuration into another one.
  109359. * @param brdfConfiguration define the config where to copy the info
  109360. */
  109361. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  109362. /**
  109363. * Serializes this BRDF configuration.
  109364. * @returns - An object with the serialized config.
  109365. */
  109366. serialize(): any;
  109367. /**
  109368. * Parses a anisotropy Configuration from a serialized object.
  109369. * @param source - Serialized object.
  109370. * @param scene Defines the scene we are parsing for
  109371. * @param rootUrl Defines the rootUrl to load from
  109372. */
  109373. parse(source: any, scene: Scene, rootUrl: string): void;
  109374. }
  109375. }
  109376. declare module BABYLON {
  109377. /**
  109378. * @hidden
  109379. */
  109380. export interface IMaterialSheenDefines {
  109381. SHEEN: boolean;
  109382. SHEEN_TEXTURE: boolean;
  109383. SHEEN_TEXTUREDIRECTUV: number;
  109384. SHEEN_LINKWITHALBEDO: boolean;
  109385. /** @hidden */
  109386. _areTexturesDirty: boolean;
  109387. }
  109388. /**
  109389. * Define the code related to the Sheen parameters of the pbr material.
  109390. */
  109391. export class PBRSheenConfiguration {
  109392. private _isEnabled;
  109393. /**
  109394. * Defines if the material uses sheen.
  109395. */
  109396. isEnabled: boolean;
  109397. private _linkSheenWithAlbedo;
  109398. /**
  109399. * Defines if the sheen is linked to the sheen color.
  109400. */
  109401. linkSheenWithAlbedo: boolean;
  109402. /**
  109403. * Defines the sheen intensity.
  109404. */
  109405. intensity: number;
  109406. /**
  109407. * Defines the sheen color.
  109408. */
  109409. color: Color3;
  109410. private _texture;
  109411. /**
  109412. * Stores the sheen tint values in a texture.
  109413. * rgb is tint
  109414. * a is a intensity
  109415. */
  109416. texture: Nullable<BaseTexture>;
  109417. /** @hidden */
  109418. private _internalMarkAllSubMeshesAsTexturesDirty;
  109419. /** @hidden */
  109420. _markAllSubMeshesAsTexturesDirty(): void;
  109421. /**
  109422. * Instantiate a new istance of clear coat configuration.
  109423. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109424. */
  109425. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109426. /**
  109427. * Specifies that the submesh is ready to be used.
  109428. * @param defines the list of "defines" to update.
  109429. * @param scene defines the scene the material belongs to.
  109430. * @returns - boolean indicating that the submesh is ready or not.
  109431. */
  109432. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  109433. /**
  109434. * Checks to see if a texture is used in the material.
  109435. * @param defines the list of "defines" to update.
  109436. * @param scene defines the scene the material belongs to.
  109437. */
  109438. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  109439. /**
  109440. * Binds the material data.
  109441. * @param uniformBuffer defines the Uniform buffer to fill in.
  109442. * @param scene defines the scene the material belongs to.
  109443. * @param isFrozen defines wether the material is frozen or not.
  109444. */
  109445. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  109446. /**
  109447. * Checks to see if a texture is used in the material.
  109448. * @param texture - Base texture to use.
  109449. * @returns - Boolean specifying if a texture is used in the material.
  109450. */
  109451. hasTexture(texture: BaseTexture): boolean;
  109452. /**
  109453. * Returns an array of the actively used textures.
  109454. * @param activeTextures Array of BaseTextures
  109455. */
  109456. getActiveTextures(activeTextures: BaseTexture[]): void;
  109457. /**
  109458. * Returns the animatable textures.
  109459. * @param animatables Array of animatable textures.
  109460. */
  109461. getAnimatables(animatables: IAnimatable[]): void;
  109462. /**
  109463. * Disposes the resources of the material.
  109464. * @param forceDisposeTextures - Forces the disposal of all textures.
  109465. */
  109466. dispose(forceDisposeTextures?: boolean): void;
  109467. /**
  109468. * Get the current class name of the texture useful for serialization or dynamic coding.
  109469. * @returns "PBRSheenConfiguration"
  109470. */
  109471. getClassName(): string;
  109472. /**
  109473. * Add fallbacks to the effect fallbacks list.
  109474. * @param defines defines the Base texture to use.
  109475. * @param fallbacks defines the current fallback list.
  109476. * @param currentRank defines the current fallback rank.
  109477. * @returns the new fallback rank.
  109478. */
  109479. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  109480. /**
  109481. * Add the required uniforms to the current list.
  109482. * @param uniforms defines the current uniform list.
  109483. */
  109484. static AddUniforms(uniforms: string[]): void;
  109485. /**
  109486. * Add the required uniforms to the current buffer.
  109487. * @param uniformBuffer defines the current uniform buffer.
  109488. */
  109489. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109490. /**
  109491. * Add the required samplers to the current list.
  109492. * @param samplers defines the current sampler list.
  109493. */
  109494. static AddSamplers(samplers: string[]): void;
  109495. /**
  109496. * Makes a duplicate of the current configuration into another one.
  109497. * @param sheenConfiguration define the config where to copy the info
  109498. */
  109499. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  109500. /**
  109501. * Serializes this BRDF configuration.
  109502. * @returns - An object with the serialized config.
  109503. */
  109504. serialize(): any;
  109505. /**
  109506. * Parses a anisotropy Configuration from a serialized object.
  109507. * @param source - Serialized object.
  109508. * @param scene Defines the scene we are parsing for
  109509. * @param rootUrl Defines the rootUrl to load from
  109510. */
  109511. parse(source: any, scene: Scene, rootUrl: string): void;
  109512. }
  109513. }
  109514. declare module BABYLON {
  109515. /**
  109516. * @hidden
  109517. */
  109518. export interface IMaterialSubSurfaceDefines {
  109519. SUBSURFACE: boolean;
  109520. SS_REFRACTION: boolean;
  109521. SS_TRANSLUCENCY: boolean;
  109522. SS_SCATERRING: boolean;
  109523. SS_THICKNESSANDMASK_TEXTURE: boolean;
  109524. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  109525. SS_REFRACTIONMAP_3D: boolean;
  109526. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  109527. SS_LODINREFRACTIONALPHA: boolean;
  109528. SS_GAMMAREFRACTION: boolean;
  109529. SS_RGBDREFRACTION: boolean;
  109530. SS_LINEARSPECULARREFRACTION: boolean;
  109531. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  109532. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  109533. /** @hidden */
  109534. _areTexturesDirty: boolean;
  109535. }
  109536. /**
  109537. * Define the code related to the sub surface parameters of the pbr material.
  109538. */
  109539. export class PBRSubSurfaceConfiguration {
  109540. private _isRefractionEnabled;
  109541. /**
  109542. * Defines if the refraction is enabled in the material.
  109543. */
  109544. isRefractionEnabled: boolean;
  109545. private _isTranslucencyEnabled;
  109546. /**
  109547. * Defines if the translucency is enabled in the material.
  109548. */
  109549. isTranslucencyEnabled: boolean;
  109550. private _isScatteringEnabled;
  109551. /**
  109552. * Defines the refraction intensity of the material.
  109553. * The refraction when enabled replaces the Diffuse part of the material.
  109554. * The intensity helps transitionning between diffuse and refraction.
  109555. */
  109556. refractionIntensity: number;
  109557. /**
  109558. * Defines the translucency intensity of the material.
  109559. * When translucency has been enabled, this defines how much of the "translucency"
  109560. * is addded to the diffuse part of the material.
  109561. */
  109562. translucencyIntensity: number;
  109563. /**
  109564. * Defines the scattering intensity of the material.
  109565. * When scattering has been enabled, this defines how much of the "scattered light"
  109566. * is addded to the diffuse part of the material.
  109567. */
  109568. scatteringIntensity: number;
  109569. private _thicknessTexture;
  109570. /**
  109571. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  109572. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  109573. * 0 would mean minimumThickness
  109574. * 1 would mean maximumThickness
  109575. * The other channels might be use as a mask to vary the different effects intensity.
  109576. */
  109577. thicknessTexture: Nullable<BaseTexture>;
  109578. private _refractionTexture;
  109579. /**
  109580. * Defines the texture to use for refraction.
  109581. */
  109582. refractionTexture: Nullable<BaseTexture>;
  109583. private _indexOfRefraction;
  109584. /**
  109585. * Defines the index of refraction used in the material.
  109586. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  109587. */
  109588. indexOfRefraction: number;
  109589. private _invertRefractionY;
  109590. /**
  109591. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  109592. */
  109593. invertRefractionY: boolean;
  109594. private _linkRefractionWithTransparency;
  109595. /**
  109596. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  109597. * Materials half opaque for instance using refraction could benefit from this control.
  109598. */
  109599. linkRefractionWithTransparency: boolean;
  109600. /**
  109601. * Defines the minimum thickness stored in the thickness map.
  109602. * If no thickness map is defined, this value will be used to simulate thickness.
  109603. */
  109604. minimumThickness: number;
  109605. /**
  109606. * Defines the maximum thickness stored in the thickness map.
  109607. */
  109608. maximumThickness: number;
  109609. /**
  109610. * Defines the volume tint of the material.
  109611. * This is used for both translucency and scattering.
  109612. */
  109613. tintColor: Color3;
  109614. /**
  109615. * Defines the distance at which the tint color should be found in the media.
  109616. * This is used for refraction only.
  109617. */
  109618. tintColorAtDistance: number;
  109619. /**
  109620. * Defines how far each channel transmit through the media.
  109621. * It is defined as a color to simplify it selection.
  109622. */
  109623. diffusionDistance: Color3;
  109624. private _useMaskFromThicknessTexture;
  109625. /**
  109626. * Stores the intensity of the different subsurface effects in the thickness texture.
  109627. * * the green channel is the translucency intensity.
  109628. * * the blue channel is the scattering intensity.
  109629. * * the alpha channel is the refraction intensity.
  109630. */
  109631. useMaskFromThicknessTexture: boolean;
  109632. /** @hidden */
  109633. private _internalMarkAllSubMeshesAsTexturesDirty;
  109634. /** @hidden */
  109635. _markAllSubMeshesAsTexturesDirty(): void;
  109636. /**
  109637. * Instantiate a new istance of sub surface configuration.
  109638. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109639. */
  109640. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109641. /**
  109642. * Gets wehter the submesh is ready to be used or not.
  109643. * @param defines the list of "defines" to update.
  109644. * @param scene defines the scene the material belongs to.
  109645. * @returns - boolean indicating that the submesh is ready or not.
  109646. */
  109647. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  109648. /**
  109649. * Checks to see if a texture is used in the material.
  109650. * @param defines the list of "defines" to update.
  109651. * @param scene defines the scene to the material belongs to.
  109652. */
  109653. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  109654. /**
  109655. * Binds the material data.
  109656. * @param uniformBuffer defines the Uniform buffer to fill in.
  109657. * @param scene defines the scene the material belongs to.
  109658. * @param engine defines the engine the material belongs to.
  109659. * @param isFrozen defines wether the material is frozen or not.
  109660. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  109661. */
  109662. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  109663. /**
  109664. * Unbinds the material from the mesh.
  109665. * @param activeEffect defines the effect that should be unbound from.
  109666. * @returns true if unbound, otherwise false
  109667. */
  109668. unbind(activeEffect: Effect): boolean;
  109669. /**
  109670. * Returns the texture used for refraction or null if none is used.
  109671. * @param scene defines the scene the material belongs to.
  109672. * @returns - Refraction texture if present. If no refraction texture and refraction
  109673. * is linked with transparency, returns environment texture. Otherwise, returns null.
  109674. */
  109675. private _getRefractionTexture;
  109676. /**
  109677. * Returns true if alpha blending should be disabled.
  109678. */
  109679. readonly disableAlphaBlending: boolean;
  109680. /**
  109681. * Fills the list of render target textures.
  109682. * @param renderTargets the list of render targets to update
  109683. */
  109684. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  109685. /**
  109686. * Checks to see if a texture is used in the material.
  109687. * @param texture - Base texture to use.
  109688. * @returns - Boolean specifying if a texture is used in the material.
  109689. */
  109690. hasTexture(texture: BaseTexture): boolean;
  109691. /**
  109692. * Gets a boolean indicating that current material needs to register RTT
  109693. * @returns true if this uses a render target otherwise false.
  109694. */
  109695. hasRenderTargetTextures(): boolean;
  109696. /**
  109697. * Returns an array of the actively used textures.
  109698. * @param activeTextures Array of BaseTextures
  109699. */
  109700. getActiveTextures(activeTextures: BaseTexture[]): void;
  109701. /**
  109702. * Returns the animatable textures.
  109703. * @param animatables Array of animatable textures.
  109704. */
  109705. getAnimatables(animatables: IAnimatable[]): void;
  109706. /**
  109707. * Disposes the resources of the material.
  109708. * @param forceDisposeTextures - Forces the disposal of all textures.
  109709. */
  109710. dispose(forceDisposeTextures?: boolean): void;
  109711. /**
  109712. * Get the current class name of the texture useful for serialization or dynamic coding.
  109713. * @returns "PBRSubSurfaceConfiguration"
  109714. */
  109715. getClassName(): string;
  109716. /**
  109717. * Add fallbacks to the effect fallbacks list.
  109718. * @param defines defines the Base texture to use.
  109719. * @param fallbacks defines the current fallback list.
  109720. * @param currentRank defines the current fallback rank.
  109721. * @returns the new fallback rank.
  109722. */
  109723. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  109724. /**
  109725. * Add the required uniforms to the current list.
  109726. * @param uniforms defines the current uniform list.
  109727. */
  109728. static AddUniforms(uniforms: string[]): void;
  109729. /**
  109730. * Add the required samplers to the current list.
  109731. * @param samplers defines the current sampler list.
  109732. */
  109733. static AddSamplers(samplers: string[]): void;
  109734. /**
  109735. * Add the required uniforms to the current buffer.
  109736. * @param uniformBuffer defines the current uniform buffer.
  109737. */
  109738. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109739. /**
  109740. * Makes a duplicate of the current configuration into another one.
  109741. * @param configuration define the config where to copy the info
  109742. */
  109743. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  109744. /**
  109745. * Serializes this Sub Surface configuration.
  109746. * @returns - An object with the serialized config.
  109747. */
  109748. serialize(): any;
  109749. /**
  109750. * Parses a anisotropy Configuration from a serialized object.
  109751. * @param source - Serialized object.
  109752. * @param scene Defines the scene we are parsing for
  109753. * @param rootUrl Defines the rootUrl to load from
  109754. */
  109755. parse(source: any, scene: Scene, rootUrl: string): void;
  109756. }
  109757. }
  109758. declare module BABYLON {
  109759. /** @hidden */
  109760. export var pbrFragmentDeclaration: {
  109761. name: string;
  109762. shader: string;
  109763. };
  109764. }
  109765. declare module BABYLON {
  109766. /** @hidden */
  109767. export var pbrUboDeclaration: {
  109768. name: string;
  109769. shader: string;
  109770. };
  109771. }
  109772. declare module BABYLON {
  109773. /** @hidden */
  109774. export var pbrFragmentExtraDeclaration: {
  109775. name: string;
  109776. shader: string;
  109777. };
  109778. }
  109779. declare module BABYLON {
  109780. /** @hidden */
  109781. export var pbrFragmentSamplersDeclaration: {
  109782. name: string;
  109783. shader: string;
  109784. };
  109785. }
  109786. declare module BABYLON {
  109787. /** @hidden */
  109788. export var pbrHelperFunctions: {
  109789. name: string;
  109790. shader: string;
  109791. };
  109792. }
  109793. declare module BABYLON {
  109794. /** @hidden */
  109795. export var harmonicsFunctions: {
  109796. name: string;
  109797. shader: string;
  109798. };
  109799. }
  109800. declare module BABYLON {
  109801. /** @hidden */
  109802. export var pbrDirectLightingSetupFunctions: {
  109803. name: string;
  109804. shader: string;
  109805. };
  109806. }
  109807. declare module BABYLON {
  109808. /** @hidden */
  109809. export var pbrDirectLightingFalloffFunctions: {
  109810. name: string;
  109811. shader: string;
  109812. };
  109813. }
  109814. declare module BABYLON {
  109815. /** @hidden */
  109816. export var pbrBRDFFunctions: {
  109817. name: string;
  109818. shader: string;
  109819. };
  109820. }
  109821. declare module BABYLON {
  109822. /** @hidden */
  109823. export var pbrDirectLightingFunctions: {
  109824. name: string;
  109825. shader: string;
  109826. };
  109827. }
  109828. declare module BABYLON {
  109829. /** @hidden */
  109830. export var pbrIBLFunctions: {
  109831. name: string;
  109832. shader: string;
  109833. };
  109834. }
  109835. declare module BABYLON {
  109836. /** @hidden */
  109837. export var pbrDebug: {
  109838. name: string;
  109839. shader: string;
  109840. };
  109841. }
  109842. declare module BABYLON {
  109843. /** @hidden */
  109844. export var pbrPixelShader: {
  109845. name: string;
  109846. shader: string;
  109847. };
  109848. }
  109849. declare module BABYLON {
  109850. /** @hidden */
  109851. export var pbrVertexDeclaration: {
  109852. name: string;
  109853. shader: string;
  109854. };
  109855. }
  109856. declare module BABYLON {
  109857. /** @hidden */
  109858. export var pbrVertexShader: {
  109859. name: string;
  109860. shader: string;
  109861. };
  109862. }
  109863. declare module BABYLON {
  109864. /**
  109865. * Manages the defines for the PBR Material.
  109866. * @hidden
  109867. */
  109868. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  109869. PBR: boolean;
  109870. MAINUV1: boolean;
  109871. MAINUV2: boolean;
  109872. UV1: boolean;
  109873. UV2: boolean;
  109874. ALBEDO: boolean;
  109875. ALBEDODIRECTUV: number;
  109876. VERTEXCOLOR: boolean;
  109877. AMBIENT: boolean;
  109878. AMBIENTDIRECTUV: number;
  109879. AMBIENTINGRAYSCALE: boolean;
  109880. OPACITY: boolean;
  109881. VERTEXALPHA: boolean;
  109882. OPACITYDIRECTUV: number;
  109883. OPACITYRGB: boolean;
  109884. ALPHATEST: boolean;
  109885. DEPTHPREPASS: boolean;
  109886. ALPHABLEND: boolean;
  109887. ALPHAFROMALBEDO: boolean;
  109888. ALPHATESTVALUE: string;
  109889. SPECULAROVERALPHA: boolean;
  109890. RADIANCEOVERALPHA: boolean;
  109891. ALPHAFRESNEL: boolean;
  109892. LINEARALPHAFRESNEL: boolean;
  109893. PREMULTIPLYALPHA: boolean;
  109894. EMISSIVE: boolean;
  109895. EMISSIVEDIRECTUV: number;
  109896. REFLECTIVITY: boolean;
  109897. REFLECTIVITYDIRECTUV: number;
  109898. SPECULARTERM: boolean;
  109899. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  109900. MICROSURFACEAUTOMATIC: boolean;
  109901. LODBASEDMICROSFURACE: boolean;
  109902. MICROSURFACEMAP: boolean;
  109903. MICROSURFACEMAPDIRECTUV: number;
  109904. METALLICWORKFLOW: boolean;
  109905. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  109906. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  109907. METALLNESSSTOREINMETALMAPBLUE: boolean;
  109908. AOSTOREINMETALMAPRED: boolean;
  109909. ENVIRONMENTBRDF: boolean;
  109910. ENVIRONMENTBRDF_RGBD: boolean;
  109911. NORMAL: boolean;
  109912. TANGENT: boolean;
  109913. BUMP: boolean;
  109914. BUMPDIRECTUV: number;
  109915. OBJECTSPACE_NORMALMAP: boolean;
  109916. PARALLAX: boolean;
  109917. PARALLAXOCCLUSION: boolean;
  109918. NORMALXYSCALE: boolean;
  109919. LIGHTMAP: boolean;
  109920. LIGHTMAPDIRECTUV: number;
  109921. USELIGHTMAPASSHADOWMAP: boolean;
  109922. GAMMALIGHTMAP: boolean;
  109923. REFLECTION: boolean;
  109924. REFLECTIONMAP_3D: boolean;
  109925. REFLECTIONMAP_SPHERICAL: boolean;
  109926. REFLECTIONMAP_PLANAR: boolean;
  109927. REFLECTIONMAP_CUBIC: boolean;
  109928. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  109929. REFLECTIONMAP_PROJECTION: boolean;
  109930. REFLECTIONMAP_SKYBOX: boolean;
  109931. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  109932. REFLECTIONMAP_EXPLICIT: boolean;
  109933. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  109934. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  109935. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  109936. INVERTCUBICMAP: boolean;
  109937. USESPHERICALFROMREFLECTIONMAP: boolean;
  109938. USEIRRADIANCEMAP: boolean;
  109939. SPHERICAL_HARMONICS: boolean;
  109940. USESPHERICALINVERTEX: boolean;
  109941. REFLECTIONMAP_OPPOSITEZ: boolean;
  109942. LODINREFLECTIONALPHA: boolean;
  109943. GAMMAREFLECTION: boolean;
  109944. RGBDREFLECTION: boolean;
  109945. LINEARSPECULARREFLECTION: boolean;
  109946. RADIANCEOCCLUSION: boolean;
  109947. HORIZONOCCLUSION: boolean;
  109948. INSTANCES: boolean;
  109949. NUM_BONE_INFLUENCERS: number;
  109950. BonesPerMesh: number;
  109951. BONETEXTURE: boolean;
  109952. NONUNIFORMSCALING: boolean;
  109953. MORPHTARGETS: boolean;
  109954. MORPHTARGETS_NORMAL: boolean;
  109955. MORPHTARGETS_TANGENT: boolean;
  109956. MORPHTARGETS_UV: boolean;
  109957. NUM_MORPH_INFLUENCERS: number;
  109958. IMAGEPROCESSING: boolean;
  109959. VIGNETTE: boolean;
  109960. VIGNETTEBLENDMODEMULTIPLY: boolean;
  109961. VIGNETTEBLENDMODEOPAQUE: boolean;
  109962. TONEMAPPING: boolean;
  109963. TONEMAPPING_ACES: boolean;
  109964. CONTRAST: boolean;
  109965. COLORCURVES: boolean;
  109966. COLORGRADING: boolean;
  109967. COLORGRADING3D: boolean;
  109968. SAMPLER3DGREENDEPTH: boolean;
  109969. SAMPLER3DBGRMAP: boolean;
  109970. IMAGEPROCESSINGPOSTPROCESS: boolean;
  109971. EXPOSURE: boolean;
  109972. MULTIVIEW: boolean;
  109973. USEPHYSICALLIGHTFALLOFF: boolean;
  109974. USEGLTFLIGHTFALLOFF: boolean;
  109975. TWOSIDEDLIGHTING: boolean;
  109976. SHADOWFLOAT: boolean;
  109977. CLIPPLANE: boolean;
  109978. CLIPPLANE2: boolean;
  109979. CLIPPLANE3: boolean;
  109980. CLIPPLANE4: boolean;
  109981. POINTSIZE: boolean;
  109982. FOG: boolean;
  109983. LOGARITHMICDEPTH: boolean;
  109984. FORCENORMALFORWARD: boolean;
  109985. SPECULARAA: boolean;
  109986. CLEARCOAT: boolean;
  109987. CLEARCOAT_DEFAULTIOR: boolean;
  109988. CLEARCOAT_TEXTURE: boolean;
  109989. CLEARCOAT_TEXTUREDIRECTUV: number;
  109990. CLEARCOAT_BUMP: boolean;
  109991. CLEARCOAT_BUMPDIRECTUV: number;
  109992. CLEARCOAT_TINT: boolean;
  109993. CLEARCOAT_TINT_TEXTURE: boolean;
  109994. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  109995. ANISOTROPIC: boolean;
  109996. ANISOTROPIC_TEXTURE: boolean;
  109997. ANISOTROPIC_TEXTUREDIRECTUV: number;
  109998. BRDF_V_HEIGHT_CORRELATED: boolean;
  109999. MS_BRDF_ENERGY_CONSERVATION: boolean;
  110000. SHEEN: boolean;
  110001. SHEEN_TEXTURE: boolean;
  110002. SHEEN_TEXTUREDIRECTUV: number;
  110003. SHEEN_LINKWITHALBEDO: boolean;
  110004. SUBSURFACE: boolean;
  110005. SS_REFRACTION: boolean;
  110006. SS_TRANSLUCENCY: boolean;
  110007. SS_SCATERRING: boolean;
  110008. SS_THICKNESSANDMASK_TEXTURE: boolean;
  110009. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  110010. SS_REFRACTIONMAP_3D: boolean;
  110011. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  110012. SS_LODINREFRACTIONALPHA: boolean;
  110013. SS_GAMMAREFRACTION: boolean;
  110014. SS_RGBDREFRACTION: boolean;
  110015. SS_LINEARSPECULARREFRACTION: boolean;
  110016. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  110017. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  110018. UNLIT: boolean;
  110019. DEBUGMODE: number;
  110020. /**
  110021. * Initializes the PBR Material defines.
  110022. */
  110023. constructor();
  110024. /**
  110025. * Resets the PBR Material defines.
  110026. */
  110027. reset(): void;
  110028. }
  110029. /**
  110030. * The Physically based material base class of BJS.
  110031. *
  110032. * This offers the main features of a standard PBR material.
  110033. * For more information, please refer to the documentation :
  110034. * https://doc.babylonjs.com/how_to/physically_based_rendering
  110035. */
  110036. export abstract class PBRBaseMaterial extends PushMaterial {
  110037. /**
  110038. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  110039. */
  110040. static readonly PBRMATERIAL_OPAQUE: number;
  110041. /**
  110042. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  110043. */
  110044. static readonly PBRMATERIAL_ALPHATEST: number;
  110045. /**
  110046. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110047. */
  110048. static readonly PBRMATERIAL_ALPHABLEND: number;
  110049. /**
  110050. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110051. * They are also discarded below the alpha cutoff threshold to improve performances.
  110052. */
  110053. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  110054. /**
  110055. * Defines the default value of how much AO map is occluding the analytical lights
  110056. * (point spot...).
  110057. */
  110058. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  110059. /**
  110060. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  110061. */
  110062. static readonly LIGHTFALLOFF_PHYSICAL: number;
  110063. /**
  110064. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  110065. * to enhance interoperability with other engines.
  110066. */
  110067. static readonly LIGHTFALLOFF_GLTF: number;
  110068. /**
  110069. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  110070. * to enhance interoperability with other materials.
  110071. */
  110072. static readonly LIGHTFALLOFF_STANDARD: number;
  110073. /**
  110074. * Intensity of the direct lights e.g. the four lights available in your scene.
  110075. * This impacts both the direct diffuse and specular highlights.
  110076. */
  110077. protected _directIntensity: number;
  110078. /**
  110079. * Intensity of the emissive part of the material.
  110080. * This helps controlling the emissive effect without modifying the emissive color.
  110081. */
  110082. protected _emissiveIntensity: number;
  110083. /**
  110084. * Intensity of the environment e.g. how much the environment will light the object
  110085. * either through harmonics for rough material or through the refelction for shiny ones.
  110086. */
  110087. protected _environmentIntensity: number;
  110088. /**
  110089. * This is a special control allowing the reduction of the specular highlights coming from the
  110090. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  110091. */
  110092. protected _specularIntensity: number;
  110093. /**
  110094. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  110095. */
  110096. private _lightingInfos;
  110097. /**
  110098. * Debug Control allowing disabling the bump map on this material.
  110099. */
  110100. protected _disableBumpMap: boolean;
  110101. /**
  110102. * AKA Diffuse Texture in standard nomenclature.
  110103. */
  110104. protected _albedoTexture: Nullable<BaseTexture>;
  110105. /**
  110106. * AKA Occlusion Texture in other nomenclature.
  110107. */
  110108. protected _ambientTexture: Nullable<BaseTexture>;
  110109. /**
  110110. * AKA Occlusion Texture Intensity in other nomenclature.
  110111. */
  110112. protected _ambientTextureStrength: number;
  110113. /**
  110114. * Defines how much the AO map is occluding the analytical lights (point spot...).
  110115. * 1 means it completely occludes it
  110116. * 0 mean it has no impact
  110117. */
  110118. protected _ambientTextureImpactOnAnalyticalLights: number;
  110119. /**
  110120. * Stores the alpha values in a texture.
  110121. */
  110122. protected _opacityTexture: Nullable<BaseTexture>;
  110123. /**
  110124. * Stores the reflection values in a texture.
  110125. */
  110126. protected _reflectionTexture: Nullable<BaseTexture>;
  110127. /**
  110128. * Stores the emissive values in a texture.
  110129. */
  110130. protected _emissiveTexture: Nullable<BaseTexture>;
  110131. /**
  110132. * AKA Specular texture in other nomenclature.
  110133. */
  110134. protected _reflectivityTexture: Nullable<BaseTexture>;
  110135. /**
  110136. * Used to switch from specular/glossiness to metallic/roughness workflow.
  110137. */
  110138. protected _metallicTexture: Nullable<BaseTexture>;
  110139. /**
  110140. * Specifies the metallic scalar of the metallic/roughness workflow.
  110141. * Can also be used to scale the metalness values of the metallic texture.
  110142. */
  110143. protected _metallic: Nullable<number>;
  110144. /**
  110145. * Specifies the roughness scalar of the metallic/roughness workflow.
  110146. * Can also be used to scale the roughness values of the metallic texture.
  110147. */
  110148. protected _roughness: Nullable<number>;
  110149. /**
  110150. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  110151. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  110152. */
  110153. protected _microSurfaceTexture: Nullable<BaseTexture>;
  110154. /**
  110155. * Stores surface normal data used to displace a mesh in a texture.
  110156. */
  110157. protected _bumpTexture: Nullable<BaseTexture>;
  110158. /**
  110159. * Stores the pre-calculated light information of a mesh in a texture.
  110160. */
  110161. protected _lightmapTexture: Nullable<BaseTexture>;
  110162. /**
  110163. * The color of a material in ambient lighting.
  110164. */
  110165. protected _ambientColor: Color3;
  110166. /**
  110167. * AKA Diffuse Color in other nomenclature.
  110168. */
  110169. protected _albedoColor: Color3;
  110170. /**
  110171. * AKA Specular Color in other nomenclature.
  110172. */
  110173. protected _reflectivityColor: Color3;
  110174. /**
  110175. * The color applied when light is reflected from a material.
  110176. */
  110177. protected _reflectionColor: Color3;
  110178. /**
  110179. * The color applied when light is emitted from a material.
  110180. */
  110181. protected _emissiveColor: Color3;
  110182. /**
  110183. * AKA Glossiness in other nomenclature.
  110184. */
  110185. protected _microSurface: number;
  110186. /**
  110187. * Specifies that the material will use the light map as a show map.
  110188. */
  110189. protected _useLightmapAsShadowmap: boolean;
  110190. /**
  110191. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  110192. * makes the reflect vector face the model (under horizon).
  110193. */
  110194. protected _useHorizonOcclusion: boolean;
  110195. /**
  110196. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  110197. * too much the area relying on ambient texture to define their ambient occlusion.
  110198. */
  110199. protected _useRadianceOcclusion: boolean;
  110200. /**
  110201. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  110202. */
  110203. protected _useAlphaFromAlbedoTexture: boolean;
  110204. /**
  110205. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  110206. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  110207. */
  110208. protected _useSpecularOverAlpha: boolean;
  110209. /**
  110210. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  110211. */
  110212. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  110213. /**
  110214. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  110215. */
  110216. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  110217. /**
  110218. * Specifies if the metallic texture contains the roughness information in its green channel.
  110219. */
  110220. protected _useRoughnessFromMetallicTextureGreen: boolean;
  110221. /**
  110222. * Specifies if the metallic texture contains the metallness information in its blue channel.
  110223. */
  110224. protected _useMetallnessFromMetallicTextureBlue: boolean;
  110225. /**
  110226. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  110227. */
  110228. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  110229. /**
  110230. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  110231. */
  110232. protected _useAmbientInGrayScale: boolean;
  110233. /**
  110234. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  110235. * The material will try to infer what glossiness each pixel should be.
  110236. */
  110237. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  110238. /**
  110239. * Defines the falloff type used in this material.
  110240. * It by default is Physical.
  110241. */
  110242. protected _lightFalloff: number;
  110243. /**
  110244. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  110245. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  110246. */
  110247. protected _useRadianceOverAlpha: boolean;
  110248. /**
  110249. * Allows using an object space normal map (instead of tangent space).
  110250. */
  110251. protected _useObjectSpaceNormalMap: boolean;
  110252. /**
  110253. * Allows using the bump map in parallax mode.
  110254. */
  110255. protected _useParallax: boolean;
  110256. /**
  110257. * Allows using the bump map in parallax occlusion mode.
  110258. */
  110259. protected _useParallaxOcclusion: boolean;
  110260. /**
  110261. * Controls the scale bias of the parallax mode.
  110262. */
  110263. protected _parallaxScaleBias: number;
  110264. /**
  110265. * If sets to true, disables all the lights affecting the material.
  110266. */
  110267. protected _disableLighting: boolean;
  110268. /**
  110269. * Number of Simultaneous lights allowed on the material.
  110270. */
  110271. protected _maxSimultaneousLights: number;
  110272. /**
  110273. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  110274. */
  110275. protected _invertNormalMapX: boolean;
  110276. /**
  110277. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  110278. */
  110279. protected _invertNormalMapY: boolean;
  110280. /**
  110281. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  110282. */
  110283. protected _twoSidedLighting: boolean;
  110284. /**
  110285. * Defines the alpha limits in alpha test mode.
  110286. */
  110287. protected _alphaCutOff: number;
  110288. /**
  110289. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  110290. */
  110291. protected _forceAlphaTest: boolean;
  110292. /**
  110293. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  110294. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  110295. */
  110296. protected _useAlphaFresnel: boolean;
  110297. /**
  110298. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  110299. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  110300. */
  110301. protected _useLinearAlphaFresnel: boolean;
  110302. /**
  110303. * The transparency mode of the material.
  110304. */
  110305. protected _transparencyMode: Nullable<number>;
  110306. /**
  110307. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  110308. * from cos thetav and roughness:
  110309. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  110310. */
  110311. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  110312. /**
  110313. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  110314. */
  110315. protected _forceIrradianceInFragment: boolean;
  110316. /**
  110317. * Force normal to face away from face.
  110318. */
  110319. protected _forceNormalForward: boolean;
  110320. /**
  110321. * Enables specular anti aliasing in the PBR shader.
  110322. * It will both interacts on the Geometry for analytical and IBL lighting.
  110323. * It also prefilter the roughness map based on the bump values.
  110324. */
  110325. protected _enableSpecularAntiAliasing: boolean;
  110326. /**
  110327. * Default configuration related to image processing available in the PBR Material.
  110328. */
  110329. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  110330. /**
  110331. * Keep track of the image processing observer to allow dispose and replace.
  110332. */
  110333. private _imageProcessingObserver;
  110334. /**
  110335. * Attaches a new image processing configuration to the PBR Material.
  110336. * @param configuration
  110337. */
  110338. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  110339. /**
  110340. * Stores the available render targets.
  110341. */
  110342. private _renderTargets;
  110343. /**
  110344. * Sets the global ambient color for the material used in lighting calculations.
  110345. */
  110346. private _globalAmbientColor;
  110347. /**
  110348. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  110349. */
  110350. private _useLogarithmicDepth;
  110351. /**
  110352. * If set to true, no lighting calculations will be applied.
  110353. */
  110354. private _unlit;
  110355. private _debugMode;
  110356. /**
  110357. * @hidden
  110358. * This is reserved for the inspector.
  110359. * Defines the material debug mode.
  110360. * It helps seeing only some components of the material while troubleshooting.
  110361. */
  110362. debugMode: number;
  110363. /**
  110364. * @hidden
  110365. * This is reserved for the inspector.
  110366. * Specify from where on screen the debug mode should start.
  110367. * The value goes from -1 (full screen) to 1 (not visible)
  110368. * It helps with side by side comparison against the final render
  110369. * This defaults to -1
  110370. */
  110371. private debugLimit;
  110372. /**
  110373. * @hidden
  110374. * This is reserved for the inspector.
  110375. * As the default viewing range might not be enough (if the ambient is really small for instance)
  110376. * You can use the factor to better multiply the final value.
  110377. */
  110378. private debugFactor;
  110379. /**
  110380. * Defines the clear coat layer parameters for the material.
  110381. */
  110382. readonly clearCoat: PBRClearCoatConfiguration;
  110383. /**
  110384. * Defines the anisotropic parameters for the material.
  110385. */
  110386. readonly anisotropy: PBRAnisotropicConfiguration;
  110387. /**
  110388. * Defines the BRDF parameters for the material.
  110389. */
  110390. readonly brdf: PBRBRDFConfiguration;
  110391. /**
  110392. * Defines the Sheen parameters for the material.
  110393. */
  110394. readonly sheen: PBRSheenConfiguration;
  110395. /**
  110396. * Defines the SubSurface parameters for the material.
  110397. */
  110398. readonly subSurface: PBRSubSurfaceConfiguration;
  110399. /**
  110400. * Custom callback helping to override the default shader used in the material.
  110401. */
  110402. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  110403. /**
  110404. * Instantiates a new PBRMaterial instance.
  110405. *
  110406. * @param name The material name
  110407. * @param scene The scene the material will be use in.
  110408. */
  110409. constructor(name: string, scene: Scene);
  110410. /**
  110411. * Gets a boolean indicating that current material needs to register RTT
  110412. */
  110413. readonly hasRenderTargetTextures: boolean;
  110414. /**
  110415. * Gets the name of the material class.
  110416. */
  110417. getClassName(): string;
  110418. /**
  110419. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  110420. */
  110421. /**
  110422. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  110423. */
  110424. useLogarithmicDepth: boolean;
  110425. /**
  110426. * Gets the current transparency mode.
  110427. */
  110428. /**
  110429. * Sets the transparency mode of the material.
  110430. *
  110431. * | Value | Type | Description |
  110432. * | ----- | ----------------------------------- | ----------- |
  110433. * | 0 | OPAQUE | |
  110434. * | 1 | ALPHATEST | |
  110435. * | 2 | ALPHABLEND | |
  110436. * | 3 | ALPHATESTANDBLEND | |
  110437. *
  110438. */
  110439. transparencyMode: Nullable<number>;
  110440. /**
  110441. * Returns true if alpha blending should be disabled.
  110442. */
  110443. private readonly _disableAlphaBlending;
  110444. /**
  110445. * Specifies whether or not this material should be rendered in alpha blend mode.
  110446. */
  110447. needAlphaBlending(): boolean;
  110448. /**
  110449. * Specifies if the mesh will require alpha blending.
  110450. * @param mesh - BJS mesh.
  110451. */
  110452. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  110453. /**
  110454. * Specifies whether or not this material should be rendered in alpha test mode.
  110455. */
  110456. needAlphaTesting(): boolean;
  110457. /**
  110458. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  110459. */
  110460. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  110461. /**
  110462. * Gets the texture used for the alpha test.
  110463. */
  110464. getAlphaTestTexture(): Nullable<BaseTexture>;
  110465. /**
  110466. * Specifies that the submesh is ready to be used.
  110467. * @param mesh - BJS mesh.
  110468. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  110469. * @param useInstances - Specifies that instances should be used.
  110470. * @returns - boolean indicating that the submesh is ready or not.
  110471. */
  110472. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110473. /**
  110474. * Specifies if the material uses metallic roughness workflow.
  110475. * @returns boolean specifiying if the material uses metallic roughness workflow.
  110476. */
  110477. isMetallicWorkflow(): boolean;
  110478. private _prepareEffect;
  110479. private _prepareDefines;
  110480. /**
  110481. * Force shader compilation
  110482. */
  110483. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  110484. clipPlane: boolean;
  110485. }>): void;
  110486. /**
  110487. * Initializes the uniform buffer layout for the shader.
  110488. */
  110489. buildUniformLayout(): void;
  110490. /**
  110491. * Unbinds the material from the mesh
  110492. */
  110493. unbind(): void;
  110494. /**
  110495. * Binds the submesh data.
  110496. * @param world - The world matrix.
  110497. * @param mesh - The BJS mesh.
  110498. * @param subMesh - A submesh of the BJS mesh.
  110499. */
  110500. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  110501. /**
  110502. * Returns the animatable textures.
  110503. * @returns - Array of animatable textures.
  110504. */
  110505. getAnimatables(): IAnimatable[];
  110506. /**
  110507. * Returns the texture used for reflections.
  110508. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  110509. */
  110510. private _getReflectionTexture;
  110511. /**
  110512. * Returns an array of the actively used textures.
  110513. * @returns - Array of BaseTextures
  110514. */
  110515. getActiveTextures(): BaseTexture[];
  110516. /**
  110517. * Checks to see if a texture is used in the material.
  110518. * @param texture - Base texture to use.
  110519. * @returns - Boolean specifying if a texture is used in the material.
  110520. */
  110521. hasTexture(texture: BaseTexture): boolean;
  110522. /**
  110523. * Disposes the resources of the material.
  110524. * @param forceDisposeEffect - Forces the disposal of effects.
  110525. * @param forceDisposeTextures - Forces the disposal of all textures.
  110526. */
  110527. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  110528. }
  110529. }
  110530. declare module BABYLON {
  110531. /**
  110532. * The Physically based material of BJS.
  110533. *
  110534. * This offers the main features of a standard PBR material.
  110535. * For more information, please refer to the documentation :
  110536. * https://doc.babylonjs.com/how_to/physically_based_rendering
  110537. */
  110538. export class PBRMaterial extends PBRBaseMaterial {
  110539. /**
  110540. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  110541. */
  110542. static readonly PBRMATERIAL_OPAQUE: number;
  110543. /**
  110544. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  110545. */
  110546. static readonly PBRMATERIAL_ALPHATEST: number;
  110547. /**
  110548. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110549. */
  110550. static readonly PBRMATERIAL_ALPHABLEND: number;
  110551. /**
  110552. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110553. * They are also discarded below the alpha cutoff threshold to improve performances.
  110554. */
  110555. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  110556. /**
  110557. * Defines the default value of how much AO map is occluding the analytical lights
  110558. * (point spot...).
  110559. */
  110560. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  110561. /**
  110562. * Intensity of the direct lights e.g. the four lights available in your scene.
  110563. * This impacts both the direct diffuse and specular highlights.
  110564. */
  110565. directIntensity: number;
  110566. /**
  110567. * Intensity of the emissive part of the material.
  110568. * This helps controlling the emissive effect without modifying the emissive color.
  110569. */
  110570. emissiveIntensity: number;
  110571. /**
  110572. * Intensity of the environment e.g. how much the environment will light the object
  110573. * either through harmonics for rough material or through the refelction for shiny ones.
  110574. */
  110575. environmentIntensity: number;
  110576. /**
  110577. * This is a special control allowing the reduction of the specular highlights coming from the
  110578. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  110579. */
  110580. specularIntensity: number;
  110581. /**
  110582. * Debug Control allowing disabling the bump map on this material.
  110583. */
  110584. disableBumpMap: boolean;
  110585. /**
  110586. * AKA Diffuse Texture in standard nomenclature.
  110587. */
  110588. albedoTexture: BaseTexture;
  110589. /**
  110590. * AKA Occlusion Texture in other nomenclature.
  110591. */
  110592. ambientTexture: BaseTexture;
  110593. /**
  110594. * AKA Occlusion Texture Intensity in other nomenclature.
  110595. */
  110596. ambientTextureStrength: number;
  110597. /**
  110598. * Defines how much the AO map is occluding the analytical lights (point spot...).
  110599. * 1 means it completely occludes it
  110600. * 0 mean it has no impact
  110601. */
  110602. ambientTextureImpactOnAnalyticalLights: number;
  110603. /**
  110604. * Stores the alpha values in a texture.
  110605. */
  110606. opacityTexture: BaseTexture;
  110607. /**
  110608. * Stores the reflection values in a texture.
  110609. */
  110610. reflectionTexture: Nullable<BaseTexture>;
  110611. /**
  110612. * Stores the emissive values in a texture.
  110613. */
  110614. emissiveTexture: BaseTexture;
  110615. /**
  110616. * AKA Specular texture in other nomenclature.
  110617. */
  110618. reflectivityTexture: BaseTexture;
  110619. /**
  110620. * Used to switch from specular/glossiness to metallic/roughness workflow.
  110621. */
  110622. metallicTexture: BaseTexture;
  110623. /**
  110624. * Specifies the metallic scalar of the metallic/roughness workflow.
  110625. * Can also be used to scale the metalness values of the metallic texture.
  110626. */
  110627. metallic: Nullable<number>;
  110628. /**
  110629. * Specifies the roughness scalar of the metallic/roughness workflow.
  110630. * Can also be used to scale the roughness values of the metallic texture.
  110631. */
  110632. roughness: Nullable<number>;
  110633. /**
  110634. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  110635. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  110636. */
  110637. microSurfaceTexture: BaseTexture;
  110638. /**
  110639. * Stores surface normal data used to displace a mesh in a texture.
  110640. */
  110641. bumpTexture: BaseTexture;
  110642. /**
  110643. * Stores the pre-calculated light information of a mesh in a texture.
  110644. */
  110645. lightmapTexture: BaseTexture;
  110646. /**
  110647. * Stores the refracted light information in a texture.
  110648. */
  110649. refractionTexture: Nullable<BaseTexture>;
  110650. /**
  110651. * The color of a material in ambient lighting.
  110652. */
  110653. ambientColor: Color3;
  110654. /**
  110655. * AKA Diffuse Color in other nomenclature.
  110656. */
  110657. albedoColor: Color3;
  110658. /**
  110659. * AKA Specular Color in other nomenclature.
  110660. */
  110661. reflectivityColor: Color3;
  110662. /**
  110663. * The color reflected from the material.
  110664. */
  110665. reflectionColor: Color3;
  110666. /**
  110667. * The color emitted from the material.
  110668. */
  110669. emissiveColor: Color3;
  110670. /**
  110671. * AKA Glossiness in other nomenclature.
  110672. */
  110673. microSurface: number;
  110674. /**
  110675. * source material index of refraction (IOR)' / 'destination material IOR.
  110676. */
  110677. indexOfRefraction: number;
  110678. /**
  110679. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  110680. */
  110681. invertRefractionY: boolean;
  110682. /**
  110683. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  110684. * Materials half opaque for instance using refraction could benefit from this control.
  110685. */
  110686. linkRefractionWithTransparency: boolean;
  110687. /**
  110688. * If true, the light map contains occlusion information instead of lighting info.
  110689. */
  110690. useLightmapAsShadowmap: boolean;
  110691. /**
  110692. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  110693. */
  110694. useAlphaFromAlbedoTexture: boolean;
  110695. /**
  110696. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  110697. */
  110698. forceAlphaTest: boolean;
  110699. /**
  110700. * Defines the alpha limits in alpha test mode.
  110701. */
  110702. alphaCutOff: number;
  110703. /**
  110704. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  110705. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  110706. */
  110707. useSpecularOverAlpha: boolean;
  110708. /**
  110709. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  110710. */
  110711. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  110712. /**
  110713. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  110714. */
  110715. useRoughnessFromMetallicTextureAlpha: boolean;
  110716. /**
  110717. * Specifies if the metallic texture contains the roughness information in its green channel.
  110718. */
  110719. useRoughnessFromMetallicTextureGreen: boolean;
  110720. /**
  110721. * Specifies if the metallic texture contains the metallness information in its blue channel.
  110722. */
  110723. useMetallnessFromMetallicTextureBlue: boolean;
  110724. /**
  110725. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  110726. */
  110727. useAmbientOcclusionFromMetallicTextureRed: boolean;
  110728. /**
  110729. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  110730. */
  110731. useAmbientInGrayScale: boolean;
  110732. /**
  110733. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  110734. * The material will try to infer what glossiness each pixel should be.
  110735. */
  110736. useAutoMicroSurfaceFromReflectivityMap: boolean;
  110737. /**
  110738. * BJS is using an harcoded light falloff based on a manually sets up range.
  110739. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  110740. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  110741. */
  110742. /**
  110743. * BJS is using an harcoded light falloff based on a manually sets up range.
  110744. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  110745. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  110746. */
  110747. usePhysicalLightFalloff: boolean;
  110748. /**
  110749. * In order to support the falloff compatibility with gltf, a special mode has been added
  110750. * to reproduce the gltf light falloff.
  110751. */
  110752. /**
  110753. * In order to support the falloff compatibility with gltf, a special mode has been added
  110754. * to reproduce the gltf light falloff.
  110755. */
  110756. useGLTFLightFalloff: boolean;
  110757. /**
  110758. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  110759. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  110760. */
  110761. useRadianceOverAlpha: boolean;
  110762. /**
  110763. * Allows using an object space normal map (instead of tangent space).
  110764. */
  110765. useObjectSpaceNormalMap: boolean;
  110766. /**
  110767. * Allows using the bump map in parallax mode.
  110768. */
  110769. useParallax: boolean;
  110770. /**
  110771. * Allows using the bump map in parallax occlusion mode.
  110772. */
  110773. useParallaxOcclusion: boolean;
  110774. /**
  110775. * Controls the scale bias of the parallax mode.
  110776. */
  110777. parallaxScaleBias: number;
  110778. /**
  110779. * If sets to true, disables all the lights affecting the material.
  110780. */
  110781. disableLighting: boolean;
  110782. /**
  110783. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  110784. */
  110785. forceIrradianceInFragment: boolean;
  110786. /**
  110787. * Number of Simultaneous lights allowed on the material.
  110788. */
  110789. maxSimultaneousLights: number;
  110790. /**
  110791. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  110792. */
  110793. invertNormalMapX: boolean;
  110794. /**
  110795. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  110796. */
  110797. invertNormalMapY: boolean;
  110798. /**
  110799. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  110800. */
  110801. twoSidedLighting: boolean;
  110802. /**
  110803. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  110804. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  110805. */
  110806. useAlphaFresnel: boolean;
  110807. /**
  110808. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  110809. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  110810. */
  110811. useLinearAlphaFresnel: boolean;
  110812. /**
  110813. * Let user defines the brdf lookup texture used for IBL.
  110814. * A default 8bit version is embedded but you could point at :
  110815. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  110816. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  110817. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  110818. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  110819. */
  110820. environmentBRDFTexture: Nullable<BaseTexture>;
  110821. /**
  110822. * Force normal to face away from face.
  110823. */
  110824. forceNormalForward: boolean;
  110825. /**
  110826. * Enables specular anti aliasing in the PBR shader.
  110827. * It will both interacts on the Geometry for analytical and IBL lighting.
  110828. * It also prefilter the roughness map based on the bump values.
  110829. */
  110830. enableSpecularAntiAliasing: boolean;
  110831. /**
  110832. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  110833. * makes the reflect vector face the model (under horizon).
  110834. */
  110835. useHorizonOcclusion: boolean;
  110836. /**
  110837. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  110838. * too much the area relying on ambient texture to define their ambient occlusion.
  110839. */
  110840. useRadianceOcclusion: boolean;
  110841. /**
  110842. * If set to true, no lighting calculations will be applied.
  110843. */
  110844. unlit: boolean;
  110845. /**
  110846. * Gets the image processing configuration used either in this material.
  110847. */
  110848. /**
  110849. * Sets the Default image processing configuration used either in the this material.
  110850. *
  110851. * If sets to null, the scene one is in use.
  110852. */
  110853. imageProcessingConfiguration: ImageProcessingConfiguration;
  110854. /**
  110855. * Gets wether the color curves effect is enabled.
  110856. */
  110857. /**
  110858. * Sets wether the color curves effect is enabled.
  110859. */
  110860. cameraColorCurvesEnabled: boolean;
  110861. /**
  110862. * Gets wether the color grading effect is enabled.
  110863. */
  110864. /**
  110865. * Gets wether the color grading effect is enabled.
  110866. */
  110867. cameraColorGradingEnabled: boolean;
  110868. /**
  110869. * Gets wether tonemapping is enabled or not.
  110870. */
  110871. /**
  110872. * Sets wether tonemapping is enabled or not
  110873. */
  110874. cameraToneMappingEnabled: boolean;
  110875. /**
  110876. * The camera exposure used on this material.
  110877. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110878. * This corresponds to a photographic exposure.
  110879. */
  110880. /**
  110881. * The camera exposure used on this material.
  110882. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110883. * This corresponds to a photographic exposure.
  110884. */
  110885. cameraExposure: number;
  110886. /**
  110887. * Gets The camera contrast used on this material.
  110888. */
  110889. /**
  110890. * Sets The camera contrast used on this material.
  110891. */
  110892. cameraContrast: number;
  110893. /**
  110894. * Gets the Color Grading 2D Lookup Texture.
  110895. */
  110896. /**
  110897. * Sets the Color Grading 2D Lookup Texture.
  110898. */
  110899. cameraColorGradingTexture: Nullable<BaseTexture>;
  110900. /**
  110901. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110902. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110903. * 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;
  110904. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110905. */
  110906. /**
  110907. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110908. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110909. * 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;
  110910. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110911. */
  110912. cameraColorCurves: Nullable<ColorCurves>;
  110913. /**
  110914. * Instantiates a new PBRMaterial instance.
  110915. *
  110916. * @param name The material name
  110917. * @param scene The scene the material will be use in.
  110918. */
  110919. constructor(name: string, scene: Scene);
  110920. /**
  110921. * Returns the name of this material class.
  110922. */
  110923. getClassName(): string;
  110924. /**
  110925. * Makes a duplicate of the current material.
  110926. * @param name - name to use for the new material.
  110927. */
  110928. clone(name: string): PBRMaterial;
  110929. /**
  110930. * Serializes this PBR Material.
  110931. * @returns - An object with the serialized material.
  110932. */
  110933. serialize(): any;
  110934. /**
  110935. * Parses a PBR Material from a serialized object.
  110936. * @param source - Serialized object.
  110937. * @param scene - BJS scene instance.
  110938. * @param rootUrl - url for the scene object
  110939. * @returns - PBRMaterial
  110940. */
  110941. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  110942. }
  110943. }
  110944. declare module BABYLON {
  110945. /**
  110946. * Direct draw surface info
  110947. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  110948. */
  110949. export interface DDSInfo {
  110950. /**
  110951. * Width of the texture
  110952. */
  110953. width: number;
  110954. /**
  110955. * Width of the texture
  110956. */
  110957. height: number;
  110958. /**
  110959. * Number of Mipmaps for the texture
  110960. * @see https://en.wikipedia.org/wiki/Mipmap
  110961. */
  110962. mipmapCount: number;
  110963. /**
  110964. * If the textures format is a known fourCC format
  110965. * @see https://www.fourcc.org/
  110966. */
  110967. isFourCC: boolean;
  110968. /**
  110969. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  110970. */
  110971. isRGB: boolean;
  110972. /**
  110973. * If the texture is a lumincance format
  110974. */
  110975. isLuminance: boolean;
  110976. /**
  110977. * If this is a cube texture
  110978. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  110979. */
  110980. isCube: boolean;
  110981. /**
  110982. * If the texture is a compressed format eg. FOURCC_DXT1
  110983. */
  110984. isCompressed: boolean;
  110985. /**
  110986. * The dxgiFormat of the texture
  110987. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  110988. */
  110989. dxgiFormat: number;
  110990. /**
  110991. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  110992. */
  110993. textureType: number;
  110994. /**
  110995. * Sphericle polynomial created for the dds texture
  110996. */
  110997. sphericalPolynomial?: SphericalPolynomial;
  110998. }
  110999. /**
  111000. * Class used to provide DDS decompression tools
  111001. */
  111002. export class DDSTools {
  111003. /**
  111004. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  111005. */
  111006. static StoreLODInAlphaChannel: boolean;
  111007. /**
  111008. * Gets DDS information from an array buffer
  111009. * @param arrayBuffer defines the array buffer to read data from
  111010. * @returns the DDS information
  111011. */
  111012. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  111013. private static _FloatView;
  111014. private static _Int32View;
  111015. private static _ToHalfFloat;
  111016. private static _FromHalfFloat;
  111017. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  111018. private static _GetHalfFloatRGBAArrayBuffer;
  111019. private static _GetFloatRGBAArrayBuffer;
  111020. private static _GetFloatAsUIntRGBAArrayBuffer;
  111021. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  111022. private static _GetRGBAArrayBuffer;
  111023. private static _ExtractLongWordOrder;
  111024. private static _GetRGBArrayBuffer;
  111025. private static _GetLuminanceArrayBuffer;
  111026. /**
  111027. * Uploads DDS Levels to a Babylon Texture
  111028. * @hidden
  111029. */
  111030. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  111031. }
  111032. interface Engine {
  111033. /**
  111034. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  111035. * @param rootUrl defines the url where the file to load is located
  111036. * @param scene defines the current scene
  111037. * @param lodScale defines scale to apply to the mip map selection
  111038. * @param lodOffset defines offset to apply to the mip map selection
  111039. * @param onLoad defines an optional callback raised when the texture is loaded
  111040. * @param onError defines an optional callback raised if there is an issue to load the texture
  111041. * @param format defines the format of the data
  111042. * @param forcedExtension defines the extension to use to pick the right loader
  111043. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  111044. * @returns the cube texture as an InternalTexture
  111045. */
  111046. 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;
  111047. }
  111048. }
  111049. declare module BABYLON {
  111050. /**
  111051. * Implementation of the DDS Texture Loader.
  111052. * @hidden
  111053. */
  111054. export class _DDSTextureLoader implements IInternalTextureLoader {
  111055. /**
  111056. * Defines wether the loader supports cascade loading the different faces.
  111057. */
  111058. readonly supportCascades: boolean;
  111059. /**
  111060. * This returns if the loader support the current file information.
  111061. * @param extension defines the file extension of the file being loaded
  111062. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111063. * @param fallback defines the fallback internal texture if any
  111064. * @param isBase64 defines whether the texture is encoded as a base64
  111065. * @param isBuffer defines whether the texture data are stored as a buffer
  111066. * @returns true if the loader can load the specified file
  111067. */
  111068. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  111069. /**
  111070. * Transform the url before loading if required.
  111071. * @param rootUrl the url of the texture
  111072. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111073. * @returns the transformed texture
  111074. */
  111075. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  111076. /**
  111077. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  111078. * @param rootUrl the url of the texture
  111079. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111080. * @returns the fallback texture
  111081. */
  111082. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  111083. /**
  111084. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  111085. * @param data contains the texture data
  111086. * @param texture defines the BabylonJS internal texture
  111087. * @param createPolynomials will be true if polynomials have been requested
  111088. * @param onLoad defines the callback to trigger once the texture is ready
  111089. * @param onError defines the callback to trigger in case of error
  111090. */
  111091. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  111092. /**
  111093. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  111094. * @param data contains the texture data
  111095. * @param texture defines the BabylonJS internal texture
  111096. * @param callback defines the method to call once ready to upload
  111097. */
  111098. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  111099. }
  111100. }
  111101. declare module BABYLON {
  111102. /** @hidden */
  111103. export var rgbdEncodePixelShader: {
  111104. name: string;
  111105. shader: string;
  111106. };
  111107. }
  111108. declare module BABYLON {
  111109. /**
  111110. * Raw texture data and descriptor sufficient for WebGL texture upload
  111111. */
  111112. export interface EnvironmentTextureInfo {
  111113. /**
  111114. * Version of the environment map
  111115. */
  111116. version: number;
  111117. /**
  111118. * Width of image
  111119. */
  111120. width: number;
  111121. /**
  111122. * Irradiance information stored in the file.
  111123. */
  111124. irradiance: any;
  111125. /**
  111126. * Specular information stored in the file.
  111127. */
  111128. specular: any;
  111129. }
  111130. /**
  111131. * Sets of helpers addressing the serialization and deserialization of environment texture
  111132. * stored in a BabylonJS env file.
  111133. * Those files are usually stored as .env files.
  111134. */
  111135. export class EnvironmentTextureTools {
  111136. /**
  111137. * Magic number identifying the env file.
  111138. */
  111139. private static _MagicBytes;
  111140. /**
  111141. * Gets the environment info from an env file.
  111142. * @param data The array buffer containing the .env bytes.
  111143. * @returns the environment file info (the json header) if successfully parsed.
  111144. */
  111145. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  111146. /**
  111147. * Creates an environment texture from a loaded cube texture.
  111148. * @param texture defines the cube texture to convert in env file
  111149. * @return a promise containing the environment data if succesfull.
  111150. */
  111151. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  111152. /**
  111153. * Creates a JSON representation of the spherical data.
  111154. * @param texture defines the texture containing the polynomials
  111155. * @return the JSON representation of the spherical info
  111156. */
  111157. private static _CreateEnvTextureIrradiance;
  111158. /**
  111159. * Uploads the texture info contained in the env file to the GPU.
  111160. * @param texture defines the internal texture to upload to
  111161. * @param arrayBuffer defines the buffer cotaining the data to load
  111162. * @param info defines the texture info retrieved through the GetEnvInfo method
  111163. * @returns a promise
  111164. */
  111165. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  111166. /**
  111167. * Uploads the levels of image data to the GPU.
  111168. * @param texture defines the internal texture to upload to
  111169. * @param imageData defines the array buffer views of image data [mipmap][face]
  111170. * @returns a promise
  111171. */
  111172. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  111173. /**
  111174. * Uploads spherical polynomials information to the texture.
  111175. * @param texture defines the texture we are trying to upload the information to
  111176. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  111177. */
  111178. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  111179. /** @hidden */
  111180. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  111181. }
  111182. }
  111183. declare module BABYLON {
  111184. /**
  111185. * Implementation of the ENV Texture Loader.
  111186. * @hidden
  111187. */
  111188. export class _ENVTextureLoader implements IInternalTextureLoader {
  111189. /**
  111190. * Defines wether the loader supports cascade loading the different faces.
  111191. */
  111192. readonly supportCascades: boolean;
  111193. /**
  111194. * This returns if the loader support the current file information.
  111195. * @param extension defines the file extension of the file being loaded
  111196. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111197. * @param fallback defines the fallback internal texture if any
  111198. * @param isBase64 defines whether the texture is encoded as a base64
  111199. * @param isBuffer defines whether the texture data are stored as a buffer
  111200. * @returns true if the loader can load the specified file
  111201. */
  111202. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  111203. /**
  111204. * Transform the url before loading if required.
  111205. * @param rootUrl the url of the texture
  111206. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111207. * @returns the transformed texture
  111208. */
  111209. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  111210. /**
  111211. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  111212. * @param rootUrl the url of the texture
  111213. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111214. * @returns the fallback texture
  111215. */
  111216. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  111217. /**
  111218. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  111219. * @param data contains the texture data
  111220. * @param texture defines the BabylonJS internal texture
  111221. * @param createPolynomials will be true if polynomials have been requested
  111222. * @param onLoad defines the callback to trigger once the texture is ready
  111223. * @param onError defines the callback to trigger in case of error
  111224. */
  111225. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  111226. /**
  111227. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  111228. * @param data contains the texture data
  111229. * @param texture defines the BabylonJS internal texture
  111230. * @param callback defines the method to call once ready to upload
  111231. */
  111232. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  111233. }
  111234. }
  111235. declare module BABYLON {
  111236. /**
  111237. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  111238. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  111239. */
  111240. export class KhronosTextureContainer {
  111241. /** contents of the KTX container file */
  111242. arrayBuffer: any;
  111243. private static HEADER_LEN;
  111244. private static COMPRESSED_2D;
  111245. private static COMPRESSED_3D;
  111246. private static TEX_2D;
  111247. private static TEX_3D;
  111248. /**
  111249. * Gets the openGL type
  111250. */
  111251. glType: number;
  111252. /**
  111253. * Gets the openGL type size
  111254. */
  111255. glTypeSize: number;
  111256. /**
  111257. * Gets the openGL format
  111258. */
  111259. glFormat: number;
  111260. /**
  111261. * Gets the openGL internal format
  111262. */
  111263. glInternalFormat: number;
  111264. /**
  111265. * Gets the base internal format
  111266. */
  111267. glBaseInternalFormat: number;
  111268. /**
  111269. * Gets image width in pixel
  111270. */
  111271. pixelWidth: number;
  111272. /**
  111273. * Gets image height in pixel
  111274. */
  111275. pixelHeight: number;
  111276. /**
  111277. * Gets image depth in pixels
  111278. */
  111279. pixelDepth: number;
  111280. /**
  111281. * Gets the number of array elements
  111282. */
  111283. numberOfArrayElements: number;
  111284. /**
  111285. * Gets the number of faces
  111286. */
  111287. numberOfFaces: number;
  111288. /**
  111289. * Gets the number of mipmap levels
  111290. */
  111291. numberOfMipmapLevels: number;
  111292. /**
  111293. * Gets the bytes of key value data
  111294. */
  111295. bytesOfKeyValueData: number;
  111296. /**
  111297. * Gets the load type
  111298. */
  111299. loadType: number;
  111300. /**
  111301. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  111302. */
  111303. isInvalid: boolean;
  111304. /**
  111305. * Creates a new KhronosTextureContainer
  111306. * @param arrayBuffer contents of the KTX container file
  111307. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  111308. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  111309. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  111310. */
  111311. constructor(
  111312. /** contents of the KTX container file */
  111313. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  111314. /**
  111315. * Uploads KTX content to a Babylon Texture.
  111316. * It is assumed that the texture has already been created & is currently bound
  111317. * @hidden
  111318. */
  111319. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  111320. private _upload2DCompressedLevels;
  111321. }
  111322. }
  111323. declare module BABYLON {
  111324. /**
  111325. * Implementation of the KTX Texture Loader.
  111326. * @hidden
  111327. */
  111328. export class _KTXTextureLoader implements IInternalTextureLoader {
  111329. /**
  111330. * Defines wether the loader supports cascade loading the different faces.
  111331. */
  111332. readonly supportCascades: boolean;
  111333. /**
  111334. * This returns if the loader support the current file information.
  111335. * @param extension defines the file extension of the file being loaded
  111336. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111337. * @param fallback defines the fallback internal texture if any
  111338. * @param isBase64 defines whether the texture is encoded as a base64
  111339. * @param isBuffer defines whether the texture data are stored as a buffer
  111340. * @returns true if the loader can load the specified file
  111341. */
  111342. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  111343. /**
  111344. * Transform the url before loading if required.
  111345. * @param rootUrl the url of the texture
  111346. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111347. * @returns the transformed texture
  111348. */
  111349. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  111350. /**
  111351. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  111352. * @param rootUrl the url of the texture
  111353. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111354. * @returns the fallback texture
  111355. */
  111356. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  111357. /**
  111358. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  111359. * @param data contains the texture data
  111360. * @param texture defines the BabylonJS internal texture
  111361. * @param createPolynomials will be true if polynomials have been requested
  111362. * @param onLoad defines the callback to trigger once the texture is ready
  111363. * @param onError defines the callback to trigger in case of error
  111364. */
  111365. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  111366. /**
  111367. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  111368. * @param data contains the texture data
  111369. * @param texture defines the BabylonJS internal texture
  111370. * @param callback defines the method to call once ready to upload
  111371. */
  111372. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  111373. }
  111374. }
  111375. declare module BABYLON {
  111376. /**
  111377. * Options for the default xr helper
  111378. */
  111379. export class WebXRDefaultExperienceOptions {
  111380. /**
  111381. * Floor meshes that should be used for teleporting
  111382. */
  111383. floorMeshes: Array<AbstractMesh>;
  111384. }
  111385. /**
  111386. * Default experience which provides a similar setup to the previous webVRExperience
  111387. */
  111388. export class WebXRDefaultExperience {
  111389. /**
  111390. * Base experience
  111391. */
  111392. baseExperience: WebXRExperienceHelper;
  111393. /**
  111394. * Input experience extension
  111395. */
  111396. input: WebXRInput;
  111397. /**
  111398. * Loads the controller models
  111399. */
  111400. controllerModelLoader: WebXRControllerModelLoader;
  111401. /**
  111402. * Enables laser pointer and selection
  111403. */
  111404. pointerSelection: WebXRControllerPointerSelection;
  111405. /**
  111406. * Enables teleportation
  111407. */
  111408. teleportation: WebXRControllerTeleportation;
  111409. /**
  111410. * Enables ui for enetering/exiting xr
  111411. */
  111412. enterExitUI: WebXREnterExitUI;
  111413. /**
  111414. * Default output canvas xr should render to
  111415. */
  111416. outputCanvas: WebXRManagedOutputCanvas;
  111417. /**
  111418. * Creates the default xr experience
  111419. * @param scene scene
  111420. * @param options options for basic configuration
  111421. * @returns resulting WebXRDefaultExperience
  111422. */
  111423. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  111424. private constructor();
  111425. /**
  111426. * DIsposes of the experience helper
  111427. */
  111428. dispose(): void;
  111429. }
  111430. }
  111431. declare module BABYLON {
  111432. /** @hidden */
  111433. export var _forceSceneHelpersToBundle: boolean;
  111434. interface Scene {
  111435. /**
  111436. * Creates a default light for the scene.
  111437. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  111438. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  111439. */
  111440. createDefaultLight(replace?: boolean): void;
  111441. /**
  111442. * Creates a default camera for the scene.
  111443. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  111444. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  111445. * @param replace has default false, when true replaces the active camera in the scene
  111446. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  111447. */
  111448. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  111449. /**
  111450. * Creates a default camera and a default light.
  111451. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  111452. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  111453. * @param replace has the default false, when true replaces the active camera/light in the scene
  111454. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  111455. */
  111456. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  111457. /**
  111458. * Creates a new sky box
  111459. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  111460. * @param environmentTexture defines the texture to use as environment texture
  111461. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  111462. * @param scale defines the overall scale of the skybox
  111463. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  111464. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  111465. * @returns a new mesh holding the sky box
  111466. */
  111467. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  111468. /**
  111469. * Creates a new environment
  111470. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  111471. * @param options defines the options you can use to configure the environment
  111472. * @returns the new EnvironmentHelper
  111473. */
  111474. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  111475. /**
  111476. * Creates a new VREXperienceHelper
  111477. * @see http://doc.babylonjs.com/how_to/webvr_helper
  111478. * @param webVROptions defines the options used to create the new VREXperienceHelper
  111479. * @returns a new VREXperienceHelper
  111480. */
  111481. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  111482. /**
  111483. * Creates a new WebXRDefaultExperience
  111484. * @see http://doc.babylonjs.com/how_to/webxr
  111485. * @param options experience options
  111486. * @returns a promise for a new WebXRDefaultExperience
  111487. */
  111488. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  111489. }
  111490. }
  111491. declare module BABYLON {
  111492. /**
  111493. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  111494. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  111495. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  111496. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  111497. */
  111498. export class VideoDome extends TransformNode {
  111499. /**
  111500. * Define the video source as a Monoscopic panoramic 360 video.
  111501. */
  111502. static readonly MODE_MONOSCOPIC: number;
  111503. /**
  111504. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  111505. */
  111506. static readonly MODE_TOPBOTTOM: number;
  111507. /**
  111508. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  111509. */
  111510. static readonly MODE_SIDEBYSIDE: number;
  111511. private _useDirectMapping;
  111512. /**
  111513. * The video texture being displayed on the sphere
  111514. */
  111515. protected _videoTexture: VideoTexture;
  111516. /**
  111517. * Gets the video texture being displayed on the sphere
  111518. */
  111519. readonly videoTexture: VideoTexture;
  111520. /**
  111521. * The skybox material
  111522. */
  111523. protected _material: BackgroundMaterial;
  111524. /**
  111525. * The surface used for the skybox
  111526. */
  111527. protected _mesh: Mesh;
  111528. /**
  111529. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  111530. * Also see the options.resolution property.
  111531. */
  111532. fovMultiplier: number;
  111533. private _videoMode;
  111534. /**
  111535. * Gets or set the current video mode for the video. It can be:
  111536. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  111537. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  111538. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  111539. */
  111540. videoMode: number;
  111541. /**
  111542. * Oberserver used in Stereoscopic VR Mode.
  111543. */
  111544. private _onBeforeCameraRenderObserver;
  111545. /**
  111546. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  111547. * @param name Element's name, child elements will append suffixes for their own names.
  111548. * @param urlsOrVideo defines the url(s) or the video element to use
  111549. * @param options An object containing optional or exposed sub element properties
  111550. */
  111551. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  111552. resolution?: number;
  111553. clickToPlay?: boolean;
  111554. autoPlay?: boolean;
  111555. loop?: boolean;
  111556. size?: number;
  111557. poster?: string;
  111558. faceForward?: boolean;
  111559. useDirectMapping?: boolean;
  111560. }, scene: Scene);
  111561. private _changeVideoMode;
  111562. /**
  111563. * Releases resources associated with this node.
  111564. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111565. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111566. */
  111567. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111568. }
  111569. }
  111570. declare module BABYLON {
  111571. /**
  111572. * This class can be used to get instrumentation data from a Babylon engine
  111573. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  111574. */
  111575. export class EngineInstrumentation implements IDisposable {
  111576. /**
  111577. * Define the instrumented engine.
  111578. */
  111579. engine: Engine;
  111580. private _captureGPUFrameTime;
  111581. private _gpuFrameTimeToken;
  111582. private _gpuFrameTime;
  111583. private _captureShaderCompilationTime;
  111584. private _shaderCompilationTime;
  111585. private _onBeginFrameObserver;
  111586. private _onEndFrameObserver;
  111587. private _onBeforeShaderCompilationObserver;
  111588. private _onAfterShaderCompilationObserver;
  111589. /**
  111590. * Gets the perf counter used for GPU frame time
  111591. */
  111592. readonly gpuFrameTimeCounter: PerfCounter;
  111593. /**
  111594. * Gets the GPU frame time capture status
  111595. */
  111596. /**
  111597. * Enable or disable the GPU frame time capture
  111598. */
  111599. captureGPUFrameTime: boolean;
  111600. /**
  111601. * Gets the perf counter used for shader compilation time
  111602. */
  111603. readonly shaderCompilationTimeCounter: PerfCounter;
  111604. /**
  111605. * Gets the shader compilation time capture status
  111606. */
  111607. /**
  111608. * Enable or disable the shader compilation time capture
  111609. */
  111610. captureShaderCompilationTime: boolean;
  111611. /**
  111612. * Instantiates a new engine instrumentation.
  111613. * This class can be used to get instrumentation data from a Babylon engine
  111614. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  111615. * @param engine Defines the engine to instrument
  111616. */
  111617. constructor(
  111618. /**
  111619. * Define the instrumented engine.
  111620. */
  111621. engine: Engine);
  111622. /**
  111623. * Dispose and release associated resources.
  111624. */
  111625. dispose(): void;
  111626. }
  111627. }
  111628. declare module BABYLON {
  111629. /**
  111630. * This class can be used to get instrumentation data from a Babylon engine
  111631. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  111632. */
  111633. export class SceneInstrumentation implements IDisposable {
  111634. /**
  111635. * Defines the scene to instrument
  111636. */
  111637. scene: Scene;
  111638. private _captureActiveMeshesEvaluationTime;
  111639. private _activeMeshesEvaluationTime;
  111640. private _captureRenderTargetsRenderTime;
  111641. private _renderTargetsRenderTime;
  111642. private _captureFrameTime;
  111643. private _frameTime;
  111644. private _captureRenderTime;
  111645. private _renderTime;
  111646. private _captureInterFrameTime;
  111647. private _interFrameTime;
  111648. private _captureParticlesRenderTime;
  111649. private _particlesRenderTime;
  111650. private _captureSpritesRenderTime;
  111651. private _spritesRenderTime;
  111652. private _capturePhysicsTime;
  111653. private _physicsTime;
  111654. private _captureAnimationsTime;
  111655. private _animationsTime;
  111656. private _captureCameraRenderTime;
  111657. private _cameraRenderTime;
  111658. private _onBeforeActiveMeshesEvaluationObserver;
  111659. private _onAfterActiveMeshesEvaluationObserver;
  111660. private _onBeforeRenderTargetsRenderObserver;
  111661. private _onAfterRenderTargetsRenderObserver;
  111662. private _onAfterRenderObserver;
  111663. private _onBeforeDrawPhaseObserver;
  111664. private _onAfterDrawPhaseObserver;
  111665. private _onBeforeAnimationsObserver;
  111666. private _onBeforeParticlesRenderingObserver;
  111667. private _onAfterParticlesRenderingObserver;
  111668. private _onBeforeSpritesRenderingObserver;
  111669. private _onAfterSpritesRenderingObserver;
  111670. private _onBeforePhysicsObserver;
  111671. private _onAfterPhysicsObserver;
  111672. private _onAfterAnimationsObserver;
  111673. private _onBeforeCameraRenderObserver;
  111674. private _onAfterCameraRenderObserver;
  111675. /**
  111676. * Gets the perf counter used for active meshes evaluation time
  111677. */
  111678. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  111679. /**
  111680. * Gets the active meshes evaluation time capture status
  111681. */
  111682. /**
  111683. * Enable or disable the active meshes evaluation time capture
  111684. */
  111685. captureActiveMeshesEvaluationTime: boolean;
  111686. /**
  111687. * Gets the perf counter used for render targets render time
  111688. */
  111689. readonly renderTargetsRenderTimeCounter: PerfCounter;
  111690. /**
  111691. * Gets the render targets render time capture status
  111692. */
  111693. /**
  111694. * Enable or disable the render targets render time capture
  111695. */
  111696. captureRenderTargetsRenderTime: boolean;
  111697. /**
  111698. * Gets the perf counter used for particles render time
  111699. */
  111700. readonly particlesRenderTimeCounter: PerfCounter;
  111701. /**
  111702. * Gets the particles render time capture status
  111703. */
  111704. /**
  111705. * Enable or disable the particles render time capture
  111706. */
  111707. captureParticlesRenderTime: boolean;
  111708. /**
  111709. * Gets the perf counter used for sprites render time
  111710. */
  111711. readonly spritesRenderTimeCounter: PerfCounter;
  111712. /**
  111713. * Gets the sprites render time capture status
  111714. */
  111715. /**
  111716. * Enable or disable the sprites render time capture
  111717. */
  111718. captureSpritesRenderTime: boolean;
  111719. /**
  111720. * Gets the perf counter used for physics time
  111721. */
  111722. readonly physicsTimeCounter: PerfCounter;
  111723. /**
  111724. * Gets the physics time capture status
  111725. */
  111726. /**
  111727. * Enable or disable the physics time capture
  111728. */
  111729. capturePhysicsTime: boolean;
  111730. /**
  111731. * Gets the perf counter used for animations time
  111732. */
  111733. readonly animationsTimeCounter: PerfCounter;
  111734. /**
  111735. * Gets the animations time capture status
  111736. */
  111737. /**
  111738. * Enable or disable the animations time capture
  111739. */
  111740. captureAnimationsTime: boolean;
  111741. /**
  111742. * Gets the perf counter used for frame time capture
  111743. */
  111744. readonly frameTimeCounter: PerfCounter;
  111745. /**
  111746. * Gets the frame time capture status
  111747. */
  111748. /**
  111749. * Enable or disable the frame time capture
  111750. */
  111751. captureFrameTime: boolean;
  111752. /**
  111753. * Gets the perf counter used for inter-frames time capture
  111754. */
  111755. readonly interFrameTimeCounter: PerfCounter;
  111756. /**
  111757. * Gets the inter-frames time capture status
  111758. */
  111759. /**
  111760. * Enable or disable the inter-frames time capture
  111761. */
  111762. captureInterFrameTime: boolean;
  111763. /**
  111764. * Gets the perf counter used for render time capture
  111765. */
  111766. readonly renderTimeCounter: PerfCounter;
  111767. /**
  111768. * Gets the render time capture status
  111769. */
  111770. /**
  111771. * Enable or disable the render time capture
  111772. */
  111773. captureRenderTime: boolean;
  111774. /**
  111775. * Gets the perf counter used for camera render time capture
  111776. */
  111777. readonly cameraRenderTimeCounter: PerfCounter;
  111778. /**
  111779. * Gets the camera render time capture status
  111780. */
  111781. /**
  111782. * Enable or disable the camera render time capture
  111783. */
  111784. captureCameraRenderTime: boolean;
  111785. /**
  111786. * Gets the perf counter used for draw calls
  111787. */
  111788. readonly drawCallsCounter: PerfCounter;
  111789. /**
  111790. * Instantiates a new scene instrumentation.
  111791. * This class can be used to get instrumentation data from a Babylon engine
  111792. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  111793. * @param scene Defines the scene to instrument
  111794. */
  111795. constructor(
  111796. /**
  111797. * Defines the scene to instrument
  111798. */
  111799. scene: Scene);
  111800. /**
  111801. * Dispose and release associated resources.
  111802. */
  111803. dispose(): void;
  111804. }
  111805. }
  111806. declare module BABYLON {
  111807. /** @hidden */
  111808. export var glowMapGenerationPixelShader: {
  111809. name: string;
  111810. shader: string;
  111811. };
  111812. }
  111813. declare module BABYLON {
  111814. /** @hidden */
  111815. export var glowMapGenerationVertexShader: {
  111816. name: string;
  111817. shader: string;
  111818. };
  111819. }
  111820. declare module BABYLON {
  111821. /**
  111822. * Effect layer options. This helps customizing the behaviour
  111823. * of the effect layer.
  111824. */
  111825. export interface IEffectLayerOptions {
  111826. /**
  111827. * Multiplication factor apply to the canvas size to compute the render target size
  111828. * used to generated the objects (the smaller the faster).
  111829. */
  111830. mainTextureRatio: number;
  111831. /**
  111832. * Enforces a fixed size texture to ensure effect stability across devices.
  111833. */
  111834. mainTextureFixedSize?: number;
  111835. /**
  111836. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  111837. */
  111838. alphaBlendingMode: number;
  111839. /**
  111840. * The camera attached to the layer.
  111841. */
  111842. camera: Nullable<Camera>;
  111843. /**
  111844. * The rendering group to draw the layer in.
  111845. */
  111846. renderingGroupId: number;
  111847. }
  111848. /**
  111849. * The effect layer Helps adding post process effect blended with the main pass.
  111850. *
  111851. * This can be for instance use to generate glow or higlight effects on the scene.
  111852. *
  111853. * The effect layer class can not be used directly and is intented to inherited from to be
  111854. * customized per effects.
  111855. */
  111856. export abstract class EffectLayer {
  111857. private _vertexBuffers;
  111858. private _indexBuffer;
  111859. private _cachedDefines;
  111860. private _effectLayerMapGenerationEffect;
  111861. private _effectLayerOptions;
  111862. private _mergeEffect;
  111863. protected _scene: Scene;
  111864. protected _engine: Engine;
  111865. protected _maxSize: number;
  111866. protected _mainTextureDesiredSize: ISize;
  111867. protected _mainTexture: RenderTargetTexture;
  111868. protected _shouldRender: boolean;
  111869. protected _postProcesses: PostProcess[];
  111870. protected _textures: BaseTexture[];
  111871. protected _emissiveTextureAndColor: {
  111872. texture: Nullable<BaseTexture>;
  111873. color: Color4;
  111874. };
  111875. /**
  111876. * The name of the layer
  111877. */
  111878. name: string;
  111879. /**
  111880. * The clear color of the texture used to generate the glow map.
  111881. */
  111882. neutralColor: Color4;
  111883. /**
  111884. * Specifies wether the highlight layer is enabled or not.
  111885. */
  111886. isEnabled: boolean;
  111887. /**
  111888. * Gets the camera attached to the layer.
  111889. */
  111890. readonly camera: Nullable<Camera>;
  111891. /**
  111892. * Gets the rendering group id the layer should render in.
  111893. */
  111894. renderingGroupId: number;
  111895. /**
  111896. * An event triggered when the effect layer has been disposed.
  111897. */
  111898. onDisposeObservable: Observable<EffectLayer>;
  111899. /**
  111900. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  111901. */
  111902. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  111903. /**
  111904. * An event triggered when the generated texture is being merged in the scene.
  111905. */
  111906. onBeforeComposeObservable: Observable<EffectLayer>;
  111907. /**
  111908. * An event triggered when the generated texture has been merged in the scene.
  111909. */
  111910. onAfterComposeObservable: Observable<EffectLayer>;
  111911. /**
  111912. * An event triggered when the efffect layer changes its size.
  111913. */
  111914. onSizeChangedObservable: Observable<EffectLayer>;
  111915. /** @hidden */
  111916. static _SceneComponentInitialization: (scene: Scene) => void;
  111917. /**
  111918. * Instantiates a new effect Layer and references it in the scene.
  111919. * @param name The name of the layer
  111920. * @param scene The scene to use the layer in
  111921. */
  111922. constructor(
  111923. /** The Friendly of the effect in the scene */
  111924. name: string, scene: Scene);
  111925. /**
  111926. * Get the effect name of the layer.
  111927. * @return The effect name
  111928. */
  111929. abstract getEffectName(): string;
  111930. /**
  111931. * Checks for the readiness of the element composing the layer.
  111932. * @param subMesh the mesh to check for
  111933. * @param useInstances specify wether or not to use instances to render the mesh
  111934. * @return true if ready otherwise, false
  111935. */
  111936. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  111937. /**
  111938. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  111939. * @returns true if the effect requires stencil during the main canvas render pass.
  111940. */
  111941. abstract needStencil(): boolean;
  111942. /**
  111943. * Create the merge effect. This is the shader use to blit the information back
  111944. * to the main canvas at the end of the scene rendering.
  111945. * @returns The effect containing the shader used to merge the effect on the main canvas
  111946. */
  111947. protected abstract _createMergeEffect(): Effect;
  111948. /**
  111949. * Creates the render target textures and post processes used in the effect layer.
  111950. */
  111951. protected abstract _createTextureAndPostProcesses(): void;
  111952. /**
  111953. * Implementation specific of rendering the generating effect on the main canvas.
  111954. * @param effect The effect used to render through
  111955. */
  111956. protected abstract _internalRender(effect: Effect): void;
  111957. /**
  111958. * Sets the required values for both the emissive texture and and the main color.
  111959. */
  111960. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  111961. /**
  111962. * Free any resources and references associated to a mesh.
  111963. * Internal use
  111964. * @param mesh The mesh to free.
  111965. */
  111966. abstract _disposeMesh(mesh: Mesh): void;
  111967. /**
  111968. * Serializes this layer (Glow or Highlight for example)
  111969. * @returns a serialized layer object
  111970. */
  111971. abstract serialize?(): any;
  111972. /**
  111973. * Initializes the effect layer with the required options.
  111974. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  111975. */
  111976. protected _init(options: Partial<IEffectLayerOptions>): void;
  111977. /**
  111978. * Generates the index buffer of the full screen quad blending to the main canvas.
  111979. */
  111980. private _generateIndexBuffer;
  111981. /**
  111982. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  111983. */
  111984. private _generateVertexBuffer;
  111985. /**
  111986. * Sets the main texture desired size which is the closest power of two
  111987. * of the engine canvas size.
  111988. */
  111989. private _setMainTextureSize;
  111990. /**
  111991. * Creates the main texture for the effect layer.
  111992. */
  111993. protected _createMainTexture(): void;
  111994. /**
  111995. * Adds specific effects defines.
  111996. * @param defines The defines to add specifics to.
  111997. */
  111998. protected _addCustomEffectDefines(defines: string[]): void;
  111999. /**
  112000. * Checks for the readiness of the element composing the layer.
  112001. * @param subMesh the mesh to check for
  112002. * @param useInstances specify wether or not to use instances to render the mesh
  112003. * @param emissiveTexture the associated emissive texture used to generate the glow
  112004. * @return true if ready otherwise, false
  112005. */
  112006. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  112007. /**
  112008. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  112009. */
  112010. render(): void;
  112011. /**
  112012. * Determine if a given mesh will be used in the current effect.
  112013. * @param mesh mesh to test
  112014. * @returns true if the mesh will be used
  112015. */
  112016. hasMesh(mesh: AbstractMesh): boolean;
  112017. /**
  112018. * Returns true if the layer contains information to display, otherwise false.
  112019. * @returns true if the glow layer should be rendered
  112020. */
  112021. shouldRender(): boolean;
  112022. /**
  112023. * Returns true if the mesh should render, otherwise false.
  112024. * @param mesh The mesh to render
  112025. * @returns true if it should render otherwise false
  112026. */
  112027. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  112028. /**
  112029. * Returns true if the mesh can be rendered, otherwise false.
  112030. * @param mesh The mesh to render
  112031. * @param material The material used on the mesh
  112032. * @returns true if it can be rendered otherwise false
  112033. */
  112034. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  112035. /**
  112036. * Returns true if the mesh should render, otherwise false.
  112037. * @param mesh The mesh to render
  112038. * @returns true if it should render otherwise false
  112039. */
  112040. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  112041. /**
  112042. * Renders the submesh passed in parameter to the generation map.
  112043. */
  112044. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  112045. /**
  112046. * Rebuild the required buffers.
  112047. * @hidden Internal use only.
  112048. */
  112049. _rebuild(): void;
  112050. /**
  112051. * Dispose only the render target textures and post process.
  112052. */
  112053. private _disposeTextureAndPostProcesses;
  112054. /**
  112055. * Dispose the highlight layer and free resources.
  112056. */
  112057. dispose(): void;
  112058. /**
  112059. * Gets the class name of the effect layer
  112060. * @returns the string with the class name of the effect layer
  112061. */
  112062. getClassName(): string;
  112063. /**
  112064. * Creates an effect layer from parsed effect layer data
  112065. * @param parsedEffectLayer defines effect layer data
  112066. * @param scene defines the current scene
  112067. * @param rootUrl defines the root URL containing the effect layer information
  112068. * @returns a parsed effect Layer
  112069. */
  112070. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  112071. }
  112072. }
  112073. declare module BABYLON {
  112074. interface AbstractScene {
  112075. /**
  112076. * The list of effect layers (highlights/glow) added to the scene
  112077. * @see http://doc.babylonjs.com/how_to/highlight_layer
  112078. * @see http://doc.babylonjs.com/how_to/glow_layer
  112079. */
  112080. effectLayers: Array<EffectLayer>;
  112081. /**
  112082. * Removes the given effect layer from this scene.
  112083. * @param toRemove defines the effect layer to remove
  112084. * @returns the index of the removed effect layer
  112085. */
  112086. removeEffectLayer(toRemove: EffectLayer): number;
  112087. /**
  112088. * Adds the given effect layer to this scene
  112089. * @param newEffectLayer defines the effect layer to add
  112090. */
  112091. addEffectLayer(newEffectLayer: EffectLayer): void;
  112092. }
  112093. /**
  112094. * Defines the layer scene component responsible to manage any effect layers
  112095. * in a given scene.
  112096. */
  112097. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  112098. /**
  112099. * The component name helpfull to identify the component in the list of scene components.
  112100. */
  112101. readonly name: string;
  112102. /**
  112103. * The scene the component belongs to.
  112104. */
  112105. scene: Scene;
  112106. private _engine;
  112107. private _renderEffects;
  112108. private _needStencil;
  112109. private _previousStencilState;
  112110. /**
  112111. * Creates a new instance of the component for the given scene
  112112. * @param scene Defines the scene to register the component in
  112113. */
  112114. constructor(scene: Scene);
  112115. /**
  112116. * Registers the component in a given scene
  112117. */
  112118. register(): void;
  112119. /**
  112120. * Rebuilds the elements related to this component in case of
  112121. * context lost for instance.
  112122. */
  112123. rebuild(): void;
  112124. /**
  112125. * Serializes the component data to the specified json object
  112126. * @param serializationObject The object to serialize to
  112127. */
  112128. serialize(serializationObject: any): void;
  112129. /**
  112130. * Adds all the elements from the container to the scene
  112131. * @param container the container holding the elements
  112132. */
  112133. addFromContainer(container: AbstractScene): void;
  112134. /**
  112135. * Removes all the elements in the container from the scene
  112136. * @param container contains the elements to remove
  112137. * @param dispose if the removed element should be disposed (default: false)
  112138. */
  112139. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  112140. /**
  112141. * Disposes the component and the associated ressources.
  112142. */
  112143. dispose(): void;
  112144. private _isReadyForMesh;
  112145. private _renderMainTexture;
  112146. private _setStencil;
  112147. private _setStencilBack;
  112148. private _draw;
  112149. private _drawCamera;
  112150. private _drawRenderingGroup;
  112151. }
  112152. }
  112153. declare module BABYLON {
  112154. /** @hidden */
  112155. export var glowMapMergePixelShader: {
  112156. name: string;
  112157. shader: string;
  112158. };
  112159. }
  112160. declare module BABYLON {
  112161. /** @hidden */
  112162. export var glowMapMergeVertexShader: {
  112163. name: string;
  112164. shader: string;
  112165. };
  112166. }
  112167. declare module BABYLON {
  112168. interface AbstractScene {
  112169. /**
  112170. * Return a the first highlight layer of the scene with a given name.
  112171. * @param name The name of the highlight layer to look for.
  112172. * @return The highlight layer if found otherwise null.
  112173. */
  112174. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  112175. }
  112176. /**
  112177. * Glow layer options. This helps customizing the behaviour
  112178. * of the glow layer.
  112179. */
  112180. export interface IGlowLayerOptions {
  112181. /**
  112182. * Multiplication factor apply to the canvas size to compute the render target size
  112183. * used to generated the glowing objects (the smaller the faster).
  112184. */
  112185. mainTextureRatio: number;
  112186. /**
  112187. * Enforces a fixed size texture to ensure resize independant blur.
  112188. */
  112189. mainTextureFixedSize?: number;
  112190. /**
  112191. * How big is the kernel of the blur texture.
  112192. */
  112193. blurKernelSize: number;
  112194. /**
  112195. * The camera attached to the layer.
  112196. */
  112197. camera: Nullable<Camera>;
  112198. /**
  112199. * Enable MSAA by chosing the number of samples.
  112200. */
  112201. mainTextureSamples?: number;
  112202. /**
  112203. * The rendering group to draw the layer in.
  112204. */
  112205. renderingGroupId: number;
  112206. }
  112207. /**
  112208. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  112209. *
  112210. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  112211. * glowy meshes to your scene.
  112212. *
  112213. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  112214. */
  112215. export class GlowLayer extends EffectLayer {
  112216. /**
  112217. * Effect Name of the layer.
  112218. */
  112219. static readonly EffectName: string;
  112220. /**
  112221. * The default blur kernel size used for the glow.
  112222. */
  112223. static DefaultBlurKernelSize: number;
  112224. /**
  112225. * The default texture size ratio used for the glow.
  112226. */
  112227. static DefaultTextureRatio: number;
  112228. /**
  112229. * Sets the kernel size of the blur.
  112230. */
  112231. /**
  112232. * Gets the kernel size of the blur.
  112233. */
  112234. blurKernelSize: number;
  112235. /**
  112236. * Sets the glow intensity.
  112237. */
  112238. /**
  112239. * Gets the glow intensity.
  112240. */
  112241. intensity: number;
  112242. private _options;
  112243. private _intensity;
  112244. private _horizontalBlurPostprocess1;
  112245. private _verticalBlurPostprocess1;
  112246. private _horizontalBlurPostprocess2;
  112247. private _verticalBlurPostprocess2;
  112248. private _blurTexture1;
  112249. private _blurTexture2;
  112250. private _postProcesses1;
  112251. private _postProcesses2;
  112252. private _includedOnlyMeshes;
  112253. private _excludedMeshes;
  112254. /**
  112255. * Callback used to let the user override the color selection on a per mesh basis
  112256. */
  112257. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  112258. /**
  112259. * Callback used to let the user override the texture selection on a per mesh basis
  112260. */
  112261. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  112262. /**
  112263. * Instantiates a new glow Layer and references it to the scene.
  112264. * @param name The name of the layer
  112265. * @param scene The scene to use the layer in
  112266. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  112267. */
  112268. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  112269. /**
  112270. * Get the effect name of the layer.
  112271. * @return The effect name
  112272. */
  112273. getEffectName(): string;
  112274. /**
  112275. * Create the merge effect. This is the shader use to blit the information back
  112276. * to the main canvas at the end of the scene rendering.
  112277. */
  112278. protected _createMergeEffect(): Effect;
  112279. /**
  112280. * Creates the render target textures and post processes used in the glow layer.
  112281. */
  112282. protected _createTextureAndPostProcesses(): void;
  112283. /**
  112284. * Checks for the readiness of the element composing the layer.
  112285. * @param subMesh the mesh to check for
  112286. * @param useInstances specify wether or not to use instances to render the mesh
  112287. * @param emissiveTexture the associated emissive texture used to generate the glow
  112288. * @return true if ready otherwise, false
  112289. */
  112290. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112291. /**
  112292. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  112293. */
  112294. needStencil(): boolean;
  112295. /**
  112296. * Returns true if the mesh can be rendered, otherwise false.
  112297. * @param mesh The mesh to render
  112298. * @param material The material used on the mesh
  112299. * @returns true if it can be rendered otherwise false
  112300. */
  112301. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  112302. /**
  112303. * Implementation specific of rendering the generating effect on the main canvas.
  112304. * @param effect The effect used to render through
  112305. */
  112306. protected _internalRender(effect: Effect): void;
  112307. /**
  112308. * Sets the required values for both the emissive texture and and the main color.
  112309. */
  112310. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  112311. /**
  112312. * Returns true if the mesh should render, otherwise false.
  112313. * @param mesh The mesh to render
  112314. * @returns true if it should render otherwise false
  112315. */
  112316. protected _shouldRenderMesh(mesh: Mesh): boolean;
  112317. /**
  112318. * Adds specific effects defines.
  112319. * @param defines The defines to add specifics to.
  112320. */
  112321. protected _addCustomEffectDefines(defines: string[]): void;
  112322. /**
  112323. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  112324. * @param mesh The mesh to exclude from the glow layer
  112325. */
  112326. addExcludedMesh(mesh: Mesh): void;
  112327. /**
  112328. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  112329. * @param mesh The mesh to remove
  112330. */
  112331. removeExcludedMesh(mesh: Mesh): void;
  112332. /**
  112333. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  112334. * @param mesh The mesh to include in the glow layer
  112335. */
  112336. addIncludedOnlyMesh(mesh: Mesh): void;
  112337. /**
  112338. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  112339. * @param mesh The mesh to remove
  112340. */
  112341. removeIncludedOnlyMesh(mesh: Mesh): void;
  112342. /**
  112343. * Determine if a given mesh will be used in the glow layer
  112344. * @param mesh The mesh to test
  112345. * @returns true if the mesh will be highlighted by the current glow layer
  112346. */
  112347. hasMesh(mesh: AbstractMesh): boolean;
  112348. /**
  112349. * Free any resources and references associated to a mesh.
  112350. * Internal use
  112351. * @param mesh The mesh to free.
  112352. * @hidden
  112353. */
  112354. _disposeMesh(mesh: Mesh): void;
  112355. /**
  112356. * Gets the class name of the effect layer
  112357. * @returns the string with the class name of the effect layer
  112358. */
  112359. getClassName(): string;
  112360. /**
  112361. * Serializes this glow layer
  112362. * @returns a serialized glow layer object
  112363. */
  112364. serialize(): any;
  112365. /**
  112366. * Creates a Glow Layer from parsed glow layer data
  112367. * @param parsedGlowLayer defines glow layer data
  112368. * @param scene defines the current scene
  112369. * @param rootUrl defines the root URL containing the glow layer information
  112370. * @returns a parsed Glow Layer
  112371. */
  112372. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  112373. }
  112374. }
  112375. declare module BABYLON {
  112376. /** @hidden */
  112377. export var glowBlurPostProcessPixelShader: {
  112378. name: string;
  112379. shader: string;
  112380. };
  112381. }
  112382. declare module BABYLON {
  112383. interface AbstractScene {
  112384. /**
  112385. * Return a the first highlight layer of the scene with a given name.
  112386. * @param name The name of the highlight layer to look for.
  112387. * @return The highlight layer if found otherwise null.
  112388. */
  112389. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  112390. }
  112391. /**
  112392. * Highlight layer options. This helps customizing the behaviour
  112393. * of the highlight layer.
  112394. */
  112395. export interface IHighlightLayerOptions {
  112396. /**
  112397. * Multiplication factor apply to the canvas size to compute the render target size
  112398. * used to generated the glowing objects (the smaller the faster).
  112399. */
  112400. mainTextureRatio: number;
  112401. /**
  112402. * Enforces a fixed size texture to ensure resize independant blur.
  112403. */
  112404. mainTextureFixedSize?: number;
  112405. /**
  112406. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  112407. * of the picture to blur (the smaller the faster).
  112408. */
  112409. blurTextureSizeRatio: number;
  112410. /**
  112411. * How big in texel of the blur texture is the vertical blur.
  112412. */
  112413. blurVerticalSize: number;
  112414. /**
  112415. * How big in texel of the blur texture is the horizontal blur.
  112416. */
  112417. blurHorizontalSize: number;
  112418. /**
  112419. * Alpha blending mode used to apply the blur. Default is combine.
  112420. */
  112421. alphaBlendingMode: number;
  112422. /**
  112423. * The camera attached to the layer.
  112424. */
  112425. camera: Nullable<Camera>;
  112426. /**
  112427. * Should we display highlight as a solid stroke?
  112428. */
  112429. isStroke?: boolean;
  112430. /**
  112431. * The rendering group to draw the layer in.
  112432. */
  112433. renderingGroupId: number;
  112434. }
  112435. /**
  112436. * The highlight layer Helps adding a glow effect around a mesh.
  112437. *
  112438. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  112439. * glowy meshes to your scene.
  112440. *
  112441. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  112442. */
  112443. export class HighlightLayer extends EffectLayer {
  112444. name: string;
  112445. /**
  112446. * Effect Name of the highlight layer.
  112447. */
  112448. static readonly EffectName: string;
  112449. /**
  112450. * The neutral color used during the preparation of the glow effect.
  112451. * This is black by default as the blend operation is a blend operation.
  112452. */
  112453. static NeutralColor: Color4;
  112454. /**
  112455. * Stencil value used for glowing meshes.
  112456. */
  112457. static GlowingMeshStencilReference: number;
  112458. /**
  112459. * Stencil value used for the other meshes in the scene.
  112460. */
  112461. static NormalMeshStencilReference: number;
  112462. /**
  112463. * Specifies whether or not the inner glow is ACTIVE in the layer.
  112464. */
  112465. innerGlow: boolean;
  112466. /**
  112467. * Specifies whether or not the outer glow is ACTIVE in the layer.
  112468. */
  112469. outerGlow: boolean;
  112470. /**
  112471. * Specifies the horizontal size of the blur.
  112472. */
  112473. /**
  112474. * Gets the horizontal size of the blur.
  112475. */
  112476. blurHorizontalSize: number;
  112477. /**
  112478. * Specifies the vertical size of the blur.
  112479. */
  112480. /**
  112481. * Gets the vertical size of the blur.
  112482. */
  112483. blurVerticalSize: number;
  112484. /**
  112485. * An event triggered when the highlight layer is being blurred.
  112486. */
  112487. onBeforeBlurObservable: Observable<HighlightLayer>;
  112488. /**
  112489. * An event triggered when the highlight layer has been blurred.
  112490. */
  112491. onAfterBlurObservable: Observable<HighlightLayer>;
  112492. private _instanceGlowingMeshStencilReference;
  112493. private _options;
  112494. private _downSamplePostprocess;
  112495. private _horizontalBlurPostprocess;
  112496. private _verticalBlurPostprocess;
  112497. private _blurTexture;
  112498. private _meshes;
  112499. private _excludedMeshes;
  112500. /**
  112501. * Instantiates a new highlight Layer and references it to the scene..
  112502. * @param name The name of the layer
  112503. * @param scene The scene to use the layer in
  112504. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  112505. */
  112506. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  112507. /**
  112508. * Get the effect name of the layer.
  112509. * @return The effect name
  112510. */
  112511. getEffectName(): string;
  112512. /**
  112513. * Create the merge effect. This is the shader use to blit the information back
  112514. * to the main canvas at the end of the scene rendering.
  112515. */
  112516. protected _createMergeEffect(): Effect;
  112517. /**
  112518. * Creates the render target textures and post processes used in the highlight layer.
  112519. */
  112520. protected _createTextureAndPostProcesses(): void;
  112521. /**
  112522. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  112523. */
  112524. needStencil(): boolean;
  112525. /**
  112526. * Checks for the readiness of the element composing the layer.
  112527. * @param subMesh the mesh to check for
  112528. * @param useInstances specify wether or not to use instances to render the mesh
  112529. * @param emissiveTexture the associated emissive texture used to generate the glow
  112530. * @return true if ready otherwise, false
  112531. */
  112532. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112533. /**
  112534. * Implementation specific of rendering the generating effect on the main canvas.
  112535. * @param effect The effect used to render through
  112536. */
  112537. protected _internalRender(effect: Effect): void;
  112538. /**
  112539. * Returns true if the layer contains information to display, otherwise false.
  112540. */
  112541. shouldRender(): boolean;
  112542. /**
  112543. * Returns true if the mesh should render, otherwise false.
  112544. * @param mesh The mesh to render
  112545. * @returns true if it should render otherwise false
  112546. */
  112547. protected _shouldRenderMesh(mesh: Mesh): boolean;
  112548. /**
  112549. * Sets the required values for both the emissive texture and and the main color.
  112550. */
  112551. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  112552. /**
  112553. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  112554. * @param mesh The mesh to exclude from the highlight layer
  112555. */
  112556. addExcludedMesh(mesh: Mesh): void;
  112557. /**
  112558. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  112559. * @param mesh The mesh to highlight
  112560. */
  112561. removeExcludedMesh(mesh: Mesh): void;
  112562. /**
  112563. * Determine if a given mesh will be highlighted by the current HighlightLayer
  112564. * @param mesh mesh to test
  112565. * @returns true if the mesh will be highlighted by the current HighlightLayer
  112566. */
  112567. hasMesh(mesh: AbstractMesh): boolean;
  112568. /**
  112569. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  112570. * @param mesh The mesh to highlight
  112571. * @param color The color of the highlight
  112572. * @param glowEmissiveOnly Extract the glow from the emissive texture
  112573. */
  112574. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  112575. /**
  112576. * Remove a mesh from the highlight layer in order to make it stop glowing.
  112577. * @param mesh The mesh to highlight
  112578. */
  112579. removeMesh(mesh: Mesh): void;
  112580. /**
  112581. * Force the stencil to the normal expected value for none glowing parts
  112582. */
  112583. private _defaultStencilReference;
  112584. /**
  112585. * Free any resources and references associated to a mesh.
  112586. * Internal use
  112587. * @param mesh The mesh to free.
  112588. * @hidden
  112589. */
  112590. _disposeMesh(mesh: Mesh): void;
  112591. /**
  112592. * Dispose the highlight layer and free resources.
  112593. */
  112594. dispose(): void;
  112595. /**
  112596. * Gets the class name of the effect layer
  112597. * @returns the string with the class name of the effect layer
  112598. */
  112599. getClassName(): string;
  112600. /**
  112601. * Serializes this Highlight layer
  112602. * @returns a serialized Highlight layer object
  112603. */
  112604. serialize(): any;
  112605. /**
  112606. * Creates a Highlight layer from parsed Highlight layer data
  112607. * @param parsedHightlightLayer defines the Highlight layer data
  112608. * @param scene defines the current scene
  112609. * @param rootUrl defines the root URL containing the Highlight layer information
  112610. * @returns a parsed Highlight layer
  112611. */
  112612. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  112613. }
  112614. }
  112615. declare module BABYLON {
  112616. interface AbstractScene {
  112617. /**
  112618. * The list of layers (background and foreground) of the scene
  112619. */
  112620. layers: Array<Layer>;
  112621. }
  112622. /**
  112623. * Defines the layer scene component responsible to manage any layers
  112624. * in a given scene.
  112625. */
  112626. export class LayerSceneComponent implements ISceneComponent {
  112627. /**
  112628. * The component name helpfull to identify the component in the list of scene components.
  112629. */
  112630. readonly name: string;
  112631. /**
  112632. * The scene the component belongs to.
  112633. */
  112634. scene: Scene;
  112635. private _engine;
  112636. /**
  112637. * Creates a new instance of the component for the given scene
  112638. * @param scene Defines the scene to register the component in
  112639. */
  112640. constructor(scene: Scene);
  112641. /**
  112642. * Registers the component in a given scene
  112643. */
  112644. register(): void;
  112645. /**
  112646. * Rebuilds the elements related to this component in case of
  112647. * context lost for instance.
  112648. */
  112649. rebuild(): void;
  112650. /**
  112651. * Disposes the component and the associated ressources.
  112652. */
  112653. dispose(): void;
  112654. private _draw;
  112655. private _drawCameraPredicate;
  112656. private _drawCameraBackground;
  112657. private _drawCameraForeground;
  112658. private _drawRenderTargetPredicate;
  112659. private _drawRenderTargetBackground;
  112660. private _drawRenderTargetForeground;
  112661. /**
  112662. * Adds all the elements from the container to the scene
  112663. * @param container the container holding the elements
  112664. */
  112665. addFromContainer(container: AbstractScene): void;
  112666. /**
  112667. * Removes all the elements in the container from the scene
  112668. * @param container contains the elements to remove
  112669. * @param dispose if the removed element should be disposed (default: false)
  112670. */
  112671. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  112672. }
  112673. }
  112674. declare module BABYLON {
  112675. /** @hidden */
  112676. export var layerPixelShader: {
  112677. name: string;
  112678. shader: string;
  112679. };
  112680. }
  112681. declare module BABYLON {
  112682. /** @hidden */
  112683. export var layerVertexShader: {
  112684. name: string;
  112685. shader: string;
  112686. };
  112687. }
  112688. declare module BABYLON {
  112689. /**
  112690. * This represents a full screen 2d layer.
  112691. * This can be useful to display a picture in the background of your scene for instance.
  112692. * @see https://www.babylonjs-playground.com/#08A2BS#1
  112693. */
  112694. export class Layer {
  112695. /**
  112696. * Define the name of the layer.
  112697. */
  112698. name: string;
  112699. /**
  112700. * Define the texture the layer should display.
  112701. */
  112702. texture: Nullable<Texture>;
  112703. /**
  112704. * Is the layer in background or foreground.
  112705. */
  112706. isBackground: boolean;
  112707. /**
  112708. * Define the color of the layer (instead of texture).
  112709. */
  112710. color: Color4;
  112711. /**
  112712. * Define the scale of the layer in order to zoom in out of the texture.
  112713. */
  112714. scale: Vector2;
  112715. /**
  112716. * Define an offset for the layer in order to shift the texture.
  112717. */
  112718. offset: Vector2;
  112719. /**
  112720. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  112721. */
  112722. alphaBlendingMode: number;
  112723. /**
  112724. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  112725. * Alpha test will not mix with the background color in case of transparency.
  112726. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  112727. */
  112728. alphaTest: boolean;
  112729. /**
  112730. * Define a mask to restrict the layer to only some of the scene cameras.
  112731. */
  112732. layerMask: number;
  112733. /**
  112734. * Define the list of render target the layer is visible into.
  112735. */
  112736. renderTargetTextures: RenderTargetTexture[];
  112737. /**
  112738. * Define if the layer is only used in renderTarget or if it also
  112739. * renders in the main frame buffer of the canvas.
  112740. */
  112741. renderOnlyInRenderTargetTextures: boolean;
  112742. private _scene;
  112743. private _vertexBuffers;
  112744. private _indexBuffer;
  112745. private _effect;
  112746. private _alphaTestEffect;
  112747. /**
  112748. * An event triggered when the layer is disposed.
  112749. */
  112750. onDisposeObservable: Observable<Layer>;
  112751. private _onDisposeObserver;
  112752. /**
  112753. * Back compatibility with callback before the onDisposeObservable existed.
  112754. * The set callback will be triggered when the layer has been disposed.
  112755. */
  112756. onDispose: () => void;
  112757. /**
  112758. * An event triggered before rendering the scene
  112759. */
  112760. onBeforeRenderObservable: Observable<Layer>;
  112761. private _onBeforeRenderObserver;
  112762. /**
  112763. * Back compatibility with callback before the onBeforeRenderObservable existed.
  112764. * The set callback will be triggered just before rendering the layer.
  112765. */
  112766. onBeforeRender: () => void;
  112767. /**
  112768. * An event triggered after rendering the scene
  112769. */
  112770. onAfterRenderObservable: Observable<Layer>;
  112771. private _onAfterRenderObserver;
  112772. /**
  112773. * Back compatibility with callback before the onAfterRenderObservable existed.
  112774. * The set callback will be triggered just after rendering the layer.
  112775. */
  112776. onAfterRender: () => void;
  112777. /**
  112778. * Instantiates a new layer.
  112779. * This represents a full screen 2d layer.
  112780. * This can be useful to display a picture in the background of your scene for instance.
  112781. * @see https://www.babylonjs-playground.com/#08A2BS#1
  112782. * @param name Define the name of the layer in the scene
  112783. * @param imgUrl Define the url of the texture to display in the layer
  112784. * @param scene Define the scene the layer belongs to
  112785. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  112786. * @param color Defines a color for the layer
  112787. */
  112788. constructor(
  112789. /**
  112790. * Define the name of the layer.
  112791. */
  112792. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  112793. private _createIndexBuffer;
  112794. /** @hidden */
  112795. _rebuild(): void;
  112796. /**
  112797. * Renders the layer in the scene.
  112798. */
  112799. render(): void;
  112800. /**
  112801. * Disposes and releases the associated ressources.
  112802. */
  112803. dispose(): void;
  112804. }
  112805. }
  112806. declare module BABYLON {
  112807. /** @hidden */
  112808. export var lensFlarePixelShader: {
  112809. name: string;
  112810. shader: string;
  112811. };
  112812. }
  112813. declare module BABYLON {
  112814. /** @hidden */
  112815. export var lensFlareVertexShader: {
  112816. name: string;
  112817. shader: string;
  112818. };
  112819. }
  112820. declare module BABYLON {
  112821. /**
  112822. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  112823. * It is usually composed of several `lensFlare`.
  112824. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112825. */
  112826. export class LensFlareSystem {
  112827. /**
  112828. * Define the name of the lens flare system
  112829. */
  112830. name: string;
  112831. /**
  112832. * List of lens flares used in this system.
  112833. */
  112834. lensFlares: LensFlare[];
  112835. /**
  112836. * Define a limit from the border the lens flare can be visible.
  112837. */
  112838. borderLimit: number;
  112839. /**
  112840. * Define a viewport border we do not want to see the lens flare in.
  112841. */
  112842. viewportBorder: number;
  112843. /**
  112844. * Define a predicate which could limit the list of meshes able to occlude the effect.
  112845. */
  112846. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  112847. /**
  112848. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  112849. */
  112850. layerMask: number;
  112851. /**
  112852. * Define the id of the lens flare system in the scene.
  112853. * (equal to name by default)
  112854. */
  112855. id: string;
  112856. private _scene;
  112857. private _emitter;
  112858. private _vertexBuffers;
  112859. private _indexBuffer;
  112860. private _effect;
  112861. private _positionX;
  112862. private _positionY;
  112863. private _isEnabled;
  112864. /** @hidden */
  112865. static _SceneComponentInitialization: (scene: Scene) => void;
  112866. /**
  112867. * Instantiates a lens flare system.
  112868. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  112869. * It is usually composed of several `lensFlare`.
  112870. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112871. * @param name Define the name of the lens flare system in the scene
  112872. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  112873. * @param scene Define the scene the lens flare system belongs to
  112874. */
  112875. constructor(
  112876. /**
  112877. * Define the name of the lens flare system
  112878. */
  112879. name: string, emitter: any, scene: Scene);
  112880. /**
  112881. * Define if the lens flare system is enabled.
  112882. */
  112883. isEnabled: boolean;
  112884. /**
  112885. * Get the scene the effects belongs to.
  112886. * @returns the scene holding the lens flare system
  112887. */
  112888. getScene(): Scene;
  112889. /**
  112890. * Get the emitter of the lens flare system.
  112891. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  112892. * @returns the emitter of the lens flare system
  112893. */
  112894. getEmitter(): any;
  112895. /**
  112896. * Set the emitter of the lens flare system.
  112897. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  112898. * @param newEmitter Define the new emitter of the system
  112899. */
  112900. setEmitter(newEmitter: any): void;
  112901. /**
  112902. * Get the lens flare system emitter position.
  112903. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  112904. * @returns the position
  112905. */
  112906. getEmitterPosition(): Vector3;
  112907. /**
  112908. * @hidden
  112909. */
  112910. computeEffectivePosition(globalViewport: Viewport): boolean;
  112911. /** @hidden */
  112912. _isVisible(): boolean;
  112913. /**
  112914. * @hidden
  112915. */
  112916. render(): boolean;
  112917. /**
  112918. * Dispose and release the lens flare with its associated resources.
  112919. */
  112920. dispose(): void;
  112921. /**
  112922. * Parse a lens flare system from a JSON repressentation
  112923. * @param parsedLensFlareSystem Define the JSON to parse
  112924. * @param scene Define the scene the parsed system should be instantiated in
  112925. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  112926. * @returns the parsed system
  112927. */
  112928. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  112929. /**
  112930. * Serialize the current Lens Flare System into a JSON representation.
  112931. * @returns the serialized JSON
  112932. */
  112933. serialize(): any;
  112934. }
  112935. }
  112936. declare module BABYLON {
  112937. /**
  112938. * This represents one of the lens effect in a `lensFlareSystem`.
  112939. * It controls one of the indiviual texture used in the effect.
  112940. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112941. */
  112942. export class LensFlare {
  112943. /**
  112944. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  112945. */
  112946. size: number;
  112947. /**
  112948. * 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.
  112949. */
  112950. position: number;
  112951. /**
  112952. * Define the lens color.
  112953. */
  112954. color: Color3;
  112955. /**
  112956. * Define the lens texture.
  112957. */
  112958. texture: Nullable<Texture>;
  112959. /**
  112960. * Define the alpha mode to render this particular lens.
  112961. */
  112962. alphaMode: number;
  112963. private _system;
  112964. /**
  112965. * Creates a new Lens Flare.
  112966. * This represents one of the lens effect in a `lensFlareSystem`.
  112967. * It controls one of the indiviual texture used in the effect.
  112968. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112969. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  112970. * @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.
  112971. * @param color Define the lens color
  112972. * @param imgUrl Define the lens texture url
  112973. * @param system Define the `lensFlareSystem` this flare is part of
  112974. * @returns The newly created Lens Flare
  112975. */
  112976. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  112977. /**
  112978. * Instantiates a new Lens Flare.
  112979. * This represents one of the lens effect in a `lensFlareSystem`.
  112980. * It controls one of the indiviual texture used in the effect.
  112981. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112982. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  112983. * @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.
  112984. * @param color Define the lens color
  112985. * @param imgUrl Define the lens texture url
  112986. * @param system Define the `lensFlareSystem` this flare is part of
  112987. */
  112988. constructor(
  112989. /**
  112990. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  112991. */
  112992. size: number,
  112993. /**
  112994. * 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.
  112995. */
  112996. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  112997. /**
  112998. * Dispose and release the lens flare with its associated resources.
  112999. */
  113000. dispose(): void;
  113001. }
  113002. }
  113003. declare module BABYLON {
  113004. interface AbstractScene {
  113005. /**
  113006. * The list of lens flare system added to the scene
  113007. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  113008. */
  113009. lensFlareSystems: Array<LensFlareSystem>;
  113010. /**
  113011. * Removes the given lens flare system from this scene.
  113012. * @param toRemove The lens flare system to remove
  113013. * @returns The index of the removed lens flare system
  113014. */
  113015. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  113016. /**
  113017. * Adds the given lens flare system to this scene
  113018. * @param newLensFlareSystem The lens flare system to add
  113019. */
  113020. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  113021. /**
  113022. * Gets a lens flare system using its name
  113023. * @param name defines the name to look for
  113024. * @returns the lens flare system or null if not found
  113025. */
  113026. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  113027. /**
  113028. * Gets a lens flare system using its id
  113029. * @param id defines the id to look for
  113030. * @returns the lens flare system or null if not found
  113031. */
  113032. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  113033. }
  113034. /**
  113035. * Defines the lens flare scene component responsible to manage any lens flares
  113036. * in a given scene.
  113037. */
  113038. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  113039. /**
  113040. * The component name helpfull to identify the component in the list of scene components.
  113041. */
  113042. readonly name: string;
  113043. /**
  113044. * The scene the component belongs to.
  113045. */
  113046. scene: Scene;
  113047. /**
  113048. * Creates a new instance of the component for the given scene
  113049. * @param scene Defines the scene to register the component in
  113050. */
  113051. constructor(scene: Scene);
  113052. /**
  113053. * Registers the component in a given scene
  113054. */
  113055. register(): void;
  113056. /**
  113057. * Rebuilds the elements related to this component in case of
  113058. * context lost for instance.
  113059. */
  113060. rebuild(): void;
  113061. /**
  113062. * Adds all the elements from the container to the scene
  113063. * @param container the container holding the elements
  113064. */
  113065. addFromContainer(container: AbstractScene): void;
  113066. /**
  113067. * Removes all the elements in the container from the scene
  113068. * @param container contains the elements to remove
  113069. * @param dispose if the removed element should be disposed (default: false)
  113070. */
  113071. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  113072. /**
  113073. * Serializes the component data to the specified json object
  113074. * @param serializationObject The object to serialize to
  113075. */
  113076. serialize(serializationObject: any): void;
  113077. /**
  113078. * Disposes the component and the associated ressources.
  113079. */
  113080. dispose(): void;
  113081. private _draw;
  113082. }
  113083. }
  113084. declare module BABYLON {
  113085. /**
  113086. * Defines the shadow generator component responsible to manage any shadow generators
  113087. * in a given scene.
  113088. */
  113089. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  113090. /**
  113091. * The component name helpfull to identify the component in the list of scene components.
  113092. */
  113093. readonly name: string;
  113094. /**
  113095. * The scene the component belongs to.
  113096. */
  113097. scene: Scene;
  113098. /**
  113099. * Creates a new instance of the component for the given scene
  113100. * @param scene Defines the scene to register the component in
  113101. */
  113102. constructor(scene: Scene);
  113103. /**
  113104. * Registers the component in a given scene
  113105. */
  113106. register(): void;
  113107. /**
  113108. * Rebuilds the elements related to this component in case of
  113109. * context lost for instance.
  113110. */
  113111. rebuild(): void;
  113112. /**
  113113. * Serializes the component data to the specified json object
  113114. * @param serializationObject The object to serialize to
  113115. */
  113116. serialize(serializationObject: any): void;
  113117. /**
  113118. * Adds all the elements from the container to the scene
  113119. * @param container the container holding the elements
  113120. */
  113121. addFromContainer(container: AbstractScene): void;
  113122. /**
  113123. * Removes all the elements in the container from the scene
  113124. * @param container contains the elements to remove
  113125. * @param dispose if the removed element should be disposed (default: false)
  113126. */
  113127. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  113128. /**
  113129. * Rebuilds the elements related to this component in case of
  113130. * context lost for instance.
  113131. */
  113132. dispose(): void;
  113133. private _gatherRenderTargets;
  113134. }
  113135. }
  113136. declare module BABYLON {
  113137. /**
  113138. * A point light is a light defined by an unique point in world space.
  113139. * The light is emitted in every direction from this point.
  113140. * A good example of a point light is a standard light bulb.
  113141. * Documentation: https://doc.babylonjs.com/babylon101/lights
  113142. */
  113143. export class PointLight extends ShadowLight {
  113144. private _shadowAngle;
  113145. /**
  113146. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  113147. * This specifies what angle the shadow will use to be created.
  113148. *
  113149. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  113150. */
  113151. /**
  113152. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  113153. * This specifies what angle the shadow will use to be created.
  113154. *
  113155. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  113156. */
  113157. shadowAngle: number;
  113158. /**
  113159. * Gets the direction if it has been set.
  113160. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  113161. */
  113162. /**
  113163. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  113164. */
  113165. direction: Vector3;
  113166. /**
  113167. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  113168. * A PointLight emits the light in every direction.
  113169. * It can cast shadows.
  113170. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  113171. * ```javascript
  113172. * var pointLight = new PointLight("pl", camera.position, scene);
  113173. * ```
  113174. * Documentation : https://doc.babylonjs.com/babylon101/lights
  113175. * @param name The light friendly name
  113176. * @param position The position of the point light in the scene
  113177. * @param scene The scene the lights belongs to
  113178. */
  113179. constructor(name: string, position: Vector3, scene: Scene);
  113180. /**
  113181. * Returns the string "PointLight"
  113182. * @returns the class name
  113183. */
  113184. getClassName(): string;
  113185. /**
  113186. * Returns the integer 0.
  113187. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  113188. */
  113189. getTypeID(): number;
  113190. /**
  113191. * Specifies wether or not the shadowmap should be a cube texture.
  113192. * @returns true if the shadowmap needs to be a cube texture.
  113193. */
  113194. needCube(): boolean;
  113195. /**
  113196. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  113197. * @param faceIndex The index of the face we are computed the direction to generate shadow
  113198. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  113199. */
  113200. getShadowDirection(faceIndex?: number): Vector3;
  113201. /**
  113202. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  113203. * - fov = PI / 2
  113204. * - aspect ratio : 1.0
  113205. * - z-near and far equal to the active camera minZ and maxZ.
  113206. * Returns the PointLight.
  113207. */
  113208. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113209. protected _buildUniformLayout(): void;
  113210. /**
  113211. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  113212. * @param effect The effect to update
  113213. * @param lightIndex The index of the light in the effect to update
  113214. * @returns The point light
  113215. */
  113216. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  113217. /**
  113218. * Prepares the list of defines specific to the light type.
  113219. * @param defines the list of defines
  113220. * @param lightIndex defines the index of the light for the effect
  113221. */
  113222. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  113223. }
  113224. }
  113225. declare module BABYLON {
  113226. /**
  113227. * Header information of HDR texture files.
  113228. */
  113229. export interface HDRInfo {
  113230. /**
  113231. * The height of the texture in pixels.
  113232. */
  113233. height: number;
  113234. /**
  113235. * The width of the texture in pixels.
  113236. */
  113237. width: number;
  113238. /**
  113239. * The index of the beginning of the data in the binary file.
  113240. */
  113241. dataPosition: number;
  113242. }
  113243. /**
  113244. * This groups tools to convert HDR texture to native colors array.
  113245. */
  113246. export class HDRTools {
  113247. private static Ldexp;
  113248. private static Rgbe2float;
  113249. private static readStringLine;
  113250. /**
  113251. * Reads header information from an RGBE texture stored in a native array.
  113252. * More information on this format are available here:
  113253. * https://en.wikipedia.org/wiki/RGBE_image_format
  113254. *
  113255. * @param uint8array The binary file stored in native array.
  113256. * @return The header information.
  113257. */
  113258. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  113259. /**
  113260. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  113261. * This RGBE texture needs to store the information as a panorama.
  113262. *
  113263. * More information on this format are available here:
  113264. * https://en.wikipedia.org/wiki/RGBE_image_format
  113265. *
  113266. * @param buffer The binary file stored in an array buffer.
  113267. * @param size The expected size of the extracted cubemap.
  113268. * @return The Cube Map information.
  113269. */
  113270. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  113271. /**
  113272. * Returns the pixels data extracted from an RGBE texture.
  113273. * This pixels will be stored left to right up to down in the R G B order in one array.
  113274. *
  113275. * More information on this format are available here:
  113276. * https://en.wikipedia.org/wiki/RGBE_image_format
  113277. *
  113278. * @param uint8array The binary file stored in an array buffer.
  113279. * @param hdrInfo The header information of the file.
  113280. * @return The pixels data in RGB right to left up to down order.
  113281. */
  113282. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  113283. private static RGBE_ReadPixels_RLE;
  113284. }
  113285. }
  113286. declare module BABYLON {
  113287. /**
  113288. * This represents a texture coming from an HDR input.
  113289. *
  113290. * The only supported format is currently panorama picture stored in RGBE format.
  113291. * Example of such files can be found on HDRLib: http://hdrlib.com/
  113292. */
  113293. export class HDRCubeTexture extends BaseTexture {
  113294. private static _facesMapping;
  113295. private _generateHarmonics;
  113296. private _noMipmap;
  113297. private _textureMatrix;
  113298. private _size;
  113299. private _onLoad;
  113300. private _onError;
  113301. /**
  113302. * The texture URL.
  113303. */
  113304. url: string;
  113305. /**
  113306. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  113307. */
  113308. coordinatesMode: number;
  113309. protected _isBlocking: boolean;
  113310. /**
  113311. * Sets wether or not the texture is blocking during loading.
  113312. */
  113313. /**
  113314. * Gets wether or not the texture is blocking during loading.
  113315. */
  113316. isBlocking: boolean;
  113317. protected _rotationY: number;
  113318. /**
  113319. * Sets texture matrix rotation angle around Y axis in radians.
  113320. */
  113321. /**
  113322. * Gets texture matrix rotation angle around Y axis radians.
  113323. */
  113324. rotationY: number;
  113325. /**
  113326. * Gets or sets the center of the bounding box associated with the cube texture
  113327. * It must define where the camera used to render the texture was set
  113328. */
  113329. boundingBoxPosition: Vector3;
  113330. private _boundingBoxSize;
  113331. /**
  113332. * Gets or sets the size of the bounding box associated with the cube texture
  113333. * When defined, the cubemap will switch to local mode
  113334. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  113335. * @example https://www.babylonjs-playground.com/#RNASML
  113336. */
  113337. boundingBoxSize: Vector3;
  113338. /**
  113339. * Instantiates an HDRTexture from the following parameters.
  113340. *
  113341. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  113342. * @param scene The scene the texture will be used in
  113343. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  113344. * @param noMipmap Forces to not generate the mipmap if true
  113345. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  113346. * @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)
  113347. * @param reserved Reserved flag for internal use.
  113348. */
  113349. 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>);
  113350. /**
  113351. * Get the current class name of the texture useful for serialization or dynamic coding.
  113352. * @returns "HDRCubeTexture"
  113353. */
  113354. getClassName(): string;
  113355. /**
  113356. * Occurs when the file is raw .hdr file.
  113357. */
  113358. private loadTexture;
  113359. clone(): HDRCubeTexture;
  113360. delayLoad(): void;
  113361. /**
  113362. * Get the texture reflection matrix used to rotate/transform the reflection.
  113363. * @returns the reflection matrix
  113364. */
  113365. getReflectionTextureMatrix(): Matrix;
  113366. /**
  113367. * Set the texture reflection matrix used to rotate/transform the reflection.
  113368. * @param value Define the reflection matrix to set
  113369. */
  113370. setReflectionTextureMatrix(value: Matrix): void;
  113371. /**
  113372. * Parses a JSON representation of an HDR Texture in order to create the texture
  113373. * @param parsedTexture Define the JSON representation
  113374. * @param scene Define the scene the texture should be created in
  113375. * @param rootUrl Define the root url in case we need to load relative dependencies
  113376. * @returns the newly created texture after parsing
  113377. */
  113378. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  113379. serialize(): any;
  113380. }
  113381. }
  113382. declare module BABYLON {
  113383. /**
  113384. * Class used to control physics engine
  113385. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  113386. */
  113387. export class PhysicsEngine implements IPhysicsEngine {
  113388. private _physicsPlugin;
  113389. /**
  113390. * Global value used to control the smallest number supported by the simulation
  113391. */
  113392. static Epsilon: number;
  113393. private _impostors;
  113394. private _joints;
  113395. /**
  113396. * Gets the gravity vector used by the simulation
  113397. */
  113398. gravity: Vector3;
  113399. /**
  113400. * Factory used to create the default physics plugin.
  113401. * @returns The default physics plugin
  113402. */
  113403. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  113404. /**
  113405. * Creates a new Physics Engine
  113406. * @param gravity defines the gravity vector used by the simulation
  113407. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  113408. */
  113409. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  113410. /**
  113411. * Sets the gravity vector used by the simulation
  113412. * @param gravity defines the gravity vector to use
  113413. */
  113414. setGravity(gravity: Vector3): void;
  113415. /**
  113416. * Set the time step of the physics engine.
  113417. * Default is 1/60.
  113418. * To slow it down, enter 1/600 for example.
  113419. * To speed it up, 1/30
  113420. * @param newTimeStep defines the new timestep to apply to this world.
  113421. */
  113422. setTimeStep(newTimeStep?: number): void;
  113423. /**
  113424. * Get the time step of the physics engine.
  113425. * @returns the current time step
  113426. */
  113427. getTimeStep(): number;
  113428. /**
  113429. * Release all resources
  113430. */
  113431. dispose(): void;
  113432. /**
  113433. * Gets the name of the current physics plugin
  113434. * @returns the name of the plugin
  113435. */
  113436. getPhysicsPluginName(): string;
  113437. /**
  113438. * Adding a new impostor for the impostor tracking.
  113439. * This will be done by the impostor itself.
  113440. * @param impostor the impostor to add
  113441. */
  113442. addImpostor(impostor: PhysicsImpostor): void;
  113443. /**
  113444. * Remove an impostor from the engine.
  113445. * This impostor and its mesh will not longer be updated by the physics engine.
  113446. * @param impostor the impostor to remove
  113447. */
  113448. removeImpostor(impostor: PhysicsImpostor): void;
  113449. /**
  113450. * Add a joint to the physics engine
  113451. * @param mainImpostor defines the main impostor to which the joint is added.
  113452. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  113453. * @param joint defines the joint that will connect both impostors.
  113454. */
  113455. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  113456. /**
  113457. * Removes a joint from the simulation
  113458. * @param mainImpostor defines the impostor used with the joint
  113459. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  113460. * @param joint defines the joint to remove
  113461. */
  113462. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  113463. /**
  113464. * Called by the scene. No need to call it.
  113465. * @param delta defines the timespam between frames
  113466. */
  113467. _step(delta: number): void;
  113468. /**
  113469. * Gets the current plugin used to run the simulation
  113470. * @returns current plugin
  113471. */
  113472. getPhysicsPlugin(): IPhysicsEnginePlugin;
  113473. /**
  113474. * Gets the list of physic impostors
  113475. * @returns an array of PhysicsImpostor
  113476. */
  113477. getImpostors(): Array<PhysicsImpostor>;
  113478. /**
  113479. * Gets the impostor for a physics enabled object
  113480. * @param object defines the object impersonated by the impostor
  113481. * @returns the PhysicsImpostor or null if not found
  113482. */
  113483. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  113484. /**
  113485. * Gets the impostor for a physics body object
  113486. * @param body defines physics body used by the impostor
  113487. * @returns the PhysicsImpostor or null if not found
  113488. */
  113489. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  113490. /**
  113491. * Does a raycast in the physics world
  113492. * @param from when should the ray start?
  113493. * @param to when should the ray end?
  113494. * @returns PhysicsRaycastResult
  113495. */
  113496. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113497. }
  113498. }
  113499. declare module BABYLON {
  113500. /** @hidden */
  113501. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  113502. private _useDeltaForWorldStep;
  113503. world: any;
  113504. name: string;
  113505. private _physicsMaterials;
  113506. private _fixedTimeStep;
  113507. private _cannonRaycastResult;
  113508. private _raycastResult;
  113509. private _physicsBodysToRemoveAfterStep;
  113510. BJSCANNON: any;
  113511. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  113512. setGravity(gravity: Vector3): void;
  113513. setTimeStep(timeStep: number): void;
  113514. getTimeStep(): number;
  113515. executeStep(delta: number): void;
  113516. private _removeMarkedPhysicsBodiesFromWorld;
  113517. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113518. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113519. generatePhysicsBody(impostor: PhysicsImpostor): void;
  113520. private _processChildMeshes;
  113521. removePhysicsBody(impostor: PhysicsImpostor): void;
  113522. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  113523. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  113524. private _addMaterial;
  113525. private _checkWithEpsilon;
  113526. private _createShape;
  113527. private _createHeightmap;
  113528. private _minus90X;
  113529. private _plus90X;
  113530. private _tmpPosition;
  113531. private _tmpDeltaPosition;
  113532. private _tmpUnityRotation;
  113533. private _updatePhysicsBodyTransformation;
  113534. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  113535. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  113536. isSupported(): boolean;
  113537. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113538. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113539. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113540. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113541. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  113542. getBodyMass(impostor: PhysicsImpostor): number;
  113543. getBodyFriction(impostor: PhysicsImpostor): number;
  113544. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  113545. getBodyRestitution(impostor: PhysicsImpostor): number;
  113546. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  113547. sleepBody(impostor: PhysicsImpostor): void;
  113548. wakeUpBody(impostor: PhysicsImpostor): void;
  113549. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  113550. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  113551. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  113552. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  113553. getRadius(impostor: PhysicsImpostor): number;
  113554. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  113555. dispose(): void;
  113556. private _extendNamespace;
  113557. /**
  113558. * Does a raycast in the physics world
  113559. * @param from when should the ray start?
  113560. * @param to when should the ray end?
  113561. * @returns PhysicsRaycastResult
  113562. */
  113563. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113564. }
  113565. }
  113566. declare module BABYLON {
  113567. /** @hidden */
  113568. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  113569. world: any;
  113570. name: string;
  113571. BJSOIMO: any;
  113572. private _raycastResult;
  113573. constructor(iterations?: number, oimoInjection?: any);
  113574. setGravity(gravity: Vector3): void;
  113575. setTimeStep(timeStep: number): void;
  113576. getTimeStep(): number;
  113577. private _tmpImpostorsArray;
  113578. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  113579. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113580. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113581. generatePhysicsBody(impostor: PhysicsImpostor): void;
  113582. private _tmpPositionVector;
  113583. removePhysicsBody(impostor: PhysicsImpostor): void;
  113584. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  113585. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  113586. isSupported(): boolean;
  113587. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  113588. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  113589. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113590. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113591. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113592. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113593. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  113594. getBodyMass(impostor: PhysicsImpostor): number;
  113595. getBodyFriction(impostor: PhysicsImpostor): number;
  113596. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  113597. getBodyRestitution(impostor: PhysicsImpostor): number;
  113598. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  113599. sleepBody(impostor: PhysicsImpostor): void;
  113600. wakeUpBody(impostor: PhysicsImpostor): void;
  113601. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  113602. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  113603. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  113604. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  113605. getRadius(impostor: PhysicsImpostor): number;
  113606. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  113607. dispose(): void;
  113608. /**
  113609. * Does a raycast in the physics world
  113610. * @param from when should the ray start?
  113611. * @param to when should the ray end?
  113612. * @returns PhysicsRaycastResult
  113613. */
  113614. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113615. }
  113616. }
  113617. declare module BABYLON {
  113618. /**
  113619. * Class containing static functions to help procedurally build meshes
  113620. */
  113621. export class RibbonBuilder {
  113622. /**
  113623. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  113624. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  113625. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  113626. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  113627. * * 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
  113628. * * 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
  113629. * * 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
  113630. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113631. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113632. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  113633. * * 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
  113634. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  113635. * * 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
  113636. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  113637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113638. * @param name defines the name of the mesh
  113639. * @param options defines the options used to create the mesh
  113640. * @param scene defines the hosting scene
  113641. * @returns the ribbon mesh
  113642. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  113643. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  113644. */
  113645. static CreateRibbon(name: string, options: {
  113646. pathArray: Vector3[][];
  113647. closeArray?: boolean;
  113648. closePath?: boolean;
  113649. offset?: number;
  113650. updatable?: boolean;
  113651. sideOrientation?: number;
  113652. frontUVs?: Vector4;
  113653. backUVs?: Vector4;
  113654. instance?: Mesh;
  113655. invertUV?: boolean;
  113656. uvs?: Vector2[];
  113657. colors?: Color4[];
  113658. }, scene?: Nullable<Scene>): Mesh;
  113659. }
  113660. }
  113661. declare module BABYLON {
  113662. /**
  113663. * Class containing static functions to help procedurally build meshes
  113664. */
  113665. export class ShapeBuilder {
  113666. /**
  113667. * 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.
  113668. * * 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.
  113669. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  113670. * * 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.
  113671. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  113672. * * 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
  113673. * * 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
  113674. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  113675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113676. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113677. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  113678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  113679. * @param name defines the name of the mesh
  113680. * @param options defines the options used to create the mesh
  113681. * @param scene defines the hosting scene
  113682. * @returns the extruded shape mesh
  113683. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  113684. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  113685. */
  113686. static ExtrudeShape(name: string, options: {
  113687. shape: Vector3[];
  113688. path: Vector3[];
  113689. scale?: number;
  113690. rotation?: number;
  113691. cap?: number;
  113692. updatable?: boolean;
  113693. sideOrientation?: number;
  113694. frontUVs?: Vector4;
  113695. backUVs?: Vector4;
  113696. instance?: Mesh;
  113697. invertUV?: boolean;
  113698. }, scene?: Nullable<Scene>): Mesh;
  113699. /**
  113700. * Creates an custom extruded shape mesh.
  113701. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  113702. * * 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.
  113703. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  113704. * * 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
  113705. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  113706. * * 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
  113707. * * It must returns a float value that will be the scale value applied to the shape on each path point
  113708. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  113709. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  113710. * * 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
  113711. * * 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
  113712. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  113713. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113714. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113715. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  113716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113717. * @param name defines the name of the mesh
  113718. * @param options defines the options used to create the mesh
  113719. * @param scene defines the hosting scene
  113720. * @returns the custom extruded shape mesh
  113721. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  113722. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  113723. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  113724. */
  113725. static ExtrudeShapeCustom(name: string, options: {
  113726. shape: Vector3[];
  113727. path: Vector3[];
  113728. scaleFunction?: any;
  113729. rotationFunction?: any;
  113730. ribbonCloseArray?: boolean;
  113731. ribbonClosePath?: boolean;
  113732. cap?: number;
  113733. updatable?: boolean;
  113734. sideOrientation?: number;
  113735. frontUVs?: Vector4;
  113736. backUVs?: Vector4;
  113737. instance?: Mesh;
  113738. invertUV?: boolean;
  113739. }, scene?: Nullable<Scene>): Mesh;
  113740. private static _ExtrudeShapeGeneric;
  113741. }
  113742. }
  113743. declare module BABYLON {
  113744. /**
  113745. * AmmoJS Physics plugin
  113746. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113747. * @see https://github.com/kripken/ammo.js/
  113748. */
  113749. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  113750. private _useDeltaForWorldStep;
  113751. /**
  113752. * Reference to the Ammo library
  113753. */
  113754. bjsAMMO: any;
  113755. /**
  113756. * Created ammoJS world which physics bodies are added to
  113757. */
  113758. world: any;
  113759. /**
  113760. * Name of the plugin
  113761. */
  113762. name: string;
  113763. private _timeStep;
  113764. private _fixedTimeStep;
  113765. private _maxSteps;
  113766. private _tmpQuaternion;
  113767. private _tmpAmmoTransform;
  113768. private _tmpAmmoQuaternion;
  113769. private _tmpAmmoConcreteContactResultCallback;
  113770. private _collisionConfiguration;
  113771. private _dispatcher;
  113772. private _overlappingPairCache;
  113773. private _solver;
  113774. private _softBodySolver;
  113775. private _tmpAmmoVectorA;
  113776. private _tmpAmmoVectorB;
  113777. private _tmpAmmoVectorC;
  113778. private _tmpAmmoVectorD;
  113779. private _tmpContactCallbackResult;
  113780. private _tmpAmmoVectorRCA;
  113781. private _tmpAmmoVectorRCB;
  113782. private _raycastResult;
  113783. private static readonly DISABLE_COLLISION_FLAG;
  113784. private static readonly KINEMATIC_FLAG;
  113785. private static readonly DISABLE_DEACTIVATION_FLAG;
  113786. /**
  113787. * Initializes the ammoJS plugin
  113788. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  113789. * @param ammoInjection can be used to inject your own ammo reference
  113790. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  113791. */
  113792. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  113793. /**
  113794. * Sets the gravity of the physics world (m/(s^2))
  113795. * @param gravity Gravity to set
  113796. */
  113797. setGravity(gravity: Vector3): void;
  113798. /**
  113799. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  113800. * @param timeStep timestep to use in seconds
  113801. */
  113802. setTimeStep(timeStep: number): void;
  113803. /**
  113804. * 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)
  113805. * @param fixedTimeStep fixedTimeStep to use in seconds
  113806. */
  113807. setFixedTimeStep(fixedTimeStep: number): void;
  113808. /**
  113809. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  113810. * @param maxSteps the maximum number of steps by the physics engine per frame
  113811. */
  113812. setMaxSteps(maxSteps: number): void;
  113813. /**
  113814. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  113815. * @returns the current timestep in seconds
  113816. */
  113817. getTimeStep(): number;
  113818. private _isImpostorInContact;
  113819. private _isImpostorPairInContact;
  113820. private _stepSimulation;
  113821. /**
  113822. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  113823. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  113824. * After the step the babylon meshes are set to the position of the physics imposters
  113825. * @param delta amount of time to step forward
  113826. * @param impostors array of imposters to update before/after the step
  113827. */
  113828. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  113829. /**
  113830. * Update babylon mesh to match physics world object
  113831. * @param impostor imposter to match
  113832. */
  113833. private _afterSoftStep;
  113834. /**
  113835. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  113836. * @param impostor imposter to match
  113837. */
  113838. private _ropeStep;
  113839. /**
  113840. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  113841. * @param impostor imposter to match
  113842. */
  113843. private _softbodyOrClothStep;
  113844. private _tmpVector;
  113845. private _tmpMatrix;
  113846. /**
  113847. * Applies an impulse on the imposter
  113848. * @param impostor imposter to apply impulse to
  113849. * @param force amount of force to be applied to the imposter
  113850. * @param contactPoint the location to apply the impulse on the imposter
  113851. */
  113852. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113853. /**
  113854. * Applies a force on the imposter
  113855. * @param impostor imposter to apply force
  113856. * @param force amount of force to be applied to the imposter
  113857. * @param contactPoint the location to apply the force on the imposter
  113858. */
  113859. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113860. /**
  113861. * Creates a physics body using the plugin
  113862. * @param impostor the imposter to create the physics body on
  113863. */
  113864. generatePhysicsBody(impostor: PhysicsImpostor): void;
  113865. /**
  113866. * Removes the physics body from the imposter and disposes of the body's memory
  113867. * @param impostor imposter to remove the physics body from
  113868. */
  113869. removePhysicsBody(impostor: PhysicsImpostor): void;
  113870. /**
  113871. * Generates a joint
  113872. * @param impostorJoint the imposter joint to create the joint with
  113873. */
  113874. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  113875. /**
  113876. * Removes a joint
  113877. * @param impostorJoint the imposter joint to remove the joint from
  113878. */
  113879. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  113880. private _addMeshVerts;
  113881. /**
  113882. * Initialise the soft body vertices to match its object's (mesh) vertices
  113883. * Softbody vertices (nodes) are in world space and to match this
  113884. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  113885. * @param impostor to create the softbody for
  113886. */
  113887. private _softVertexData;
  113888. /**
  113889. * Create an impostor's soft body
  113890. * @param impostor to create the softbody for
  113891. */
  113892. private _createSoftbody;
  113893. /**
  113894. * Create cloth for an impostor
  113895. * @param impostor to create the softbody for
  113896. */
  113897. private _createCloth;
  113898. /**
  113899. * Create rope for an impostor
  113900. * @param impostor to create the softbody for
  113901. */
  113902. private _createRope;
  113903. private _addHullVerts;
  113904. private _createShape;
  113905. /**
  113906. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  113907. * @param impostor imposter containing the physics body and babylon object
  113908. */
  113909. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  113910. /**
  113911. * Sets the babylon object's position/rotation from the physics body's position/rotation
  113912. * @param impostor imposter containing the physics body and babylon object
  113913. * @param newPosition new position
  113914. * @param newRotation new rotation
  113915. */
  113916. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  113917. /**
  113918. * If this plugin is supported
  113919. * @returns true if its supported
  113920. */
  113921. isSupported(): boolean;
  113922. /**
  113923. * Sets the linear velocity of the physics body
  113924. * @param impostor imposter to set the velocity on
  113925. * @param velocity velocity to set
  113926. */
  113927. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113928. /**
  113929. * Sets the angular velocity of the physics body
  113930. * @param impostor imposter to set the velocity on
  113931. * @param velocity velocity to set
  113932. */
  113933. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113934. /**
  113935. * gets the linear velocity
  113936. * @param impostor imposter to get linear velocity from
  113937. * @returns linear velocity
  113938. */
  113939. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113940. /**
  113941. * gets the angular velocity
  113942. * @param impostor imposter to get angular velocity from
  113943. * @returns angular velocity
  113944. */
  113945. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113946. /**
  113947. * Sets the mass of physics body
  113948. * @param impostor imposter to set the mass on
  113949. * @param mass mass to set
  113950. */
  113951. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  113952. /**
  113953. * Gets the mass of the physics body
  113954. * @param impostor imposter to get the mass from
  113955. * @returns mass
  113956. */
  113957. getBodyMass(impostor: PhysicsImpostor): number;
  113958. /**
  113959. * Gets friction of the impostor
  113960. * @param impostor impostor to get friction from
  113961. * @returns friction value
  113962. */
  113963. getBodyFriction(impostor: PhysicsImpostor): number;
  113964. /**
  113965. * Sets friction of the impostor
  113966. * @param impostor impostor to set friction on
  113967. * @param friction friction value
  113968. */
  113969. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  113970. /**
  113971. * Gets restitution of the impostor
  113972. * @param impostor impostor to get restitution from
  113973. * @returns restitution value
  113974. */
  113975. getBodyRestitution(impostor: PhysicsImpostor): number;
  113976. /**
  113977. * Sets resitution of the impostor
  113978. * @param impostor impostor to set resitution on
  113979. * @param restitution resitution value
  113980. */
  113981. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  113982. /**
  113983. * Gets pressure inside the impostor
  113984. * @param impostor impostor to get pressure from
  113985. * @returns pressure value
  113986. */
  113987. getBodyPressure(impostor: PhysicsImpostor): number;
  113988. /**
  113989. * Sets pressure inside a soft body impostor
  113990. * Cloth and rope must remain 0 pressure
  113991. * @param impostor impostor to set pressure on
  113992. * @param pressure pressure value
  113993. */
  113994. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  113995. /**
  113996. * Gets stiffness of the impostor
  113997. * @param impostor impostor to get stiffness from
  113998. * @returns pressure value
  113999. */
  114000. getBodyStiffness(impostor: PhysicsImpostor): number;
  114001. /**
  114002. * Sets stiffness of the impostor
  114003. * @param impostor impostor to set stiffness on
  114004. * @param stiffness stiffness value from 0 to 1
  114005. */
  114006. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  114007. /**
  114008. * Gets velocityIterations of the impostor
  114009. * @param impostor impostor to get velocity iterations from
  114010. * @returns velocityIterations value
  114011. */
  114012. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  114013. /**
  114014. * Sets velocityIterations of the impostor
  114015. * @param impostor impostor to set velocity iterations on
  114016. * @param velocityIterations velocityIterations value
  114017. */
  114018. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  114019. /**
  114020. * Gets positionIterations of the impostor
  114021. * @param impostor impostor to get position iterations from
  114022. * @returns positionIterations value
  114023. */
  114024. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  114025. /**
  114026. * Sets positionIterations of the impostor
  114027. * @param impostor impostor to set position on
  114028. * @param positionIterations positionIterations value
  114029. */
  114030. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  114031. /**
  114032. * Append an anchor to a cloth object
  114033. * @param impostor is the cloth impostor to add anchor to
  114034. * @param otherImpostor is the rigid impostor to anchor to
  114035. * @param width ratio across width from 0 to 1
  114036. * @param height ratio up height from 0 to 1
  114037. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  114038. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  114039. */
  114040. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  114041. /**
  114042. * Append an hook to a rope object
  114043. * @param impostor is the rope impostor to add hook to
  114044. * @param otherImpostor is the rigid impostor to hook to
  114045. * @param length ratio along the rope from 0 to 1
  114046. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  114047. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  114048. */
  114049. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  114050. /**
  114051. * Sleeps the physics body and stops it from being active
  114052. * @param impostor impostor to sleep
  114053. */
  114054. sleepBody(impostor: PhysicsImpostor): void;
  114055. /**
  114056. * Activates the physics body
  114057. * @param impostor impostor to activate
  114058. */
  114059. wakeUpBody(impostor: PhysicsImpostor): void;
  114060. /**
  114061. * Updates the distance parameters of the joint
  114062. * @param joint joint to update
  114063. * @param maxDistance maximum distance of the joint
  114064. * @param minDistance minimum distance of the joint
  114065. */
  114066. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  114067. /**
  114068. * Sets a motor on the joint
  114069. * @param joint joint to set motor on
  114070. * @param speed speed of the motor
  114071. * @param maxForce maximum force of the motor
  114072. * @param motorIndex index of the motor
  114073. */
  114074. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  114075. /**
  114076. * Sets the motors limit
  114077. * @param joint joint to set limit on
  114078. * @param upperLimit upper limit
  114079. * @param lowerLimit lower limit
  114080. */
  114081. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  114082. /**
  114083. * Syncs the position and rotation of a mesh with the impostor
  114084. * @param mesh mesh to sync
  114085. * @param impostor impostor to update the mesh with
  114086. */
  114087. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  114088. /**
  114089. * Gets the radius of the impostor
  114090. * @param impostor impostor to get radius from
  114091. * @returns the radius
  114092. */
  114093. getRadius(impostor: PhysicsImpostor): number;
  114094. /**
  114095. * Gets the box size of the impostor
  114096. * @param impostor impostor to get box size from
  114097. * @param result the resulting box size
  114098. */
  114099. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  114100. /**
  114101. * Disposes of the impostor
  114102. */
  114103. dispose(): void;
  114104. /**
  114105. * Does a raycast in the physics world
  114106. * @param from when should the ray start?
  114107. * @param to when should the ray end?
  114108. * @returns PhysicsRaycastResult
  114109. */
  114110. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  114111. }
  114112. }
  114113. declare module BABYLON {
  114114. interface AbstractScene {
  114115. /**
  114116. * The list of reflection probes added to the scene
  114117. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  114118. */
  114119. reflectionProbes: Array<ReflectionProbe>;
  114120. /**
  114121. * Removes the given reflection probe from this scene.
  114122. * @param toRemove The reflection probe to remove
  114123. * @returns The index of the removed reflection probe
  114124. */
  114125. removeReflectionProbe(toRemove: ReflectionProbe): number;
  114126. /**
  114127. * Adds the given reflection probe to this scene.
  114128. * @param newReflectionProbe The reflection probe to add
  114129. */
  114130. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  114131. }
  114132. /**
  114133. * Class used to generate realtime reflection / refraction cube textures
  114134. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  114135. */
  114136. export class ReflectionProbe {
  114137. /** defines the name of the probe */
  114138. name: string;
  114139. private _scene;
  114140. private _renderTargetTexture;
  114141. private _projectionMatrix;
  114142. private _viewMatrix;
  114143. private _target;
  114144. private _add;
  114145. private _attachedMesh;
  114146. private _invertYAxis;
  114147. /** Gets or sets probe position (center of the cube map) */
  114148. position: Vector3;
  114149. /**
  114150. * Creates a new reflection probe
  114151. * @param name defines the name of the probe
  114152. * @param size defines the texture resolution (for each face)
  114153. * @param scene defines the hosting scene
  114154. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  114155. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  114156. */
  114157. constructor(
  114158. /** defines the name of the probe */
  114159. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  114160. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  114161. samples: number;
  114162. /** Gets or sets the refresh rate to use (on every frame by default) */
  114163. refreshRate: number;
  114164. /**
  114165. * Gets the hosting scene
  114166. * @returns a Scene
  114167. */
  114168. getScene(): Scene;
  114169. /** Gets the internal CubeTexture used to render to */
  114170. readonly cubeTexture: RenderTargetTexture;
  114171. /** Gets the list of meshes to render */
  114172. readonly renderList: Nullable<AbstractMesh[]>;
  114173. /**
  114174. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  114175. * @param mesh defines the mesh to attach to
  114176. */
  114177. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  114178. /**
  114179. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  114180. * @param renderingGroupId The rendering group id corresponding to its index
  114181. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  114182. */
  114183. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  114184. /**
  114185. * Clean all associated resources
  114186. */
  114187. dispose(): void;
  114188. /**
  114189. * Converts the reflection probe information to a readable string for debug purpose.
  114190. * @param fullDetails Supports for multiple levels of logging within scene loading
  114191. * @returns the human readable reflection probe info
  114192. */
  114193. toString(fullDetails?: boolean): string;
  114194. /**
  114195. * Get the class name of the relfection probe.
  114196. * @returns "ReflectionProbe"
  114197. */
  114198. getClassName(): string;
  114199. /**
  114200. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  114201. * @returns The JSON representation of the texture
  114202. */
  114203. serialize(): any;
  114204. /**
  114205. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  114206. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  114207. * @param scene Define the scene the parsed reflection probe should be instantiated in
  114208. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  114209. * @returns The parsed reflection probe if successful
  114210. */
  114211. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  114212. }
  114213. }
  114214. declare module BABYLON {
  114215. /** @hidden */
  114216. export var _BabylonLoaderRegistered: boolean;
  114217. }
  114218. declare module BABYLON {
  114219. /**
  114220. * The Physically based simple base material of BJS.
  114221. *
  114222. * This enables better naming and convention enforcements on top of the pbrMaterial.
  114223. * It is used as the base class for both the specGloss and metalRough conventions.
  114224. */
  114225. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  114226. /**
  114227. * Number of Simultaneous lights allowed on the material.
  114228. */
  114229. maxSimultaneousLights: number;
  114230. /**
  114231. * If sets to true, disables all the lights affecting the material.
  114232. */
  114233. disableLighting: boolean;
  114234. /**
  114235. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  114236. */
  114237. environmentTexture: BaseTexture;
  114238. /**
  114239. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  114240. */
  114241. invertNormalMapX: boolean;
  114242. /**
  114243. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  114244. */
  114245. invertNormalMapY: boolean;
  114246. /**
  114247. * Normal map used in the model.
  114248. */
  114249. normalTexture: BaseTexture;
  114250. /**
  114251. * Emissivie color used to self-illuminate the model.
  114252. */
  114253. emissiveColor: Color3;
  114254. /**
  114255. * Emissivie texture used to self-illuminate the model.
  114256. */
  114257. emissiveTexture: BaseTexture;
  114258. /**
  114259. * Occlusion Channel Strenght.
  114260. */
  114261. occlusionStrength: number;
  114262. /**
  114263. * Occlusion Texture of the material (adding extra occlusion effects).
  114264. */
  114265. occlusionTexture: BaseTexture;
  114266. /**
  114267. * Defines the alpha limits in alpha test mode.
  114268. */
  114269. alphaCutOff: number;
  114270. /**
  114271. * Gets the current double sided mode.
  114272. */
  114273. /**
  114274. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  114275. */
  114276. doubleSided: boolean;
  114277. /**
  114278. * Stores the pre-calculated light information of a mesh in a texture.
  114279. */
  114280. lightmapTexture: BaseTexture;
  114281. /**
  114282. * If true, the light map contains occlusion information instead of lighting info.
  114283. */
  114284. useLightmapAsShadowmap: boolean;
  114285. /**
  114286. * Instantiates a new PBRMaterial instance.
  114287. *
  114288. * @param name The material name
  114289. * @param scene The scene the material will be use in.
  114290. */
  114291. constructor(name: string, scene: Scene);
  114292. getClassName(): string;
  114293. }
  114294. }
  114295. declare module BABYLON {
  114296. /**
  114297. * The PBR material of BJS following the metal roughness convention.
  114298. *
  114299. * This fits to the PBR convention in the GLTF definition:
  114300. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  114301. */
  114302. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  114303. /**
  114304. * The base color has two different interpretations depending on the value of metalness.
  114305. * When the material is a metal, the base color is the specific measured reflectance value
  114306. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  114307. * of the material.
  114308. */
  114309. baseColor: Color3;
  114310. /**
  114311. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  114312. * well as opacity information in the alpha channel.
  114313. */
  114314. baseTexture: BaseTexture;
  114315. /**
  114316. * Specifies the metallic scalar value of the material.
  114317. * Can also be used to scale the metalness values of the metallic texture.
  114318. */
  114319. metallic: number;
  114320. /**
  114321. * Specifies the roughness scalar value of the material.
  114322. * Can also be used to scale the roughness values of the metallic texture.
  114323. */
  114324. roughness: number;
  114325. /**
  114326. * Texture containing both the metallic value in the B channel and the
  114327. * roughness value in the G channel to keep better precision.
  114328. */
  114329. metallicRoughnessTexture: BaseTexture;
  114330. /**
  114331. * Instantiates a new PBRMetalRoughnessMaterial instance.
  114332. *
  114333. * @param name The material name
  114334. * @param scene The scene the material will be use in.
  114335. */
  114336. constructor(name: string, scene: Scene);
  114337. /**
  114338. * Return the currrent class name of the material.
  114339. */
  114340. getClassName(): string;
  114341. /**
  114342. * Makes a duplicate of the current material.
  114343. * @param name - name to use for the new material.
  114344. */
  114345. clone(name: string): PBRMetallicRoughnessMaterial;
  114346. /**
  114347. * Serialize the material to a parsable JSON object.
  114348. */
  114349. serialize(): any;
  114350. /**
  114351. * Parses a JSON object correponding to the serialize function.
  114352. */
  114353. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  114354. }
  114355. }
  114356. declare module BABYLON {
  114357. /**
  114358. * The PBR material of BJS following the specular glossiness convention.
  114359. *
  114360. * This fits to the PBR convention in the GLTF definition:
  114361. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  114362. */
  114363. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  114364. /**
  114365. * Specifies the diffuse color of the material.
  114366. */
  114367. diffuseColor: Color3;
  114368. /**
  114369. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  114370. * channel.
  114371. */
  114372. diffuseTexture: BaseTexture;
  114373. /**
  114374. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  114375. */
  114376. specularColor: Color3;
  114377. /**
  114378. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  114379. */
  114380. glossiness: number;
  114381. /**
  114382. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  114383. */
  114384. specularGlossinessTexture: BaseTexture;
  114385. /**
  114386. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  114387. *
  114388. * @param name The material name
  114389. * @param scene The scene the material will be use in.
  114390. */
  114391. constructor(name: string, scene: Scene);
  114392. /**
  114393. * Return the currrent class name of the material.
  114394. */
  114395. getClassName(): string;
  114396. /**
  114397. * Makes a duplicate of the current material.
  114398. * @param name - name to use for the new material.
  114399. */
  114400. clone(name: string): PBRSpecularGlossinessMaterial;
  114401. /**
  114402. * Serialize the material to a parsable JSON object.
  114403. */
  114404. serialize(): any;
  114405. /**
  114406. * Parses a JSON object correponding to the serialize function.
  114407. */
  114408. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  114409. }
  114410. }
  114411. declare module BABYLON {
  114412. /**
  114413. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  114414. * It can help converting any input color in a desired output one. This can then be used to create effects
  114415. * from sepia, black and white to sixties or futuristic rendering...
  114416. *
  114417. * The only supported format is currently 3dl.
  114418. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  114419. */
  114420. export class ColorGradingTexture extends BaseTexture {
  114421. /**
  114422. * The current texture matrix. (will always be identity in color grading texture)
  114423. */
  114424. private _textureMatrix;
  114425. /**
  114426. * The texture URL.
  114427. */
  114428. url: string;
  114429. /**
  114430. * Empty line regex stored for GC.
  114431. */
  114432. private static _noneEmptyLineRegex;
  114433. private _engine;
  114434. /**
  114435. * Instantiates a ColorGradingTexture from the following parameters.
  114436. *
  114437. * @param url The location of the color gradind data (currently only supporting 3dl)
  114438. * @param scene The scene the texture will be used in
  114439. */
  114440. constructor(url: string, scene: Scene);
  114441. /**
  114442. * Returns the texture matrix used in most of the material.
  114443. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  114444. */
  114445. getTextureMatrix(): Matrix;
  114446. /**
  114447. * Occurs when the file being loaded is a .3dl LUT file.
  114448. */
  114449. private load3dlTexture;
  114450. /**
  114451. * Starts the loading process of the texture.
  114452. */
  114453. private loadTexture;
  114454. /**
  114455. * Clones the color gradind texture.
  114456. */
  114457. clone(): ColorGradingTexture;
  114458. /**
  114459. * Called during delayed load for textures.
  114460. */
  114461. delayLoad(): void;
  114462. /**
  114463. * Parses a color grading texture serialized by Babylon.
  114464. * @param parsedTexture The texture information being parsedTexture
  114465. * @param scene The scene to load the texture in
  114466. * @param rootUrl The root url of the data assets to load
  114467. * @return A color gradind texture
  114468. */
  114469. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  114470. /**
  114471. * Serializes the LUT texture to json format.
  114472. */
  114473. serialize(): any;
  114474. }
  114475. }
  114476. declare module BABYLON {
  114477. /**
  114478. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  114479. */
  114480. export class EquiRectangularCubeTexture extends BaseTexture {
  114481. /** The six faces of the cube. */
  114482. private static _FacesMapping;
  114483. private _noMipmap;
  114484. private _onLoad;
  114485. private _onError;
  114486. /** The size of the cubemap. */
  114487. private _size;
  114488. /** The buffer of the image. */
  114489. private _buffer;
  114490. /** The width of the input image. */
  114491. private _width;
  114492. /** The height of the input image. */
  114493. private _height;
  114494. /** The URL to the image. */
  114495. url: string;
  114496. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  114497. coordinatesMode: number;
  114498. /**
  114499. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  114500. * @param url The location of the image
  114501. * @param scene The scene the texture will be used in
  114502. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  114503. * @param noMipmap Forces to not generate the mipmap if true
  114504. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  114505. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  114506. * @param onLoad — defines a callback called when texture is loaded
  114507. * @param onError — defines a callback called if there is an error
  114508. */
  114509. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  114510. /**
  114511. * Load the image data, by putting the image on a canvas and extracting its buffer.
  114512. */
  114513. private loadImage;
  114514. /**
  114515. * Convert the image buffer into a cubemap and create a CubeTexture.
  114516. */
  114517. private loadTexture;
  114518. /**
  114519. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  114520. * @param buffer The ArrayBuffer that should be converted.
  114521. * @returns The buffer as Float32Array.
  114522. */
  114523. private getFloat32ArrayFromArrayBuffer;
  114524. /**
  114525. * Get the current class name of the texture useful for serialization or dynamic coding.
  114526. * @returns "EquiRectangularCubeTexture"
  114527. */
  114528. getClassName(): string;
  114529. /**
  114530. * Create a clone of the current EquiRectangularCubeTexture and return it.
  114531. * @returns A clone of the current EquiRectangularCubeTexture.
  114532. */
  114533. clone(): EquiRectangularCubeTexture;
  114534. }
  114535. }
  114536. declare module BABYLON {
  114537. /**
  114538. * Based on jsTGALoader - Javascript loader for TGA file
  114539. * By Vincent Thibault
  114540. * @see http://blog.robrowser.com/javascript-tga-loader.html
  114541. */
  114542. export class TGATools {
  114543. private static _TYPE_INDEXED;
  114544. private static _TYPE_RGB;
  114545. private static _TYPE_GREY;
  114546. private static _TYPE_RLE_INDEXED;
  114547. private static _TYPE_RLE_RGB;
  114548. private static _TYPE_RLE_GREY;
  114549. private static _ORIGIN_MASK;
  114550. private static _ORIGIN_SHIFT;
  114551. private static _ORIGIN_BL;
  114552. private static _ORIGIN_BR;
  114553. private static _ORIGIN_UL;
  114554. private static _ORIGIN_UR;
  114555. /**
  114556. * Gets the header of a TGA file
  114557. * @param data defines the TGA data
  114558. * @returns the header
  114559. */
  114560. static GetTGAHeader(data: Uint8Array): any;
  114561. /**
  114562. * Uploads TGA content to a Babylon Texture
  114563. * @hidden
  114564. */
  114565. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  114566. /** @hidden */
  114567. 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;
  114568. /** @hidden */
  114569. 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;
  114570. /** @hidden */
  114571. 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;
  114572. /** @hidden */
  114573. 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;
  114574. /** @hidden */
  114575. 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;
  114576. /** @hidden */
  114577. 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;
  114578. }
  114579. }
  114580. declare module BABYLON {
  114581. /**
  114582. * Implementation of the TGA Texture Loader.
  114583. * @hidden
  114584. */
  114585. export class _TGATextureLoader implements IInternalTextureLoader {
  114586. /**
  114587. * Defines wether the loader supports cascade loading the different faces.
  114588. */
  114589. readonly supportCascades: boolean;
  114590. /**
  114591. * This returns if the loader support the current file information.
  114592. * @param extension defines the file extension of the file being loaded
  114593. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114594. * @param fallback defines the fallback internal texture if any
  114595. * @param isBase64 defines whether the texture is encoded as a base64
  114596. * @param isBuffer defines whether the texture data are stored as a buffer
  114597. * @returns true if the loader can load the specified file
  114598. */
  114599. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114600. /**
  114601. * Transform the url before loading if required.
  114602. * @param rootUrl the url of the texture
  114603. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114604. * @returns the transformed texture
  114605. */
  114606. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114607. /**
  114608. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114609. * @param rootUrl the url of the texture
  114610. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114611. * @returns the fallback texture
  114612. */
  114613. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114614. /**
  114615. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  114616. * @param data contains the texture data
  114617. * @param texture defines the BabylonJS internal texture
  114618. * @param createPolynomials will be true if polynomials have been requested
  114619. * @param onLoad defines the callback to trigger once the texture is ready
  114620. * @param onError defines the callback to trigger in case of error
  114621. */
  114622. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114623. /**
  114624. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114625. * @param data contains the texture data
  114626. * @param texture defines the BabylonJS internal texture
  114627. * @param callback defines the method to call once ready to upload
  114628. */
  114629. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  114630. }
  114631. }
  114632. declare module BABYLON {
  114633. /**
  114634. * Info about the .basis files
  114635. */
  114636. class BasisFileInfo {
  114637. /**
  114638. * If the file has alpha
  114639. */
  114640. hasAlpha: boolean;
  114641. /**
  114642. * Info about each image of the basis file
  114643. */
  114644. images: Array<{
  114645. levels: Array<{
  114646. width: number;
  114647. height: number;
  114648. transcodedPixels: ArrayBufferView;
  114649. }>;
  114650. }>;
  114651. }
  114652. /**
  114653. * Result of transcoding a basis file
  114654. */
  114655. class TranscodeResult {
  114656. /**
  114657. * Info about the .basis file
  114658. */
  114659. fileInfo: BasisFileInfo;
  114660. /**
  114661. * Format to use when loading the file
  114662. */
  114663. format: number;
  114664. }
  114665. /**
  114666. * Configuration options for the Basis transcoder
  114667. */
  114668. export class BasisTranscodeConfiguration {
  114669. /**
  114670. * Supported compression formats used to determine the supported output format of the transcoder
  114671. */
  114672. supportedCompressionFormats?: {
  114673. /**
  114674. * etc1 compression format
  114675. */
  114676. etc1?: boolean;
  114677. /**
  114678. * s3tc compression format
  114679. */
  114680. s3tc?: boolean;
  114681. /**
  114682. * pvrtc compression format
  114683. */
  114684. pvrtc?: boolean;
  114685. /**
  114686. * etc2 compression format
  114687. */
  114688. etc2?: boolean;
  114689. };
  114690. /**
  114691. * If mipmap levels should be loaded for transcoded images (Default: true)
  114692. */
  114693. loadMipmapLevels?: boolean;
  114694. /**
  114695. * Index of a single image to load (Default: all images)
  114696. */
  114697. loadSingleImage?: number;
  114698. }
  114699. /**
  114700. * Used to load .Basis files
  114701. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  114702. */
  114703. export class BasisTools {
  114704. private static _IgnoreSupportedFormats;
  114705. /**
  114706. * URL to use when loading the basis transcoder
  114707. */
  114708. static JSModuleURL: string;
  114709. /**
  114710. * URL to use when loading the wasm module for the transcoder
  114711. */
  114712. static WasmModuleURL: string;
  114713. /**
  114714. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  114715. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  114716. * @returns internal format corresponding to the Basis format
  114717. */
  114718. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  114719. private static _WorkerPromise;
  114720. private static _Worker;
  114721. private static _actionId;
  114722. private static _CreateWorkerAsync;
  114723. /**
  114724. * Transcodes a loaded image file to compressed pixel data
  114725. * @param imageData image data to transcode
  114726. * @param config configuration options for the transcoding
  114727. * @returns a promise resulting in the transcoded image
  114728. */
  114729. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  114730. /**
  114731. * Loads a texture from the transcode result
  114732. * @param texture texture load to
  114733. * @param transcodeResult the result of transcoding the basis file to load from
  114734. */
  114735. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  114736. }
  114737. }
  114738. declare module BABYLON {
  114739. /**
  114740. * Loader for .basis file format
  114741. */
  114742. export class _BasisTextureLoader implements IInternalTextureLoader {
  114743. /**
  114744. * Defines whether the loader supports cascade loading the different faces.
  114745. */
  114746. readonly supportCascades: boolean;
  114747. /**
  114748. * This returns if the loader support the current file information.
  114749. * @param extension defines the file extension of the file being loaded
  114750. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114751. * @param fallback defines the fallback internal texture if any
  114752. * @param isBase64 defines whether the texture is encoded as a base64
  114753. * @param isBuffer defines whether the texture data are stored as a buffer
  114754. * @returns true if the loader can load the specified file
  114755. */
  114756. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114757. /**
  114758. * Transform the url before loading if required.
  114759. * @param rootUrl the url of the texture
  114760. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114761. * @returns the transformed texture
  114762. */
  114763. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114764. /**
  114765. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114766. * @param rootUrl the url of the texture
  114767. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114768. * @returns the fallback texture
  114769. */
  114770. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114771. /**
  114772. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  114773. * @param data contains the texture data
  114774. * @param texture defines the BabylonJS internal texture
  114775. * @param createPolynomials will be true if polynomials have been requested
  114776. * @param onLoad defines the callback to trigger once the texture is ready
  114777. * @param onError defines the callback to trigger in case of error
  114778. */
  114779. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114780. /**
  114781. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114782. * @param data contains the texture data
  114783. * @param texture defines the BabylonJS internal texture
  114784. * @param callback defines the method to call once ready to upload
  114785. */
  114786. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  114787. }
  114788. }
  114789. declare module BABYLON {
  114790. /**
  114791. * 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.
  114792. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  114793. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  114794. */
  114795. export class CustomProceduralTexture extends ProceduralTexture {
  114796. private _animate;
  114797. private _time;
  114798. private _config;
  114799. private _texturePath;
  114800. /**
  114801. * Instantiates a new Custom Procedural Texture.
  114802. * 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.
  114803. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  114804. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  114805. * @param name Define the name of the texture
  114806. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  114807. * @param size Define the size of the texture to create
  114808. * @param scene Define the scene the texture belongs to
  114809. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  114810. * @param generateMipMaps Define if the texture should creates mip maps or not
  114811. */
  114812. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  114813. private _loadJson;
  114814. /**
  114815. * Is the texture ready to be used ? (rendered at least once)
  114816. * @returns true if ready, otherwise, false.
  114817. */
  114818. isReady(): boolean;
  114819. /**
  114820. * Render the texture to its associated render target.
  114821. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  114822. */
  114823. render(useCameraPostProcess?: boolean): void;
  114824. /**
  114825. * Update the list of dependant textures samplers in the shader.
  114826. */
  114827. updateTextures(): void;
  114828. /**
  114829. * Update the uniform values of the procedural texture in the shader.
  114830. */
  114831. updateShaderUniforms(): void;
  114832. /**
  114833. * Define if the texture animates or not.
  114834. */
  114835. animate: boolean;
  114836. }
  114837. }
  114838. declare module BABYLON {
  114839. /** @hidden */
  114840. export var noisePixelShader: {
  114841. name: string;
  114842. shader: string;
  114843. };
  114844. }
  114845. declare module BABYLON {
  114846. /**
  114847. * Class used to generate noise procedural textures
  114848. */
  114849. export class NoiseProceduralTexture extends ProceduralTexture {
  114850. private _time;
  114851. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  114852. brightness: number;
  114853. /** Defines the number of octaves to process */
  114854. octaves: number;
  114855. /** Defines the level of persistence (0.8 by default) */
  114856. persistence: number;
  114857. /** Gets or sets animation speed factor (default is 1) */
  114858. animationSpeedFactor: number;
  114859. /**
  114860. * Creates a new NoiseProceduralTexture
  114861. * @param name defines the name fo the texture
  114862. * @param size defines the size of the texture (default is 256)
  114863. * @param scene defines the hosting scene
  114864. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  114865. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  114866. */
  114867. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  114868. private _updateShaderUniforms;
  114869. protected _getDefines(): string;
  114870. /** Generate the current state of the procedural texture */
  114871. render(useCameraPostProcess?: boolean): void;
  114872. /**
  114873. * Serializes this noise procedural texture
  114874. * @returns a serialized noise procedural texture object
  114875. */
  114876. serialize(): any;
  114877. /**
  114878. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  114879. * @param parsedTexture defines parsed texture data
  114880. * @param scene defines the current scene
  114881. * @param rootUrl defines the root URL containing noise procedural texture information
  114882. * @returns a parsed NoiseProceduralTexture
  114883. */
  114884. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  114885. }
  114886. }
  114887. declare module BABYLON {
  114888. /**
  114889. * Raw cube texture where the raw buffers are passed in
  114890. */
  114891. export class RawCubeTexture extends CubeTexture {
  114892. /**
  114893. * Creates a cube texture where the raw buffers are passed in.
  114894. * @param scene defines the scene the texture is attached to
  114895. * @param data defines the array of data to use to create each face
  114896. * @param size defines the size of the textures
  114897. * @param format defines the format of the data
  114898. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  114899. * @param generateMipMaps defines if the engine should generate the mip levels
  114900. * @param invertY defines if data must be stored with Y axis inverted
  114901. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  114902. * @param compression defines the compression used (null by default)
  114903. */
  114904. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  114905. /**
  114906. * Updates the raw cube texture.
  114907. * @param data defines the data to store
  114908. * @param format defines the data format
  114909. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  114910. * @param invertY defines if data must be stored with Y axis inverted
  114911. * @param compression defines the compression used (null by default)
  114912. * @param level defines which level of the texture to update
  114913. */
  114914. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  114915. /**
  114916. * Updates a raw cube texture with RGBD encoded data.
  114917. * @param data defines the array of data [mipmap][face] to use to create each face
  114918. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  114919. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  114920. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  114921. * @returns a promsie that resolves when the operation is complete
  114922. */
  114923. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  114924. /**
  114925. * Clones the raw cube texture.
  114926. * @return a new cube texture
  114927. */
  114928. clone(): CubeTexture;
  114929. /** @hidden */
  114930. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  114931. }
  114932. }
  114933. declare module BABYLON {
  114934. /**
  114935. * Class used to store 3D textures containing user data
  114936. */
  114937. export class RawTexture3D extends Texture {
  114938. /** Gets or sets the texture format to use */
  114939. format: number;
  114940. private _engine;
  114941. /**
  114942. * Create a new RawTexture3D
  114943. * @param data defines the data of the texture
  114944. * @param width defines the width of the texture
  114945. * @param height defines the height of the texture
  114946. * @param depth defines the depth of the texture
  114947. * @param format defines the texture format to use
  114948. * @param scene defines the hosting scene
  114949. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  114950. * @param invertY defines if texture must be stored with Y axis inverted
  114951. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  114952. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  114953. */
  114954. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  114955. /** Gets or sets the texture format to use */
  114956. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  114957. /**
  114958. * Update the texture with new data
  114959. * @param data defines the data to store in the texture
  114960. */
  114961. update(data: ArrayBufferView): void;
  114962. }
  114963. }
  114964. declare module BABYLON {
  114965. /**
  114966. * Creates a refraction texture used by refraction channel of the standard material.
  114967. * It is like a mirror but to see through a material.
  114968. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  114969. */
  114970. export class RefractionTexture extends RenderTargetTexture {
  114971. /**
  114972. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  114973. * 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.
  114974. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  114975. */
  114976. refractionPlane: Plane;
  114977. /**
  114978. * Define how deep under the surface we should see.
  114979. */
  114980. depth: number;
  114981. /**
  114982. * Creates a refraction texture used by refraction channel of the standard material.
  114983. * It is like a mirror but to see through a material.
  114984. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  114985. * @param name Define the texture name
  114986. * @param size Define the size of the underlying texture
  114987. * @param scene Define the scene the refraction belongs to
  114988. * @param generateMipMaps Define if we need to generate mips level for the refraction
  114989. */
  114990. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  114991. /**
  114992. * Clone the refraction texture.
  114993. * @returns the cloned texture
  114994. */
  114995. clone(): RefractionTexture;
  114996. /**
  114997. * Serialize the texture to a JSON representation you could use in Parse later on
  114998. * @returns the serialized JSON representation
  114999. */
  115000. serialize(): any;
  115001. }
  115002. }
  115003. declare module BABYLON {
  115004. /**
  115005. * Defines the options related to the creation of an HtmlElementTexture
  115006. */
  115007. export interface IHtmlElementTextureOptions {
  115008. /**
  115009. * Defines wether mip maps should be created or not.
  115010. */
  115011. generateMipMaps?: boolean;
  115012. /**
  115013. * Defines the sampling mode of the texture.
  115014. */
  115015. samplingMode?: number;
  115016. /**
  115017. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  115018. */
  115019. engine: Nullable<Engine>;
  115020. /**
  115021. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  115022. */
  115023. scene: Nullable<Scene>;
  115024. }
  115025. /**
  115026. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  115027. * To be as efficient as possible depending on your constraints nothing aside the first upload
  115028. * is automatically managed.
  115029. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  115030. * in your application.
  115031. *
  115032. * As the update is not automatic, you need to call them manually.
  115033. */
  115034. export class HtmlElementTexture extends BaseTexture {
  115035. /**
  115036. * The texture URL.
  115037. */
  115038. element: HTMLVideoElement | HTMLCanvasElement;
  115039. private static readonly DefaultOptions;
  115040. private _textureMatrix;
  115041. private _engine;
  115042. private _isVideo;
  115043. private _generateMipMaps;
  115044. private _samplingMode;
  115045. /**
  115046. * Instantiates a HtmlElementTexture from the following parameters.
  115047. *
  115048. * @param name Defines the name of the texture
  115049. * @param element Defines the video or canvas the texture is filled with
  115050. * @param options Defines the other none mandatory texture creation options
  115051. */
  115052. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  115053. private _createInternalTexture;
  115054. /**
  115055. * Returns the texture matrix used in most of the material.
  115056. */
  115057. getTextureMatrix(): Matrix;
  115058. /**
  115059. * Updates the content of the texture.
  115060. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  115061. */
  115062. update(invertY?: Nullable<boolean>): void;
  115063. }
  115064. }
  115065. declare module BABYLON {
  115066. /**
  115067. * Enum used to define the target of a block
  115068. */
  115069. export enum NodeMaterialBlockTargets {
  115070. /** Vertex shader */
  115071. Vertex = 1,
  115072. /** Fragment shader */
  115073. Fragment = 2,
  115074. /** Neutral */
  115075. Neutral = 4,
  115076. /** Vertex and Fragment */
  115077. VertexAndFragment = 3
  115078. }
  115079. }
  115080. declare module BABYLON {
  115081. /**
  115082. * Defines the kind of connection point for node based material
  115083. */
  115084. export enum NodeMaterialBlockConnectionPointTypes {
  115085. /** Float */
  115086. Float = 1,
  115087. /** Int */
  115088. Int = 2,
  115089. /** Vector2 */
  115090. Vector2 = 4,
  115091. /** Vector3 */
  115092. Vector3 = 8,
  115093. /** Vector4 */
  115094. Vector4 = 16,
  115095. /** Color3 */
  115096. Color3 = 32,
  115097. /** Color4 */
  115098. Color4 = 64,
  115099. /** Matrix */
  115100. Matrix = 128,
  115101. /** Vector3 or Color3 */
  115102. Vector3OrColor3 = 40,
  115103. /** Vector3 or Vector4 */
  115104. Vector3OrVector4 = 24,
  115105. /** Vector4 or Color4 */
  115106. Vector4OrColor4 = 80,
  115107. /** Color3 or Color4 */
  115108. Color3OrColor4 = 96,
  115109. /** Vector2 or Color3 or Color4 */
  115110. Vector2OrColor3OrColor4 = 100,
  115111. /** Vector3 or Color3 or Color4 or Vector4 */
  115112. Vector3OrColor3OrVector4OrColor4 = 120,
  115113. /** Vector2 or Vector3 or Color3 or Color4 or Vector4 */
  115114. Vector2OrVector3OrColor3OrVector4OrColor4 = 124,
  115115. /** Detect type based on connection */
  115116. AutoDetect = 1024,
  115117. /** Output type that will be defined by input type */
  115118. BasedOnInput = 2048
  115119. }
  115120. }
  115121. declare module BABYLON {
  115122. /**
  115123. * Root class for all node material optimizers
  115124. */
  115125. export class NodeMaterialOptimizer {
  115126. /**
  115127. * Function used to optimize a NodeMaterial graph
  115128. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  115129. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  115130. */
  115131. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  115132. }
  115133. }
  115134. declare module BABYLON {
  115135. /**
  115136. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  115137. */
  115138. export class TransformBlock extends NodeMaterialBlock {
  115139. /**
  115140. * Defines the value to use to complement W value to transform it to a Vector4
  115141. */
  115142. complementW: number;
  115143. /**
  115144. * Defines the value to use to complement z value to transform it to a Vector4
  115145. */
  115146. complementZ: number;
  115147. /**
  115148. * Creates a new TransformBlock
  115149. * @param name defines the block name
  115150. */
  115151. constructor(name: string);
  115152. /**
  115153. * Gets the current class name
  115154. * @returns the class name
  115155. */
  115156. getClassName(): string;
  115157. /**
  115158. * Gets the vector input
  115159. */
  115160. readonly vector: NodeMaterialConnectionPoint;
  115161. /**
  115162. * Gets the output component
  115163. */
  115164. readonly output: NodeMaterialConnectionPoint;
  115165. /**
  115166. * Gets the matrix transform input
  115167. */
  115168. readonly transform: NodeMaterialConnectionPoint;
  115169. protected _buildBlock(state: NodeMaterialBuildState): this;
  115170. serialize(): any;
  115171. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  115172. }
  115173. }
  115174. declare module BABYLON {
  115175. /**
  115176. * Block used to output the vertex position
  115177. */
  115178. export class VertexOutputBlock extends NodeMaterialBlock {
  115179. /**
  115180. * Creates a new VertexOutputBlock
  115181. * @param name defines the block name
  115182. */
  115183. constructor(name: string);
  115184. /**
  115185. * Gets the current class name
  115186. * @returns the class name
  115187. */
  115188. getClassName(): string;
  115189. /**
  115190. * Gets the vector input component
  115191. */
  115192. readonly vector: NodeMaterialConnectionPoint;
  115193. protected _buildBlock(state: NodeMaterialBuildState): this;
  115194. }
  115195. }
  115196. declare module BABYLON {
  115197. /**
  115198. * Block used to output the final color
  115199. */
  115200. export class FragmentOutputBlock extends NodeMaterialBlock {
  115201. /**
  115202. * Create a new FragmentOutputBlock
  115203. * @param name defines the block name
  115204. */
  115205. constructor(name: string);
  115206. /**
  115207. * Gets the current class name
  115208. * @returns the class name
  115209. */
  115210. getClassName(): string;
  115211. /**
  115212. * Gets the rgba input component
  115213. */
  115214. readonly rgba: NodeMaterialConnectionPoint;
  115215. /**
  115216. * Gets the rgb input component
  115217. */
  115218. readonly rgb: NodeMaterialConnectionPoint;
  115219. /**
  115220. * Gets the a input component
  115221. */
  115222. readonly a: NodeMaterialConnectionPoint;
  115223. protected _buildBlock(state: NodeMaterialBuildState): this;
  115224. }
  115225. }
  115226. declare module BABYLON {
  115227. /**
  115228. * Interface used to configure the node material editor
  115229. */
  115230. export interface INodeMaterialEditorOptions {
  115231. /** Define the URl to load node editor script */
  115232. editorURL?: string;
  115233. }
  115234. /** @hidden */
  115235. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  115236. /** BONES */
  115237. NUM_BONE_INFLUENCERS: number;
  115238. BonesPerMesh: number;
  115239. BONETEXTURE: boolean;
  115240. /** MORPH TARGETS */
  115241. MORPHTARGETS: boolean;
  115242. MORPHTARGETS_NORMAL: boolean;
  115243. MORPHTARGETS_TANGENT: boolean;
  115244. MORPHTARGETS_UV: boolean;
  115245. NUM_MORPH_INFLUENCERS: number;
  115246. /** IMAGE PROCESSING */
  115247. IMAGEPROCESSING: boolean;
  115248. VIGNETTE: boolean;
  115249. VIGNETTEBLENDMODEMULTIPLY: boolean;
  115250. VIGNETTEBLENDMODEOPAQUE: boolean;
  115251. TONEMAPPING: boolean;
  115252. TONEMAPPING_ACES: boolean;
  115253. CONTRAST: boolean;
  115254. EXPOSURE: boolean;
  115255. COLORCURVES: boolean;
  115256. COLORGRADING: boolean;
  115257. COLORGRADING3D: boolean;
  115258. SAMPLER3DGREENDEPTH: boolean;
  115259. SAMPLER3DBGRMAP: boolean;
  115260. IMAGEPROCESSINGPOSTPROCESS: boolean;
  115261. constructor();
  115262. setValue(name: string, value: boolean): void;
  115263. }
  115264. /**
  115265. * Class used to configure NodeMaterial
  115266. */
  115267. export interface INodeMaterialOptions {
  115268. /**
  115269. * Defines if blocks should emit comments
  115270. */
  115271. emitComments: boolean;
  115272. }
  115273. /**
  115274. * Class used to create a node based material built by assembling shader blocks
  115275. */
  115276. export class NodeMaterial extends PushMaterial {
  115277. private _options;
  115278. private _vertexCompilationState;
  115279. private _fragmentCompilationState;
  115280. private _sharedData;
  115281. private _buildId;
  115282. private _buildWasSuccessful;
  115283. private _cachedWorldViewMatrix;
  115284. private _cachedWorldViewProjectionMatrix;
  115285. private _optimizers;
  115286. /** Define the URl to load node editor script */
  115287. static EditorURL: string;
  115288. private BJSNODEMATERIALEDITOR;
  115289. /** Get the inspector from bundle or global */
  115290. private _getGlobalNodeMaterialEditor;
  115291. /**
  115292. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  115293. */
  115294. ignoreAlpha: boolean;
  115295. /**
  115296. * Defines the maximum number of lights that can be used in the material
  115297. */
  115298. maxSimultaneousLights: number;
  115299. /**
  115300. * Observable raised when the material is built
  115301. */
  115302. onBuildObservable: Observable<NodeMaterial>;
  115303. /**
  115304. * Gets or sets the root nodes of the material vertex shader
  115305. */
  115306. _vertexOutputNodes: NodeMaterialBlock[];
  115307. /**
  115308. * Gets or sets the root nodes of the material fragment (pixel) shader
  115309. */
  115310. _fragmentOutputNodes: NodeMaterialBlock[];
  115311. /** Gets or sets options to control the node material overall behavior */
  115312. options: INodeMaterialOptions;
  115313. /**
  115314. * Default configuration related to image processing available in the standard Material.
  115315. */
  115316. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115317. /**
  115318. * Gets the image processing configuration used either in this material.
  115319. */
  115320. /**
  115321. * Sets the Default image processing configuration used either in the this material.
  115322. *
  115323. * If sets to null, the scene one is in use.
  115324. */
  115325. imageProcessingConfiguration: ImageProcessingConfiguration;
  115326. /**
  115327. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  115328. */
  115329. attachedBlocks: NodeMaterialBlock[];
  115330. /**
  115331. * Create a new node based material
  115332. * @param name defines the material name
  115333. * @param scene defines the hosting scene
  115334. * @param options defines creation option
  115335. */
  115336. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  115337. /**
  115338. * Gets the current class name of the material e.g. "NodeMaterial"
  115339. * @returns the class name
  115340. */
  115341. getClassName(): string;
  115342. /**
  115343. * Keep track of the image processing observer to allow dispose and replace.
  115344. */
  115345. private _imageProcessingObserver;
  115346. /**
  115347. * Attaches a new image processing configuration to the Standard Material.
  115348. * @param configuration
  115349. */
  115350. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  115351. /**
  115352. * Adds a new optimizer to the list of optimizers
  115353. * @param optimizer defines the optimizers to add
  115354. * @returns the current material
  115355. */
  115356. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  115357. /**
  115358. * Remove an optimizer from the list of optimizers
  115359. * @param optimizer defines the optimizers to remove
  115360. * @returns the current material
  115361. */
  115362. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  115363. /**
  115364. * Add a new block to the list of output nodes
  115365. * @param node defines the node to add
  115366. * @returns the current material
  115367. */
  115368. addOutputNode(node: NodeMaterialBlock): this;
  115369. /**
  115370. * Remove a block from the list of root nodes
  115371. * @param node defines the node to remove
  115372. * @returns the current material
  115373. */
  115374. removeOutputNode(node: NodeMaterialBlock): this;
  115375. private _addVertexOutputNode;
  115376. private _removeVertexOutputNode;
  115377. private _addFragmentOutputNode;
  115378. private _removeFragmentOutputNode;
  115379. /**
  115380. * Specifies if the material will require alpha blending
  115381. * @returns a boolean specifying if alpha blending is needed
  115382. */
  115383. needAlphaBlending(): boolean;
  115384. /**
  115385. * Specifies if this material should be rendered in alpha test mode
  115386. * @returns a boolean specifying if an alpha test is needed.
  115387. */
  115388. needAlphaTesting(): boolean;
  115389. private _initializeBlock;
  115390. private _resetDualBlocks;
  115391. /**
  115392. * Build the material and generates the inner effect
  115393. * @param verbose defines if the build should log activity
  115394. */
  115395. build(verbose?: boolean): void;
  115396. /**
  115397. * Runs an otpimization phase to try to improve the shader code
  115398. */
  115399. optimize(): void;
  115400. private _prepareDefinesForAttributes;
  115401. /**
  115402. * Get if the submesh is ready to be used and all its information available.
  115403. * Child classes can use it to update shaders
  115404. * @param mesh defines the mesh to check
  115405. * @param subMesh defines which submesh to check
  115406. * @param useInstances specifies that instances should be used
  115407. * @returns a boolean indicating that the submesh is ready or not
  115408. */
  115409. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  115410. /**
  115411. * Get a string representing the shaders built by the current node graph
  115412. */
  115413. readonly compiledShaders: string;
  115414. /**
  115415. * Binds the world matrix to the material
  115416. * @param world defines the world transformation matrix
  115417. */
  115418. bindOnlyWorldMatrix(world: Matrix): void;
  115419. /**
  115420. * Binds the submesh to this material by preparing the effect and shader to draw
  115421. * @param world defines the world transformation matrix
  115422. * @param mesh defines the mesh containing the submesh
  115423. * @param subMesh defines the submesh to bind the material to
  115424. */
  115425. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  115426. /**
  115427. * Gets the active textures from the material
  115428. * @returns an array of textures
  115429. */
  115430. getActiveTextures(): BaseTexture[];
  115431. /**
  115432. * Specifies if the material uses a texture
  115433. * @param texture defines the texture to check against the material
  115434. * @returns a boolean specifying if the material uses the texture
  115435. */
  115436. hasTexture(texture: BaseTexture): boolean;
  115437. /**
  115438. * Disposes the material
  115439. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  115440. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  115441. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  115442. */
  115443. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  115444. /** Creates the node editor window. */
  115445. private _createNodeEditor;
  115446. /**
  115447. * Launch the node material editor
  115448. * @param config Define the configuration of the editor
  115449. * @return a promise fulfilled when the node editor is visible
  115450. */
  115451. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  115452. /**
  115453. * Clear the current material
  115454. */
  115455. clear(): void;
  115456. /**
  115457. * Clear the current material and set it to a default state
  115458. */
  115459. setToDefault(): void;
  115460. private _gatherBlocks;
  115461. /**
  115462. * Serializes this material in a JSON representation
  115463. * @returns the serialized material object
  115464. */
  115465. serialize(): any;
  115466. /**
  115467. * Clear the current graph and load a new one from a serialization object
  115468. * @param source defines the JSON representation of the material
  115469. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  115470. */
  115471. loadFromSerialization(source: any, rootUrl?: string): void;
  115472. /**
  115473. * Creates a node material from parsed material data
  115474. * @param source defines the JSON representation of the material
  115475. * @param scene defines the hosting scene
  115476. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  115477. * @returns a new node material
  115478. */
  115479. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  115480. }
  115481. }
  115482. declare module BABYLON {
  115483. /**
  115484. * Block used to read a texture from a sampler
  115485. */
  115486. export class TextureBlock extends NodeMaterialBlock {
  115487. private _defineName;
  115488. private _samplerName;
  115489. private _transformedUVName;
  115490. private _textureTransformName;
  115491. private _textureInfoName;
  115492. private _mainUVName;
  115493. private _mainUVDefineName;
  115494. /**
  115495. * Gets or sets the texture associated with the node
  115496. */
  115497. texture: Nullable<BaseTexture>;
  115498. /**
  115499. * Create a new TextureBlock
  115500. * @param name defines the block name
  115501. */
  115502. constructor(name: string);
  115503. /**
  115504. * Gets the current class name
  115505. * @returns the class name
  115506. */
  115507. getClassName(): string;
  115508. /**
  115509. * Gets the uv input component
  115510. */
  115511. readonly uv: NodeMaterialConnectionPoint;
  115512. /**
  115513. * Gets the output component
  115514. */
  115515. readonly output: NodeMaterialConnectionPoint;
  115516. autoConfigure(): void;
  115517. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  115518. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  115519. isReady(): boolean;
  115520. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  115521. private _injectVertexCode;
  115522. private _writeOutput;
  115523. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  115524. serialize(): any;
  115525. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  115526. }
  115527. }
  115528. declare module BABYLON {
  115529. /**
  115530. * Class used to store shared data between 2 NodeMaterialBuildState
  115531. */
  115532. export class NodeMaterialBuildStateSharedData {
  115533. /**
  115534. * Gets the list of emitted varyings
  115535. */
  115536. varyings: string[];
  115537. /**
  115538. * Gets the varying declaration string
  115539. */
  115540. varyingDeclaration: string;
  115541. /**
  115542. * Input blocks
  115543. */
  115544. inputBlocks: InputBlock[];
  115545. /**
  115546. * Input blocks
  115547. */
  115548. textureBlocks: TextureBlock[];
  115549. /**
  115550. * Bindable blocks (Blocks that need to set data to the effect)
  115551. */
  115552. bindableBlocks: NodeMaterialBlock[];
  115553. /**
  115554. * List of blocks that can provide a compilation fallback
  115555. */
  115556. blocksWithFallbacks: NodeMaterialBlock[];
  115557. /**
  115558. * List of blocks that can provide a define update
  115559. */
  115560. blocksWithDefines: NodeMaterialBlock[];
  115561. /**
  115562. * List of blocks that can provide a repeatable content
  115563. */
  115564. repeatableContentBlocks: NodeMaterialBlock[];
  115565. /**
  115566. * List of blocks that can provide a dynamic list of uniforms
  115567. */
  115568. dynamicUniformBlocks: NodeMaterialBlock[];
  115569. /**
  115570. * List of blocks that can block the isReady function for the material
  115571. */
  115572. blockingBlocks: NodeMaterialBlock[];
  115573. /**
  115574. * Build Id used to avoid multiple recompilations
  115575. */
  115576. buildId: number;
  115577. /** List of emitted variables */
  115578. variableNames: {
  115579. [key: string]: number;
  115580. };
  115581. /** List of emitted defines */
  115582. defineNames: {
  115583. [key: string]: number;
  115584. };
  115585. /** Should emit comments? */
  115586. emitComments: boolean;
  115587. /** Emit build activity */
  115588. verbose: boolean;
  115589. /**
  115590. * Gets the compilation hints emitted at compilation time
  115591. */
  115592. hints: {
  115593. needWorldViewMatrix: boolean;
  115594. needWorldViewProjectionMatrix: boolean;
  115595. needAlphaBlending: boolean;
  115596. needAlphaTesting: boolean;
  115597. };
  115598. /**
  115599. * List of compilation checks
  115600. */
  115601. checks: {
  115602. emitVertex: boolean;
  115603. emitFragment: boolean;
  115604. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  115605. };
  115606. /** Creates a new shared data */
  115607. constructor();
  115608. /**
  115609. * Emits console errors and exceptions if there is a failing check
  115610. */
  115611. emitErrors(): void;
  115612. }
  115613. }
  115614. declare module BABYLON {
  115615. /**
  115616. * Class used to store node based material build state
  115617. */
  115618. export class NodeMaterialBuildState {
  115619. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  115620. supportUniformBuffers: boolean;
  115621. /**
  115622. * Gets the list of emitted attributes
  115623. */
  115624. attributes: string[];
  115625. /**
  115626. * Gets the list of emitted uniforms
  115627. */
  115628. uniforms: string[];
  115629. /**
  115630. * Gets the list of emitted uniform buffers
  115631. */
  115632. uniformBuffers: string[];
  115633. /**
  115634. * Gets the list of emitted samplers
  115635. */
  115636. samplers: string[];
  115637. /**
  115638. * Gets the list of emitted functions
  115639. */
  115640. functions: {
  115641. [key: string]: string;
  115642. };
  115643. /**
  115644. * Gets the target of the compilation state
  115645. */
  115646. target: NodeMaterialBlockTargets;
  115647. /**
  115648. * Gets the list of emitted counters
  115649. */
  115650. counters: {
  115651. [key: string]: number;
  115652. };
  115653. /**
  115654. * Shared data between multiple NodeMaterialBuildState instances
  115655. */
  115656. sharedData: NodeMaterialBuildStateSharedData;
  115657. /** @hidden */
  115658. _vertexState: NodeMaterialBuildState;
  115659. /** @hidden */
  115660. _attributeDeclaration: string;
  115661. /** @hidden */
  115662. _uniformDeclaration: string;
  115663. /** @hidden */
  115664. _samplerDeclaration: string;
  115665. /** @hidden */
  115666. _varyingTransfer: string;
  115667. private _repeatableContentAnchorIndex;
  115668. /** @hidden */
  115669. _builtCompilationString: string;
  115670. /**
  115671. * Gets the emitted compilation strings
  115672. */
  115673. compilationString: string;
  115674. /**
  115675. * Finalize the compilation strings
  115676. * @param state defines the current compilation state
  115677. */
  115678. finalize(state: NodeMaterialBuildState): void;
  115679. /** @hidden */
  115680. readonly _repeatableContentAnchor: string;
  115681. /** @hidden */
  115682. _getFreeVariableName(prefix: string): string;
  115683. /** @hidden */
  115684. _getFreeDefineName(prefix: string): string;
  115685. /** @hidden */
  115686. _excludeVariableName(name: string): void;
  115687. /** @hidden */
  115688. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  115689. /** @hidden */
  115690. _emitFunction(name: string, code: string, comments: string): void;
  115691. /** @hidden */
  115692. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  115693. replaceStrings?: {
  115694. search: RegExp;
  115695. replace: string;
  115696. }[];
  115697. repeatKey?: string;
  115698. }): string;
  115699. /** @hidden */
  115700. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  115701. repeatKey?: string;
  115702. removeAttributes?: boolean;
  115703. removeUniforms?: boolean;
  115704. removeVaryings?: boolean;
  115705. removeIfDef?: boolean;
  115706. replaceStrings?: {
  115707. search: RegExp;
  115708. replace: string;
  115709. }[];
  115710. }, storeKey?: string): void;
  115711. /** @hidden */
  115712. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  115713. /** @hidden */
  115714. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  115715. }
  115716. }
  115717. declare module BABYLON {
  115718. /**
  115719. * Defines a block that can be used inside a node based material
  115720. */
  115721. export class NodeMaterialBlock {
  115722. private _buildId;
  115723. private _buildTarget;
  115724. private _target;
  115725. private _isFinalMerger;
  115726. private _isInput;
  115727. /** @hidden */
  115728. _inputs: NodeMaterialConnectionPoint[];
  115729. /** @hidden */
  115730. _outputs: NodeMaterialConnectionPoint[];
  115731. /**
  115732. * Gets or sets the name of the block
  115733. */
  115734. name: string;
  115735. /**
  115736. * Gets or sets the unique id of the node
  115737. */
  115738. uniqueId: number;
  115739. /**
  115740. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  115741. */
  115742. readonly isFinalMerger: boolean;
  115743. /**
  115744. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  115745. */
  115746. readonly isInput: boolean;
  115747. /**
  115748. * Gets or sets the build Id
  115749. */
  115750. buildId: number;
  115751. /**
  115752. * Gets or sets the target of the block
  115753. */
  115754. target: NodeMaterialBlockTargets;
  115755. /**
  115756. * Gets the list of input points
  115757. */
  115758. readonly inputs: NodeMaterialConnectionPoint[];
  115759. /** Gets the list of output points */
  115760. readonly outputs: NodeMaterialConnectionPoint[];
  115761. /**
  115762. * Find an input by its name
  115763. * @param name defines the name of the input to look for
  115764. * @returns the input or null if not found
  115765. */
  115766. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  115767. /**
  115768. * Find an output by its name
  115769. * @param name defines the name of the outputto look for
  115770. * @returns the output or null if not found
  115771. */
  115772. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  115773. /**
  115774. * Creates a new NodeMaterialBlock
  115775. * @param name defines the block name
  115776. * @param target defines the target of that block (Vertex by default)
  115777. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  115778. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  115779. */
  115780. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  115781. /**
  115782. * Initialize the block and prepare the context for build
  115783. * @param state defines the state that will be used for the build
  115784. */
  115785. initialize(state: NodeMaterialBuildState): void;
  115786. /**
  115787. * Bind data to effect. Will only be called for blocks with isBindable === true
  115788. * @param effect defines the effect to bind data to
  115789. * @param nodeMaterial defines the hosting NodeMaterial
  115790. * @param mesh defines the mesh that will be rendered
  115791. */
  115792. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  115793. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  115794. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  115795. protected _writeFloat(value: number): string;
  115796. /**
  115797. * Gets the current class name e.g. "NodeMaterialBlock"
  115798. * @returns the class name
  115799. */
  115800. getClassName(): string;
  115801. /**
  115802. * Register a new input. Must be called inside a block constructor
  115803. * @param name defines the connection point name
  115804. * @param type defines the connection point type
  115805. * @param isOptional defines a boolean indicating that this input can be omitted
  115806. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  115807. * @returns the current block
  115808. */
  115809. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  115810. /**
  115811. * Register a new output. Must be called inside a block constructor
  115812. * @param name defines the connection point name
  115813. * @param type defines the connection point type
  115814. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  115815. * @returns the current block
  115816. */
  115817. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  115818. /**
  115819. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  115820. * @param forOutput defines an optional connection point to check compatibility with
  115821. * @returns the first available input or null
  115822. */
  115823. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  115824. /**
  115825. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  115826. * @param forBlock defines an optional block to check compatibility with
  115827. * @returns the first available input or null
  115828. */
  115829. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  115830. /**
  115831. * Connect current block with another block
  115832. * @param other defines the block to connect with
  115833. * @param options define the various options to help pick the right connections
  115834. * @returns the current block
  115835. */
  115836. connectTo(other: NodeMaterialBlock, options?: {
  115837. input?: string;
  115838. output?: string;
  115839. outputSwizzle?: string;
  115840. }): this | undefined;
  115841. protected _buildBlock(state: NodeMaterialBuildState): void;
  115842. /**
  115843. * Add uniforms, samplers and uniform buffers at compilation time
  115844. * @param state defines the state to update
  115845. * @param nodeMaterial defines the node material requesting the update
  115846. * @param defines defines the material defines to update
  115847. */
  115848. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  115849. /**
  115850. * Add potential fallbacks if shader compilation fails
  115851. * @param mesh defines the mesh to be rendered
  115852. * @param fallbacks defines the current prioritized list of fallbacks
  115853. */
  115854. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  115855. /**
  115856. * Update defines for shader compilation
  115857. * @param mesh defines the mesh to be rendered
  115858. * @param nodeMaterial defines the node material requesting the update
  115859. * @param defines defines the material defines to update
  115860. * @param useInstances specifies that instances should be used
  115861. */
  115862. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  115863. /**
  115864. * Initialize defines for shader compilation
  115865. * @param mesh defines the mesh to be rendered
  115866. * @param nodeMaterial defines the node material requesting the update
  115867. * @param defines defines the material defines to be prepared
  115868. * @param useInstances specifies that instances should be used
  115869. */
  115870. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  115871. /**
  115872. * Lets the block try to connect some inputs automatically
  115873. */
  115874. autoConfigure(): void;
  115875. /**
  115876. * Function called when a block is declared as repeatable content generator
  115877. * @param vertexShaderState defines the current compilation state for the vertex shader
  115878. * @param fragmentShaderState defines the current compilation state for the fragment shader
  115879. * @param mesh defines the mesh to be rendered
  115880. * @param defines defines the material defines to update
  115881. */
  115882. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  115883. /**
  115884. * Checks if the block is ready
  115885. * @param mesh defines the mesh to be rendered
  115886. * @param nodeMaterial defines the node material requesting the update
  115887. * @param defines defines the material defines to update
  115888. * @param useInstances specifies that instances should be used
  115889. * @returns true if the block is ready
  115890. */
  115891. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  115892. private _processBuild;
  115893. /**
  115894. * Compile the current node and generate the shader code
  115895. * @param state defines the current compilation state (uniforms, samplers, current string)
  115896. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  115897. * @returns true if already built
  115898. */
  115899. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  115900. /**
  115901. * Serializes this block in a JSON representation
  115902. * @returns the serialized block object
  115903. */
  115904. serialize(): any;
  115905. /** @hidden */
  115906. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  115907. }
  115908. }
  115909. declare module BABYLON {
  115910. /**
  115911. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  115912. */
  115913. export enum NodeMaterialBlockConnectionPointMode {
  115914. /** Value is an uniform */
  115915. Uniform = 0,
  115916. /** Value is a mesh attribute */
  115917. Attribute = 1,
  115918. /** Value is a varying between vertex and fragment shaders */
  115919. Varying = 2,
  115920. /** Mode is undefined */
  115921. Undefined = 3
  115922. }
  115923. }
  115924. declare module BABYLON {
  115925. /**
  115926. * Enum used to define well known values e.g. values automatically provided by the system
  115927. */
  115928. export enum NodeMaterialWellKnownValues {
  115929. /** World */
  115930. World = 1,
  115931. /** View */
  115932. View = 2,
  115933. /** Projection */
  115934. Projection = 3,
  115935. /** ViewProjection */
  115936. ViewProjection = 4,
  115937. /** WorldView */
  115938. WorldView = 5,
  115939. /** WorldViewProjection */
  115940. WorldViewProjection = 6,
  115941. /** CameraPosition */
  115942. CameraPosition = 7,
  115943. /** Fog Color */
  115944. FogColor = 8
  115945. }
  115946. }
  115947. declare module BABYLON {
  115948. /**
  115949. * Contains position and normal vectors for a vertex
  115950. */
  115951. export class PositionNormalVertex {
  115952. /** the position of the vertex (defaut: 0,0,0) */
  115953. position: Vector3;
  115954. /** the normal of the vertex (defaut: 0,1,0) */
  115955. normal: Vector3;
  115956. /**
  115957. * Creates a PositionNormalVertex
  115958. * @param position the position of the vertex (defaut: 0,0,0)
  115959. * @param normal the normal of the vertex (defaut: 0,1,0)
  115960. */
  115961. constructor(
  115962. /** the position of the vertex (defaut: 0,0,0) */
  115963. position?: Vector3,
  115964. /** the normal of the vertex (defaut: 0,1,0) */
  115965. normal?: Vector3);
  115966. /**
  115967. * Clones the PositionNormalVertex
  115968. * @returns the cloned PositionNormalVertex
  115969. */
  115970. clone(): PositionNormalVertex;
  115971. }
  115972. /**
  115973. * Contains position, normal and uv vectors for a vertex
  115974. */
  115975. export class PositionNormalTextureVertex {
  115976. /** the position of the vertex (defaut: 0,0,0) */
  115977. position: Vector3;
  115978. /** the normal of the vertex (defaut: 0,1,0) */
  115979. normal: Vector3;
  115980. /** the uv of the vertex (default: 0,0) */
  115981. uv: Vector2;
  115982. /**
  115983. * Creates a PositionNormalTextureVertex
  115984. * @param position the position of the vertex (defaut: 0,0,0)
  115985. * @param normal the normal of the vertex (defaut: 0,1,0)
  115986. * @param uv the uv of the vertex (default: 0,0)
  115987. */
  115988. constructor(
  115989. /** the position of the vertex (defaut: 0,0,0) */
  115990. position?: Vector3,
  115991. /** the normal of the vertex (defaut: 0,1,0) */
  115992. normal?: Vector3,
  115993. /** the uv of the vertex (default: 0,0) */
  115994. uv?: Vector2);
  115995. /**
  115996. * Clones the PositionNormalTextureVertex
  115997. * @returns the cloned PositionNormalTextureVertex
  115998. */
  115999. clone(): PositionNormalTextureVertex;
  116000. }
  116001. }
  116002. declare module BABYLON {
  116003. /**
  116004. * Block used to expose an input value
  116005. */
  116006. export class InputBlock extends NodeMaterialBlock {
  116007. private _mode;
  116008. private _associatedVariableName;
  116009. private _storedValue;
  116010. private _valueCallback;
  116011. private _type;
  116012. /** @hidden */
  116013. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  116014. /**
  116015. * Gets or sets the connection point type (default is float)
  116016. */
  116017. readonly type: NodeMaterialBlockConnectionPointTypes;
  116018. /**
  116019. * Creates a new InputBlock
  116020. * @param name defines the block name
  116021. * @param target defines the target of that block (Vertex by default)
  116022. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  116023. */
  116024. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  116025. /**
  116026. * Gets the output component
  116027. */
  116028. readonly output: NodeMaterialConnectionPoint;
  116029. /**
  116030. * Set the source of this connection point to a vertex attribute
  116031. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  116032. * @returns the current connection point
  116033. */
  116034. setAsAttribute(attributeName?: string): InputBlock;
  116035. /**
  116036. * Set the source of this connection point to a well known value
  116037. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  116038. * @returns the current connection point
  116039. */
  116040. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  116041. /**
  116042. * Gets or sets the value of that point.
  116043. * Please note that this value will be ignored if valueCallback is defined
  116044. */
  116045. value: any;
  116046. /**
  116047. * Gets or sets a callback used to get the value of that point.
  116048. * Please note that setting this value will force the connection point to ignore the value property
  116049. */
  116050. valueCallback: () => any;
  116051. /**
  116052. * Gets or sets the associated variable name in the shader
  116053. */
  116054. associatedVariableName: string;
  116055. /**
  116056. * Gets a boolean indicating that this connection point not defined yet
  116057. */
  116058. readonly isUndefined: boolean;
  116059. /**
  116060. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  116061. * In this case the connection point name must be the name of the uniform to use.
  116062. * Can only be set on inputs
  116063. */
  116064. isUniform: boolean;
  116065. /**
  116066. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  116067. * In this case the connection point name must be the name of the attribute to use
  116068. * Can only be set on inputs
  116069. */
  116070. isAttribute: boolean;
  116071. /**
  116072. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  116073. * Can only be set on exit points
  116074. */
  116075. isVarying: boolean;
  116076. /**
  116077. * Gets a boolean indicating that the current connection point is a well known value
  116078. */
  116079. readonly isWellKnownValue: boolean;
  116080. /**
  116081. * Gets or sets the current well known value or null if not defined as well know value
  116082. */
  116083. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  116084. /**
  116085. * Gets the current class name
  116086. * @returns the class name
  116087. */
  116088. getClassName(): string;
  116089. private _emitDefine;
  116090. /**
  116091. * Set the input block to its default value (based on its type)
  116092. */
  116093. setDefaultValue(): void;
  116094. private _emit;
  116095. /** @hidden */
  116096. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  116097. /** @hidden */
  116098. _transmit(effect: Effect, scene: Scene): void;
  116099. protected _buildBlock(state: NodeMaterialBuildState): void;
  116100. serialize(): any;
  116101. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116102. }
  116103. }
  116104. declare module BABYLON {
  116105. /**
  116106. * Defines a connection point for a block
  116107. */
  116108. export class NodeMaterialConnectionPoint {
  116109. /** @hidden */
  116110. _ownerBlock: NodeMaterialBlock;
  116111. /** @hidden */
  116112. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  116113. private _endpoints;
  116114. private _associatedVariableName;
  116115. /** @hidden */
  116116. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  116117. private _type;
  116118. /** @hidden */
  116119. _enforceAssociatedVariableName: boolean;
  116120. /**
  116121. * Gets or sets the associated variable name in the shader
  116122. */
  116123. associatedVariableName: string;
  116124. /**
  116125. * Gets or sets the connection point type (default is float)
  116126. */
  116127. type: NodeMaterialBlockConnectionPointTypes;
  116128. /**
  116129. * Gets or sets the connection point name
  116130. */
  116131. name: string;
  116132. /**
  116133. * Gets or sets the swizzle to apply to this connection point when reading or writing
  116134. */
  116135. swizzle: string;
  116136. /**
  116137. * Gets or sets a boolean indicating that this connection point can be omitted
  116138. */
  116139. isOptional: boolean;
  116140. /**
  116141. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  116142. */
  116143. define: string;
  116144. /** Gets or sets the target of that connection point */
  116145. target: NodeMaterialBlockTargets;
  116146. /**
  116147. * Gets a boolean indicating that the current point is connected
  116148. */
  116149. readonly isConnected: boolean;
  116150. /**
  116151. * Gets a boolean indicating that the current point is connected to an input block
  116152. */
  116153. readonly isConnectedToInput: boolean;
  116154. /**
  116155. * Gets a the connected input block (if any)
  116156. */
  116157. readonly connectInputBlock: Nullable<InputBlock>;
  116158. /** Get the other side of the connection (if any) */
  116159. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  116160. /** Get the block that owns this connection point */
  116161. readonly ownerBlock: NodeMaterialBlock;
  116162. /** Get the block connected on the other side of this connection (if any) */
  116163. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  116164. /** Get the block connected on the endpoints of this connection (if any) */
  116165. readonly connectedBlocks: Array<NodeMaterialBlock>;
  116166. /** Gets the list of connected endpoints */
  116167. readonly endpoints: NodeMaterialConnectionPoint[];
  116168. /**
  116169. * Creates a new connection point
  116170. * @param name defines the connection point name
  116171. * @param ownerBlock defines the block hosting this connection point
  116172. */
  116173. constructor(name: string, ownerBlock: NodeMaterialBlock);
  116174. /**
  116175. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  116176. * @returns the class name
  116177. */
  116178. getClassName(): string;
  116179. /**
  116180. * Gets an boolean indicating if the current point can be connected to another point
  116181. * @param connectionPoint defines the other connection point
  116182. * @returns true if the connection is possible
  116183. */
  116184. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  116185. /**
  116186. * Connect this point to another connection point
  116187. * @param connectionPoint defines the other connection point
  116188. * @returns the current connection point
  116189. */
  116190. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  116191. /**
  116192. * Disconnect this point from one of his endpoint
  116193. * @param endpoint defines the other connection point
  116194. * @returns the current connection point
  116195. */
  116196. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  116197. /**
  116198. * Serializes this point in a JSON representation
  116199. * @returns the serialized point object
  116200. */
  116201. serialize(): any;
  116202. private static _GetTypeLength;
  116203. }
  116204. }
  116205. declare module BABYLON {
  116206. /**
  116207. * Block used to add support for vertex skinning (bones)
  116208. */
  116209. export class BonesBlock extends NodeMaterialBlock {
  116210. /**
  116211. * Creates a new BonesBlock
  116212. * @param name defines the block name
  116213. */
  116214. constructor(name: string);
  116215. /**
  116216. * Initialize the block and prepare the context for build
  116217. * @param state defines the state that will be used for the build
  116218. */
  116219. initialize(state: NodeMaterialBuildState): void;
  116220. /**
  116221. * Gets the current class name
  116222. * @returns the class name
  116223. */
  116224. getClassName(): string;
  116225. /**
  116226. * Gets the matrix indices input component
  116227. */
  116228. readonly matricesIndices: NodeMaterialConnectionPoint;
  116229. /**
  116230. * Gets the matrix weights input component
  116231. */
  116232. readonly matricesWeights: NodeMaterialConnectionPoint;
  116233. /**
  116234. * Gets the extra matrix indices input component
  116235. */
  116236. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  116237. /**
  116238. * Gets the extra matrix weights input component
  116239. */
  116240. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  116241. /**
  116242. * Gets the world input component
  116243. */
  116244. readonly world: NodeMaterialConnectionPoint;
  116245. /**
  116246. * Gets the output component
  116247. */
  116248. readonly output: NodeMaterialConnectionPoint;
  116249. autoConfigure(): void;
  116250. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  116251. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116252. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116253. protected _buildBlock(state: NodeMaterialBuildState): this;
  116254. }
  116255. }
  116256. declare module BABYLON {
  116257. /**
  116258. * Block used to add support for instances
  116259. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  116260. */
  116261. export class InstancesBlock extends NodeMaterialBlock {
  116262. /**
  116263. * Creates a new InstancesBlock
  116264. * @param name defines the block name
  116265. */
  116266. constructor(name: string);
  116267. /**
  116268. * Gets the current class name
  116269. * @returns the class name
  116270. */
  116271. getClassName(): string;
  116272. /**
  116273. * Gets the first world row input component
  116274. */
  116275. readonly world0: NodeMaterialConnectionPoint;
  116276. /**
  116277. * Gets the second world row input component
  116278. */
  116279. readonly world1: NodeMaterialConnectionPoint;
  116280. /**
  116281. * Gets the third world row input component
  116282. */
  116283. readonly world2: NodeMaterialConnectionPoint;
  116284. /**
  116285. * Gets the forth world row input component
  116286. */
  116287. readonly world3: NodeMaterialConnectionPoint;
  116288. /**
  116289. * Gets the world input component
  116290. */
  116291. readonly world: NodeMaterialConnectionPoint;
  116292. /**
  116293. * Gets the output component
  116294. */
  116295. readonly output: NodeMaterialConnectionPoint;
  116296. autoConfigure(): void;
  116297. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  116298. protected _buildBlock(state: NodeMaterialBuildState): this;
  116299. }
  116300. }
  116301. declare module BABYLON {
  116302. /**
  116303. * Block used to add morph targets support to vertex shader
  116304. */
  116305. export class MorphTargetsBlock extends NodeMaterialBlock {
  116306. private _repeatableContentAnchor;
  116307. private _repeatebleContentGenerated;
  116308. /**
  116309. * Create a new MorphTargetsBlock
  116310. * @param name defines the block name
  116311. */
  116312. constructor(name: string);
  116313. /**
  116314. * Gets the current class name
  116315. * @returns the class name
  116316. */
  116317. getClassName(): string;
  116318. /**
  116319. * Gets the position input component
  116320. */
  116321. readonly position: NodeMaterialConnectionPoint;
  116322. /**
  116323. * Gets the normal input component
  116324. */
  116325. readonly normal: NodeMaterialConnectionPoint;
  116326. /**
  116327. * Gets the tangent input component
  116328. */
  116329. readonly tangent: NodeMaterialConnectionPoint;
  116330. /**
  116331. * Gets the tangent input component
  116332. */
  116333. readonly uv: NodeMaterialConnectionPoint;
  116334. /**
  116335. * Gets the position output component
  116336. */
  116337. readonly positionOutput: NodeMaterialConnectionPoint;
  116338. /**
  116339. * Gets the normal output component
  116340. */
  116341. readonly normalOutput: NodeMaterialConnectionPoint;
  116342. /**
  116343. * Gets the tangent output component
  116344. */
  116345. readonly tangentOutput: NodeMaterialConnectionPoint;
  116346. /**
  116347. * Gets the tangent output component
  116348. */
  116349. readonly uvOutput: NodeMaterialConnectionPoint;
  116350. initialize(state: NodeMaterialBuildState): void;
  116351. autoConfigure(): void;
  116352. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116353. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116354. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  116355. protected _buildBlock(state: NodeMaterialBuildState): this;
  116356. }
  116357. }
  116358. declare module BABYLON {
  116359. /**
  116360. * Block used to add an alpha test in the fragment shader
  116361. */
  116362. export class AlphaTestBlock extends NodeMaterialBlock {
  116363. /**
  116364. * Gets or sets the alpha value where alpha testing happens
  116365. */
  116366. alphaCutOff: number;
  116367. /**
  116368. * Create a new AlphaTestBlock
  116369. * @param name defines the block name
  116370. */
  116371. constructor(name: string);
  116372. /**
  116373. * Gets the current class name
  116374. * @returns the class name
  116375. */
  116376. getClassName(): string;
  116377. /**
  116378. * Gets the color input component
  116379. */
  116380. readonly color: NodeMaterialConnectionPoint;
  116381. protected _buildBlock(state: NodeMaterialBuildState): this;
  116382. }
  116383. }
  116384. declare module BABYLON {
  116385. /**
  116386. * Block used to create a Color3/4 out of individual inputs (one for each component)
  116387. */
  116388. export class ColorMergerBlock extends NodeMaterialBlock {
  116389. /**
  116390. * Create a new ColorMergerBlock
  116391. * @param name defines the block name
  116392. */
  116393. constructor(name: string);
  116394. /**
  116395. * Gets the current class name
  116396. * @returns the class name
  116397. */
  116398. getClassName(): string;
  116399. /**
  116400. * Gets the r component (input)
  116401. */
  116402. readonly r: NodeMaterialConnectionPoint;
  116403. /**
  116404. * Gets the g component (input)
  116405. */
  116406. readonly g: NodeMaterialConnectionPoint;
  116407. /**
  116408. * Gets the b component (input)
  116409. */
  116410. readonly b: NodeMaterialConnectionPoint;
  116411. /**
  116412. * Gets the a component (input)
  116413. */
  116414. readonly a: NodeMaterialConnectionPoint;
  116415. /**
  116416. * Gets the rgba component (output)
  116417. */
  116418. readonly rgba: NodeMaterialConnectionPoint;
  116419. /**
  116420. * Gets the rgb component (output)
  116421. */
  116422. readonly rgb: NodeMaterialConnectionPoint;
  116423. protected _buildBlock(state: NodeMaterialBuildState): this;
  116424. }
  116425. }
  116426. declare module BABYLON {
  116427. /**
  116428. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  116429. */
  116430. export class VectorMergerBlock extends NodeMaterialBlock {
  116431. /**
  116432. * Create a new VectorMergerBlock
  116433. * @param name defines the block name
  116434. */
  116435. constructor(name: string);
  116436. /**
  116437. * Gets the current class name
  116438. * @returns the class name
  116439. */
  116440. getClassName(): string;
  116441. /**
  116442. * Gets the x component (input)
  116443. */
  116444. readonly x: NodeMaterialConnectionPoint;
  116445. /**
  116446. * Gets the y component (input)
  116447. */
  116448. readonly y: NodeMaterialConnectionPoint;
  116449. /**
  116450. * Gets the z component (input)
  116451. */
  116452. readonly z: NodeMaterialConnectionPoint;
  116453. /**
  116454. * Gets the w component (input)
  116455. */
  116456. readonly w: NodeMaterialConnectionPoint;
  116457. /**
  116458. * Gets the xyzw component (output)
  116459. */
  116460. readonly xyzw: NodeMaterialConnectionPoint;
  116461. /**
  116462. * Gets the xyz component (output)
  116463. */
  116464. readonly xyz: NodeMaterialConnectionPoint;
  116465. /**
  116466. * Gets the xy component (output)
  116467. */
  116468. readonly xy: NodeMaterialConnectionPoint;
  116469. protected _buildBlock(state: NodeMaterialBuildState): this;
  116470. }
  116471. }
  116472. declare module BABYLON {
  116473. /**
  116474. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  116475. */
  116476. export class ColorSplitterBlock extends NodeMaterialBlock {
  116477. /**
  116478. * Create a new ColorSplitterBlock
  116479. * @param name defines the block name
  116480. */
  116481. constructor(name: string);
  116482. /**
  116483. * Gets the current class name
  116484. * @returns the class name
  116485. */
  116486. getClassName(): string;
  116487. /**
  116488. * Gets the rgba component (input)
  116489. */
  116490. readonly rgba: NodeMaterialConnectionPoint;
  116491. /**
  116492. * Gets the rgb component (input)
  116493. */
  116494. readonly rgbIn: NodeMaterialConnectionPoint;
  116495. /**
  116496. * Gets the rgb component (output)
  116497. */
  116498. readonly rgbOut: NodeMaterialConnectionPoint;
  116499. /**
  116500. * Gets the r component (output)
  116501. */
  116502. readonly r: NodeMaterialConnectionPoint;
  116503. /**
  116504. * Gets the g component (output)
  116505. */
  116506. readonly g: NodeMaterialConnectionPoint;
  116507. /**
  116508. * Gets the b component (output)
  116509. */
  116510. readonly b: NodeMaterialConnectionPoint;
  116511. /**
  116512. * Gets the a component (output)
  116513. */
  116514. readonly a: NodeMaterialConnectionPoint;
  116515. protected _buildBlock(state: NodeMaterialBuildState): this;
  116516. }
  116517. }
  116518. declare module BABYLON {
  116519. /**
  116520. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  116521. */
  116522. export class VectorSplitterBlock extends NodeMaterialBlock {
  116523. /**
  116524. * Create a new VectorSplitterBlock
  116525. * @param name defines the block name
  116526. */
  116527. constructor(name: string);
  116528. /**
  116529. * Gets the current class name
  116530. * @returns the class name
  116531. */
  116532. getClassName(): string;
  116533. /**
  116534. * Gets the xyzw component (input)
  116535. */
  116536. readonly xyzw: NodeMaterialConnectionPoint;
  116537. /**
  116538. * Gets the xyz component (input)
  116539. */
  116540. readonly xyzIn: NodeMaterialConnectionPoint;
  116541. /**
  116542. * Gets the xyz component (output)
  116543. */
  116544. readonly xyzOut: NodeMaterialConnectionPoint;
  116545. /**
  116546. * Gets the xy component (output)
  116547. */
  116548. readonly xy: NodeMaterialConnectionPoint;
  116549. /**
  116550. * Gets the x component (output)
  116551. */
  116552. readonly x: NodeMaterialConnectionPoint;
  116553. /**
  116554. * Gets the y component (output)
  116555. */
  116556. readonly y: NodeMaterialConnectionPoint;
  116557. /**
  116558. * Gets the z component (output)
  116559. */
  116560. readonly z: NodeMaterialConnectionPoint;
  116561. /**
  116562. * Gets the w component (output)
  116563. */
  116564. readonly w: NodeMaterialConnectionPoint;
  116565. protected _buildBlock(state: NodeMaterialBuildState): this;
  116566. }
  116567. }
  116568. declare module BABYLON {
  116569. /**
  116570. * Block used to add image processing support to fragment shader
  116571. */
  116572. export class ImageProcessingBlock extends NodeMaterialBlock {
  116573. /**
  116574. * Create a new ImageProcessingBlock
  116575. * @param name defines the block name
  116576. */
  116577. constructor(name: string);
  116578. /**
  116579. * Gets the current class name
  116580. * @returns the class name
  116581. */
  116582. getClassName(): string;
  116583. /**
  116584. * Gets the color input component
  116585. */
  116586. readonly color: NodeMaterialConnectionPoint;
  116587. /**
  116588. * Gets the output component
  116589. */
  116590. readonly output: NodeMaterialConnectionPoint;
  116591. /**
  116592. * Initialize the block and prepare the context for build
  116593. * @param state defines the state that will be used for the build
  116594. */
  116595. initialize(state: NodeMaterialBuildState): void;
  116596. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  116597. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116598. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116599. protected _buildBlock(state: NodeMaterialBuildState): this;
  116600. }
  116601. }
  116602. declare module BABYLON {
  116603. /**
  116604. * Block used to add support for scene fog
  116605. */
  116606. export class FogBlock extends NodeMaterialBlock {
  116607. private _fogDistanceName;
  116608. private _fogParameters;
  116609. /**
  116610. * Create a new FogBlock
  116611. * @param name defines the block name
  116612. */
  116613. constructor(name: string);
  116614. /**
  116615. * Gets the current class name
  116616. * @returns the class name
  116617. */
  116618. getClassName(): string;
  116619. /**
  116620. * Gets the world position input component
  116621. */
  116622. readonly worldPosition: NodeMaterialConnectionPoint;
  116623. /**
  116624. * Gets the view input component
  116625. */
  116626. readonly view: NodeMaterialConnectionPoint;
  116627. /**
  116628. * Gets the color input component
  116629. */
  116630. readonly color: NodeMaterialConnectionPoint;
  116631. /**
  116632. * Gets the fog color input component
  116633. */
  116634. readonly fogColor: NodeMaterialConnectionPoint;
  116635. /**
  116636. * Gets the output component
  116637. */
  116638. readonly output: NodeMaterialConnectionPoint;
  116639. autoConfigure(): void;
  116640. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116641. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116642. protected _buildBlock(state: NodeMaterialBuildState): this;
  116643. }
  116644. }
  116645. declare module BABYLON {
  116646. /**
  116647. * Block used to add light in the fragment shader
  116648. */
  116649. export class LightBlock extends NodeMaterialBlock {
  116650. private _lightId;
  116651. /**
  116652. * Gets or sets the light associated with this block
  116653. */
  116654. light: Nullable<Light>;
  116655. /**
  116656. * Create a new LightBlock
  116657. * @param name defines the block name
  116658. */
  116659. constructor(name: string);
  116660. /**
  116661. * Gets the current class name
  116662. * @returns the class name
  116663. */
  116664. getClassName(): string;
  116665. /**
  116666. * Gets the world position input component
  116667. */
  116668. readonly worldPosition: NodeMaterialConnectionPoint;
  116669. /**
  116670. * Gets the world normal input component
  116671. */
  116672. readonly worldNormal: NodeMaterialConnectionPoint;
  116673. /**
  116674. * Gets the camera (or eye) position component
  116675. */
  116676. readonly cameraPosition: NodeMaterialConnectionPoint;
  116677. /**
  116678. * Gets the diffuse output component
  116679. */
  116680. readonly diffuseOutput: NodeMaterialConnectionPoint;
  116681. /**
  116682. * Gets the specular output component
  116683. */
  116684. readonly specularOutput: NodeMaterialConnectionPoint;
  116685. autoConfigure(): void;
  116686. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116687. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116688. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116689. private _injectVertexCode;
  116690. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  116691. serialize(): any;
  116692. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116693. }
  116694. }
  116695. declare module BABYLON {
  116696. /**
  116697. * Block used to multiply 2 values
  116698. */
  116699. export class MultiplyBlock extends NodeMaterialBlock {
  116700. /**
  116701. * Creates a new MultiplyBlock
  116702. * @param name defines the block name
  116703. */
  116704. constructor(name: string);
  116705. /**
  116706. * Gets the current class name
  116707. * @returns the class name
  116708. */
  116709. getClassName(): string;
  116710. /**
  116711. * Gets the left operand input component
  116712. */
  116713. readonly left: NodeMaterialConnectionPoint;
  116714. /**
  116715. * Gets the right operand input component
  116716. */
  116717. readonly right: NodeMaterialConnectionPoint;
  116718. /**
  116719. * Gets the output component
  116720. */
  116721. readonly output: NodeMaterialConnectionPoint;
  116722. protected _buildBlock(state: NodeMaterialBuildState): this;
  116723. }
  116724. }
  116725. declare module BABYLON {
  116726. /**
  116727. * Block used to add 2 vectors
  116728. */
  116729. export class AddBlock extends NodeMaterialBlock {
  116730. /**
  116731. * Creates a new AddBlock
  116732. * @param name defines the block name
  116733. */
  116734. constructor(name: string);
  116735. /**
  116736. * Gets the current class name
  116737. * @returns the class name
  116738. */
  116739. getClassName(): string;
  116740. /**
  116741. * Gets the left operand input component
  116742. */
  116743. readonly left: NodeMaterialConnectionPoint;
  116744. /**
  116745. * Gets the right operand input component
  116746. */
  116747. readonly right: NodeMaterialConnectionPoint;
  116748. /**
  116749. * Gets the output component
  116750. */
  116751. readonly output: NodeMaterialConnectionPoint;
  116752. protected _buildBlock(state: NodeMaterialBuildState): this;
  116753. }
  116754. }
  116755. declare module BABYLON {
  116756. /**
  116757. * Block used to clamp a float
  116758. */
  116759. export class ClampBlock extends NodeMaterialBlock {
  116760. /** Gets or sets the minimum range */
  116761. minimum: number;
  116762. /** Gets or sets the maximum range */
  116763. maximum: number;
  116764. /**
  116765. * Creates a new ClampBlock
  116766. * @param name defines the block name
  116767. */
  116768. constructor(name: string);
  116769. /**
  116770. * Gets the current class name
  116771. * @returns the class name
  116772. */
  116773. getClassName(): string;
  116774. /**
  116775. * Gets the value input component
  116776. */
  116777. readonly value: NodeMaterialConnectionPoint;
  116778. /**
  116779. * Gets the output component
  116780. */
  116781. readonly output: NodeMaterialConnectionPoint;
  116782. protected _buildBlock(state: NodeMaterialBuildState): this;
  116783. }
  116784. }
  116785. declare module BABYLON {
  116786. /**
  116787. * Block used to apply a cross product between 2 vectors
  116788. */
  116789. export class CrossBlock extends NodeMaterialBlock {
  116790. /**
  116791. * Creates a new CrossBlock
  116792. * @param name defines the block name
  116793. */
  116794. constructor(name: string);
  116795. /**
  116796. * Gets the current class name
  116797. * @returns the class name
  116798. */
  116799. getClassName(): string;
  116800. /**
  116801. * Gets the left operand input component
  116802. */
  116803. readonly left: NodeMaterialConnectionPoint;
  116804. /**
  116805. * Gets the right operand input component
  116806. */
  116807. readonly right: NodeMaterialConnectionPoint;
  116808. /**
  116809. * Gets the output component
  116810. */
  116811. readonly output: NodeMaterialConnectionPoint;
  116812. protected _buildBlock(state: NodeMaterialBuildState): this;
  116813. }
  116814. }
  116815. declare module BABYLON {
  116816. /**
  116817. * Block used to apply a dot product between 2 vectors
  116818. */
  116819. export class DotBlock extends NodeMaterialBlock {
  116820. /**
  116821. * Creates a new DotBlock
  116822. * @param name defines the block name
  116823. */
  116824. constructor(name: string);
  116825. /**
  116826. * Gets the current class name
  116827. * @returns the class name
  116828. */
  116829. getClassName(): string;
  116830. /**
  116831. * Gets the left operand input component
  116832. */
  116833. readonly left: NodeMaterialConnectionPoint;
  116834. /**
  116835. * Gets the right operand input component
  116836. */
  116837. readonly right: NodeMaterialConnectionPoint;
  116838. /**
  116839. * Gets the output component
  116840. */
  116841. readonly output: NodeMaterialConnectionPoint;
  116842. protected _buildBlock(state: NodeMaterialBuildState): this;
  116843. }
  116844. }
  116845. declare module BABYLON {
  116846. /**
  116847. * Block used to remap a float from a range to a new one
  116848. */
  116849. export class RemapBlock extends NodeMaterialBlock {
  116850. /**
  116851. * Gets or sets the source range
  116852. */
  116853. sourceRange: Vector2;
  116854. /**
  116855. * Gets or sets the target range
  116856. */
  116857. targetRange: Vector2;
  116858. /**
  116859. * Creates a new RemapBlock
  116860. * @param name defines the block name
  116861. */
  116862. constructor(name: string);
  116863. /**
  116864. * Gets the current class name
  116865. * @returns the class name
  116866. */
  116867. getClassName(): string;
  116868. /**
  116869. * Gets the input component
  116870. */
  116871. readonly input: NodeMaterialConnectionPoint;
  116872. /**
  116873. * Gets the output component
  116874. */
  116875. readonly output: NodeMaterialConnectionPoint;
  116876. protected _buildBlock(state: NodeMaterialBuildState): this;
  116877. }
  116878. }
  116879. declare module BABYLON {
  116880. /**
  116881. * Block used to normalize a vector
  116882. */
  116883. export class NormalizeBlock extends NodeMaterialBlock {
  116884. /**
  116885. * Creates a new NormalizeBlock
  116886. * @param name defines the block name
  116887. */
  116888. constructor(name: string);
  116889. /**
  116890. * Gets the current class name
  116891. * @returns the class name
  116892. */
  116893. getClassName(): string;
  116894. /**
  116895. * Gets the input component
  116896. */
  116897. readonly input: NodeMaterialConnectionPoint;
  116898. /**
  116899. * Gets the output component
  116900. */
  116901. readonly output: NodeMaterialConnectionPoint;
  116902. protected _buildBlock(state: NodeMaterialBuildState): this;
  116903. }
  116904. }
  116905. declare module BABYLON {
  116906. /**
  116907. * Effect Render Options
  116908. */
  116909. export interface IEffectRendererOptions {
  116910. /**
  116911. * Defines the vertices positions.
  116912. */
  116913. positions?: number[];
  116914. /**
  116915. * Defines the indices.
  116916. */
  116917. indices?: number[];
  116918. }
  116919. /**
  116920. * Helper class to render one or more effects
  116921. */
  116922. export class EffectRenderer {
  116923. private engine;
  116924. private static _DefaultOptions;
  116925. private _vertexBuffers;
  116926. private _indexBuffer;
  116927. private _ringBufferIndex;
  116928. private _ringScreenBuffer;
  116929. private _fullscreenViewport;
  116930. private _getNextFrameBuffer;
  116931. /**
  116932. * Creates an effect renderer
  116933. * @param engine the engine to use for rendering
  116934. * @param options defines the options of the effect renderer
  116935. */
  116936. constructor(engine: Engine, options?: IEffectRendererOptions);
  116937. /**
  116938. * Sets the current viewport in normalized coordinates 0-1
  116939. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  116940. */
  116941. setViewport(viewport?: Viewport): void;
  116942. /**
  116943. * Sets the current effect wrapper to use during draw.
  116944. * The effect needs to be ready before calling this api.
  116945. * This also sets the default full screen position attribute.
  116946. * @param effectWrapper Defines the effect to draw with
  116947. */
  116948. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  116949. /**
  116950. * Draws a full screen quad.
  116951. */
  116952. draw(): void;
  116953. /**
  116954. * renders one or more effects to a specified texture
  116955. * @param effectWrappers list of effects to renderer
  116956. * @param outputTexture texture to draw to, if null it will render to the screen
  116957. */
  116958. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  116959. /**
  116960. * Disposes of the effect renderer
  116961. */
  116962. dispose(): void;
  116963. }
  116964. /**
  116965. * Options to create an EffectWrapper
  116966. */
  116967. interface EffectWrapperCreationOptions {
  116968. /**
  116969. * Engine to use to create the effect
  116970. */
  116971. engine: Engine;
  116972. /**
  116973. * Fragment shader for the effect
  116974. */
  116975. fragmentShader: string;
  116976. /**
  116977. * Vertex shader for the effect
  116978. */
  116979. vertexShader: string;
  116980. /**
  116981. * Attributes to use in the shader
  116982. */
  116983. attributeNames?: Array<string>;
  116984. /**
  116985. * Uniforms to use in the shader
  116986. */
  116987. uniformNames?: Array<string>;
  116988. /**
  116989. * Texture sampler names to use in the shader
  116990. */
  116991. samplerNames?: Array<string>;
  116992. /**
  116993. * The friendly name of the effect displayed in Spector.
  116994. */
  116995. name?: string;
  116996. }
  116997. /**
  116998. * Wraps an effect to be used for rendering
  116999. */
  117000. export class EffectWrapper {
  117001. /**
  117002. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  117003. */
  117004. onApplyObservable: Observable<{}>;
  117005. /**
  117006. * The underlying effect
  117007. */
  117008. effect: Effect;
  117009. /**
  117010. * Creates an effect to be renderer
  117011. * @param creationOptions options to create the effect
  117012. */
  117013. constructor(creationOptions: EffectWrapperCreationOptions);
  117014. /**
  117015. * Disposes of the effect wrapper
  117016. */
  117017. dispose(): void;
  117018. }
  117019. }
  117020. declare module BABYLON {
  117021. /**
  117022. * Helper class to push actions to a pool of workers.
  117023. */
  117024. export class WorkerPool implements IDisposable {
  117025. private _workerInfos;
  117026. private _pendingActions;
  117027. /**
  117028. * Constructor
  117029. * @param workers Array of workers to use for actions
  117030. */
  117031. constructor(workers: Array<Worker>);
  117032. /**
  117033. * Terminates all workers and clears any pending actions.
  117034. */
  117035. dispose(): void;
  117036. /**
  117037. * Pushes an action to the worker pool. If all the workers are active, the action will be
  117038. * pended until a worker has completed its action.
  117039. * @param action The action to perform. Call onComplete when the action is complete.
  117040. */
  117041. push(action: (worker: Worker, onComplete: () => void) => void): void;
  117042. private _execute;
  117043. }
  117044. }
  117045. declare module BABYLON {
  117046. /**
  117047. * Configuration for Draco compression
  117048. */
  117049. export interface IDracoCompressionConfiguration {
  117050. /**
  117051. * Configuration for the decoder.
  117052. */
  117053. decoder: {
  117054. /**
  117055. * The url to the WebAssembly module.
  117056. */
  117057. wasmUrl?: string;
  117058. /**
  117059. * The url to the WebAssembly binary.
  117060. */
  117061. wasmBinaryUrl?: string;
  117062. /**
  117063. * The url to the fallback JavaScript module.
  117064. */
  117065. fallbackUrl?: string;
  117066. };
  117067. }
  117068. /**
  117069. * Draco compression (https://google.github.io/draco/)
  117070. *
  117071. * This class wraps the Draco module.
  117072. *
  117073. * **Encoder**
  117074. *
  117075. * The encoder is not currently implemented.
  117076. *
  117077. * **Decoder**
  117078. *
  117079. * 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.
  117080. *
  117081. * To update the configuration, use the following code:
  117082. * ```javascript
  117083. * DracoCompression.Configuration = {
  117084. * decoder: {
  117085. * wasmUrl: "<url to the WebAssembly library>",
  117086. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  117087. * fallbackUrl: "<url to the fallback JavaScript library>",
  117088. * }
  117089. * };
  117090. * ```
  117091. *
  117092. * 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.
  117093. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  117094. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  117095. *
  117096. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  117097. * ```javascript
  117098. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  117099. * ```
  117100. *
  117101. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  117102. */
  117103. export class DracoCompression implements IDisposable {
  117104. private _workerPoolPromise?;
  117105. private _decoderModulePromise?;
  117106. /**
  117107. * The configuration. Defaults to the following urls:
  117108. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  117109. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  117110. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  117111. */
  117112. static Configuration: IDracoCompressionConfiguration;
  117113. /**
  117114. * Returns true if the decoder configuration is available.
  117115. */
  117116. static readonly DecoderAvailable: boolean;
  117117. /**
  117118. * Default number of workers to create when creating the draco compression object.
  117119. */
  117120. static DefaultNumWorkers: number;
  117121. private static GetDefaultNumWorkers;
  117122. private static _Default;
  117123. /**
  117124. * Default instance for the draco compression object.
  117125. */
  117126. static readonly Default: DracoCompression;
  117127. /**
  117128. * Constructor
  117129. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  117130. */
  117131. constructor(numWorkers?: number);
  117132. /**
  117133. * Stop all async operations and release resources.
  117134. */
  117135. dispose(): void;
  117136. /**
  117137. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  117138. * @returns a promise that resolves when ready
  117139. */
  117140. whenReadyAsync(): Promise<void>;
  117141. /**
  117142. * Decode Draco compressed mesh data to vertex data.
  117143. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  117144. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  117145. * @returns A promise that resolves with the decoded vertex data
  117146. */
  117147. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  117148. [kind: string]: number;
  117149. }): Promise<VertexData>;
  117150. }
  117151. }
  117152. declare module BABYLON {
  117153. /**
  117154. * Class for building Constructive Solid Geometry
  117155. */
  117156. export class CSG {
  117157. private polygons;
  117158. /**
  117159. * The world matrix
  117160. */
  117161. matrix: Matrix;
  117162. /**
  117163. * Stores the position
  117164. */
  117165. position: Vector3;
  117166. /**
  117167. * Stores the rotation
  117168. */
  117169. rotation: Vector3;
  117170. /**
  117171. * Stores the rotation quaternion
  117172. */
  117173. rotationQuaternion: Nullable<Quaternion>;
  117174. /**
  117175. * Stores the scaling vector
  117176. */
  117177. scaling: Vector3;
  117178. /**
  117179. * Convert the Mesh to CSG
  117180. * @param mesh The Mesh to convert to CSG
  117181. * @returns A new CSG from the Mesh
  117182. */
  117183. static FromMesh(mesh: Mesh): CSG;
  117184. /**
  117185. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  117186. * @param polygons Polygons used to construct a CSG solid
  117187. */
  117188. private static FromPolygons;
  117189. /**
  117190. * Clones, or makes a deep copy, of the CSG
  117191. * @returns A new CSG
  117192. */
  117193. clone(): CSG;
  117194. /**
  117195. * Unions this CSG with another CSG
  117196. * @param csg The CSG to union against this CSG
  117197. * @returns The unioned CSG
  117198. */
  117199. union(csg: CSG): CSG;
  117200. /**
  117201. * Unions this CSG with another CSG in place
  117202. * @param csg The CSG to union against this CSG
  117203. */
  117204. unionInPlace(csg: CSG): void;
  117205. /**
  117206. * Subtracts this CSG with another CSG
  117207. * @param csg The CSG to subtract against this CSG
  117208. * @returns A new CSG
  117209. */
  117210. subtract(csg: CSG): CSG;
  117211. /**
  117212. * Subtracts this CSG with another CSG in place
  117213. * @param csg The CSG to subtact against this CSG
  117214. */
  117215. subtractInPlace(csg: CSG): void;
  117216. /**
  117217. * Intersect this CSG with another CSG
  117218. * @param csg The CSG to intersect against this CSG
  117219. * @returns A new CSG
  117220. */
  117221. intersect(csg: CSG): CSG;
  117222. /**
  117223. * Intersects this CSG with another CSG in place
  117224. * @param csg The CSG to intersect against this CSG
  117225. */
  117226. intersectInPlace(csg: CSG): void;
  117227. /**
  117228. * Return a new CSG solid with solid and empty space switched. This solid is
  117229. * not modified.
  117230. * @returns A new CSG solid with solid and empty space switched
  117231. */
  117232. inverse(): CSG;
  117233. /**
  117234. * Inverses the CSG in place
  117235. */
  117236. inverseInPlace(): void;
  117237. /**
  117238. * This is used to keep meshes transformations so they can be restored
  117239. * when we build back a Babylon Mesh
  117240. * NB : All CSG operations are performed in world coordinates
  117241. * @param csg The CSG to copy the transform attributes from
  117242. * @returns This CSG
  117243. */
  117244. copyTransformAttributes(csg: CSG): CSG;
  117245. /**
  117246. * Build Raw mesh from CSG
  117247. * Coordinates here are in world space
  117248. * @param name The name of the mesh geometry
  117249. * @param scene The Scene
  117250. * @param keepSubMeshes Specifies if the submeshes should be kept
  117251. * @returns A new Mesh
  117252. */
  117253. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  117254. /**
  117255. * Build Mesh from CSG taking material and transforms into account
  117256. * @param name The name of the Mesh
  117257. * @param material The material of the Mesh
  117258. * @param scene The Scene
  117259. * @param keepSubMeshes Specifies if submeshes should be kept
  117260. * @returns The new Mesh
  117261. */
  117262. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  117263. }
  117264. }
  117265. declare module BABYLON {
  117266. /**
  117267. * Class used to create a trail following a mesh
  117268. */
  117269. export class TrailMesh extends Mesh {
  117270. private _generator;
  117271. private _autoStart;
  117272. private _running;
  117273. private _diameter;
  117274. private _length;
  117275. private _sectionPolygonPointsCount;
  117276. private _sectionVectors;
  117277. private _sectionNormalVectors;
  117278. private _beforeRenderObserver;
  117279. /**
  117280. * @constructor
  117281. * @param name The value used by scene.getMeshByName() to do a lookup.
  117282. * @param generator The mesh to generate a trail.
  117283. * @param scene The scene to add this mesh to.
  117284. * @param diameter Diameter of trailing mesh. Default is 1.
  117285. * @param length Length of trailing mesh. Default is 60.
  117286. * @param autoStart Automatically start trailing mesh. Default true.
  117287. */
  117288. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  117289. /**
  117290. * "TrailMesh"
  117291. * @returns "TrailMesh"
  117292. */
  117293. getClassName(): string;
  117294. private _createMesh;
  117295. /**
  117296. * Start trailing mesh.
  117297. */
  117298. start(): void;
  117299. /**
  117300. * Stop trailing mesh.
  117301. */
  117302. stop(): void;
  117303. /**
  117304. * Update trailing mesh geometry.
  117305. */
  117306. update(): void;
  117307. /**
  117308. * Returns a new TrailMesh object.
  117309. * @param name is a string, the name given to the new mesh
  117310. * @param newGenerator use new generator object for cloned trail mesh
  117311. * @returns a new mesh
  117312. */
  117313. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  117314. /**
  117315. * Serializes this trail mesh
  117316. * @param serializationObject object to write serialization to
  117317. */
  117318. serialize(serializationObject: any): void;
  117319. /**
  117320. * Parses a serialized trail mesh
  117321. * @param parsedMesh the serialized mesh
  117322. * @param scene the scene to create the trail mesh in
  117323. * @returns the created trail mesh
  117324. */
  117325. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  117326. }
  117327. }
  117328. declare module BABYLON {
  117329. /**
  117330. * Class containing static functions to help procedurally build meshes
  117331. */
  117332. export class TiledBoxBuilder {
  117333. /**
  117334. * Creates a box mesh
  117335. * 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)
  117336. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  117337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117338. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117340. * @param name defines the name of the mesh
  117341. * @param options defines the options used to create the mesh
  117342. * @param scene defines the hosting scene
  117343. * @returns the box mesh
  117344. */
  117345. static CreateTiledBox(name: string, options: {
  117346. pattern?: number;
  117347. width?: number;
  117348. height?: number;
  117349. depth?: number;
  117350. tileSize?: number;
  117351. tileWidth?: number;
  117352. tileHeight?: number;
  117353. alignHorizontal?: number;
  117354. alignVertical?: number;
  117355. faceUV?: Vector4[];
  117356. faceColors?: Color4[];
  117357. sideOrientation?: number;
  117358. updatable?: boolean;
  117359. }, scene?: Nullable<Scene>): Mesh;
  117360. }
  117361. }
  117362. declare module BABYLON {
  117363. /**
  117364. * Class containing static functions to help procedurally build meshes
  117365. */
  117366. export class TorusKnotBuilder {
  117367. /**
  117368. * Creates a torus knot mesh
  117369. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  117370. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  117371. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  117372. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  117373. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117374. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117376. * @param name defines the name of the mesh
  117377. * @param options defines the options used to create the mesh
  117378. * @param scene defines the hosting scene
  117379. * @returns the torus knot mesh
  117380. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  117381. */
  117382. static CreateTorusKnot(name: string, options: {
  117383. radius?: number;
  117384. tube?: number;
  117385. radialSegments?: number;
  117386. tubularSegments?: number;
  117387. p?: number;
  117388. q?: number;
  117389. updatable?: boolean;
  117390. sideOrientation?: number;
  117391. frontUVs?: Vector4;
  117392. backUVs?: Vector4;
  117393. }, scene: any): Mesh;
  117394. }
  117395. }
  117396. declare module BABYLON {
  117397. /**
  117398. * Polygon
  117399. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  117400. */
  117401. export class Polygon {
  117402. /**
  117403. * Creates a rectangle
  117404. * @param xmin bottom X coord
  117405. * @param ymin bottom Y coord
  117406. * @param xmax top X coord
  117407. * @param ymax top Y coord
  117408. * @returns points that make the resulting rectation
  117409. */
  117410. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  117411. /**
  117412. * Creates a circle
  117413. * @param radius radius of circle
  117414. * @param cx scale in x
  117415. * @param cy scale in y
  117416. * @param numberOfSides number of sides that make up the circle
  117417. * @returns points that make the resulting circle
  117418. */
  117419. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  117420. /**
  117421. * Creates a polygon from input string
  117422. * @param input Input polygon data
  117423. * @returns the parsed points
  117424. */
  117425. static Parse(input: string): Vector2[];
  117426. /**
  117427. * Starts building a polygon from x and y coordinates
  117428. * @param x x coordinate
  117429. * @param y y coordinate
  117430. * @returns the started path2
  117431. */
  117432. static StartingAt(x: number, y: number): Path2;
  117433. }
  117434. /**
  117435. * Builds a polygon
  117436. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  117437. */
  117438. export class PolygonMeshBuilder {
  117439. private _points;
  117440. private _outlinepoints;
  117441. private _holes;
  117442. private _name;
  117443. private _scene;
  117444. private _epoints;
  117445. private _eholes;
  117446. private _addToepoint;
  117447. /**
  117448. * Babylon reference to the earcut plugin.
  117449. */
  117450. bjsEarcut: any;
  117451. /**
  117452. * Creates a PolygonMeshBuilder
  117453. * @param name name of the builder
  117454. * @param contours Path of the polygon
  117455. * @param scene scene to add to when creating the mesh
  117456. * @param earcutInjection can be used to inject your own earcut reference
  117457. */
  117458. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  117459. /**
  117460. * Adds a whole within the polygon
  117461. * @param hole Array of points defining the hole
  117462. * @returns this
  117463. */
  117464. addHole(hole: Vector2[]): PolygonMeshBuilder;
  117465. /**
  117466. * Creates the polygon
  117467. * @param updatable If the mesh should be updatable
  117468. * @param depth The depth of the mesh created
  117469. * @returns the created mesh
  117470. */
  117471. build(updatable?: boolean, depth?: number): Mesh;
  117472. /**
  117473. * Creates the polygon
  117474. * @param depth The depth of the mesh created
  117475. * @returns the created VertexData
  117476. */
  117477. buildVertexData(depth?: number): VertexData;
  117478. /**
  117479. * Adds a side to the polygon
  117480. * @param positions points that make the polygon
  117481. * @param normals normals of the polygon
  117482. * @param uvs uvs of the polygon
  117483. * @param indices indices of the polygon
  117484. * @param bounds bounds of the polygon
  117485. * @param points points of the polygon
  117486. * @param depth depth of the polygon
  117487. * @param flip flip of the polygon
  117488. */
  117489. private addSide;
  117490. }
  117491. }
  117492. declare module BABYLON {
  117493. /**
  117494. * Class containing static functions to help procedurally build meshes
  117495. */
  117496. export class PolygonBuilder {
  117497. /**
  117498. * Creates a polygon mesh
  117499. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  117500. * * 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
  117501. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  117502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117503. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  117504. * * Remember you can only change the shape positions, not their number when updating a polygon
  117505. * @param name defines the name of the mesh
  117506. * @param options defines the options used to create the mesh
  117507. * @param scene defines the hosting scene
  117508. * @param earcutInjection can be used to inject your own earcut reference
  117509. * @returns the polygon mesh
  117510. */
  117511. static CreatePolygon(name: string, options: {
  117512. shape: Vector3[];
  117513. holes?: Vector3[][];
  117514. depth?: number;
  117515. faceUV?: Vector4[];
  117516. faceColors?: Color4[];
  117517. updatable?: boolean;
  117518. sideOrientation?: number;
  117519. frontUVs?: Vector4;
  117520. backUVs?: Vector4;
  117521. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  117522. /**
  117523. * Creates an extruded polygon mesh, with depth in the Y direction.
  117524. * * 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)
  117525. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  117526. * @param name defines the name of the mesh
  117527. * @param options defines the options used to create the mesh
  117528. * @param scene defines the hosting scene
  117529. * @param earcutInjection can be used to inject your own earcut reference
  117530. * @returns the polygon mesh
  117531. */
  117532. static ExtrudePolygon(name: string, options: {
  117533. shape: Vector3[];
  117534. holes?: Vector3[][];
  117535. depth?: number;
  117536. faceUV?: Vector4[];
  117537. faceColors?: Color4[];
  117538. updatable?: boolean;
  117539. sideOrientation?: number;
  117540. frontUVs?: Vector4;
  117541. backUVs?: Vector4;
  117542. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  117543. }
  117544. }
  117545. declare module BABYLON {
  117546. /**
  117547. * Class containing static functions to help procedurally build meshes
  117548. */
  117549. export class LatheBuilder {
  117550. /**
  117551. * Creates lathe mesh.
  117552. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  117553. * * 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
  117554. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  117555. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  117556. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  117557. * * 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
  117558. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  117559. * * 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
  117560. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117561. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117562. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117564. * @param name defines the name of the mesh
  117565. * @param options defines the options used to create the mesh
  117566. * @param scene defines the hosting scene
  117567. * @returns the lathe mesh
  117568. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  117569. */
  117570. static CreateLathe(name: string, options: {
  117571. shape: Vector3[];
  117572. radius?: number;
  117573. tessellation?: number;
  117574. clip?: number;
  117575. arc?: number;
  117576. closed?: boolean;
  117577. updatable?: boolean;
  117578. sideOrientation?: number;
  117579. frontUVs?: Vector4;
  117580. backUVs?: Vector4;
  117581. cap?: number;
  117582. invertUV?: boolean;
  117583. }, scene?: Nullable<Scene>): Mesh;
  117584. }
  117585. }
  117586. declare module BABYLON {
  117587. /**
  117588. * Class containing static functions to help procedurally build meshes
  117589. */
  117590. export class TiledPlaneBuilder {
  117591. /**
  117592. * Creates a tiled plane mesh
  117593. * * The parameter `pattern` will, depending on value, do nothing or
  117594. * * * flip (reflect about central vertical) alternate tiles across and up
  117595. * * * flip every tile on alternate rows
  117596. * * * rotate (180 degs) alternate tiles across and up
  117597. * * * rotate every tile on alternate rows
  117598. * * * flip and rotate alternate tiles across and up
  117599. * * * flip and rotate every tile on alternate rows
  117600. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  117601. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  117602. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117603. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  117604. * * 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)
  117605. * * 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)
  117606. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  117607. * @param name defines the name of the mesh
  117608. * @param options defines the options used to create the mesh
  117609. * @param scene defines the hosting scene
  117610. * @returns the box mesh
  117611. */
  117612. static CreateTiledPlane(name: string, options: {
  117613. pattern?: number;
  117614. tileSize?: number;
  117615. tileWidth?: number;
  117616. tileHeight?: number;
  117617. size?: number;
  117618. width?: number;
  117619. height?: number;
  117620. alignHorizontal?: number;
  117621. alignVertical?: number;
  117622. sideOrientation?: number;
  117623. frontUVs?: Vector4;
  117624. backUVs?: Vector4;
  117625. updatable?: boolean;
  117626. }, scene?: Nullable<Scene>): Mesh;
  117627. }
  117628. }
  117629. declare module BABYLON {
  117630. /**
  117631. * Class containing static functions to help procedurally build meshes
  117632. */
  117633. export class TubeBuilder {
  117634. /**
  117635. * Creates a tube mesh.
  117636. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  117637. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  117638. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  117639. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  117640. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  117641. * * 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)
  117642. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  117643. * * 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
  117644. * * 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
  117645. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117646. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117647. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117648. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117649. * @param name defines the name of the mesh
  117650. * @param options defines the options used to create the mesh
  117651. * @param scene defines the hosting scene
  117652. * @returns the tube mesh
  117653. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117654. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  117655. */
  117656. static CreateTube(name: string, options: {
  117657. path: Vector3[];
  117658. radius?: number;
  117659. tessellation?: number;
  117660. radiusFunction?: {
  117661. (i: number, distance: number): number;
  117662. };
  117663. cap?: number;
  117664. arc?: number;
  117665. updatable?: boolean;
  117666. sideOrientation?: number;
  117667. frontUVs?: Vector4;
  117668. backUVs?: Vector4;
  117669. instance?: Mesh;
  117670. invertUV?: boolean;
  117671. }, scene?: Nullable<Scene>): Mesh;
  117672. }
  117673. }
  117674. declare module BABYLON {
  117675. /**
  117676. * Class containing static functions to help procedurally build meshes
  117677. */
  117678. export class IcoSphereBuilder {
  117679. /**
  117680. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  117681. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  117682. * * 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`)
  117683. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  117684. * * 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
  117685. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117686. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117688. * @param name defines the name of the mesh
  117689. * @param options defines the options used to create the mesh
  117690. * @param scene defines the hosting scene
  117691. * @returns the icosahedron mesh
  117692. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  117693. */
  117694. static CreateIcoSphere(name: string, options: {
  117695. radius?: number;
  117696. radiusX?: number;
  117697. radiusY?: number;
  117698. radiusZ?: number;
  117699. flat?: boolean;
  117700. subdivisions?: number;
  117701. sideOrientation?: number;
  117702. frontUVs?: Vector4;
  117703. backUVs?: Vector4;
  117704. updatable?: boolean;
  117705. }, scene?: Nullable<Scene>): Mesh;
  117706. }
  117707. }
  117708. declare module BABYLON {
  117709. /**
  117710. * Class containing static functions to help procedurally build meshes
  117711. */
  117712. export class DecalBuilder {
  117713. /**
  117714. * Creates a decal mesh.
  117715. * 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
  117716. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  117717. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  117718. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  117719. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  117720. * @param name defines the name of the mesh
  117721. * @param sourceMesh defines the mesh where the decal must be applied
  117722. * @param options defines the options used to create the mesh
  117723. * @param scene defines the hosting scene
  117724. * @returns the decal mesh
  117725. * @see https://doc.babylonjs.com/how_to/decals
  117726. */
  117727. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  117728. position?: Vector3;
  117729. normal?: Vector3;
  117730. size?: Vector3;
  117731. angle?: number;
  117732. }): Mesh;
  117733. }
  117734. }
  117735. declare module BABYLON {
  117736. /**
  117737. * Class containing static functions to help procedurally build meshes
  117738. */
  117739. export class MeshBuilder {
  117740. /**
  117741. * Creates a box mesh
  117742. * * The parameter `size` sets the size (float) of each box side (default 1)
  117743. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  117744. * * 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)
  117745. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  117746. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117747. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117749. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  117750. * @param name defines the name of the mesh
  117751. * @param options defines the options used to create the mesh
  117752. * @param scene defines the hosting scene
  117753. * @returns the box mesh
  117754. */
  117755. static CreateBox(name: string, options: {
  117756. size?: number;
  117757. width?: number;
  117758. height?: number;
  117759. depth?: number;
  117760. faceUV?: Vector4[];
  117761. faceColors?: Color4[];
  117762. sideOrientation?: number;
  117763. frontUVs?: Vector4;
  117764. backUVs?: Vector4;
  117765. updatable?: boolean;
  117766. }, scene?: Nullable<Scene>): Mesh;
  117767. /**
  117768. * Creates a tiled box mesh
  117769. * * faceTiles sets the pattern, tile size and number of tiles for a face
  117770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117771. * @param name defines the name of the mesh
  117772. * @param options defines the options used to create the mesh
  117773. * @param scene defines the hosting scene
  117774. * @returns the tiled box mesh
  117775. */
  117776. static CreateTiledBox(name: string, options: {
  117777. pattern?: number;
  117778. size?: number;
  117779. width?: number;
  117780. height?: number;
  117781. depth: number;
  117782. tileSize?: number;
  117783. tileWidth?: number;
  117784. tileHeight?: number;
  117785. faceUV?: Vector4[];
  117786. faceColors?: Color4[];
  117787. alignHorizontal?: number;
  117788. alignVertical?: number;
  117789. sideOrientation?: number;
  117790. updatable?: boolean;
  117791. }, scene?: Nullable<Scene>): Mesh;
  117792. /**
  117793. * Creates a sphere mesh
  117794. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  117795. * * 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`)
  117796. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  117797. * * 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
  117798. * * 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)
  117799. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117800. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117801. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117802. * @param name defines the name of the mesh
  117803. * @param options defines the options used to create the mesh
  117804. * @param scene defines the hosting scene
  117805. * @returns the sphere mesh
  117806. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  117807. */
  117808. static CreateSphere(name: string, options: {
  117809. segments?: number;
  117810. diameter?: number;
  117811. diameterX?: number;
  117812. diameterY?: number;
  117813. diameterZ?: number;
  117814. arc?: number;
  117815. slice?: number;
  117816. sideOrientation?: number;
  117817. frontUVs?: Vector4;
  117818. backUVs?: Vector4;
  117819. updatable?: boolean;
  117820. }, scene?: Nullable<Scene>): Mesh;
  117821. /**
  117822. * Creates a plane polygonal mesh. By default, this is a disc
  117823. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  117824. * * 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
  117825. * * 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
  117826. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117827. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117829. * @param name defines the name of the mesh
  117830. * @param options defines the options used to create the mesh
  117831. * @param scene defines the hosting scene
  117832. * @returns the plane polygonal mesh
  117833. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  117834. */
  117835. static CreateDisc(name: string, options: {
  117836. radius?: number;
  117837. tessellation?: number;
  117838. arc?: number;
  117839. updatable?: boolean;
  117840. sideOrientation?: number;
  117841. frontUVs?: Vector4;
  117842. backUVs?: Vector4;
  117843. }, scene?: Nullable<Scene>): Mesh;
  117844. /**
  117845. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  117846. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  117847. * * 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`)
  117848. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  117849. * * 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
  117850. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117851. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117853. * @param name defines the name of the mesh
  117854. * @param options defines the options used to create the mesh
  117855. * @param scene defines the hosting scene
  117856. * @returns the icosahedron mesh
  117857. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  117858. */
  117859. static CreateIcoSphere(name: string, options: {
  117860. radius?: number;
  117861. radiusX?: number;
  117862. radiusY?: number;
  117863. radiusZ?: number;
  117864. flat?: boolean;
  117865. subdivisions?: number;
  117866. sideOrientation?: number;
  117867. frontUVs?: Vector4;
  117868. backUVs?: Vector4;
  117869. updatable?: boolean;
  117870. }, scene?: Nullable<Scene>): Mesh;
  117871. /**
  117872. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  117873. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  117874. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  117875. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  117876. * * 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
  117877. * * 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
  117878. * * 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
  117879. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117880. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117881. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117882. * * 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
  117883. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  117884. * * 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
  117885. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  117886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117887. * @param name defines the name of the mesh
  117888. * @param options defines the options used to create the mesh
  117889. * @param scene defines the hosting scene
  117890. * @returns the ribbon mesh
  117891. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  117892. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117893. */
  117894. static CreateRibbon(name: string, options: {
  117895. pathArray: Vector3[][];
  117896. closeArray?: boolean;
  117897. closePath?: boolean;
  117898. offset?: number;
  117899. updatable?: boolean;
  117900. sideOrientation?: number;
  117901. frontUVs?: Vector4;
  117902. backUVs?: Vector4;
  117903. instance?: Mesh;
  117904. invertUV?: boolean;
  117905. uvs?: Vector2[];
  117906. colors?: Color4[];
  117907. }, scene?: Nullable<Scene>): Mesh;
  117908. /**
  117909. * Creates a cylinder or a cone mesh
  117910. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  117911. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  117912. * * 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.
  117913. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  117914. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  117915. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  117916. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  117917. * * 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).
  117918. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  117919. * * 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).
  117920. * * 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
  117921. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  117922. * * 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
  117923. * * 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.
  117924. * * If `enclose` is false, a ring surface is one element.
  117925. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  117926. * * 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
  117927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117928. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117930. * @param name defines the name of the mesh
  117931. * @param options defines the options used to create the mesh
  117932. * @param scene defines the hosting scene
  117933. * @returns the cylinder mesh
  117934. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  117935. */
  117936. static CreateCylinder(name: string, options: {
  117937. height?: number;
  117938. diameterTop?: number;
  117939. diameterBottom?: number;
  117940. diameter?: number;
  117941. tessellation?: number;
  117942. subdivisions?: number;
  117943. arc?: number;
  117944. faceColors?: Color4[];
  117945. faceUV?: Vector4[];
  117946. updatable?: boolean;
  117947. hasRings?: boolean;
  117948. enclose?: boolean;
  117949. cap?: number;
  117950. sideOrientation?: number;
  117951. frontUVs?: Vector4;
  117952. backUVs?: Vector4;
  117953. }, scene?: Nullable<Scene>): Mesh;
  117954. /**
  117955. * Creates a torus mesh
  117956. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  117957. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  117958. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  117959. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117960. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117962. * @param name defines the name of the mesh
  117963. * @param options defines the options used to create the mesh
  117964. * @param scene defines the hosting scene
  117965. * @returns the torus mesh
  117966. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  117967. */
  117968. static CreateTorus(name: string, options: {
  117969. diameter?: number;
  117970. thickness?: number;
  117971. tessellation?: number;
  117972. updatable?: boolean;
  117973. sideOrientation?: number;
  117974. frontUVs?: Vector4;
  117975. backUVs?: Vector4;
  117976. }, scene?: Nullable<Scene>): Mesh;
  117977. /**
  117978. * Creates a torus knot mesh
  117979. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  117980. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  117981. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  117982. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  117983. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117984. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117986. * @param name defines the name of the mesh
  117987. * @param options defines the options used to create the mesh
  117988. * @param scene defines the hosting scene
  117989. * @returns the torus knot mesh
  117990. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  117991. */
  117992. static CreateTorusKnot(name: string, options: {
  117993. radius?: number;
  117994. tube?: number;
  117995. radialSegments?: number;
  117996. tubularSegments?: number;
  117997. p?: number;
  117998. q?: number;
  117999. updatable?: boolean;
  118000. sideOrientation?: number;
  118001. frontUVs?: Vector4;
  118002. backUVs?: Vector4;
  118003. }, scene?: Nullable<Scene>): Mesh;
  118004. /**
  118005. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  118006. * * 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
  118007. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  118008. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  118009. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  118010. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  118011. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  118012. * * 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
  118013. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  118014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118015. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  118016. * @param name defines the name of the new line system
  118017. * @param options defines the options used to create the line system
  118018. * @param scene defines the hosting scene
  118019. * @returns a new line system mesh
  118020. */
  118021. static CreateLineSystem(name: string, options: {
  118022. lines: Vector3[][];
  118023. updatable?: boolean;
  118024. instance?: Nullable<LinesMesh>;
  118025. colors?: Nullable<Color4[][]>;
  118026. useVertexAlpha?: boolean;
  118027. }, scene: Nullable<Scene>): LinesMesh;
  118028. /**
  118029. * Creates a line mesh
  118030. * 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
  118031. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118032. * * The parameter `points` is an array successive Vector3
  118033. * * 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
  118034. * * The optional parameter `colors` is an array of successive Color4, one per line point
  118035. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  118036. * * When updating an instance, remember that only point positions can change, not the number of points
  118037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118038. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  118039. * @param name defines the name of the new line system
  118040. * @param options defines the options used to create the line system
  118041. * @param scene defines the hosting scene
  118042. * @returns a new line mesh
  118043. */
  118044. static CreateLines(name: string, options: {
  118045. points: Vector3[];
  118046. updatable?: boolean;
  118047. instance?: Nullable<LinesMesh>;
  118048. colors?: Color4[];
  118049. useVertexAlpha?: boolean;
  118050. }, scene?: Nullable<Scene>): LinesMesh;
  118051. /**
  118052. * Creates a dashed line mesh
  118053. * * 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
  118054. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118055. * * The parameter `points` is an array successive Vector3
  118056. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  118057. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  118058. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  118059. * * 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
  118060. * * When updating an instance, remember that only point positions can change, not the number of points
  118061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118062. * @param name defines the name of the mesh
  118063. * @param options defines the options used to create the mesh
  118064. * @param scene defines the hosting scene
  118065. * @returns the dashed line mesh
  118066. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  118067. */
  118068. static CreateDashedLines(name: string, options: {
  118069. points: Vector3[];
  118070. dashSize?: number;
  118071. gapSize?: number;
  118072. dashNb?: number;
  118073. updatable?: boolean;
  118074. instance?: LinesMesh;
  118075. }, scene?: Nullable<Scene>): LinesMesh;
  118076. /**
  118077. * 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.
  118078. * * 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.
  118079. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  118080. * * 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.
  118081. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  118082. * * 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
  118083. * * 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
  118084. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  118085. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118086. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118087. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  118088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118089. * @param name defines the name of the mesh
  118090. * @param options defines the options used to create the mesh
  118091. * @param scene defines the hosting scene
  118092. * @returns the extruded shape mesh
  118093. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118094. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118095. */
  118096. static ExtrudeShape(name: string, options: {
  118097. shape: Vector3[];
  118098. path: Vector3[];
  118099. scale?: number;
  118100. rotation?: number;
  118101. cap?: number;
  118102. updatable?: boolean;
  118103. sideOrientation?: number;
  118104. frontUVs?: Vector4;
  118105. backUVs?: Vector4;
  118106. instance?: Mesh;
  118107. invertUV?: boolean;
  118108. }, scene?: Nullable<Scene>): Mesh;
  118109. /**
  118110. * Creates an custom extruded shape mesh.
  118111. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  118112. * * 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.
  118113. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  118114. * * 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
  118115. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  118116. * * 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
  118117. * * It must returns a float value that will be the scale value applied to the shape on each path point
  118118. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  118119. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  118120. * * 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
  118121. * * 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
  118122. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  118123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118124. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118125. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118127. * @param name defines the name of the mesh
  118128. * @param options defines the options used to create the mesh
  118129. * @param scene defines the hosting scene
  118130. * @returns the custom extruded shape mesh
  118131. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  118132. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118133. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118134. */
  118135. static ExtrudeShapeCustom(name: string, options: {
  118136. shape: Vector3[];
  118137. path: Vector3[];
  118138. scaleFunction?: any;
  118139. rotationFunction?: any;
  118140. ribbonCloseArray?: boolean;
  118141. ribbonClosePath?: boolean;
  118142. cap?: number;
  118143. updatable?: boolean;
  118144. sideOrientation?: number;
  118145. frontUVs?: Vector4;
  118146. backUVs?: Vector4;
  118147. instance?: Mesh;
  118148. invertUV?: boolean;
  118149. }, scene?: Nullable<Scene>): Mesh;
  118150. /**
  118151. * Creates lathe mesh.
  118152. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  118153. * * 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
  118154. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  118155. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  118156. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  118157. * * 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
  118158. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  118159. * * 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
  118160. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118161. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118162. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118164. * @param name defines the name of the mesh
  118165. * @param options defines the options used to create the mesh
  118166. * @param scene defines the hosting scene
  118167. * @returns the lathe mesh
  118168. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  118169. */
  118170. static CreateLathe(name: string, options: {
  118171. shape: Vector3[];
  118172. radius?: number;
  118173. tessellation?: number;
  118174. clip?: number;
  118175. arc?: number;
  118176. closed?: boolean;
  118177. updatable?: boolean;
  118178. sideOrientation?: number;
  118179. frontUVs?: Vector4;
  118180. backUVs?: Vector4;
  118181. cap?: number;
  118182. invertUV?: boolean;
  118183. }, scene?: Nullable<Scene>): Mesh;
  118184. /**
  118185. * Creates a tiled plane mesh
  118186. * * You can set a limited pattern arrangement with the tiles
  118187. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118188. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118190. * @param name defines the name of the mesh
  118191. * @param options defines the options used to create the mesh
  118192. * @param scene defines the hosting scene
  118193. * @returns the plane mesh
  118194. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  118195. */
  118196. static CreateTiledPlane(name: string, options: {
  118197. pattern?: number;
  118198. tileSize?: number;
  118199. tileWidth?: number;
  118200. tileHeight?: number;
  118201. size?: number;
  118202. width?: number;
  118203. height?: number;
  118204. alignHorizontal?: number;
  118205. alignVertical?: number;
  118206. sideOrientation?: number;
  118207. frontUVs?: Vector4;
  118208. backUVs?: Vector4;
  118209. updatable?: boolean;
  118210. }, scene?: Nullable<Scene>): Mesh;
  118211. /**
  118212. * Creates a plane mesh
  118213. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  118214. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  118215. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  118216. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118217. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118219. * @param name defines the name of the mesh
  118220. * @param options defines the options used to create the mesh
  118221. * @param scene defines the hosting scene
  118222. * @returns the plane mesh
  118223. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  118224. */
  118225. static CreatePlane(name: string, options: {
  118226. size?: number;
  118227. width?: number;
  118228. height?: number;
  118229. sideOrientation?: number;
  118230. frontUVs?: Vector4;
  118231. backUVs?: Vector4;
  118232. updatable?: boolean;
  118233. sourcePlane?: Plane;
  118234. }, scene?: Nullable<Scene>): Mesh;
  118235. /**
  118236. * Creates a ground mesh
  118237. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  118238. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  118239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118240. * @param name defines the name of the mesh
  118241. * @param options defines the options used to create the mesh
  118242. * @param scene defines the hosting scene
  118243. * @returns the ground mesh
  118244. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  118245. */
  118246. static CreateGround(name: string, options: {
  118247. width?: number;
  118248. height?: number;
  118249. subdivisions?: number;
  118250. subdivisionsX?: number;
  118251. subdivisionsY?: number;
  118252. updatable?: boolean;
  118253. }, scene?: Nullable<Scene>): Mesh;
  118254. /**
  118255. * Creates a tiled ground mesh
  118256. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  118257. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  118258. * * 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
  118259. * * 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
  118260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118261. * @param name defines the name of the mesh
  118262. * @param options defines the options used to create the mesh
  118263. * @param scene defines the hosting scene
  118264. * @returns the tiled ground mesh
  118265. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  118266. */
  118267. static CreateTiledGround(name: string, options: {
  118268. xmin: number;
  118269. zmin: number;
  118270. xmax: number;
  118271. zmax: number;
  118272. subdivisions?: {
  118273. w: number;
  118274. h: number;
  118275. };
  118276. precision?: {
  118277. w: number;
  118278. h: number;
  118279. };
  118280. updatable?: boolean;
  118281. }, scene?: Nullable<Scene>): Mesh;
  118282. /**
  118283. * Creates a ground mesh from a height map
  118284. * * The parameter `url` sets the URL of the height map image resource.
  118285. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  118286. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  118287. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  118288. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  118289. * * 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.
  118290. * * 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).
  118291. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  118292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118293. * @param name defines the name of the mesh
  118294. * @param url defines the url to the height map
  118295. * @param options defines the options used to create the mesh
  118296. * @param scene defines the hosting scene
  118297. * @returns the ground mesh
  118298. * @see https://doc.babylonjs.com/babylon101/height_map
  118299. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  118300. */
  118301. static CreateGroundFromHeightMap(name: string, url: string, options: {
  118302. width?: number;
  118303. height?: number;
  118304. subdivisions?: number;
  118305. minHeight?: number;
  118306. maxHeight?: number;
  118307. colorFilter?: Color3;
  118308. alphaFilter?: number;
  118309. updatable?: boolean;
  118310. onReady?: (mesh: GroundMesh) => void;
  118311. }, scene?: Nullable<Scene>): GroundMesh;
  118312. /**
  118313. * Creates a polygon mesh
  118314. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  118315. * * 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
  118316. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118318. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  118319. * * Remember you can only change the shape positions, not their number when updating a polygon
  118320. * @param name defines the name of the mesh
  118321. * @param options defines the options used to create the mesh
  118322. * @param scene defines the hosting scene
  118323. * @param earcutInjection can be used to inject your own earcut reference
  118324. * @returns the polygon mesh
  118325. */
  118326. static CreatePolygon(name: string, options: {
  118327. shape: Vector3[];
  118328. holes?: Vector3[][];
  118329. depth?: number;
  118330. faceUV?: Vector4[];
  118331. faceColors?: Color4[];
  118332. updatable?: boolean;
  118333. sideOrientation?: number;
  118334. frontUVs?: Vector4;
  118335. backUVs?: Vector4;
  118336. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  118337. /**
  118338. * Creates an extruded polygon mesh, with depth in the Y direction.
  118339. * * 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)
  118340. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  118341. * @param name defines the name of the mesh
  118342. * @param options defines the options used to create the mesh
  118343. * @param scene defines the hosting scene
  118344. * @param earcutInjection can be used to inject your own earcut reference
  118345. * @returns the polygon mesh
  118346. */
  118347. static ExtrudePolygon(name: string, options: {
  118348. shape: Vector3[];
  118349. holes?: Vector3[][];
  118350. depth?: number;
  118351. faceUV?: Vector4[];
  118352. faceColors?: Color4[];
  118353. updatable?: boolean;
  118354. sideOrientation?: number;
  118355. frontUVs?: Vector4;
  118356. backUVs?: Vector4;
  118357. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  118358. /**
  118359. * Creates a tube mesh.
  118360. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  118361. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  118362. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  118363. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  118364. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  118365. * * 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)
  118366. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  118367. * * 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
  118368. * * 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
  118369. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118370. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118371. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118373. * @param name defines the name of the mesh
  118374. * @param options defines the options used to create the mesh
  118375. * @param scene defines the hosting scene
  118376. * @returns the tube mesh
  118377. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118378. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  118379. */
  118380. static CreateTube(name: string, options: {
  118381. path: Vector3[];
  118382. radius?: number;
  118383. tessellation?: number;
  118384. radiusFunction?: {
  118385. (i: number, distance: number): number;
  118386. };
  118387. cap?: number;
  118388. arc?: number;
  118389. updatable?: boolean;
  118390. sideOrientation?: number;
  118391. frontUVs?: Vector4;
  118392. backUVs?: Vector4;
  118393. instance?: Mesh;
  118394. invertUV?: boolean;
  118395. }, scene?: Nullable<Scene>): Mesh;
  118396. /**
  118397. * Creates a polyhedron mesh
  118398. * * 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
  118399. * * The parameter `size` (positive float, default 1) sets the polygon size
  118400. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  118401. * * 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`
  118402. * * 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
  118403. * * 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)`)
  118404. * * 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
  118405. * * 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
  118406. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118407. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118409. * @param name defines the name of the mesh
  118410. * @param options defines the options used to create the mesh
  118411. * @param scene defines the hosting scene
  118412. * @returns the polyhedron mesh
  118413. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  118414. */
  118415. static CreatePolyhedron(name: string, options: {
  118416. type?: number;
  118417. size?: number;
  118418. sizeX?: number;
  118419. sizeY?: number;
  118420. sizeZ?: number;
  118421. custom?: any;
  118422. faceUV?: Vector4[];
  118423. faceColors?: Color4[];
  118424. flat?: boolean;
  118425. updatable?: boolean;
  118426. sideOrientation?: number;
  118427. frontUVs?: Vector4;
  118428. backUVs?: Vector4;
  118429. }, scene?: Nullable<Scene>): Mesh;
  118430. /**
  118431. * Creates a decal mesh.
  118432. * 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
  118433. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  118434. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  118435. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  118436. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  118437. * @param name defines the name of the mesh
  118438. * @param sourceMesh defines the mesh where the decal must be applied
  118439. * @param options defines the options used to create the mesh
  118440. * @param scene defines the hosting scene
  118441. * @returns the decal mesh
  118442. * @see https://doc.babylonjs.com/how_to/decals
  118443. */
  118444. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  118445. position?: Vector3;
  118446. normal?: Vector3;
  118447. size?: Vector3;
  118448. angle?: number;
  118449. }): Mesh;
  118450. }
  118451. }
  118452. declare module BABYLON {
  118453. /**
  118454. * A simplifier interface for future simplification implementations
  118455. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118456. */
  118457. export interface ISimplifier {
  118458. /**
  118459. * Simplification of a given mesh according to the given settings.
  118460. * Since this requires computation, it is assumed that the function runs async.
  118461. * @param settings The settings of the simplification, including quality and distance
  118462. * @param successCallback A callback that will be called after the mesh was simplified.
  118463. * @param errorCallback in case of an error, this callback will be called. optional.
  118464. */
  118465. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  118466. }
  118467. /**
  118468. * Expected simplification settings.
  118469. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  118470. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118471. */
  118472. export interface ISimplificationSettings {
  118473. /**
  118474. * Gets or sets the expected quality
  118475. */
  118476. quality: number;
  118477. /**
  118478. * Gets or sets the distance when this optimized version should be used
  118479. */
  118480. distance: number;
  118481. /**
  118482. * Gets an already optimized mesh
  118483. */
  118484. optimizeMesh?: boolean;
  118485. }
  118486. /**
  118487. * Class used to specify simplification options
  118488. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118489. */
  118490. export class SimplificationSettings implements ISimplificationSettings {
  118491. /** expected quality */
  118492. quality: number;
  118493. /** distance when this optimized version should be used */
  118494. distance: number;
  118495. /** already optimized mesh */
  118496. optimizeMesh?: boolean | undefined;
  118497. /**
  118498. * Creates a SimplificationSettings
  118499. * @param quality expected quality
  118500. * @param distance distance when this optimized version should be used
  118501. * @param optimizeMesh already optimized mesh
  118502. */
  118503. constructor(
  118504. /** expected quality */
  118505. quality: number,
  118506. /** distance when this optimized version should be used */
  118507. distance: number,
  118508. /** already optimized mesh */
  118509. optimizeMesh?: boolean | undefined);
  118510. }
  118511. /**
  118512. * Interface used to define a simplification task
  118513. */
  118514. export interface ISimplificationTask {
  118515. /**
  118516. * Array of settings
  118517. */
  118518. settings: Array<ISimplificationSettings>;
  118519. /**
  118520. * Simplification type
  118521. */
  118522. simplificationType: SimplificationType;
  118523. /**
  118524. * Mesh to simplify
  118525. */
  118526. mesh: Mesh;
  118527. /**
  118528. * Callback called on success
  118529. */
  118530. successCallback?: () => void;
  118531. /**
  118532. * Defines if parallel processing can be used
  118533. */
  118534. parallelProcessing: boolean;
  118535. }
  118536. /**
  118537. * Queue used to order the simplification tasks
  118538. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118539. */
  118540. export class SimplificationQueue {
  118541. private _simplificationArray;
  118542. /**
  118543. * Gets a boolean indicating that the process is still running
  118544. */
  118545. running: boolean;
  118546. /**
  118547. * Creates a new queue
  118548. */
  118549. constructor();
  118550. /**
  118551. * Adds a new simplification task
  118552. * @param task defines a task to add
  118553. */
  118554. addTask(task: ISimplificationTask): void;
  118555. /**
  118556. * Execute next task
  118557. */
  118558. executeNext(): void;
  118559. /**
  118560. * Execute a simplification task
  118561. * @param task defines the task to run
  118562. */
  118563. runSimplification(task: ISimplificationTask): void;
  118564. private getSimplifier;
  118565. }
  118566. /**
  118567. * The implemented types of simplification
  118568. * At the moment only Quadratic Error Decimation is implemented
  118569. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118570. */
  118571. export enum SimplificationType {
  118572. /** Quadratic error decimation */
  118573. QUADRATIC = 0
  118574. }
  118575. }
  118576. declare module BABYLON {
  118577. interface Scene {
  118578. /** @hidden (Backing field) */
  118579. _simplificationQueue: SimplificationQueue;
  118580. /**
  118581. * Gets or sets the simplification queue attached to the scene
  118582. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118583. */
  118584. simplificationQueue: SimplificationQueue;
  118585. }
  118586. interface Mesh {
  118587. /**
  118588. * Simplify the mesh according to the given array of settings.
  118589. * Function will return immediately and will simplify async
  118590. * @param settings a collection of simplification settings
  118591. * @param parallelProcessing should all levels calculate parallel or one after the other
  118592. * @param simplificationType the type of simplification to run
  118593. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  118594. * @returns the current mesh
  118595. */
  118596. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  118597. }
  118598. /**
  118599. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  118600. * created in a scene
  118601. */
  118602. export class SimplicationQueueSceneComponent implements ISceneComponent {
  118603. /**
  118604. * The component name helpfull to identify the component in the list of scene components.
  118605. */
  118606. readonly name: string;
  118607. /**
  118608. * The scene the component belongs to.
  118609. */
  118610. scene: Scene;
  118611. /**
  118612. * Creates a new instance of the component for the given scene
  118613. * @param scene Defines the scene to register the component in
  118614. */
  118615. constructor(scene: Scene);
  118616. /**
  118617. * Registers the component in a given scene
  118618. */
  118619. register(): void;
  118620. /**
  118621. * Rebuilds the elements related to this component in case of
  118622. * context lost for instance.
  118623. */
  118624. rebuild(): void;
  118625. /**
  118626. * Disposes the component and the associated ressources
  118627. */
  118628. dispose(): void;
  118629. private _beforeCameraUpdate;
  118630. }
  118631. }
  118632. declare module BABYLON {
  118633. /**
  118634. * Navigation plugin interface to add navigation constrained by a navigation mesh
  118635. */
  118636. export interface INavigationEnginePlugin {
  118637. /**
  118638. * plugin name
  118639. */
  118640. name: string;
  118641. /**
  118642. * Creates a navigation mesh
  118643. * @param meshes array of all the geometry used to compute the navigatio mesh
  118644. * @param parameters bunch of parameters used to filter geometry
  118645. */
  118646. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  118647. /**
  118648. * Create a navigation mesh debug mesh
  118649. * @param scene is where the mesh will be added
  118650. * @returns debug display mesh
  118651. */
  118652. createDebugNavMesh(scene: Scene): Mesh;
  118653. /**
  118654. * Get a navigation mesh constrained position, closest to the parameter position
  118655. * @param position world position
  118656. * @returns the closest point to position constrained by the navigation mesh
  118657. */
  118658. getClosestPoint(position: Vector3): Vector3;
  118659. /**
  118660. * Get a navigation mesh constrained position, within a particular radius
  118661. * @param position world position
  118662. * @param maxRadius the maximum distance to the constrained world position
  118663. * @returns the closest point to position constrained by the navigation mesh
  118664. */
  118665. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  118666. /**
  118667. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  118668. * @param start world position
  118669. * @param end world position
  118670. * @returns array containing world position composing the path
  118671. */
  118672. computePath(start: Vector3, end: Vector3): Vector3[];
  118673. /**
  118674. * If this plugin is supported
  118675. * @returns true if plugin is supported
  118676. */
  118677. isSupported(): boolean;
  118678. /**
  118679. * Create a new Crowd so you can add agents
  118680. * @param maxAgents the maximum agent count in the crowd
  118681. * @param maxAgentRadius the maximum radius an agent can have
  118682. * @param scene to attach the crowd to
  118683. * @returns the crowd you can add agents to
  118684. */
  118685. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  118686. /**
  118687. * Release all resources
  118688. */
  118689. dispose(): void;
  118690. }
  118691. /**
  118692. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  118693. */
  118694. export interface ICrowd {
  118695. /**
  118696. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  118697. * You can attach anything to that node. The node position is updated in the scene update tick.
  118698. * @param pos world position that will be constrained by the navigation mesh
  118699. * @param parameters agent parameters
  118700. * @param transform hooked to the agent that will be update by the scene
  118701. * @returns agent index
  118702. */
  118703. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  118704. /**
  118705. * Returns the agent position in world space
  118706. * @param index agent index returned by addAgent
  118707. * @returns world space position
  118708. */
  118709. getAgentPosition(index: number): Vector3;
  118710. /**
  118711. * Gets the agent velocity in world space
  118712. * @param index agent index returned by addAgent
  118713. * @returns world space velocity
  118714. */
  118715. getAgentVelocity(index: number): Vector3;
  118716. /**
  118717. * remove a particular agent previously created
  118718. * @param index agent index returned by addAgent
  118719. */
  118720. removeAgent(index: number): void;
  118721. /**
  118722. * get the list of all agents attached to this crowd
  118723. * @returns list of agent indices
  118724. */
  118725. getAgents(): number[];
  118726. /**
  118727. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  118728. * @param deltaTime in seconds
  118729. */
  118730. update(deltaTime: number): void;
  118731. /**
  118732. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  118733. * @param index agent index returned by addAgent
  118734. * @param destination targeted world position
  118735. */
  118736. agentGoto(index: number, destination: Vector3): void;
  118737. /**
  118738. * Release all resources
  118739. */
  118740. dispose(): void;
  118741. }
  118742. /**
  118743. * Configures an agent
  118744. */
  118745. export interface IAgentParameters {
  118746. /**
  118747. * Agent radius. [Limit: >= 0]
  118748. */
  118749. radius: number;
  118750. /**
  118751. * Agent height. [Limit: > 0]
  118752. */
  118753. height: number;
  118754. /**
  118755. * Maximum allowed acceleration. [Limit: >= 0]
  118756. */
  118757. maxAcceleration: number;
  118758. /**
  118759. * Maximum allowed speed. [Limit: >= 0]
  118760. */
  118761. maxSpeed: number;
  118762. /**
  118763. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  118764. */
  118765. collisionQueryRange: number;
  118766. /**
  118767. * The path visibility optimization range. [Limit: > 0]
  118768. */
  118769. pathOptimizationRange: number;
  118770. /**
  118771. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  118772. */
  118773. separationWeight: number;
  118774. }
  118775. /**
  118776. * Configures the navigation mesh creation
  118777. */
  118778. export interface INavMeshParameters {
  118779. /**
  118780. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  118781. */
  118782. cs: number;
  118783. /**
  118784. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  118785. */
  118786. ch: number;
  118787. /**
  118788. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  118789. */
  118790. walkableSlopeAngle: number;
  118791. /**
  118792. * Minimum floor to 'ceiling' height that will still allow the floor area to
  118793. * be considered walkable. [Limit: >= 3] [Units: vx]
  118794. */
  118795. walkableHeight: number;
  118796. /**
  118797. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  118798. */
  118799. walkableClimb: number;
  118800. /**
  118801. * The distance to erode/shrink the walkable area of the heightfield away from
  118802. * obstructions. [Limit: >=0] [Units: vx]
  118803. */
  118804. walkableRadius: number;
  118805. /**
  118806. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  118807. */
  118808. maxEdgeLen: number;
  118809. /**
  118810. * The maximum distance a simplfied contour's border edges should deviate
  118811. * the original raw contour. [Limit: >=0] [Units: vx]
  118812. */
  118813. maxSimplificationError: number;
  118814. /**
  118815. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  118816. */
  118817. minRegionArea: number;
  118818. /**
  118819. * Any regions with a span count smaller than this value will, if possible,
  118820. * be merged with larger regions. [Limit: >=0] [Units: vx]
  118821. */
  118822. mergeRegionArea: number;
  118823. /**
  118824. * The maximum number of vertices allowed for polygons generated during the
  118825. * contour to polygon conversion process. [Limit: >= 3]
  118826. */
  118827. maxVertsPerPoly: number;
  118828. /**
  118829. * Sets the sampling distance to use when generating the detail mesh.
  118830. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  118831. */
  118832. detailSampleDist: number;
  118833. /**
  118834. * The maximum distance the detail mesh surface should deviate from heightfield
  118835. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  118836. */
  118837. detailSampleMaxError: number;
  118838. }
  118839. }
  118840. declare module BABYLON {
  118841. /**
  118842. * RecastJS navigation plugin
  118843. */
  118844. export class RecastJSPlugin implements INavigationEnginePlugin {
  118845. /**
  118846. * Reference to the Recast library
  118847. */
  118848. bjsRECAST: any;
  118849. /**
  118850. * plugin name
  118851. */
  118852. name: string;
  118853. /**
  118854. * the first navmesh created. We might extend this to support multiple navmeshes
  118855. */
  118856. navMesh: any;
  118857. /**
  118858. * Initializes the recastJS plugin
  118859. * @param recastInjection can be used to inject your own recast reference
  118860. */
  118861. constructor(recastInjection?: any);
  118862. /**
  118863. * Creates a navigation mesh
  118864. * @param meshes array of all the geometry used to compute the navigatio mesh
  118865. * @param parameters bunch of parameters used to filter geometry
  118866. */
  118867. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  118868. /**
  118869. * Create a navigation mesh debug mesh
  118870. * @param scene is where the mesh will be added
  118871. * @returns debug display mesh
  118872. */
  118873. createDebugNavMesh(scene: Scene): Mesh;
  118874. /**
  118875. * Get a navigation mesh constrained position, closest to the parameter position
  118876. * @param position world position
  118877. * @returns the closest point to position constrained by the navigation mesh
  118878. */
  118879. getClosestPoint(position: Vector3): Vector3;
  118880. /**
  118881. * Get a navigation mesh constrained position, within a particular radius
  118882. * @param position world position
  118883. * @param maxRadius the maximum distance to the constrained world position
  118884. * @returns the closest point to position constrained by the navigation mesh
  118885. */
  118886. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  118887. /**
  118888. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  118889. * @param start world position
  118890. * @param end world position
  118891. * @returns array containing world position composing the path
  118892. */
  118893. computePath(start: Vector3, end: Vector3): Vector3[];
  118894. /**
  118895. * Create a new Crowd so you can add agents
  118896. * @param maxAgents the maximum agent count in the crowd
  118897. * @param maxAgentRadius the maximum radius an agent can have
  118898. * @param scene to attach the crowd to
  118899. * @returns the crowd you can add agents to
  118900. */
  118901. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  118902. /**
  118903. * Disposes
  118904. */
  118905. dispose(): void;
  118906. /**
  118907. * If this plugin is supported
  118908. * @returns true if plugin is supported
  118909. */
  118910. isSupported(): boolean;
  118911. }
  118912. /**
  118913. * Recast detour crowd implementation
  118914. */
  118915. export class RecastJSCrowd implements ICrowd {
  118916. /**
  118917. * Recast/detour plugin
  118918. */
  118919. bjsRECASTPlugin: RecastJSPlugin;
  118920. /**
  118921. * Link to the detour crowd
  118922. */
  118923. recastCrowd: any;
  118924. /**
  118925. * One transform per agent
  118926. */
  118927. transforms: TransformNode[];
  118928. /**
  118929. * All agents created
  118930. */
  118931. agents: number[];
  118932. /**
  118933. * Link to the scene is kept to unregister the crowd from the scene
  118934. */
  118935. private _scene;
  118936. /**
  118937. * Observer for crowd updates
  118938. */
  118939. private _onBeforeAnimationsObserver;
  118940. /**
  118941. * Constructor
  118942. * @param plugin recastJS plugin
  118943. * @param maxAgents the maximum agent count in the crowd
  118944. * @param maxAgentRadius the maximum radius an agent can have
  118945. * @param scene to attach the crowd to
  118946. * @returns the crowd you can add agents to
  118947. */
  118948. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  118949. /**
  118950. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  118951. * You can attach anything to that node. The node position is updated in the scene update tick.
  118952. * @param pos world position that will be constrained by the navigation mesh
  118953. * @param parameters agent parameters
  118954. * @param transform hooked to the agent that will be update by the scene
  118955. * @returns agent index
  118956. */
  118957. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  118958. /**
  118959. * Returns the agent position in world space
  118960. * @param index agent index returned by addAgent
  118961. * @returns world space position
  118962. */
  118963. getAgentPosition(index: number): Vector3;
  118964. /**
  118965. * Returns the agent velocity in world space
  118966. * @param index agent index returned by addAgent
  118967. * @returns world space velocity
  118968. */
  118969. getAgentVelocity(index: number): Vector3;
  118970. /**
  118971. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  118972. * @param index agent index returned by addAgent
  118973. * @param destination targeted world position
  118974. */
  118975. agentGoto(index: number, destination: Vector3): void;
  118976. /**
  118977. * remove a particular agent previously created
  118978. * @param index agent index returned by addAgent
  118979. */
  118980. removeAgent(index: number): void;
  118981. /**
  118982. * get the list of all agents attached to this crowd
  118983. * @returns list of agent indices
  118984. */
  118985. getAgents(): number[];
  118986. /**
  118987. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  118988. * @param deltaTime in seconds
  118989. */
  118990. update(deltaTime: number): void;
  118991. /**
  118992. * Release all resources
  118993. */
  118994. dispose(): void;
  118995. }
  118996. }
  118997. declare module BABYLON {
  118998. /**
  118999. * Class used to enable access to IndexedDB
  119000. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  119001. */
  119002. export class Database implements IOfflineProvider {
  119003. private _callbackManifestChecked;
  119004. private _currentSceneUrl;
  119005. private _db;
  119006. private _enableSceneOffline;
  119007. private _enableTexturesOffline;
  119008. private _manifestVersionFound;
  119009. private _mustUpdateRessources;
  119010. private _hasReachedQuota;
  119011. private _isSupported;
  119012. private _idbFactory;
  119013. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  119014. private static IsUASupportingBlobStorage;
  119015. /**
  119016. * Gets a boolean indicating if Database storate is enabled (off by default)
  119017. */
  119018. static IDBStorageEnabled: boolean;
  119019. /**
  119020. * Gets a boolean indicating if scene must be saved in the database
  119021. */
  119022. readonly enableSceneOffline: boolean;
  119023. /**
  119024. * Gets a boolean indicating if textures must be saved in the database
  119025. */
  119026. readonly enableTexturesOffline: boolean;
  119027. /**
  119028. * Creates a new Database
  119029. * @param urlToScene defines the url to load the scene
  119030. * @param callbackManifestChecked defines the callback to use when manifest is checked
  119031. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  119032. */
  119033. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  119034. private static _ParseURL;
  119035. private static _ReturnFullUrlLocation;
  119036. private _checkManifestFile;
  119037. /**
  119038. * Open the database and make it available
  119039. * @param successCallback defines the callback to call on success
  119040. * @param errorCallback defines the callback to call on error
  119041. */
  119042. open(successCallback: () => void, errorCallback: () => void): void;
  119043. /**
  119044. * Loads an image from the database
  119045. * @param url defines the url to load from
  119046. * @param image defines the target DOM image
  119047. */
  119048. loadImage(url: string, image: HTMLImageElement): void;
  119049. private _loadImageFromDBAsync;
  119050. private _saveImageIntoDBAsync;
  119051. private _checkVersionFromDB;
  119052. private _loadVersionFromDBAsync;
  119053. private _saveVersionIntoDBAsync;
  119054. /**
  119055. * Loads a file from database
  119056. * @param url defines the URL to load from
  119057. * @param sceneLoaded defines a callback to call on success
  119058. * @param progressCallBack defines a callback to call when progress changed
  119059. * @param errorCallback defines a callback to call on error
  119060. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  119061. */
  119062. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  119063. private _loadFileAsync;
  119064. private _saveFileAsync;
  119065. /**
  119066. * Validates if xhr data is correct
  119067. * @param xhr defines the request to validate
  119068. * @param dataType defines the expected data type
  119069. * @returns true if data is correct
  119070. */
  119071. private static _ValidateXHRData;
  119072. }
  119073. }
  119074. declare module BABYLON {
  119075. /** @hidden */
  119076. export var gpuUpdateParticlesPixelShader: {
  119077. name: string;
  119078. shader: string;
  119079. };
  119080. }
  119081. declare module BABYLON {
  119082. /** @hidden */
  119083. export var gpuUpdateParticlesVertexShader: {
  119084. name: string;
  119085. shader: string;
  119086. };
  119087. }
  119088. declare module BABYLON {
  119089. /** @hidden */
  119090. export var clipPlaneFragmentDeclaration2: {
  119091. name: string;
  119092. shader: string;
  119093. };
  119094. }
  119095. declare module BABYLON {
  119096. /** @hidden */
  119097. export var gpuRenderParticlesPixelShader: {
  119098. name: string;
  119099. shader: string;
  119100. };
  119101. }
  119102. declare module BABYLON {
  119103. /** @hidden */
  119104. export var clipPlaneVertexDeclaration2: {
  119105. name: string;
  119106. shader: string;
  119107. };
  119108. }
  119109. declare module BABYLON {
  119110. /** @hidden */
  119111. export var gpuRenderParticlesVertexShader: {
  119112. name: string;
  119113. shader: string;
  119114. };
  119115. }
  119116. declare module BABYLON {
  119117. /**
  119118. * This represents a GPU particle system in Babylon
  119119. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  119120. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  119121. */
  119122. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  119123. /**
  119124. * The layer mask we are rendering the particles through.
  119125. */
  119126. layerMask: number;
  119127. private _capacity;
  119128. private _activeCount;
  119129. private _currentActiveCount;
  119130. private _accumulatedCount;
  119131. private _renderEffect;
  119132. private _updateEffect;
  119133. private _buffer0;
  119134. private _buffer1;
  119135. private _spriteBuffer;
  119136. private _updateVAO;
  119137. private _renderVAO;
  119138. private _targetIndex;
  119139. private _sourceBuffer;
  119140. private _targetBuffer;
  119141. private _engine;
  119142. private _currentRenderId;
  119143. private _started;
  119144. private _stopped;
  119145. private _timeDelta;
  119146. private _randomTexture;
  119147. private _randomTexture2;
  119148. private _attributesStrideSize;
  119149. private _updateEffectOptions;
  119150. private _randomTextureSize;
  119151. private _actualFrame;
  119152. private readonly _rawTextureWidth;
  119153. /**
  119154. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  119155. */
  119156. static readonly IsSupported: boolean;
  119157. /**
  119158. * An event triggered when the system is disposed.
  119159. */
  119160. onDisposeObservable: Observable<GPUParticleSystem>;
  119161. /**
  119162. * Gets the maximum number of particles active at the same time.
  119163. * @returns The max number of active particles.
  119164. */
  119165. getCapacity(): number;
  119166. /**
  119167. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  119168. * to override the particles.
  119169. */
  119170. forceDepthWrite: boolean;
  119171. /**
  119172. * Gets or set the number of active particles
  119173. */
  119174. activeParticleCount: number;
  119175. private _preWarmDone;
  119176. /**
  119177. * Is this system ready to be used/rendered
  119178. * @return true if the system is ready
  119179. */
  119180. isReady(): boolean;
  119181. /**
  119182. * Gets if the system has been started. (Note: this will still be true after stop is called)
  119183. * @returns True if it has been started, otherwise false.
  119184. */
  119185. isStarted(): boolean;
  119186. /**
  119187. * Starts the particle system and begins to emit
  119188. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  119189. */
  119190. start(delay?: number): void;
  119191. /**
  119192. * Stops the particle system.
  119193. */
  119194. stop(): void;
  119195. /**
  119196. * Remove all active particles
  119197. */
  119198. reset(): void;
  119199. /**
  119200. * Returns the string "GPUParticleSystem"
  119201. * @returns a string containing the class name
  119202. */
  119203. getClassName(): string;
  119204. private _colorGradientsTexture;
  119205. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  119206. /**
  119207. * Adds a new color gradient
  119208. * @param gradient defines the gradient to use (between 0 and 1)
  119209. * @param color1 defines the color to affect to the specified gradient
  119210. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  119211. * @returns the current particle system
  119212. */
  119213. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  119214. /**
  119215. * Remove a specific color gradient
  119216. * @param gradient defines the gradient to remove
  119217. * @returns the current particle system
  119218. */
  119219. removeColorGradient(gradient: number): GPUParticleSystem;
  119220. private _angularSpeedGradientsTexture;
  119221. private _sizeGradientsTexture;
  119222. private _velocityGradientsTexture;
  119223. private _limitVelocityGradientsTexture;
  119224. private _dragGradientsTexture;
  119225. private _addFactorGradient;
  119226. /**
  119227. * Adds a new size gradient
  119228. * @param gradient defines the gradient to use (between 0 and 1)
  119229. * @param factor defines the size factor to affect to the specified gradient
  119230. * @returns the current particle system
  119231. */
  119232. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  119233. /**
  119234. * Remove a specific size gradient
  119235. * @param gradient defines the gradient to remove
  119236. * @returns the current particle system
  119237. */
  119238. removeSizeGradient(gradient: number): GPUParticleSystem;
  119239. /**
  119240. * Adds a new angular speed gradient
  119241. * @param gradient defines the gradient to use (between 0 and 1)
  119242. * @param factor defines the angular speed to affect to the specified gradient
  119243. * @returns the current particle system
  119244. */
  119245. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  119246. /**
  119247. * Remove a specific angular speed gradient
  119248. * @param gradient defines the gradient to remove
  119249. * @returns the current particle system
  119250. */
  119251. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  119252. /**
  119253. * Adds a new velocity gradient
  119254. * @param gradient defines the gradient to use (between 0 and 1)
  119255. * @param factor defines the velocity to affect to the specified gradient
  119256. * @returns the current particle system
  119257. */
  119258. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  119259. /**
  119260. * Remove a specific velocity gradient
  119261. * @param gradient defines the gradient to remove
  119262. * @returns the current particle system
  119263. */
  119264. removeVelocityGradient(gradient: number): GPUParticleSystem;
  119265. /**
  119266. * Adds a new limit velocity gradient
  119267. * @param gradient defines the gradient to use (between 0 and 1)
  119268. * @param factor defines the limit velocity value to affect to the specified gradient
  119269. * @returns the current particle system
  119270. */
  119271. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  119272. /**
  119273. * Remove a specific limit velocity gradient
  119274. * @param gradient defines the gradient to remove
  119275. * @returns the current particle system
  119276. */
  119277. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  119278. /**
  119279. * Adds a new drag gradient
  119280. * @param gradient defines the gradient to use (between 0 and 1)
  119281. * @param factor defines the drag value to affect to the specified gradient
  119282. * @returns the current particle system
  119283. */
  119284. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  119285. /**
  119286. * Remove a specific drag gradient
  119287. * @param gradient defines the gradient to remove
  119288. * @returns the current particle system
  119289. */
  119290. removeDragGradient(gradient: number): GPUParticleSystem;
  119291. /**
  119292. * Not supported by GPUParticleSystem
  119293. * @param gradient defines the gradient to use (between 0 and 1)
  119294. * @param factor defines the emit rate value to affect to the specified gradient
  119295. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  119296. * @returns the current particle system
  119297. */
  119298. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  119299. /**
  119300. * Not supported by GPUParticleSystem
  119301. * @param gradient defines the gradient to remove
  119302. * @returns the current particle system
  119303. */
  119304. removeEmitRateGradient(gradient: number): IParticleSystem;
  119305. /**
  119306. * Not supported by GPUParticleSystem
  119307. * @param gradient defines the gradient to use (between 0 and 1)
  119308. * @param factor defines the start size value to affect to the specified gradient
  119309. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  119310. * @returns the current particle system
  119311. */
  119312. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  119313. /**
  119314. * Not supported by GPUParticleSystem
  119315. * @param gradient defines the gradient to remove
  119316. * @returns the current particle system
  119317. */
  119318. removeStartSizeGradient(gradient: number): IParticleSystem;
  119319. /**
  119320. * Not supported by GPUParticleSystem
  119321. * @param gradient defines the gradient to use (between 0 and 1)
  119322. * @param min defines the color remap minimal range
  119323. * @param max defines the color remap maximal range
  119324. * @returns the current particle system
  119325. */
  119326. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  119327. /**
  119328. * Not supported by GPUParticleSystem
  119329. * @param gradient defines the gradient to remove
  119330. * @returns the current particle system
  119331. */
  119332. removeColorRemapGradient(): IParticleSystem;
  119333. /**
  119334. * Not supported by GPUParticleSystem
  119335. * @param gradient defines the gradient to use (between 0 and 1)
  119336. * @param min defines the alpha remap minimal range
  119337. * @param max defines the alpha remap maximal range
  119338. * @returns the current particle system
  119339. */
  119340. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  119341. /**
  119342. * Not supported by GPUParticleSystem
  119343. * @param gradient defines the gradient to remove
  119344. * @returns the current particle system
  119345. */
  119346. removeAlphaRemapGradient(): IParticleSystem;
  119347. /**
  119348. * Not supported by GPUParticleSystem
  119349. * @param gradient defines the gradient to use (between 0 and 1)
  119350. * @param color defines the color to affect to the specified gradient
  119351. * @returns the current particle system
  119352. */
  119353. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  119354. /**
  119355. * Not supported by GPUParticleSystem
  119356. * @param gradient defines the gradient to remove
  119357. * @returns the current particle system
  119358. */
  119359. removeRampGradient(): IParticleSystem;
  119360. /**
  119361. * Not supported by GPUParticleSystem
  119362. * @returns the list of ramp gradients
  119363. */
  119364. getRampGradients(): Nullable<Array<Color3Gradient>>;
  119365. /**
  119366. * Not supported by GPUParticleSystem
  119367. * Gets or sets a boolean indicating that ramp gradients must be used
  119368. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  119369. */
  119370. useRampGradients: boolean;
  119371. /**
  119372. * Not supported by GPUParticleSystem
  119373. * @param gradient defines the gradient to use (between 0 and 1)
  119374. * @param factor defines the life time factor to affect to the specified gradient
  119375. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  119376. * @returns the current particle system
  119377. */
  119378. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  119379. /**
  119380. * Not supported by GPUParticleSystem
  119381. * @param gradient defines the gradient to remove
  119382. * @returns the current particle system
  119383. */
  119384. removeLifeTimeGradient(gradient: number): IParticleSystem;
  119385. /**
  119386. * Instantiates a GPU particle system.
  119387. * 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.
  119388. * @param name The name of the particle system
  119389. * @param options The options used to create the system
  119390. * @param scene The scene the particle system belongs to
  119391. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  119392. */
  119393. constructor(name: string, options: Partial<{
  119394. capacity: number;
  119395. randomTextureSize: number;
  119396. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  119397. protected _reset(): void;
  119398. private _createUpdateVAO;
  119399. private _createRenderVAO;
  119400. private _initialize;
  119401. /** @hidden */
  119402. _recreateUpdateEffect(): void;
  119403. /** @hidden */
  119404. _recreateRenderEffect(): void;
  119405. /**
  119406. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  119407. * @param preWarm defines if we are in the pre-warmimg phase
  119408. */
  119409. animate(preWarm?: boolean): void;
  119410. private _createFactorGradientTexture;
  119411. private _createSizeGradientTexture;
  119412. private _createAngularSpeedGradientTexture;
  119413. private _createVelocityGradientTexture;
  119414. private _createLimitVelocityGradientTexture;
  119415. private _createDragGradientTexture;
  119416. private _createColorGradientTexture;
  119417. /**
  119418. * Renders the particle system in its current state
  119419. * @param preWarm defines if the system should only update the particles but not render them
  119420. * @returns the current number of particles
  119421. */
  119422. render(preWarm?: boolean): number;
  119423. /**
  119424. * Rebuilds the particle system
  119425. */
  119426. rebuild(): void;
  119427. private _releaseBuffers;
  119428. private _releaseVAOs;
  119429. /**
  119430. * Disposes the particle system and free the associated resources
  119431. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  119432. */
  119433. dispose(disposeTexture?: boolean): void;
  119434. /**
  119435. * Clones the particle system.
  119436. * @param name The name of the cloned object
  119437. * @param newEmitter The new emitter to use
  119438. * @returns the cloned particle system
  119439. */
  119440. clone(name: string, newEmitter: any): GPUParticleSystem;
  119441. /**
  119442. * Serializes the particle system to a JSON object.
  119443. * @returns the JSON object
  119444. */
  119445. serialize(): any;
  119446. /**
  119447. * Parses a JSON object to create a GPU particle system.
  119448. * @param parsedParticleSystem The JSON object to parse
  119449. * @param scene The scene to create the particle system in
  119450. * @param rootUrl The root url to use to load external dependencies like texture
  119451. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  119452. * @returns the parsed GPU particle system
  119453. */
  119454. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  119455. }
  119456. }
  119457. declare module BABYLON {
  119458. /**
  119459. * Represents a set of particle systems working together to create a specific effect
  119460. */
  119461. export class ParticleSystemSet implements IDisposable {
  119462. private _emitterCreationOptions;
  119463. private _emitterNode;
  119464. /**
  119465. * Gets the particle system list
  119466. */
  119467. systems: IParticleSystem[];
  119468. /**
  119469. * Gets the emitter node used with this set
  119470. */
  119471. readonly emitterNode: Nullable<TransformNode>;
  119472. /**
  119473. * Creates a new emitter mesh as a sphere
  119474. * @param options defines the options used to create the sphere
  119475. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  119476. * @param scene defines the hosting scene
  119477. */
  119478. setEmitterAsSphere(options: {
  119479. diameter: number;
  119480. segments: number;
  119481. color: Color3;
  119482. }, renderingGroupId: number, scene: Scene): void;
  119483. /**
  119484. * Starts all particle systems of the set
  119485. * @param emitter defines an optional mesh to use as emitter for the particle systems
  119486. */
  119487. start(emitter?: AbstractMesh): void;
  119488. /**
  119489. * Release all associated resources
  119490. */
  119491. dispose(): void;
  119492. /**
  119493. * Serialize the set into a JSON compatible object
  119494. * @returns a JSON compatible representation of the set
  119495. */
  119496. serialize(): any;
  119497. /**
  119498. * Parse a new ParticleSystemSet from a serialized source
  119499. * @param data defines a JSON compatible representation of the set
  119500. * @param scene defines the hosting scene
  119501. * @param gpu defines if we want GPU particles or CPU particles
  119502. * @returns a new ParticleSystemSet
  119503. */
  119504. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  119505. }
  119506. }
  119507. declare module BABYLON {
  119508. /**
  119509. * This class is made for on one-liner static method to help creating particle system set.
  119510. */
  119511. export class ParticleHelper {
  119512. /**
  119513. * Gets or sets base Assets URL
  119514. */
  119515. static BaseAssetsUrl: string;
  119516. /**
  119517. * Create a default particle system that you can tweak
  119518. * @param emitter defines the emitter to use
  119519. * @param capacity defines the system capacity (default is 500 particles)
  119520. * @param scene defines the hosting scene
  119521. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  119522. * @returns the new Particle system
  119523. */
  119524. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  119525. /**
  119526. * This is the main static method (one-liner) of this helper to create different particle systems
  119527. * @param type This string represents the type to the particle system to create
  119528. * @param scene The scene where the particle system should live
  119529. * @param gpu If the system will use gpu
  119530. * @returns the ParticleSystemSet created
  119531. */
  119532. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  119533. /**
  119534. * Static function used to export a particle system to a ParticleSystemSet variable.
  119535. * Please note that the emitter shape is not exported
  119536. * @param systems defines the particle systems to export
  119537. * @returns the created particle system set
  119538. */
  119539. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  119540. }
  119541. }
  119542. declare module BABYLON {
  119543. interface Engine {
  119544. /**
  119545. * Create an effect to use with particle systems.
  119546. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  119547. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  119548. * @param uniformsNames defines a list of attribute names
  119549. * @param samplers defines an array of string used to represent textures
  119550. * @param defines defines the string containing the defines to use to compile the shaders
  119551. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  119552. * @param onCompiled defines a function to call when the effect creation is successful
  119553. * @param onError defines a function to call when the effect creation has failed
  119554. * @returns the new Effect
  119555. */
  119556. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  119557. }
  119558. interface Mesh {
  119559. /**
  119560. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  119561. * @returns an array of IParticleSystem
  119562. */
  119563. getEmittedParticleSystems(): IParticleSystem[];
  119564. /**
  119565. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  119566. * @returns an array of IParticleSystem
  119567. */
  119568. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  119569. }
  119570. /**
  119571. * @hidden
  119572. */
  119573. export var _IDoNeedToBeInTheBuild: number;
  119574. }
  119575. declare module BABYLON {
  119576. interface Scene {
  119577. /** @hidden (Backing field) */
  119578. _physicsEngine: Nullable<IPhysicsEngine>;
  119579. /**
  119580. * Gets the current physics engine
  119581. * @returns a IPhysicsEngine or null if none attached
  119582. */
  119583. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  119584. /**
  119585. * Enables physics to the current scene
  119586. * @param gravity defines the scene's gravity for the physics engine
  119587. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  119588. * @return a boolean indicating if the physics engine was initialized
  119589. */
  119590. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  119591. /**
  119592. * Disables and disposes the physics engine associated with the scene
  119593. */
  119594. disablePhysicsEngine(): void;
  119595. /**
  119596. * Gets a boolean indicating if there is an active physics engine
  119597. * @returns a boolean indicating if there is an active physics engine
  119598. */
  119599. isPhysicsEnabled(): boolean;
  119600. /**
  119601. * Deletes a physics compound impostor
  119602. * @param compound defines the compound to delete
  119603. */
  119604. deleteCompoundImpostor(compound: any): void;
  119605. /**
  119606. * An event triggered when physic simulation is about to be run
  119607. */
  119608. onBeforePhysicsObservable: Observable<Scene>;
  119609. /**
  119610. * An event triggered when physic simulation has been done
  119611. */
  119612. onAfterPhysicsObservable: Observable<Scene>;
  119613. }
  119614. interface AbstractMesh {
  119615. /** @hidden */
  119616. _physicsImpostor: Nullable<PhysicsImpostor>;
  119617. /**
  119618. * Gets or sets impostor used for physic simulation
  119619. * @see http://doc.babylonjs.com/features/physics_engine
  119620. */
  119621. physicsImpostor: Nullable<PhysicsImpostor>;
  119622. /**
  119623. * Gets the current physics impostor
  119624. * @see http://doc.babylonjs.com/features/physics_engine
  119625. * @returns a physics impostor or null
  119626. */
  119627. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  119628. /** Apply a physic impulse to the mesh
  119629. * @param force defines the force to apply
  119630. * @param contactPoint defines where to apply the force
  119631. * @returns the current mesh
  119632. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  119633. */
  119634. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  119635. /**
  119636. * Creates a physic joint between two meshes
  119637. * @param otherMesh defines the other mesh to use
  119638. * @param pivot1 defines the pivot to use on this mesh
  119639. * @param pivot2 defines the pivot to use on the other mesh
  119640. * @param options defines additional options (can be plugin dependent)
  119641. * @returns the current mesh
  119642. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  119643. */
  119644. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  119645. /** @hidden */
  119646. _disposePhysicsObserver: Nullable<Observer<Node>>;
  119647. }
  119648. /**
  119649. * Defines the physics engine scene component responsible to manage a physics engine
  119650. */
  119651. export class PhysicsEngineSceneComponent implements ISceneComponent {
  119652. /**
  119653. * The component name helpful to identify the component in the list of scene components.
  119654. */
  119655. readonly name: string;
  119656. /**
  119657. * The scene the component belongs to.
  119658. */
  119659. scene: Scene;
  119660. /**
  119661. * Creates a new instance of the component for the given scene
  119662. * @param scene Defines the scene to register the component in
  119663. */
  119664. constructor(scene: Scene);
  119665. /**
  119666. * Registers the component in a given scene
  119667. */
  119668. register(): void;
  119669. /**
  119670. * Rebuilds the elements related to this component in case of
  119671. * context lost for instance.
  119672. */
  119673. rebuild(): void;
  119674. /**
  119675. * Disposes the component and the associated ressources
  119676. */
  119677. dispose(): void;
  119678. }
  119679. }
  119680. declare module BABYLON {
  119681. /**
  119682. * A helper for physics simulations
  119683. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119684. */
  119685. export class PhysicsHelper {
  119686. private _scene;
  119687. private _physicsEngine;
  119688. /**
  119689. * Initializes the Physics helper
  119690. * @param scene Babylon.js scene
  119691. */
  119692. constructor(scene: Scene);
  119693. /**
  119694. * Applies a radial explosion impulse
  119695. * @param origin the origin of the explosion
  119696. * @param radiusOrEventOptions the radius or the options of radial explosion
  119697. * @param strength the explosion strength
  119698. * @param falloff possible options: Constant & Linear. Defaults to Constant
  119699. * @returns A physics radial explosion event, or null
  119700. */
  119701. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  119702. /**
  119703. * Applies a radial explosion force
  119704. * @param origin the origin of the explosion
  119705. * @param radiusOrEventOptions the radius or the options of radial explosion
  119706. * @param strength the explosion strength
  119707. * @param falloff possible options: Constant & Linear. Defaults to Constant
  119708. * @returns A physics radial explosion event, or null
  119709. */
  119710. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  119711. /**
  119712. * Creates a gravitational field
  119713. * @param origin the origin of the explosion
  119714. * @param radiusOrEventOptions the radius or the options of radial explosion
  119715. * @param strength the explosion strength
  119716. * @param falloff possible options: Constant & Linear. Defaults to Constant
  119717. * @returns A physics gravitational field event, or null
  119718. */
  119719. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  119720. /**
  119721. * Creates a physics updraft event
  119722. * @param origin the origin of the updraft
  119723. * @param radiusOrEventOptions the radius or the options of the updraft
  119724. * @param strength the strength of the updraft
  119725. * @param height the height of the updraft
  119726. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  119727. * @returns A physics updraft event, or null
  119728. */
  119729. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  119730. /**
  119731. * Creates a physics vortex event
  119732. * @param origin the of the vortex
  119733. * @param radiusOrEventOptions the radius or the options of the vortex
  119734. * @param strength the strength of the vortex
  119735. * @param height the height of the vortex
  119736. * @returns a Physics vortex event, or null
  119737. * A physics vortex event or null
  119738. */
  119739. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  119740. }
  119741. /**
  119742. * Represents a physics radial explosion event
  119743. */
  119744. class PhysicsRadialExplosionEvent {
  119745. private _scene;
  119746. private _options;
  119747. private _sphere;
  119748. private _dataFetched;
  119749. /**
  119750. * Initializes a radial explosioin event
  119751. * @param _scene BabylonJS scene
  119752. * @param _options The options for the vortex event
  119753. */
  119754. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  119755. /**
  119756. * Returns the data related to the radial explosion event (sphere).
  119757. * @returns The radial explosion event data
  119758. */
  119759. getData(): PhysicsRadialExplosionEventData;
  119760. /**
  119761. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  119762. * @param impostor A physics imposter
  119763. * @param origin the origin of the explosion
  119764. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  119765. */
  119766. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  119767. /**
  119768. * Triggers affecterd impostors callbacks
  119769. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  119770. */
  119771. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  119772. /**
  119773. * Disposes the sphere.
  119774. * @param force Specifies if the sphere should be disposed by force
  119775. */
  119776. dispose(force?: boolean): void;
  119777. /*** Helpers ***/
  119778. private _prepareSphere;
  119779. private _intersectsWithSphere;
  119780. }
  119781. /**
  119782. * Represents a gravitational field event
  119783. */
  119784. class PhysicsGravitationalFieldEvent {
  119785. private _physicsHelper;
  119786. private _scene;
  119787. private _origin;
  119788. private _options;
  119789. private _tickCallback;
  119790. private _sphere;
  119791. private _dataFetched;
  119792. /**
  119793. * Initializes the physics gravitational field event
  119794. * @param _physicsHelper A physics helper
  119795. * @param _scene BabylonJS scene
  119796. * @param _origin The origin position of the gravitational field event
  119797. * @param _options The options for the vortex event
  119798. */
  119799. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  119800. /**
  119801. * Returns the data related to the gravitational field event (sphere).
  119802. * @returns A gravitational field event
  119803. */
  119804. getData(): PhysicsGravitationalFieldEventData;
  119805. /**
  119806. * Enables the gravitational field.
  119807. */
  119808. enable(): void;
  119809. /**
  119810. * Disables the gravitational field.
  119811. */
  119812. disable(): void;
  119813. /**
  119814. * Disposes the sphere.
  119815. * @param force The force to dispose from the gravitational field event
  119816. */
  119817. dispose(force?: boolean): void;
  119818. private _tick;
  119819. }
  119820. /**
  119821. * Represents a physics updraft event
  119822. */
  119823. class PhysicsUpdraftEvent {
  119824. private _scene;
  119825. private _origin;
  119826. private _options;
  119827. private _physicsEngine;
  119828. private _originTop;
  119829. private _originDirection;
  119830. private _tickCallback;
  119831. private _cylinder;
  119832. private _cylinderPosition;
  119833. private _dataFetched;
  119834. /**
  119835. * Initializes the physics updraft event
  119836. * @param _scene BabylonJS scene
  119837. * @param _origin The origin position of the updraft
  119838. * @param _options The options for the updraft event
  119839. */
  119840. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  119841. /**
  119842. * Returns the data related to the updraft event (cylinder).
  119843. * @returns A physics updraft event
  119844. */
  119845. getData(): PhysicsUpdraftEventData;
  119846. /**
  119847. * Enables the updraft.
  119848. */
  119849. enable(): void;
  119850. /**
  119851. * Disables the updraft.
  119852. */
  119853. disable(): void;
  119854. /**
  119855. * Disposes the cylinder.
  119856. * @param force Specifies if the updraft should be disposed by force
  119857. */
  119858. dispose(force?: boolean): void;
  119859. private getImpostorHitData;
  119860. private _tick;
  119861. /*** Helpers ***/
  119862. private _prepareCylinder;
  119863. private _intersectsWithCylinder;
  119864. }
  119865. /**
  119866. * Represents a physics vortex event
  119867. */
  119868. class PhysicsVortexEvent {
  119869. private _scene;
  119870. private _origin;
  119871. private _options;
  119872. private _physicsEngine;
  119873. private _originTop;
  119874. private _tickCallback;
  119875. private _cylinder;
  119876. private _cylinderPosition;
  119877. private _dataFetched;
  119878. /**
  119879. * Initializes the physics vortex event
  119880. * @param _scene The BabylonJS scene
  119881. * @param _origin The origin position of the vortex
  119882. * @param _options The options for the vortex event
  119883. */
  119884. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  119885. /**
  119886. * Returns the data related to the vortex event (cylinder).
  119887. * @returns The physics vortex event data
  119888. */
  119889. getData(): PhysicsVortexEventData;
  119890. /**
  119891. * Enables the vortex.
  119892. */
  119893. enable(): void;
  119894. /**
  119895. * Disables the cortex.
  119896. */
  119897. disable(): void;
  119898. /**
  119899. * Disposes the sphere.
  119900. * @param force
  119901. */
  119902. dispose(force?: boolean): void;
  119903. private getImpostorHitData;
  119904. private _tick;
  119905. /*** Helpers ***/
  119906. private _prepareCylinder;
  119907. private _intersectsWithCylinder;
  119908. }
  119909. /**
  119910. * Options fot the radial explosion event
  119911. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119912. */
  119913. export class PhysicsRadialExplosionEventOptions {
  119914. /**
  119915. * The radius of the sphere for the radial explosion.
  119916. */
  119917. radius: number;
  119918. /**
  119919. * The strenth of the explosion.
  119920. */
  119921. strength: number;
  119922. /**
  119923. * The strenght of the force in correspondence to the distance of the affected object
  119924. */
  119925. falloff: PhysicsRadialImpulseFalloff;
  119926. /**
  119927. * Sphere options for the radial explosion.
  119928. */
  119929. sphere: {
  119930. segments: number;
  119931. diameter: number;
  119932. };
  119933. /**
  119934. * Sphere options for the radial explosion.
  119935. */
  119936. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  119937. }
  119938. /**
  119939. * Options fot the updraft event
  119940. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119941. */
  119942. export class PhysicsUpdraftEventOptions {
  119943. /**
  119944. * The radius of the cylinder for the vortex
  119945. */
  119946. radius: number;
  119947. /**
  119948. * The strenth of the updraft.
  119949. */
  119950. strength: number;
  119951. /**
  119952. * The height of the cylinder for the updraft.
  119953. */
  119954. height: number;
  119955. /**
  119956. * The mode for the the updraft.
  119957. */
  119958. updraftMode: PhysicsUpdraftMode;
  119959. }
  119960. /**
  119961. * Options fot the vortex event
  119962. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119963. */
  119964. export class PhysicsVortexEventOptions {
  119965. /**
  119966. * The radius of the cylinder for the vortex
  119967. */
  119968. radius: number;
  119969. /**
  119970. * The strenth of the vortex.
  119971. */
  119972. strength: number;
  119973. /**
  119974. * The height of the cylinder for the vortex.
  119975. */
  119976. height: number;
  119977. /**
  119978. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  119979. */
  119980. centripetalForceThreshold: number;
  119981. /**
  119982. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  119983. */
  119984. centripetalForceMultiplier: number;
  119985. /**
  119986. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  119987. */
  119988. centrifugalForceMultiplier: number;
  119989. /**
  119990. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  119991. */
  119992. updraftForceMultiplier: number;
  119993. }
  119994. /**
  119995. * The strenght of the force in correspondence to the distance of the affected object
  119996. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119997. */
  119998. export enum PhysicsRadialImpulseFalloff {
  119999. /** Defines that impulse is constant in strength across it's whole radius */
  120000. Constant = 0,
  120001. /** Defines that impulse gets weaker if it's further from the origin */
  120002. Linear = 1
  120003. }
  120004. /**
  120005. * The strength of the force in correspondence to the distance of the affected object
  120006. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120007. */
  120008. export enum PhysicsUpdraftMode {
  120009. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  120010. Center = 0,
  120011. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  120012. Perpendicular = 1
  120013. }
  120014. /**
  120015. * Interface for a physics hit data
  120016. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120017. */
  120018. export interface PhysicsHitData {
  120019. /**
  120020. * The force applied at the contact point
  120021. */
  120022. force: Vector3;
  120023. /**
  120024. * The contact point
  120025. */
  120026. contactPoint: Vector3;
  120027. /**
  120028. * The distance from the origin to the contact point
  120029. */
  120030. distanceFromOrigin: number;
  120031. }
  120032. /**
  120033. * Interface for radial explosion event data
  120034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120035. */
  120036. export interface PhysicsRadialExplosionEventData {
  120037. /**
  120038. * A sphere used for the radial explosion event
  120039. */
  120040. sphere: Mesh;
  120041. }
  120042. /**
  120043. * Interface for gravitational field event data
  120044. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120045. */
  120046. export interface PhysicsGravitationalFieldEventData {
  120047. /**
  120048. * A sphere mesh used for the gravitational field event
  120049. */
  120050. sphere: Mesh;
  120051. }
  120052. /**
  120053. * Interface for updraft event data
  120054. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120055. */
  120056. export interface PhysicsUpdraftEventData {
  120057. /**
  120058. * A cylinder used for the updraft event
  120059. */
  120060. cylinder: Mesh;
  120061. }
  120062. /**
  120063. * Interface for vortex event data
  120064. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120065. */
  120066. export interface PhysicsVortexEventData {
  120067. /**
  120068. * A cylinder used for the vortex event
  120069. */
  120070. cylinder: Mesh;
  120071. }
  120072. /**
  120073. * Interface for an affected physics impostor
  120074. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  120075. */
  120076. export interface PhysicsAffectedImpostorWithData {
  120077. /**
  120078. * The impostor affected by the effect
  120079. */
  120080. impostor: PhysicsImpostor;
  120081. /**
  120082. * The data about the hit/horce from the explosion
  120083. */
  120084. hitData: PhysicsHitData;
  120085. }
  120086. }
  120087. declare module BABYLON {
  120088. /** @hidden */
  120089. export var blackAndWhitePixelShader: {
  120090. name: string;
  120091. shader: string;
  120092. };
  120093. }
  120094. declare module BABYLON {
  120095. /**
  120096. * Post process used to render in black and white
  120097. */
  120098. export class BlackAndWhitePostProcess extends PostProcess {
  120099. /**
  120100. * Linear about to convert he result to black and white (default: 1)
  120101. */
  120102. degree: number;
  120103. /**
  120104. * Creates a black and white post process
  120105. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  120106. * @param name The name of the effect.
  120107. * @param options The required width/height ratio to downsize to before computing the render pass.
  120108. * @param camera The camera to apply the render pass to.
  120109. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120110. * @param engine The engine which the post process will be applied. (default: current engine)
  120111. * @param reusable If the post process can be reused on the same frame. (default: false)
  120112. */
  120113. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  120114. }
  120115. }
  120116. declare module BABYLON {
  120117. /**
  120118. * This represents a set of one or more post processes in Babylon.
  120119. * A post process can be used to apply a shader to a texture after it is rendered.
  120120. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  120121. */
  120122. export class PostProcessRenderEffect {
  120123. private _postProcesses;
  120124. private _getPostProcesses;
  120125. private _singleInstance;
  120126. private _cameras;
  120127. private _indicesForCamera;
  120128. /**
  120129. * Name of the effect
  120130. * @hidden
  120131. */
  120132. _name: string;
  120133. /**
  120134. * Instantiates a post process render effect.
  120135. * A post process can be used to apply a shader to a texture after it is rendered.
  120136. * @param engine The engine the effect is tied to
  120137. * @param name The name of the effect
  120138. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  120139. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  120140. */
  120141. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  120142. /**
  120143. * Checks if all the post processes in the effect are supported.
  120144. */
  120145. readonly isSupported: boolean;
  120146. /**
  120147. * Updates the current state of the effect
  120148. * @hidden
  120149. */
  120150. _update(): void;
  120151. /**
  120152. * Attaches the effect on cameras
  120153. * @param cameras The camera to attach to.
  120154. * @hidden
  120155. */
  120156. _attachCameras(cameras: Camera): void;
  120157. /**
  120158. * Attaches the effect on cameras
  120159. * @param cameras The camera to attach to.
  120160. * @hidden
  120161. */
  120162. _attachCameras(cameras: Camera[]): void;
  120163. /**
  120164. * Detaches the effect on cameras
  120165. * @param cameras The camera to detatch from.
  120166. * @hidden
  120167. */
  120168. _detachCameras(cameras: Camera): void;
  120169. /**
  120170. * Detatches the effect on cameras
  120171. * @param cameras The camera to detatch from.
  120172. * @hidden
  120173. */
  120174. _detachCameras(cameras: Camera[]): void;
  120175. /**
  120176. * Enables the effect on given cameras
  120177. * @param cameras The camera to enable.
  120178. * @hidden
  120179. */
  120180. _enable(cameras: Camera): void;
  120181. /**
  120182. * Enables the effect on given cameras
  120183. * @param cameras The camera to enable.
  120184. * @hidden
  120185. */
  120186. _enable(cameras: Nullable<Camera[]>): void;
  120187. /**
  120188. * Disables the effect on the given cameras
  120189. * @param cameras The camera to disable.
  120190. * @hidden
  120191. */
  120192. _disable(cameras: Camera): void;
  120193. /**
  120194. * Disables the effect on the given cameras
  120195. * @param cameras The camera to disable.
  120196. * @hidden
  120197. */
  120198. _disable(cameras: Nullable<Camera[]>): void;
  120199. /**
  120200. * Gets a list of the post processes contained in the effect.
  120201. * @param camera The camera to get the post processes on.
  120202. * @returns The list of the post processes in the effect.
  120203. */
  120204. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  120205. }
  120206. }
  120207. declare module BABYLON {
  120208. /** @hidden */
  120209. export var extractHighlightsPixelShader: {
  120210. name: string;
  120211. shader: string;
  120212. };
  120213. }
  120214. declare module BABYLON {
  120215. /**
  120216. * 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.
  120217. */
  120218. export class ExtractHighlightsPostProcess extends PostProcess {
  120219. /**
  120220. * The luminance threshold, pixels below this value will be set to black.
  120221. */
  120222. threshold: number;
  120223. /** @hidden */
  120224. _exposure: number;
  120225. /**
  120226. * Post process which has the input texture to be used when performing highlight extraction
  120227. * @hidden
  120228. */
  120229. _inputPostProcess: Nullable<PostProcess>;
  120230. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120231. }
  120232. }
  120233. declare module BABYLON {
  120234. /** @hidden */
  120235. export var bloomMergePixelShader: {
  120236. name: string;
  120237. shader: string;
  120238. };
  120239. }
  120240. declare module BABYLON {
  120241. /**
  120242. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  120243. */
  120244. export class BloomMergePostProcess extends PostProcess {
  120245. /** Weight of the bloom to be added to the original input. */
  120246. weight: number;
  120247. /**
  120248. * Creates a new instance of @see BloomMergePostProcess
  120249. * @param name The name of the effect.
  120250. * @param originalFromInput Post process which's input will be used for the merge.
  120251. * @param blurred Blurred highlights post process which's output will be used.
  120252. * @param weight Weight of the bloom to be added to the original input.
  120253. * @param options The required width/height ratio to downsize to before computing the render pass.
  120254. * @param camera The camera to apply the render pass to.
  120255. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120256. * @param engine The engine which the post process will be applied. (default: current engine)
  120257. * @param reusable If the post process can be reused on the same frame. (default: false)
  120258. * @param textureType Type of textures used when performing the post process. (default: 0)
  120259. * @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)
  120260. */
  120261. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  120262. /** Weight of the bloom to be added to the original input. */
  120263. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120264. }
  120265. }
  120266. declare module BABYLON {
  120267. /**
  120268. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  120269. */
  120270. export class BloomEffect extends PostProcessRenderEffect {
  120271. private bloomScale;
  120272. /**
  120273. * @hidden Internal
  120274. */
  120275. _effects: Array<PostProcess>;
  120276. /**
  120277. * @hidden Internal
  120278. */
  120279. _downscale: ExtractHighlightsPostProcess;
  120280. private _blurX;
  120281. private _blurY;
  120282. private _merge;
  120283. /**
  120284. * The luminance threshold to find bright areas of the image to bloom.
  120285. */
  120286. threshold: number;
  120287. /**
  120288. * The strength of the bloom.
  120289. */
  120290. weight: number;
  120291. /**
  120292. * Specifies the size of the bloom blur kernel, relative to the final output size
  120293. */
  120294. kernel: number;
  120295. /**
  120296. * Creates a new instance of @see BloomEffect
  120297. * @param scene The scene the effect belongs to.
  120298. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  120299. * @param bloomKernel The size of the kernel to be used when applying the blur.
  120300. * @param bloomWeight The the strength of bloom.
  120301. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  120302. * @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)
  120303. */
  120304. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  120305. /**
  120306. * Disposes each of the internal effects for a given camera.
  120307. * @param camera The camera to dispose the effect on.
  120308. */
  120309. disposeEffects(camera: Camera): void;
  120310. /**
  120311. * @hidden Internal
  120312. */
  120313. _updateEffects(): void;
  120314. /**
  120315. * Internal
  120316. * @returns if all the contained post processes are ready.
  120317. * @hidden
  120318. */
  120319. _isReady(): boolean;
  120320. }
  120321. }
  120322. declare module BABYLON {
  120323. /** @hidden */
  120324. export var chromaticAberrationPixelShader: {
  120325. name: string;
  120326. shader: string;
  120327. };
  120328. }
  120329. declare module BABYLON {
  120330. /**
  120331. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  120332. */
  120333. export class ChromaticAberrationPostProcess extends PostProcess {
  120334. /**
  120335. * The amount of seperation of rgb channels (default: 30)
  120336. */
  120337. aberrationAmount: number;
  120338. /**
  120339. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  120340. */
  120341. radialIntensity: number;
  120342. /**
  120343. * 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))
  120344. */
  120345. direction: Vector2;
  120346. /**
  120347. * 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))
  120348. */
  120349. centerPosition: Vector2;
  120350. /**
  120351. * Creates a new instance ChromaticAberrationPostProcess
  120352. * @param name The name of the effect.
  120353. * @param screenWidth The width of the screen to apply the effect on.
  120354. * @param screenHeight The height of the screen to apply the effect on.
  120355. * @param options The required width/height ratio to downsize to before computing the render pass.
  120356. * @param camera The camera to apply the render pass to.
  120357. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120358. * @param engine The engine which the post process will be applied. (default: current engine)
  120359. * @param reusable If the post process can be reused on the same frame. (default: false)
  120360. * @param textureType Type of textures used when performing the post process. (default: 0)
  120361. * @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)
  120362. */
  120363. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120364. }
  120365. }
  120366. declare module BABYLON {
  120367. /** @hidden */
  120368. export var circleOfConfusionPixelShader: {
  120369. name: string;
  120370. shader: string;
  120371. };
  120372. }
  120373. declare module BABYLON {
  120374. /**
  120375. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  120376. */
  120377. export class CircleOfConfusionPostProcess extends PostProcess {
  120378. /**
  120379. * 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.
  120380. */
  120381. lensSize: number;
  120382. /**
  120383. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  120384. */
  120385. fStop: number;
  120386. /**
  120387. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  120388. */
  120389. focusDistance: number;
  120390. /**
  120391. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  120392. */
  120393. focalLength: number;
  120394. private _depthTexture;
  120395. /**
  120396. * Creates a new instance CircleOfConfusionPostProcess
  120397. * @param name The name of the effect.
  120398. * @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.
  120399. * @param options The required width/height ratio to downsize to before computing the render pass.
  120400. * @param camera The camera to apply the render pass to.
  120401. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120402. * @param engine The engine which the post process will be applied. (default: current engine)
  120403. * @param reusable If the post process can be reused on the same frame. (default: false)
  120404. * @param textureType Type of textures used when performing the post process. (default: 0)
  120405. * @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)
  120406. */
  120407. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120408. /**
  120409. * 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.
  120410. */
  120411. depthTexture: RenderTargetTexture;
  120412. }
  120413. }
  120414. declare module BABYLON {
  120415. /** @hidden */
  120416. export var colorCorrectionPixelShader: {
  120417. name: string;
  120418. shader: string;
  120419. };
  120420. }
  120421. declare module BABYLON {
  120422. /**
  120423. *
  120424. * This post-process allows the modification of rendered colors by using
  120425. * a 'look-up table' (LUT). This effect is also called Color Grading.
  120426. *
  120427. * The object needs to be provided an url to a texture containing the color
  120428. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  120429. * Use an image editing software to tweak the LUT to match your needs.
  120430. *
  120431. * For an example of a color LUT, see here:
  120432. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  120433. * For explanations on color grading, see here:
  120434. * @see http://udn.epicgames.com/Three/ColorGrading.html
  120435. *
  120436. */
  120437. export class ColorCorrectionPostProcess extends PostProcess {
  120438. private _colorTableTexture;
  120439. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  120440. }
  120441. }
  120442. declare module BABYLON {
  120443. /** @hidden */
  120444. export var convolutionPixelShader: {
  120445. name: string;
  120446. shader: string;
  120447. };
  120448. }
  120449. declare module BABYLON {
  120450. /**
  120451. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  120452. * input texture to perform effects such as edge detection or sharpening
  120453. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  120454. */
  120455. export class ConvolutionPostProcess extends PostProcess {
  120456. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  120457. kernel: number[];
  120458. /**
  120459. * Creates a new instance ConvolutionPostProcess
  120460. * @param name The name of the effect.
  120461. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  120462. * @param options The required width/height ratio to downsize to before computing the render pass.
  120463. * @param camera The camera to apply the render pass to.
  120464. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120465. * @param engine The engine which the post process will be applied. (default: current engine)
  120466. * @param reusable If the post process can be reused on the same frame. (default: false)
  120467. * @param textureType Type of textures used when performing the post process. (default: 0)
  120468. */
  120469. constructor(name: string,
  120470. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  120471. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  120472. /**
  120473. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120474. */
  120475. static EdgeDetect0Kernel: number[];
  120476. /**
  120477. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120478. */
  120479. static EdgeDetect1Kernel: number[];
  120480. /**
  120481. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120482. */
  120483. static EdgeDetect2Kernel: number[];
  120484. /**
  120485. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120486. */
  120487. static SharpenKernel: number[];
  120488. /**
  120489. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120490. */
  120491. static EmbossKernel: number[];
  120492. /**
  120493. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120494. */
  120495. static GaussianKernel: number[];
  120496. }
  120497. }
  120498. declare module BABYLON {
  120499. /**
  120500. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  120501. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  120502. * based on samples that have a large difference in distance than the center pixel.
  120503. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  120504. */
  120505. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  120506. direction: Vector2;
  120507. /**
  120508. * Creates a new instance CircleOfConfusionPostProcess
  120509. * @param name The name of the effect.
  120510. * @param scene The scene the effect belongs to.
  120511. * @param direction The direction the blur should be applied.
  120512. * @param kernel The size of the kernel used to blur.
  120513. * @param options The required width/height ratio to downsize to before computing the render pass.
  120514. * @param camera The camera to apply the render pass to.
  120515. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  120516. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  120517. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120518. * @param engine The engine which the post process will be applied. (default: current engine)
  120519. * @param reusable If the post process can be reused on the same frame. (default: false)
  120520. * @param textureType Type of textures used when performing the post process. (default: 0)
  120521. * @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)
  120522. */
  120523. 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);
  120524. }
  120525. }
  120526. declare module BABYLON {
  120527. /** @hidden */
  120528. export var depthOfFieldMergePixelShader: {
  120529. name: string;
  120530. shader: string;
  120531. };
  120532. }
  120533. declare module BABYLON {
  120534. /**
  120535. * Options to be set when merging outputs from the default pipeline.
  120536. */
  120537. export class DepthOfFieldMergePostProcessOptions {
  120538. /**
  120539. * The original image to merge on top of
  120540. */
  120541. originalFromInput: PostProcess;
  120542. /**
  120543. * Parameters to perform the merge of the depth of field effect
  120544. */
  120545. depthOfField?: {
  120546. circleOfConfusion: PostProcess;
  120547. blurSteps: Array<PostProcess>;
  120548. };
  120549. /**
  120550. * Parameters to perform the merge of bloom effect
  120551. */
  120552. bloom?: {
  120553. blurred: PostProcess;
  120554. weight: number;
  120555. };
  120556. }
  120557. /**
  120558. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  120559. */
  120560. export class DepthOfFieldMergePostProcess extends PostProcess {
  120561. private blurSteps;
  120562. /**
  120563. * Creates a new instance of DepthOfFieldMergePostProcess
  120564. * @param name The name of the effect.
  120565. * @param originalFromInput Post process which's input will be used for the merge.
  120566. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  120567. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  120568. * @param options The required width/height ratio to downsize to before computing the render pass.
  120569. * @param camera The camera to apply the render pass to.
  120570. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120571. * @param engine The engine which the post process will be applied. (default: current engine)
  120572. * @param reusable If the post process can be reused on the same frame. (default: false)
  120573. * @param textureType Type of textures used when performing the post process. (default: 0)
  120574. * @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)
  120575. */
  120576. 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);
  120577. /**
  120578. * Updates the effect with the current post process compile time values and recompiles the shader.
  120579. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  120580. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  120581. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  120582. * @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
  120583. * @param onCompiled Called when the shader has been compiled.
  120584. * @param onError Called if there is an error when compiling a shader.
  120585. */
  120586. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  120587. }
  120588. }
  120589. declare module BABYLON {
  120590. /**
  120591. * Specifies the level of max blur that should be applied when using the depth of field effect
  120592. */
  120593. export enum DepthOfFieldEffectBlurLevel {
  120594. /**
  120595. * Subtle blur
  120596. */
  120597. Low = 0,
  120598. /**
  120599. * Medium blur
  120600. */
  120601. Medium = 1,
  120602. /**
  120603. * Large blur
  120604. */
  120605. High = 2
  120606. }
  120607. /**
  120608. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  120609. */
  120610. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  120611. private _circleOfConfusion;
  120612. /**
  120613. * @hidden Internal, blurs from high to low
  120614. */
  120615. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  120616. private _depthOfFieldBlurY;
  120617. private _dofMerge;
  120618. /**
  120619. * @hidden Internal post processes in depth of field effect
  120620. */
  120621. _effects: Array<PostProcess>;
  120622. /**
  120623. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  120624. */
  120625. focalLength: number;
  120626. /**
  120627. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  120628. */
  120629. fStop: number;
  120630. /**
  120631. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  120632. */
  120633. focusDistance: number;
  120634. /**
  120635. * 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.
  120636. */
  120637. lensSize: number;
  120638. /**
  120639. * Creates a new instance DepthOfFieldEffect
  120640. * @param scene The scene the effect belongs to.
  120641. * @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.
  120642. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  120643. * @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)
  120644. */
  120645. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  120646. /**
  120647. * Get the current class name of the current effet
  120648. * @returns "DepthOfFieldEffect"
  120649. */
  120650. getClassName(): string;
  120651. /**
  120652. * 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.
  120653. */
  120654. depthTexture: RenderTargetTexture;
  120655. /**
  120656. * Disposes each of the internal effects for a given camera.
  120657. * @param camera The camera to dispose the effect on.
  120658. */
  120659. disposeEffects(camera: Camera): void;
  120660. /**
  120661. * @hidden Internal
  120662. */
  120663. _updateEffects(): void;
  120664. /**
  120665. * Internal
  120666. * @returns if all the contained post processes are ready.
  120667. * @hidden
  120668. */
  120669. _isReady(): boolean;
  120670. }
  120671. }
  120672. declare module BABYLON {
  120673. /** @hidden */
  120674. export var displayPassPixelShader: {
  120675. name: string;
  120676. shader: string;
  120677. };
  120678. }
  120679. declare module BABYLON {
  120680. /**
  120681. * DisplayPassPostProcess which produces an output the same as it's input
  120682. */
  120683. export class DisplayPassPostProcess extends PostProcess {
  120684. /**
  120685. * Creates the DisplayPassPostProcess
  120686. * @param name The name of the effect.
  120687. * @param options The required width/height ratio to downsize to before computing the render pass.
  120688. * @param camera The camera to apply the render pass to.
  120689. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120690. * @param engine The engine which the post process will be applied. (default: current engine)
  120691. * @param reusable If the post process can be reused on the same frame. (default: false)
  120692. */
  120693. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  120694. }
  120695. }
  120696. declare module BABYLON {
  120697. /** @hidden */
  120698. export var filterPixelShader: {
  120699. name: string;
  120700. shader: string;
  120701. };
  120702. }
  120703. declare module BABYLON {
  120704. /**
  120705. * Applies a kernel filter to the image
  120706. */
  120707. export class FilterPostProcess extends PostProcess {
  120708. /** The matrix to be applied to the image */
  120709. kernelMatrix: Matrix;
  120710. /**
  120711. *
  120712. * @param name The name of the effect.
  120713. * @param kernelMatrix The matrix to be applied to the image
  120714. * @param options The required width/height ratio to downsize to before computing the render pass.
  120715. * @param camera The camera to apply the render pass to.
  120716. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120717. * @param engine The engine which the post process will be applied. (default: current engine)
  120718. * @param reusable If the post process can be reused on the same frame. (default: false)
  120719. */
  120720. constructor(name: string,
  120721. /** The matrix to be applied to the image */
  120722. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  120723. }
  120724. }
  120725. declare module BABYLON {
  120726. /** @hidden */
  120727. export var fxaaPixelShader: {
  120728. name: string;
  120729. shader: string;
  120730. };
  120731. }
  120732. declare module BABYLON {
  120733. /** @hidden */
  120734. export var fxaaVertexShader: {
  120735. name: string;
  120736. shader: string;
  120737. };
  120738. }
  120739. declare module BABYLON {
  120740. /**
  120741. * Fxaa post process
  120742. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  120743. */
  120744. export class FxaaPostProcess extends PostProcess {
  120745. /** @hidden */
  120746. texelWidth: number;
  120747. /** @hidden */
  120748. texelHeight: number;
  120749. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  120750. private _getDefines;
  120751. }
  120752. }
  120753. declare module BABYLON {
  120754. /** @hidden */
  120755. export var grainPixelShader: {
  120756. name: string;
  120757. shader: string;
  120758. };
  120759. }
  120760. declare module BABYLON {
  120761. /**
  120762. * The GrainPostProcess adds noise to the image at mid luminance levels
  120763. */
  120764. export class GrainPostProcess extends PostProcess {
  120765. /**
  120766. * The intensity of the grain added (default: 30)
  120767. */
  120768. intensity: number;
  120769. /**
  120770. * If the grain should be randomized on every frame
  120771. */
  120772. animated: boolean;
  120773. /**
  120774. * Creates a new instance of @see GrainPostProcess
  120775. * @param name The name of the effect.
  120776. * @param options The required width/height ratio to downsize to before computing the render pass.
  120777. * @param camera The camera to apply the render pass to.
  120778. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120779. * @param engine The engine which the post process will be applied. (default: current engine)
  120780. * @param reusable If the post process can be reused on the same frame. (default: false)
  120781. * @param textureType Type of textures used when performing the post process. (default: 0)
  120782. * @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)
  120783. */
  120784. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120785. }
  120786. }
  120787. declare module BABYLON {
  120788. /** @hidden */
  120789. export var highlightsPixelShader: {
  120790. name: string;
  120791. shader: string;
  120792. };
  120793. }
  120794. declare module BABYLON {
  120795. /**
  120796. * Extracts highlights from the image
  120797. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  120798. */
  120799. export class HighlightsPostProcess extends PostProcess {
  120800. /**
  120801. * Extracts highlights from the image
  120802. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  120803. * @param name The name of the effect.
  120804. * @param options The required width/height ratio to downsize to before computing the render pass.
  120805. * @param camera The camera to apply the render pass to.
  120806. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120807. * @param engine The engine which the post process will be applied. (default: current engine)
  120808. * @param reusable If the post process can be reused on the same frame. (default: false)
  120809. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  120810. */
  120811. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  120812. }
  120813. }
  120814. declare module BABYLON {
  120815. /** @hidden */
  120816. export var mrtFragmentDeclaration: {
  120817. name: string;
  120818. shader: string;
  120819. };
  120820. }
  120821. declare module BABYLON {
  120822. /** @hidden */
  120823. export var geometryPixelShader: {
  120824. name: string;
  120825. shader: string;
  120826. };
  120827. }
  120828. declare module BABYLON {
  120829. /** @hidden */
  120830. export var geometryVertexShader: {
  120831. name: string;
  120832. shader: string;
  120833. };
  120834. }
  120835. declare module BABYLON {
  120836. /** @hidden */
  120837. interface ISavedTransformationMatrix {
  120838. world: Matrix;
  120839. viewProjection: Matrix;
  120840. }
  120841. /**
  120842. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  120843. */
  120844. export class GeometryBufferRenderer {
  120845. /**
  120846. * Constant used to retrieve the position texture index in the G-Buffer textures array
  120847. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  120848. */
  120849. static readonly POSITION_TEXTURE_TYPE: number;
  120850. /**
  120851. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  120852. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  120853. */
  120854. static readonly VELOCITY_TEXTURE_TYPE: number;
  120855. /**
  120856. * Dictionary used to store the previous transformation matrices of each rendered mesh
  120857. * in order to compute objects velocities when enableVelocity is set to "true"
  120858. * @hidden
  120859. */
  120860. _previousTransformationMatrices: {
  120861. [index: number]: ISavedTransformationMatrix;
  120862. };
  120863. /**
  120864. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  120865. * in order to compute objects velocities when enableVelocity is set to "true"
  120866. * @hidden
  120867. */
  120868. _previousBonesTransformationMatrices: {
  120869. [index: number]: Float32Array;
  120870. };
  120871. /**
  120872. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  120873. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  120874. */
  120875. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  120876. private _scene;
  120877. private _multiRenderTarget;
  120878. private _ratio;
  120879. private _enablePosition;
  120880. private _enableVelocity;
  120881. private _positionIndex;
  120882. private _velocityIndex;
  120883. protected _effect: Effect;
  120884. protected _cachedDefines: string;
  120885. /**
  120886. * Set the render list (meshes to be rendered) used in the G buffer.
  120887. */
  120888. renderList: Mesh[];
  120889. /**
  120890. * Gets wether or not G buffer are supported by the running hardware.
  120891. * This requires draw buffer supports
  120892. */
  120893. readonly isSupported: boolean;
  120894. /**
  120895. * Returns the index of the given texture type in the G-Buffer textures array
  120896. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  120897. * @returns the index of the given texture type in the G-Buffer textures array
  120898. */
  120899. getTextureIndex(textureType: number): number;
  120900. /**
  120901. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  120902. */
  120903. /**
  120904. * Sets whether or not objects positions are enabled for the G buffer.
  120905. */
  120906. enablePosition: boolean;
  120907. /**
  120908. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  120909. */
  120910. /**
  120911. * Sets wether or not objects velocities are enabled for the G buffer.
  120912. */
  120913. enableVelocity: boolean;
  120914. /**
  120915. * Gets the scene associated with the buffer.
  120916. */
  120917. readonly scene: Scene;
  120918. /**
  120919. * Gets the ratio used by the buffer during its creation.
  120920. * How big is the buffer related to the main canvas.
  120921. */
  120922. readonly ratio: number;
  120923. /** @hidden */
  120924. static _SceneComponentInitialization: (scene: Scene) => void;
  120925. /**
  120926. * Creates a new G Buffer for the scene
  120927. * @param scene The scene the buffer belongs to
  120928. * @param ratio How big is the buffer related to the main canvas.
  120929. */
  120930. constructor(scene: Scene, ratio?: number);
  120931. /**
  120932. * Checks wether everything is ready to render a submesh to the G buffer.
  120933. * @param subMesh the submesh to check readiness for
  120934. * @param useInstances is the mesh drawn using instance or not
  120935. * @returns true if ready otherwise false
  120936. */
  120937. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120938. /**
  120939. * Gets the current underlying G Buffer.
  120940. * @returns the buffer
  120941. */
  120942. getGBuffer(): MultiRenderTarget;
  120943. /**
  120944. * Gets the number of samples used to render the buffer (anti aliasing).
  120945. */
  120946. /**
  120947. * Sets the number of samples used to render the buffer (anti aliasing).
  120948. */
  120949. samples: number;
  120950. /**
  120951. * Disposes the renderer and frees up associated resources.
  120952. */
  120953. dispose(): void;
  120954. protected _createRenderTargets(): void;
  120955. private _copyBonesTransformationMatrices;
  120956. }
  120957. }
  120958. declare module BABYLON {
  120959. interface Scene {
  120960. /** @hidden (Backing field) */
  120961. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  120962. /**
  120963. * Gets or Sets the current geometry buffer associated to the scene.
  120964. */
  120965. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  120966. /**
  120967. * Enables a GeometryBufferRender and associates it with the scene
  120968. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  120969. * @returns the GeometryBufferRenderer
  120970. */
  120971. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  120972. /**
  120973. * Disables the GeometryBufferRender associated with the scene
  120974. */
  120975. disableGeometryBufferRenderer(): void;
  120976. }
  120977. /**
  120978. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  120979. * in several rendering techniques.
  120980. */
  120981. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  120982. /**
  120983. * The component name helpful to identify the component in the list of scene components.
  120984. */
  120985. readonly name: string;
  120986. /**
  120987. * The scene the component belongs to.
  120988. */
  120989. scene: Scene;
  120990. /**
  120991. * Creates a new instance of the component for the given scene
  120992. * @param scene Defines the scene to register the component in
  120993. */
  120994. constructor(scene: Scene);
  120995. /**
  120996. * Registers the component in a given scene
  120997. */
  120998. register(): void;
  120999. /**
  121000. * Rebuilds the elements related to this component in case of
  121001. * context lost for instance.
  121002. */
  121003. rebuild(): void;
  121004. /**
  121005. * Disposes the component and the associated ressources
  121006. */
  121007. dispose(): void;
  121008. private _gatherRenderTargets;
  121009. }
  121010. }
  121011. declare module BABYLON {
  121012. /** @hidden */
  121013. export var motionBlurPixelShader: {
  121014. name: string;
  121015. shader: string;
  121016. };
  121017. }
  121018. declare module BABYLON {
  121019. /**
  121020. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  121021. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  121022. * As an example, all you have to do is to create the post-process:
  121023. * var mb = new BABYLON.MotionBlurPostProcess(
  121024. * 'mb', // The name of the effect.
  121025. * scene, // The scene containing the objects to blur according to their velocity.
  121026. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  121027. * camera // The camera to apply the render pass to.
  121028. * );
  121029. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  121030. */
  121031. export class MotionBlurPostProcess extends PostProcess {
  121032. /**
  121033. * Defines how much the image is blurred by the movement. Default value is equal to 1
  121034. */
  121035. motionStrength: number;
  121036. /**
  121037. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  121038. */
  121039. /**
  121040. * Sets the number of iterations to be used for motion blur quality
  121041. */
  121042. motionBlurSamples: number;
  121043. private _motionBlurSamples;
  121044. private _geometryBufferRenderer;
  121045. /**
  121046. * Creates a new instance MotionBlurPostProcess
  121047. * @param name The name of the effect.
  121048. * @param scene The scene containing the objects to blur according to their velocity.
  121049. * @param options The required width/height ratio to downsize to before computing the render pass.
  121050. * @param camera The camera to apply the render pass to.
  121051. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121052. * @param engine The engine which the post process will be applied. (default: current engine)
  121053. * @param reusable If the post process can be reused on the same frame. (default: false)
  121054. * @param textureType Type of textures used when performing the post process. (default: 0)
  121055. * @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)
  121056. */
  121057. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121058. /**
  121059. * Excludes the given skinned mesh from computing bones velocities.
  121060. * 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.
  121061. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  121062. */
  121063. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  121064. /**
  121065. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  121066. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  121067. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  121068. */
  121069. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  121070. /**
  121071. * Disposes the post process.
  121072. * @param camera The camera to dispose the post process on.
  121073. */
  121074. dispose(camera?: Camera): void;
  121075. }
  121076. }
  121077. declare module BABYLON {
  121078. /** @hidden */
  121079. export var refractionPixelShader: {
  121080. name: string;
  121081. shader: string;
  121082. };
  121083. }
  121084. declare module BABYLON {
  121085. /**
  121086. * Post process which applies a refractin texture
  121087. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  121088. */
  121089. export class RefractionPostProcess extends PostProcess {
  121090. /** the base color of the refraction (used to taint the rendering) */
  121091. color: Color3;
  121092. /** simulated refraction depth */
  121093. depth: number;
  121094. /** the coefficient of the base color (0 to remove base color tainting) */
  121095. colorLevel: number;
  121096. private _refTexture;
  121097. private _ownRefractionTexture;
  121098. /**
  121099. * Gets or sets the refraction texture
  121100. * Please note that you are responsible for disposing the texture if you set it manually
  121101. */
  121102. refractionTexture: Texture;
  121103. /**
  121104. * Initializes the RefractionPostProcess
  121105. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  121106. * @param name The name of the effect.
  121107. * @param refractionTextureUrl Url of the refraction texture to use
  121108. * @param color the base color of the refraction (used to taint the rendering)
  121109. * @param depth simulated refraction depth
  121110. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  121111. * @param camera The camera to apply the render pass to.
  121112. * @param options The required width/height ratio to downsize to before computing the render pass.
  121113. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121114. * @param engine The engine which the post process will be applied. (default: current engine)
  121115. * @param reusable If the post process can be reused on the same frame. (default: false)
  121116. */
  121117. constructor(name: string, refractionTextureUrl: string,
  121118. /** the base color of the refraction (used to taint the rendering) */
  121119. color: Color3,
  121120. /** simulated refraction depth */
  121121. depth: number,
  121122. /** the coefficient of the base color (0 to remove base color tainting) */
  121123. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  121124. /**
  121125. * Disposes of the post process
  121126. * @param camera Camera to dispose post process on
  121127. */
  121128. dispose(camera: Camera): void;
  121129. }
  121130. }
  121131. declare module BABYLON {
  121132. /** @hidden */
  121133. export var sharpenPixelShader: {
  121134. name: string;
  121135. shader: string;
  121136. };
  121137. }
  121138. declare module BABYLON {
  121139. /**
  121140. * The SharpenPostProcess applies a sharpen kernel to every pixel
  121141. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  121142. */
  121143. export class SharpenPostProcess extends PostProcess {
  121144. /**
  121145. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  121146. */
  121147. colorAmount: number;
  121148. /**
  121149. * How much sharpness should be applied (default: 0.3)
  121150. */
  121151. edgeAmount: number;
  121152. /**
  121153. * Creates a new instance ConvolutionPostProcess
  121154. * @param name The name of the effect.
  121155. * @param options The required width/height ratio to downsize to before computing the render pass.
  121156. * @param camera The camera to apply the render pass to.
  121157. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  121158. * @param engine The engine which the post process will be applied. (default: current engine)
  121159. * @param reusable If the post process can be reused on the same frame. (default: false)
  121160. * @param textureType Type of textures used when performing the post process. (default: 0)
  121161. * @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)
  121162. */
  121163. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  121164. }
  121165. }
  121166. declare module BABYLON {
  121167. /**
  121168. * PostProcessRenderPipeline
  121169. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121170. */
  121171. export class PostProcessRenderPipeline {
  121172. private engine;
  121173. private _renderEffects;
  121174. private _renderEffectsForIsolatedPass;
  121175. /**
  121176. * List of inspectable custom properties (used by the Inspector)
  121177. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  121178. */
  121179. inspectableCustomProperties: IInspectable[];
  121180. /**
  121181. * @hidden
  121182. */
  121183. protected _cameras: Camera[];
  121184. /** @hidden */
  121185. _name: string;
  121186. /**
  121187. * Gets pipeline name
  121188. */
  121189. readonly name: string;
  121190. /**
  121191. * Initializes a PostProcessRenderPipeline
  121192. * @param engine engine to add the pipeline to
  121193. * @param name name of the pipeline
  121194. */
  121195. constructor(engine: Engine, name: string);
  121196. /**
  121197. * Gets the class name
  121198. * @returns "PostProcessRenderPipeline"
  121199. */
  121200. getClassName(): string;
  121201. /**
  121202. * If all the render effects in the pipeline are supported
  121203. */
  121204. readonly isSupported: boolean;
  121205. /**
  121206. * Adds an effect to the pipeline
  121207. * @param renderEffect the effect to add
  121208. */
  121209. addEffect(renderEffect: PostProcessRenderEffect): void;
  121210. /** @hidden */
  121211. _rebuild(): void;
  121212. /** @hidden */
  121213. _enableEffect(renderEffectName: string, cameras: Camera): void;
  121214. /** @hidden */
  121215. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  121216. /** @hidden */
  121217. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  121218. /** @hidden */
  121219. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  121220. /** @hidden */
  121221. _attachCameras(cameras: Camera, unique: boolean): void;
  121222. /** @hidden */
  121223. _attachCameras(cameras: Camera[], unique: boolean): void;
  121224. /** @hidden */
  121225. _detachCameras(cameras: Camera): void;
  121226. /** @hidden */
  121227. _detachCameras(cameras: Nullable<Camera[]>): void;
  121228. /** @hidden */
  121229. _update(): void;
  121230. /** @hidden */
  121231. _reset(): void;
  121232. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  121233. /**
  121234. * Disposes of the pipeline
  121235. */
  121236. dispose(): void;
  121237. }
  121238. }
  121239. declare module BABYLON {
  121240. /**
  121241. * PostProcessRenderPipelineManager class
  121242. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121243. */
  121244. export class PostProcessRenderPipelineManager {
  121245. private _renderPipelines;
  121246. /**
  121247. * Initializes a PostProcessRenderPipelineManager
  121248. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121249. */
  121250. constructor();
  121251. /**
  121252. * Gets the list of supported render pipelines
  121253. */
  121254. readonly supportedPipelines: PostProcessRenderPipeline[];
  121255. /**
  121256. * Adds a pipeline to the manager
  121257. * @param renderPipeline The pipeline to add
  121258. */
  121259. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  121260. /**
  121261. * Attaches a camera to the pipeline
  121262. * @param renderPipelineName The name of the pipeline to attach to
  121263. * @param cameras the camera to attach
  121264. * @param unique if the camera can be attached multiple times to the pipeline
  121265. */
  121266. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  121267. /**
  121268. * Detaches a camera from the pipeline
  121269. * @param renderPipelineName The name of the pipeline to detach from
  121270. * @param cameras the camera to detach
  121271. */
  121272. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  121273. /**
  121274. * Enables an effect by name on a pipeline
  121275. * @param renderPipelineName the name of the pipeline to enable the effect in
  121276. * @param renderEffectName the name of the effect to enable
  121277. * @param cameras the cameras that the effect should be enabled on
  121278. */
  121279. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  121280. /**
  121281. * Disables an effect by name on a pipeline
  121282. * @param renderPipelineName the name of the pipeline to disable the effect in
  121283. * @param renderEffectName the name of the effect to disable
  121284. * @param cameras the cameras that the effect should be disabled on
  121285. */
  121286. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  121287. /**
  121288. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  121289. */
  121290. update(): void;
  121291. /** @hidden */
  121292. _rebuild(): void;
  121293. /**
  121294. * Disposes of the manager and pipelines
  121295. */
  121296. dispose(): void;
  121297. }
  121298. }
  121299. declare module BABYLON {
  121300. interface Scene {
  121301. /** @hidden (Backing field) */
  121302. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  121303. /**
  121304. * Gets the postprocess render pipeline manager
  121305. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121306. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  121307. */
  121308. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  121309. }
  121310. /**
  121311. * Defines the Render Pipeline scene component responsible to rendering pipelines
  121312. */
  121313. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  121314. /**
  121315. * The component name helpfull to identify the component in the list of scene components.
  121316. */
  121317. readonly name: string;
  121318. /**
  121319. * The scene the component belongs to.
  121320. */
  121321. scene: Scene;
  121322. /**
  121323. * Creates a new instance of the component for the given scene
  121324. * @param scene Defines the scene to register the component in
  121325. */
  121326. constructor(scene: Scene);
  121327. /**
  121328. * Registers the component in a given scene
  121329. */
  121330. register(): void;
  121331. /**
  121332. * Rebuilds the elements related to this component in case of
  121333. * context lost for instance.
  121334. */
  121335. rebuild(): void;
  121336. /**
  121337. * Disposes the component and the associated ressources
  121338. */
  121339. dispose(): void;
  121340. private _gatherRenderTargets;
  121341. }
  121342. }
  121343. declare module BABYLON {
  121344. /**
  121345. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  121346. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  121347. */
  121348. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  121349. private _scene;
  121350. private _camerasToBeAttached;
  121351. /**
  121352. * ID of the sharpen post process,
  121353. */
  121354. private readonly SharpenPostProcessId;
  121355. /**
  121356. * @ignore
  121357. * ID of the image processing post process;
  121358. */
  121359. readonly ImageProcessingPostProcessId: string;
  121360. /**
  121361. * @ignore
  121362. * ID of the Fast Approximate Anti-Aliasing post process;
  121363. */
  121364. readonly FxaaPostProcessId: string;
  121365. /**
  121366. * ID of the chromatic aberration post process,
  121367. */
  121368. private readonly ChromaticAberrationPostProcessId;
  121369. /**
  121370. * ID of the grain post process
  121371. */
  121372. private readonly GrainPostProcessId;
  121373. /**
  121374. * Sharpen post process which will apply a sharpen convolution to enhance edges
  121375. */
  121376. sharpen: SharpenPostProcess;
  121377. private _sharpenEffect;
  121378. private bloom;
  121379. /**
  121380. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  121381. */
  121382. depthOfField: DepthOfFieldEffect;
  121383. /**
  121384. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  121385. */
  121386. fxaa: FxaaPostProcess;
  121387. /**
  121388. * Image post processing pass used to perform operations such as tone mapping or color grading.
  121389. */
  121390. imageProcessing: ImageProcessingPostProcess;
  121391. /**
  121392. * Chromatic aberration post process which will shift rgb colors in the image
  121393. */
  121394. chromaticAberration: ChromaticAberrationPostProcess;
  121395. private _chromaticAberrationEffect;
  121396. /**
  121397. * Grain post process which add noise to the image
  121398. */
  121399. grain: GrainPostProcess;
  121400. private _grainEffect;
  121401. /**
  121402. * Glow post process which adds a glow to emissive areas of the image
  121403. */
  121404. private _glowLayer;
  121405. /**
  121406. * Animations which can be used to tweak settings over a period of time
  121407. */
  121408. animations: Animation[];
  121409. private _imageProcessingConfigurationObserver;
  121410. private _sharpenEnabled;
  121411. private _bloomEnabled;
  121412. private _depthOfFieldEnabled;
  121413. private _depthOfFieldBlurLevel;
  121414. private _fxaaEnabled;
  121415. private _imageProcessingEnabled;
  121416. private _defaultPipelineTextureType;
  121417. private _bloomScale;
  121418. private _chromaticAberrationEnabled;
  121419. private _grainEnabled;
  121420. private _buildAllowed;
  121421. /**
  121422. * Gets active scene
  121423. */
  121424. readonly scene: Scene;
  121425. /**
  121426. * Enable or disable the sharpen process from the pipeline
  121427. */
  121428. sharpenEnabled: boolean;
  121429. private _resizeObserver;
  121430. private _hardwareScaleLevel;
  121431. private _bloomKernel;
  121432. /**
  121433. * Specifies the size of the bloom blur kernel, relative to the final output size
  121434. */
  121435. bloomKernel: number;
  121436. /**
  121437. * Specifies the weight of the bloom in the final rendering
  121438. */
  121439. private _bloomWeight;
  121440. /**
  121441. * Specifies the luma threshold for the area that will be blurred by the bloom
  121442. */
  121443. private _bloomThreshold;
  121444. private _hdr;
  121445. /**
  121446. * The strength of the bloom.
  121447. */
  121448. bloomWeight: number;
  121449. /**
  121450. * The strength of the bloom.
  121451. */
  121452. bloomThreshold: number;
  121453. /**
  121454. * The scale of the bloom, lower value will provide better performance.
  121455. */
  121456. bloomScale: number;
  121457. /**
  121458. * Enable or disable the bloom from the pipeline
  121459. */
  121460. bloomEnabled: boolean;
  121461. private _rebuildBloom;
  121462. /**
  121463. * If the depth of field is enabled.
  121464. */
  121465. depthOfFieldEnabled: boolean;
  121466. /**
  121467. * Blur level of the depth of field effect. (Higher blur will effect performance)
  121468. */
  121469. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  121470. /**
  121471. * If the anti aliasing is enabled.
  121472. */
  121473. fxaaEnabled: boolean;
  121474. private _samples;
  121475. /**
  121476. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  121477. */
  121478. samples: number;
  121479. /**
  121480. * If image processing is enabled.
  121481. */
  121482. imageProcessingEnabled: boolean;
  121483. /**
  121484. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  121485. */
  121486. glowLayerEnabled: boolean;
  121487. /**
  121488. * Gets the glow layer (or null if not defined)
  121489. */
  121490. readonly glowLayer: Nullable<GlowLayer>;
  121491. /**
  121492. * Enable or disable the chromaticAberration process from the pipeline
  121493. */
  121494. chromaticAberrationEnabled: boolean;
  121495. /**
  121496. * Enable or disable the grain process from the pipeline
  121497. */
  121498. grainEnabled: boolean;
  121499. /**
  121500. * @constructor
  121501. * @param name - The rendering pipeline name (default: "")
  121502. * @param hdr - If high dynamic range textures should be used (default: true)
  121503. * @param scene - The scene linked to this pipeline (default: the last created scene)
  121504. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  121505. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  121506. */
  121507. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  121508. /**
  121509. * Get the class name
  121510. * @returns "DefaultRenderingPipeline"
  121511. */
  121512. getClassName(): string;
  121513. /**
  121514. * Force the compilation of the entire pipeline.
  121515. */
  121516. prepare(): void;
  121517. private _hasCleared;
  121518. private _prevPostProcess;
  121519. private _prevPrevPostProcess;
  121520. private _setAutoClearAndTextureSharing;
  121521. private _depthOfFieldSceneObserver;
  121522. private _buildPipeline;
  121523. private _disposePostProcesses;
  121524. /**
  121525. * Adds a camera to the pipeline
  121526. * @param camera the camera to be added
  121527. */
  121528. addCamera(camera: Camera): void;
  121529. /**
  121530. * Removes a camera from the pipeline
  121531. * @param camera the camera to remove
  121532. */
  121533. removeCamera(camera: Camera): void;
  121534. /**
  121535. * Dispose of the pipeline and stop all post processes
  121536. */
  121537. dispose(): void;
  121538. /**
  121539. * Serialize the rendering pipeline (Used when exporting)
  121540. * @returns the serialized object
  121541. */
  121542. serialize(): any;
  121543. /**
  121544. * Parse the serialized pipeline
  121545. * @param source Source pipeline.
  121546. * @param scene The scene to load the pipeline to.
  121547. * @param rootUrl The URL of the serialized pipeline.
  121548. * @returns An instantiated pipeline from the serialized object.
  121549. */
  121550. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  121551. }
  121552. }
  121553. declare module BABYLON {
  121554. /** @hidden */
  121555. export var lensHighlightsPixelShader: {
  121556. name: string;
  121557. shader: string;
  121558. };
  121559. }
  121560. declare module BABYLON {
  121561. /** @hidden */
  121562. export var depthOfFieldPixelShader: {
  121563. name: string;
  121564. shader: string;
  121565. };
  121566. }
  121567. declare module BABYLON {
  121568. /**
  121569. * BABYLON.JS Chromatic Aberration GLSL Shader
  121570. * Author: Olivier Guyot
  121571. * Separates very slightly R, G and B colors on the edges of the screen
  121572. * Inspired by Francois Tarlier & Martins Upitis
  121573. */
  121574. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  121575. /**
  121576. * @ignore
  121577. * The chromatic aberration PostProcess id in the pipeline
  121578. */
  121579. LensChromaticAberrationEffect: string;
  121580. /**
  121581. * @ignore
  121582. * The highlights enhancing PostProcess id in the pipeline
  121583. */
  121584. HighlightsEnhancingEffect: string;
  121585. /**
  121586. * @ignore
  121587. * The depth-of-field PostProcess id in the pipeline
  121588. */
  121589. LensDepthOfFieldEffect: string;
  121590. private _scene;
  121591. private _depthTexture;
  121592. private _grainTexture;
  121593. private _chromaticAberrationPostProcess;
  121594. private _highlightsPostProcess;
  121595. private _depthOfFieldPostProcess;
  121596. private _edgeBlur;
  121597. private _grainAmount;
  121598. private _chromaticAberration;
  121599. private _distortion;
  121600. private _highlightsGain;
  121601. private _highlightsThreshold;
  121602. private _dofDistance;
  121603. private _dofAperture;
  121604. private _dofDarken;
  121605. private _dofPentagon;
  121606. private _blurNoise;
  121607. /**
  121608. * @constructor
  121609. *
  121610. * Effect parameters are as follow:
  121611. * {
  121612. * chromatic_aberration: number; // from 0 to x (1 for realism)
  121613. * edge_blur: number; // from 0 to x (1 for realism)
  121614. * distortion: number; // from 0 to x (1 for realism)
  121615. * grain_amount: number; // from 0 to 1
  121616. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  121617. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  121618. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  121619. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  121620. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  121621. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  121622. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  121623. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  121624. * }
  121625. * Note: if an effect parameter is unset, effect is disabled
  121626. *
  121627. * @param name The rendering pipeline name
  121628. * @param parameters - An object containing all parameters (see above)
  121629. * @param scene The scene linked to this pipeline
  121630. * @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)
  121631. * @param cameras The array of cameras that the rendering pipeline will be attached to
  121632. */
  121633. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  121634. /**
  121635. * Get the class name
  121636. * @returns "LensRenderingPipeline"
  121637. */
  121638. getClassName(): string;
  121639. /**
  121640. * Gets associated scene
  121641. */
  121642. readonly scene: Scene;
  121643. /**
  121644. * Gets or sets the edge blur
  121645. */
  121646. edgeBlur: number;
  121647. /**
  121648. * Gets or sets the grain amount
  121649. */
  121650. grainAmount: number;
  121651. /**
  121652. * Gets or sets the chromatic aberration amount
  121653. */
  121654. chromaticAberration: number;
  121655. /**
  121656. * Gets or sets the depth of field aperture
  121657. */
  121658. dofAperture: number;
  121659. /**
  121660. * Gets or sets the edge distortion
  121661. */
  121662. edgeDistortion: number;
  121663. /**
  121664. * Gets or sets the depth of field distortion
  121665. */
  121666. dofDistortion: number;
  121667. /**
  121668. * Gets or sets the darken out of focus amount
  121669. */
  121670. darkenOutOfFocus: number;
  121671. /**
  121672. * Gets or sets a boolean indicating if blur noise is enabled
  121673. */
  121674. blurNoise: boolean;
  121675. /**
  121676. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  121677. */
  121678. pentagonBokeh: boolean;
  121679. /**
  121680. * Gets or sets the highlight grain amount
  121681. */
  121682. highlightsGain: number;
  121683. /**
  121684. * Gets or sets the highlight threshold
  121685. */
  121686. highlightsThreshold: number;
  121687. /**
  121688. * Sets the amount of blur at the edges
  121689. * @param amount blur amount
  121690. */
  121691. setEdgeBlur(amount: number): void;
  121692. /**
  121693. * Sets edge blur to 0
  121694. */
  121695. disableEdgeBlur(): void;
  121696. /**
  121697. * Sets the amout of grain
  121698. * @param amount Amount of grain
  121699. */
  121700. setGrainAmount(amount: number): void;
  121701. /**
  121702. * Set grain amount to 0
  121703. */
  121704. disableGrain(): void;
  121705. /**
  121706. * Sets the chromatic aberration amount
  121707. * @param amount amount of chromatic aberration
  121708. */
  121709. setChromaticAberration(amount: number): void;
  121710. /**
  121711. * Sets chromatic aberration amount to 0
  121712. */
  121713. disableChromaticAberration(): void;
  121714. /**
  121715. * Sets the EdgeDistortion amount
  121716. * @param amount amount of EdgeDistortion
  121717. */
  121718. setEdgeDistortion(amount: number): void;
  121719. /**
  121720. * Sets edge distortion to 0
  121721. */
  121722. disableEdgeDistortion(): void;
  121723. /**
  121724. * Sets the FocusDistance amount
  121725. * @param amount amount of FocusDistance
  121726. */
  121727. setFocusDistance(amount: number): void;
  121728. /**
  121729. * Disables depth of field
  121730. */
  121731. disableDepthOfField(): void;
  121732. /**
  121733. * Sets the Aperture amount
  121734. * @param amount amount of Aperture
  121735. */
  121736. setAperture(amount: number): void;
  121737. /**
  121738. * Sets the DarkenOutOfFocus amount
  121739. * @param amount amount of DarkenOutOfFocus
  121740. */
  121741. setDarkenOutOfFocus(amount: number): void;
  121742. private _pentagonBokehIsEnabled;
  121743. /**
  121744. * Creates a pentagon bokeh effect
  121745. */
  121746. enablePentagonBokeh(): void;
  121747. /**
  121748. * Disables the pentagon bokeh effect
  121749. */
  121750. disablePentagonBokeh(): void;
  121751. /**
  121752. * Enables noise blur
  121753. */
  121754. enableNoiseBlur(): void;
  121755. /**
  121756. * Disables noise blur
  121757. */
  121758. disableNoiseBlur(): void;
  121759. /**
  121760. * Sets the HighlightsGain amount
  121761. * @param amount amount of HighlightsGain
  121762. */
  121763. setHighlightsGain(amount: number): void;
  121764. /**
  121765. * Sets the HighlightsThreshold amount
  121766. * @param amount amount of HighlightsThreshold
  121767. */
  121768. setHighlightsThreshold(amount: number): void;
  121769. /**
  121770. * Disables highlights
  121771. */
  121772. disableHighlights(): void;
  121773. /**
  121774. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  121775. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  121776. */
  121777. dispose(disableDepthRender?: boolean): void;
  121778. private _createChromaticAberrationPostProcess;
  121779. private _createHighlightsPostProcess;
  121780. private _createDepthOfFieldPostProcess;
  121781. private _createGrainTexture;
  121782. }
  121783. }
  121784. declare module BABYLON {
  121785. /** @hidden */
  121786. export var ssao2PixelShader: {
  121787. name: string;
  121788. shader: string;
  121789. };
  121790. }
  121791. declare module BABYLON {
  121792. /** @hidden */
  121793. export var ssaoCombinePixelShader: {
  121794. name: string;
  121795. shader: string;
  121796. };
  121797. }
  121798. declare module BABYLON {
  121799. /**
  121800. * Render pipeline to produce ssao effect
  121801. */
  121802. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  121803. /**
  121804. * @ignore
  121805. * The PassPostProcess id in the pipeline that contains the original scene color
  121806. */
  121807. SSAOOriginalSceneColorEffect: string;
  121808. /**
  121809. * @ignore
  121810. * The SSAO PostProcess id in the pipeline
  121811. */
  121812. SSAORenderEffect: string;
  121813. /**
  121814. * @ignore
  121815. * The horizontal blur PostProcess id in the pipeline
  121816. */
  121817. SSAOBlurHRenderEffect: string;
  121818. /**
  121819. * @ignore
  121820. * The vertical blur PostProcess id in the pipeline
  121821. */
  121822. SSAOBlurVRenderEffect: string;
  121823. /**
  121824. * @ignore
  121825. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  121826. */
  121827. SSAOCombineRenderEffect: string;
  121828. /**
  121829. * The output strength of the SSAO post-process. Default value is 1.0.
  121830. */
  121831. totalStrength: number;
  121832. /**
  121833. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  121834. */
  121835. maxZ: number;
  121836. /**
  121837. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  121838. */
  121839. minZAspect: number;
  121840. private _samples;
  121841. /**
  121842. * Number of samples used for the SSAO calculations. Default value is 8
  121843. */
  121844. samples: number;
  121845. private _textureSamples;
  121846. /**
  121847. * Number of samples to use for antialiasing
  121848. */
  121849. textureSamples: number;
  121850. /**
  121851. * Ratio object used for SSAO ratio and blur ratio
  121852. */
  121853. private _ratio;
  121854. /**
  121855. * Dynamically generated sphere sampler.
  121856. */
  121857. private _sampleSphere;
  121858. /**
  121859. * Blur filter offsets
  121860. */
  121861. private _samplerOffsets;
  121862. private _expensiveBlur;
  121863. /**
  121864. * If bilateral blur should be used
  121865. */
  121866. expensiveBlur: boolean;
  121867. /**
  121868. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  121869. */
  121870. radius: number;
  121871. /**
  121872. * The base color of the SSAO post-process
  121873. * The final result is "base + ssao" between [0, 1]
  121874. */
  121875. base: number;
  121876. /**
  121877. * Support test.
  121878. */
  121879. static readonly IsSupported: boolean;
  121880. private _scene;
  121881. private _depthTexture;
  121882. private _normalTexture;
  121883. private _randomTexture;
  121884. private _originalColorPostProcess;
  121885. private _ssaoPostProcess;
  121886. private _blurHPostProcess;
  121887. private _blurVPostProcess;
  121888. private _ssaoCombinePostProcess;
  121889. private _firstUpdate;
  121890. /**
  121891. * Gets active scene
  121892. */
  121893. readonly scene: Scene;
  121894. /**
  121895. * @constructor
  121896. * @param name The rendering pipeline name
  121897. * @param scene The scene linked to this pipeline
  121898. * @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 }
  121899. * @param cameras The array of cameras that the rendering pipeline will be attached to
  121900. */
  121901. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  121902. /**
  121903. * Get the class name
  121904. * @returns "SSAO2RenderingPipeline"
  121905. */
  121906. getClassName(): string;
  121907. /**
  121908. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  121909. */
  121910. dispose(disableGeometryBufferRenderer?: boolean): void;
  121911. private _createBlurPostProcess;
  121912. /** @hidden */
  121913. _rebuild(): void;
  121914. private _bits;
  121915. private _radicalInverse_VdC;
  121916. private _hammersley;
  121917. private _hemisphereSample_uniform;
  121918. private _generateHemisphere;
  121919. private _createSSAOPostProcess;
  121920. private _createSSAOCombinePostProcess;
  121921. private _createRandomTexture;
  121922. /**
  121923. * Serialize the rendering pipeline (Used when exporting)
  121924. * @returns the serialized object
  121925. */
  121926. serialize(): any;
  121927. /**
  121928. * Parse the serialized pipeline
  121929. * @param source Source pipeline.
  121930. * @param scene The scene to load the pipeline to.
  121931. * @param rootUrl The URL of the serialized pipeline.
  121932. * @returns An instantiated pipeline from the serialized object.
  121933. */
  121934. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  121935. }
  121936. }
  121937. declare module BABYLON {
  121938. /** @hidden */
  121939. export var ssaoPixelShader: {
  121940. name: string;
  121941. shader: string;
  121942. };
  121943. }
  121944. declare module BABYLON {
  121945. /**
  121946. * Render pipeline to produce ssao effect
  121947. */
  121948. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  121949. /**
  121950. * @ignore
  121951. * The PassPostProcess id in the pipeline that contains the original scene color
  121952. */
  121953. SSAOOriginalSceneColorEffect: string;
  121954. /**
  121955. * @ignore
  121956. * The SSAO PostProcess id in the pipeline
  121957. */
  121958. SSAORenderEffect: string;
  121959. /**
  121960. * @ignore
  121961. * The horizontal blur PostProcess id in the pipeline
  121962. */
  121963. SSAOBlurHRenderEffect: string;
  121964. /**
  121965. * @ignore
  121966. * The vertical blur PostProcess id in the pipeline
  121967. */
  121968. SSAOBlurVRenderEffect: string;
  121969. /**
  121970. * @ignore
  121971. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  121972. */
  121973. SSAOCombineRenderEffect: string;
  121974. /**
  121975. * The output strength of the SSAO post-process. Default value is 1.0.
  121976. */
  121977. totalStrength: number;
  121978. /**
  121979. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  121980. */
  121981. radius: number;
  121982. /**
  121983. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  121984. * Must not be equal to fallOff and superior to fallOff.
  121985. * Default value is 0.0075
  121986. */
  121987. area: number;
  121988. /**
  121989. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  121990. * Must not be equal to area and inferior to area.
  121991. * Default value is 0.000001
  121992. */
  121993. fallOff: number;
  121994. /**
  121995. * The base color of the SSAO post-process
  121996. * The final result is "base + ssao" between [0, 1]
  121997. */
  121998. base: number;
  121999. private _scene;
  122000. private _depthTexture;
  122001. private _randomTexture;
  122002. private _originalColorPostProcess;
  122003. private _ssaoPostProcess;
  122004. private _blurHPostProcess;
  122005. private _blurVPostProcess;
  122006. private _ssaoCombinePostProcess;
  122007. private _firstUpdate;
  122008. /**
  122009. * Gets active scene
  122010. */
  122011. readonly scene: Scene;
  122012. /**
  122013. * @constructor
  122014. * @param name - The rendering pipeline name
  122015. * @param scene - The scene linked to this pipeline
  122016. * @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 }
  122017. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  122018. */
  122019. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  122020. /**
  122021. * Get the class name
  122022. * @returns "SSAORenderingPipeline"
  122023. */
  122024. getClassName(): string;
  122025. /**
  122026. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  122027. */
  122028. dispose(disableDepthRender?: boolean): void;
  122029. private _createBlurPostProcess;
  122030. /** @hidden */
  122031. _rebuild(): void;
  122032. private _createSSAOPostProcess;
  122033. private _createSSAOCombinePostProcess;
  122034. private _createRandomTexture;
  122035. }
  122036. }
  122037. declare module BABYLON {
  122038. /** @hidden */
  122039. export var standardPixelShader: {
  122040. name: string;
  122041. shader: string;
  122042. };
  122043. }
  122044. declare module BABYLON {
  122045. /**
  122046. * Standard rendering pipeline
  122047. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  122048. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  122049. */
  122050. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  122051. /**
  122052. * Public members
  122053. */
  122054. /**
  122055. * Post-process which contains the original scene color before the pipeline applies all the effects
  122056. */
  122057. originalPostProcess: Nullable<PostProcess>;
  122058. /**
  122059. * Post-process used to down scale an image x4
  122060. */
  122061. downSampleX4PostProcess: Nullable<PostProcess>;
  122062. /**
  122063. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  122064. */
  122065. brightPassPostProcess: Nullable<PostProcess>;
  122066. /**
  122067. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  122068. */
  122069. blurHPostProcesses: PostProcess[];
  122070. /**
  122071. * Post-process array storing all the vertical blur post-processes used by the pipeline
  122072. */
  122073. blurVPostProcesses: PostProcess[];
  122074. /**
  122075. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  122076. */
  122077. textureAdderPostProcess: Nullable<PostProcess>;
  122078. /**
  122079. * Post-process used to create volumetric lighting effect
  122080. */
  122081. volumetricLightPostProcess: Nullable<PostProcess>;
  122082. /**
  122083. * Post-process used to smooth the previous volumetric light post-process on the X axis
  122084. */
  122085. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  122086. /**
  122087. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  122088. */
  122089. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  122090. /**
  122091. * Post-process used to merge the volumetric light effect and the real scene color
  122092. */
  122093. volumetricLightMergePostProces: Nullable<PostProcess>;
  122094. /**
  122095. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  122096. */
  122097. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  122098. /**
  122099. * Base post-process used to calculate the average luminance of the final image for HDR
  122100. */
  122101. luminancePostProcess: Nullable<PostProcess>;
  122102. /**
  122103. * Post-processes used to create down sample post-processes in order to get
  122104. * the average luminance of the final image for HDR
  122105. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  122106. */
  122107. luminanceDownSamplePostProcesses: PostProcess[];
  122108. /**
  122109. * Post-process used to create a HDR effect (light adaptation)
  122110. */
  122111. hdrPostProcess: Nullable<PostProcess>;
  122112. /**
  122113. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  122114. */
  122115. textureAdderFinalPostProcess: Nullable<PostProcess>;
  122116. /**
  122117. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  122118. */
  122119. lensFlareFinalPostProcess: Nullable<PostProcess>;
  122120. /**
  122121. * Post-process used to merge the final HDR post-process and the real scene color
  122122. */
  122123. hdrFinalPostProcess: Nullable<PostProcess>;
  122124. /**
  122125. * Post-process used to create a lens flare effect
  122126. */
  122127. lensFlarePostProcess: Nullable<PostProcess>;
  122128. /**
  122129. * Post-process that merges the result of the lens flare post-process and the real scene color
  122130. */
  122131. lensFlareComposePostProcess: Nullable<PostProcess>;
  122132. /**
  122133. * Post-process used to create a motion blur effect
  122134. */
  122135. motionBlurPostProcess: Nullable<PostProcess>;
  122136. /**
  122137. * Post-process used to create a depth of field effect
  122138. */
  122139. depthOfFieldPostProcess: Nullable<PostProcess>;
  122140. /**
  122141. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  122142. */
  122143. fxaaPostProcess: Nullable<FxaaPostProcess>;
  122144. /**
  122145. * Represents the brightness threshold in order to configure the illuminated surfaces
  122146. */
  122147. brightThreshold: number;
  122148. /**
  122149. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  122150. */
  122151. blurWidth: number;
  122152. /**
  122153. * Sets if the blur for highlighted surfaces must be only horizontal
  122154. */
  122155. horizontalBlur: boolean;
  122156. /**
  122157. * Gets the overall exposure used by the pipeline
  122158. */
  122159. /**
  122160. * Sets the overall exposure used by the pipeline
  122161. */
  122162. exposure: number;
  122163. /**
  122164. * Texture used typically to simulate "dirty" on camera lens
  122165. */
  122166. lensTexture: Nullable<Texture>;
  122167. /**
  122168. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  122169. */
  122170. volumetricLightCoefficient: number;
  122171. /**
  122172. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  122173. */
  122174. volumetricLightPower: number;
  122175. /**
  122176. * Used the set the blur intensity to smooth the volumetric lights
  122177. */
  122178. volumetricLightBlurScale: number;
  122179. /**
  122180. * Light (spot or directional) used to generate the volumetric lights rays
  122181. * The source light must have a shadow generate so the pipeline can get its
  122182. * depth map
  122183. */
  122184. sourceLight: Nullable<SpotLight | DirectionalLight>;
  122185. /**
  122186. * For eye adaptation, represents the minimum luminance the eye can see
  122187. */
  122188. hdrMinimumLuminance: number;
  122189. /**
  122190. * For eye adaptation, represents the decrease luminance speed
  122191. */
  122192. hdrDecreaseRate: number;
  122193. /**
  122194. * For eye adaptation, represents the increase luminance speed
  122195. */
  122196. hdrIncreaseRate: number;
  122197. /**
  122198. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  122199. */
  122200. /**
  122201. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  122202. */
  122203. hdrAutoExposure: boolean;
  122204. /**
  122205. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  122206. */
  122207. lensColorTexture: Nullable<Texture>;
  122208. /**
  122209. * The overall strengh for the lens flare effect
  122210. */
  122211. lensFlareStrength: number;
  122212. /**
  122213. * Dispersion coefficient for lens flare ghosts
  122214. */
  122215. lensFlareGhostDispersal: number;
  122216. /**
  122217. * Main lens flare halo width
  122218. */
  122219. lensFlareHaloWidth: number;
  122220. /**
  122221. * Based on the lens distortion effect, defines how much the lens flare result
  122222. * is distorted
  122223. */
  122224. lensFlareDistortionStrength: number;
  122225. /**
  122226. * Lens star texture must be used to simulate rays on the flares and is available
  122227. * in the documentation
  122228. */
  122229. lensStarTexture: Nullable<Texture>;
  122230. /**
  122231. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  122232. * flare effect by taking account of the dirt texture
  122233. */
  122234. lensFlareDirtTexture: Nullable<Texture>;
  122235. /**
  122236. * Represents the focal length for the depth of field effect
  122237. */
  122238. depthOfFieldDistance: number;
  122239. /**
  122240. * Represents the blur intensity for the blurred part of the depth of field effect
  122241. */
  122242. depthOfFieldBlurWidth: number;
  122243. /**
  122244. * Gets how much the image is blurred by the movement while using the motion blur post-process
  122245. */
  122246. /**
  122247. * Sets how much the image is blurred by the movement while using the motion blur post-process
  122248. */
  122249. motionStrength: number;
  122250. /**
  122251. * Gets wether or not the motion blur post-process is object based or screen based.
  122252. */
  122253. /**
  122254. * Sets wether or not the motion blur post-process should be object based or screen based
  122255. */
  122256. objectBasedMotionBlur: boolean;
  122257. /**
  122258. * List of animations for the pipeline (IAnimatable implementation)
  122259. */
  122260. animations: Animation[];
  122261. /**
  122262. * Private members
  122263. */
  122264. private _scene;
  122265. private _currentDepthOfFieldSource;
  122266. private _basePostProcess;
  122267. private _fixedExposure;
  122268. private _currentExposure;
  122269. private _hdrAutoExposure;
  122270. private _hdrCurrentLuminance;
  122271. private _motionStrength;
  122272. private _isObjectBasedMotionBlur;
  122273. private _floatTextureType;
  122274. private _ratio;
  122275. private _bloomEnabled;
  122276. private _depthOfFieldEnabled;
  122277. private _vlsEnabled;
  122278. private _lensFlareEnabled;
  122279. private _hdrEnabled;
  122280. private _motionBlurEnabled;
  122281. private _fxaaEnabled;
  122282. private _motionBlurSamples;
  122283. private _volumetricLightStepsCount;
  122284. private _samples;
  122285. /**
  122286. * @ignore
  122287. * Specifies if the bloom pipeline is enabled
  122288. */
  122289. BloomEnabled: boolean;
  122290. /**
  122291. * @ignore
  122292. * Specifies if the depth of field pipeline is enabed
  122293. */
  122294. DepthOfFieldEnabled: boolean;
  122295. /**
  122296. * @ignore
  122297. * Specifies if the lens flare pipeline is enabed
  122298. */
  122299. LensFlareEnabled: boolean;
  122300. /**
  122301. * @ignore
  122302. * Specifies if the HDR pipeline is enabled
  122303. */
  122304. HDREnabled: boolean;
  122305. /**
  122306. * @ignore
  122307. * Specifies if the volumetric lights scattering effect is enabled
  122308. */
  122309. VLSEnabled: boolean;
  122310. /**
  122311. * @ignore
  122312. * Specifies if the motion blur effect is enabled
  122313. */
  122314. MotionBlurEnabled: boolean;
  122315. /**
  122316. * Specifies if anti-aliasing is enabled
  122317. */
  122318. fxaaEnabled: boolean;
  122319. /**
  122320. * Specifies the number of steps used to calculate the volumetric lights
  122321. * Typically in interval [50, 200]
  122322. */
  122323. volumetricLightStepsCount: number;
  122324. /**
  122325. * Specifies the number of samples used for the motion blur effect
  122326. * Typically in interval [16, 64]
  122327. */
  122328. motionBlurSamples: number;
  122329. /**
  122330. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  122331. */
  122332. samples: number;
  122333. /**
  122334. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  122335. * @constructor
  122336. * @param name The rendering pipeline name
  122337. * @param scene The scene linked to this pipeline
  122338. * @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)
  122339. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  122340. * @param cameras The array of cameras that the rendering pipeline will be attached to
  122341. */
  122342. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  122343. private _buildPipeline;
  122344. private _createDownSampleX4PostProcess;
  122345. private _createBrightPassPostProcess;
  122346. private _createBlurPostProcesses;
  122347. private _createTextureAdderPostProcess;
  122348. private _createVolumetricLightPostProcess;
  122349. private _createLuminancePostProcesses;
  122350. private _createHdrPostProcess;
  122351. private _createLensFlarePostProcess;
  122352. private _createDepthOfFieldPostProcess;
  122353. private _createMotionBlurPostProcess;
  122354. private _getDepthTexture;
  122355. private _disposePostProcesses;
  122356. /**
  122357. * Dispose of the pipeline and stop all post processes
  122358. */
  122359. dispose(): void;
  122360. /**
  122361. * Serialize the rendering pipeline (Used when exporting)
  122362. * @returns the serialized object
  122363. */
  122364. serialize(): any;
  122365. /**
  122366. * Parse the serialized pipeline
  122367. * @param source Source pipeline.
  122368. * @param scene The scene to load the pipeline to.
  122369. * @param rootUrl The URL of the serialized pipeline.
  122370. * @returns An instantiated pipeline from the serialized object.
  122371. */
  122372. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  122373. /**
  122374. * Luminance steps
  122375. */
  122376. static LuminanceSteps: number;
  122377. }
  122378. }
  122379. declare module BABYLON {
  122380. /** @hidden */
  122381. export var tonemapPixelShader: {
  122382. name: string;
  122383. shader: string;
  122384. };
  122385. }
  122386. declare module BABYLON {
  122387. /** Defines operator used for tonemapping */
  122388. export enum TonemappingOperator {
  122389. /** Hable */
  122390. Hable = 0,
  122391. /** Reinhard */
  122392. Reinhard = 1,
  122393. /** HejiDawson */
  122394. HejiDawson = 2,
  122395. /** Photographic */
  122396. Photographic = 3
  122397. }
  122398. /**
  122399. * Defines a post process to apply tone mapping
  122400. */
  122401. export class TonemapPostProcess extends PostProcess {
  122402. private _operator;
  122403. /** Defines the required exposure adjustement */
  122404. exposureAdjustment: number;
  122405. /**
  122406. * Creates a new TonemapPostProcess
  122407. * @param name defines the name of the postprocess
  122408. * @param _operator defines the operator to use
  122409. * @param exposureAdjustment defines the required exposure adjustement
  122410. * @param camera defines the camera to use (can be null)
  122411. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  122412. * @param engine defines the hosting engine (can be ignore if camera is set)
  122413. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  122414. */
  122415. constructor(name: string, _operator: TonemappingOperator,
  122416. /** Defines the required exposure adjustement */
  122417. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  122418. }
  122419. }
  122420. declare module BABYLON {
  122421. /** @hidden */
  122422. export var depthVertexShader: {
  122423. name: string;
  122424. shader: string;
  122425. };
  122426. }
  122427. declare module BABYLON {
  122428. /** @hidden */
  122429. export var volumetricLightScatteringPixelShader: {
  122430. name: string;
  122431. shader: string;
  122432. };
  122433. }
  122434. declare module BABYLON {
  122435. /** @hidden */
  122436. export var volumetricLightScatteringPassPixelShader: {
  122437. name: string;
  122438. shader: string;
  122439. };
  122440. }
  122441. declare module BABYLON {
  122442. /**
  122443. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  122444. */
  122445. export class VolumetricLightScatteringPostProcess extends PostProcess {
  122446. private _volumetricLightScatteringPass;
  122447. private _volumetricLightScatteringRTT;
  122448. private _viewPort;
  122449. private _screenCoordinates;
  122450. private _cachedDefines;
  122451. /**
  122452. * If not undefined, the mesh position is computed from the attached node position
  122453. */
  122454. attachedNode: {
  122455. position: Vector3;
  122456. };
  122457. /**
  122458. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  122459. */
  122460. customMeshPosition: Vector3;
  122461. /**
  122462. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  122463. */
  122464. useCustomMeshPosition: boolean;
  122465. /**
  122466. * If the post-process should inverse the light scattering direction
  122467. */
  122468. invert: boolean;
  122469. /**
  122470. * The internal mesh used by the post-process
  122471. */
  122472. mesh: Mesh;
  122473. /**
  122474. * @hidden
  122475. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  122476. */
  122477. useDiffuseColor: boolean;
  122478. /**
  122479. * Array containing the excluded meshes not rendered in the internal pass
  122480. */
  122481. excludedMeshes: AbstractMesh[];
  122482. /**
  122483. * Controls the overall intensity of the post-process
  122484. */
  122485. exposure: number;
  122486. /**
  122487. * Dissipates each sample's contribution in range [0, 1]
  122488. */
  122489. decay: number;
  122490. /**
  122491. * Controls the overall intensity of each sample
  122492. */
  122493. weight: number;
  122494. /**
  122495. * Controls the density of each sample
  122496. */
  122497. density: number;
  122498. /**
  122499. * @constructor
  122500. * @param name The post-process name
  122501. * @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)
  122502. * @param camera The camera that the post-process will be attached to
  122503. * @param mesh The mesh used to create the light scattering
  122504. * @param samples The post-process quality, default 100
  122505. * @param samplingModeThe post-process filtering mode
  122506. * @param engine The babylon engine
  122507. * @param reusable If the post-process is reusable
  122508. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  122509. */
  122510. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  122511. /**
  122512. * Returns the string "VolumetricLightScatteringPostProcess"
  122513. * @returns "VolumetricLightScatteringPostProcess"
  122514. */
  122515. getClassName(): string;
  122516. private _isReady;
  122517. /**
  122518. * Sets the new light position for light scattering effect
  122519. * @param position The new custom light position
  122520. */
  122521. setCustomMeshPosition(position: Vector3): void;
  122522. /**
  122523. * Returns the light position for light scattering effect
  122524. * @return Vector3 The custom light position
  122525. */
  122526. getCustomMeshPosition(): Vector3;
  122527. /**
  122528. * Disposes the internal assets and detaches the post-process from the camera
  122529. */
  122530. dispose(camera: Camera): void;
  122531. /**
  122532. * Returns the render target texture used by the post-process
  122533. * @return the render target texture used by the post-process
  122534. */
  122535. getPass(): RenderTargetTexture;
  122536. private _meshExcluded;
  122537. private _createPass;
  122538. private _updateMeshScreenCoordinates;
  122539. /**
  122540. * Creates a default mesh for the Volumeric Light Scattering post-process
  122541. * @param name The mesh name
  122542. * @param scene The scene where to create the mesh
  122543. * @return the default mesh
  122544. */
  122545. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  122546. }
  122547. }
  122548. declare module BABYLON {
  122549. interface Scene {
  122550. /** @hidden (Backing field) */
  122551. _boundingBoxRenderer: BoundingBoxRenderer;
  122552. /** @hidden (Backing field) */
  122553. _forceShowBoundingBoxes: boolean;
  122554. /**
  122555. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  122556. */
  122557. forceShowBoundingBoxes: boolean;
  122558. /**
  122559. * Gets the bounding box renderer associated with the scene
  122560. * @returns a BoundingBoxRenderer
  122561. */
  122562. getBoundingBoxRenderer(): BoundingBoxRenderer;
  122563. }
  122564. interface AbstractMesh {
  122565. /** @hidden (Backing field) */
  122566. _showBoundingBox: boolean;
  122567. /**
  122568. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  122569. */
  122570. showBoundingBox: boolean;
  122571. }
  122572. /**
  122573. * Component responsible of rendering the bounding box of the meshes in a scene.
  122574. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  122575. */
  122576. export class BoundingBoxRenderer implements ISceneComponent {
  122577. /**
  122578. * The component name helpfull to identify the component in the list of scene components.
  122579. */
  122580. readonly name: string;
  122581. /**
  122582. * The scene the component belongs to.
  122583. */
  122584. scene: Scene;
  122585. /**
  122586. * Color of the bounding box lines placed in front of an object
  122587. */
  122588. frontColor: Color3;
  122589. /**
  122590. * Color of the bounding box lines placed behind an object
  122591. */
  122592. backColor: Color3;
  122593. /**
  122594. * Defines if the renderer should show the back lines or not
  122595. */
  122596. showBackLines: boolean;
  122597. /**
  122598. * @hidden
  122599. */
  122600. renderList: SmartArray<BoundingBox>;
  122601. private _colorShader;
  122602. private _vertexBuffers;
  122603. private _indexBuffer;
  122604. private _fillIndexBuffer;
  122605. private _fillIndexData;
  122606. /**
  122607. * Instantiates a new bounding box renderer in a scene.
  122608. * @param scene the scene the renderer renders in
  122609. */
  122610. constructor(scene: Scene);
  122611. /**
  122612. * Registers the component in a given scene
  122613. */
  122614. register(): void;
  122615. private _evaluateSubMesh;
  122616. private _activeMesh;
  122617. private _prepareRessources;
  122618. private _createIndexBuffer;
  122619. /**
  122620. * Rebuilds the elements related to this component in case of
  122621. * context lost for instance.
  122622. */
  122623. rebuild(): void;
  122624. /**
  122625. * @hidden
  122626. */
  122627. reset(): void;
  122628. /**
  122629. * Render the bounding boxes of a specific rendering group
  122630. * @param renderingGroupId defines the rendering group to render
  122631. */
  122632. render(renderingGroupId: number): void;
  122633. /**
  122634. * In case of occlusion queries, we can render the occlusion bounding box through this method
  122635. * @param mesh Define the mesh to render the occlusion bounding box for
  122636. */
  122637. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  122638. /**
  122639. * Dispose and release the resources attached to this renderer.
  122640. */
  122641. dispose(): void;
  122642. }
  122643. }
  122644. declare module BABYLON {
  122645. /** @hidden */
  122646. export var depthPixelShader: {
  122647. name: string;
  122648. shader: string;
  122649. };
  122650. }
  122651. declare module BABYLON {
  122652. /**
  122653. * This represents a depth renderer in Babylon.
  122654. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  122655. */
  122656. export class DepthRenderer {
  122657. private _scene;
  122658. private _depthMap;
  122659. private _effect;
  122660. private readonly _storeNonLinearDepth;
  122661. private readonly _clearColor;
  122662. /** Get if the depth renderer is using packed depth or not */
  122663. readonly isPacked: boolean;
  122664. private _cachedDefines;
  122665. private _camera;
  122666. /**
  122667. * Specifiess that the depth renderer will only be used within
  122668. * the camera it is created for.
  122669. * This can help forcing its rendering during the camera processing.
  122670. */
  122671. useOnlyInActiveCamera: boolean;
  122672. /** @hidden */
  122673. static _SceneComponentInitialization: (scene: Scene) => void;
  122674. /**
  122675. * Instantiates a depth renderer
  122676. * @param scene The scene the renderer belongs to
  122677. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  122678. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  122679. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  122680. */
  122681. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  122682. /**
  122683. * Creates the depth rendering effect and checks if the effect is ready.
  122684. * @param subMesh The submesh to be used to render the depth map of
  122685. * @param useInstances If multiple world instances should be used
  122686. * @returns if the depth renderer is ready to render the depth map
  122687. */
  122688. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122689. /**
  122690. * Gets the texture which the depth map will be written to.
  122691. * @returns The depth map texture
  122692. */
  122693. getDepthMap(): RenderTargetTexture;
  122694. /**
  122695. * Disposes of the depth renderer.
  122696. */
  122697. dispose(): void;
  122698. }
  122699. }
  122700. declare module BABYLON {
  122701. interface Scene {
  122702. /** @hidden (Backing field) */
  122703. _depthRenderer: {
  122704. [id: string]: DepthRenderer;
  122705. };
  122706. /**
  122707. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  122708. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  122709. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  122710. * @returns the created depth renderer
  122711. */
  122712. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  122713. /**
  122714. * Disables a depth renderer for a given camera
  122715. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  122716. */
  122717. disableDepthRenderer(camera?: Nullable<Camera>): void;
  122718. }
  122719. /**
  122720. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  122721. * in several rendering techniques.
  122722. */
  122723. export class DepthRendererSceneComponent implements ISceneComponent {
  122724. /**
  122725. * The component name helpfull to identify the component in the list of scene components.
  122726. */
  122727. readonly name: string;
  122728. /**
  122729. * The scene the component belongs to.
  122730. */
  122731. scene: Scene;
  122732. /**
  122733. * Creates a new instance of the component for the given scene
  122734. * @param scene Defines the scene to register the component in
  122735. */
  122736. constructor(scene: Scene);
  122737. /**
  122738. * Registers the component in a given scene
  122739. */
  122740. register(): void;
  122741. /**
  122742. * Rebuilds the elements related to this component in case of
  122743. * context lost for instance.
  122744. */
  122745. rebuild(): void;
  122746. /**
  122747. * Disposes the component and the associated ressources
  122748. */
  122749. dispose(): void;
  122750. private _gatherRenderTargets;
  122751. private _gatherActiveCameraRenderTargets;
  122752. }
  122753. }
  122754. declare module BABYLON {
  122755. /** @hidden */
  122756. export var outlinePixelShader: {
  122757. name: string;
  122758. shader: string;
  122759. };
  122760. }
  122761. declare module BABYLON {
  122762. /** @hidden */
  122763. export var outlineVertexShader: {
  122764. name: string;
  122765. shader: string;
  122766. };
  122767. }
  122768. declare module BABYLON {
  122769. interface Scene {
  122770. /** @hidden */
  122771. _outlineRenderer: OutlineRenderer;
  122772. /**
  122773. * Gets the outline renderer associated with the scene
  122774. * @returns a OutlineRenderer
  122775. */
  122776. getOutlineRenderer(): OutlineRenderer;
  122777. }
  122778. interface AbstractMesh {
  122779. /** @hidden (Backing field) */
  122780. _renderOutline: boolean;
  122781. /**
  122782. * Gets or sets a boolean indicating if the outline must be rendered as well
  122783. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  122784. */
  122785. renderOutline: boolean;
  122786. /** @hidden (Backing field) */
  122787. _renderOverlay: boolean;
  122788. /**
  122789. * Gets or sets a boolean indicating if the overlay must be rendered as well
  122790. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  122791. */
  122792. renderOverlay: boolean;
  122793. }
  122794. /**
  122795. * This class is responsible to draw bothe outline/overlay of meshes.
  122796. * It should not be used directly but through the available method on mesh.
  122797. */
  122798. export class OutlineRenderer implements ISceneComponent {
  122799. /**
  122800. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  122801. */
  122802. private static _StencilReference;
  122803. /**
  122804. * The name of the component. Each component must have a unique name.
  122805. */
  122806. name: string;
  122807. /**
  122808. * The scene the component belongs to.
  122809. */
  122810. scene: Scene;
  122811. /**
  122812. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  122813. */
  122814. zOffset: number;
  122815. private _engine;
  122816. private _effect;
  122817. private _cachedDefines;
  122818. private _savedDepthWrite;
  122819. /**
  122820. * Instantiates a new outline renderer. (There could be only one per scene).
  122821. * @param scene Defines the scene it belongs to
  122822. */
  122823. constructor(scene: Scene);
  122824. /**
  122825. * Register the component to one instance of a scene.
  122826. */
  122827. register(): void;
  122828. /**
  122829. * Rebuilds the elements related to this component in case of
  122830. * context lost for instance.
  122831. */
  122832. rebuild(): void;
  122833. /**
  122834. * Disposes the component and the associated ressources.
  122835. */
  122836. dispose(): void;
  122837. /**
  122838. * Renders the outline in the canvas.
  122839. * @param subMesh Defines the sumesh to render
  122840. * @param batch Defines the batch of meshes in case of instances
  122841. * @param useOverlay Defines if the rendering is for the overlay or the outline
  122842. */
  122843. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  122844. /**
  122845. * Returns whether or not the outline renderer is ready for a given submesh.
  122846. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  122847. * @param subMesh Defines the submesh to check readyness for
  122848. * @param useInstances Defines wheter wee are trying to render instances or not
  122849. * @returns true if ready otherwise false
  122850. */
  122851. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122852. private _beforeRenderingMesh;
  122853. private _afterRenderingMesh;
  122854. }
  122855. }
  122856. declare module BABYLON {
  122857. /**
  122858. * Defines the list of states available for a task inside a AssetsManager
  122859. */
  122860. export enum AssetTaskState {
  122861. /**
  122862. * Initialization
  122863. */
  122864. INIT = 0,
  122865. /**
  122866. * Running
  122867. */
  122868. RUNNING = 1,
  122869. /**
  122870. * Done
  122871. */
  122872. DONE = 2,
  122873. /**
  122874. * Error
  122875. */
  122876. ERROR = 3
  122877. }
  122878. /**
  122879. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  122880. */
  122881. export abstract class AbstractAssetTask {
  122882. /**
  122883. * Task name
  122884. */ name: string;
  122885. /**
  122886. * Callback called when the task is successful
  122887. */
  122888. onSuccess: (task: any) => void;
  122889. /**
  122890. * Callback called when the task is not successful
  122891. */
  122892. onError: (task: any, message?: string, exception?: any) => void;
  122893. /**
  122894. * Creates a new AssetsManager
  122895. * @param name defines the name of the task
  122896. */
  122897. constructor(
  122898. /**
  122899. * Task name
  122900. */ name: string);
  122901. private _isCompleted;
  122902. private _taskState;
  122903. private _errorObject;
  122904. /**
  122905. * Get if the task is completed
  122906. */
  122907. readonly isCompleted: boolean;
  122908. /**
  122909. * Gets the current state of the task
  122910. */
  122911. readonly taskState: AssetTaskState;
  122912. /**
  122913. * Gets the current error object (if task is in error)
  122914. */
  122915. readonly errorObject: {
  122916. message?: string;
  122917. exception?: any;
  122918. };
  122919. /**
  122920. * Internal only
  122921. * @hidden
  122922. */
  122923. _setErrorObject(message?: string, exception?: any): void;
  122924. /**
  122925. * Execute the current task
  122926. * @param scene defines the scene where you want your assets to be loaded
  122927. * @param onSuccess is a callback called when the task is successfully executed
  122928. * @param onError is a callback called if an error occurs
  122929. */
  122930. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  122931. /**
  122932. * Execute the current task
  122933. * @param scene defines the scene where you want your assets to be loaded
  122934. * @param onSuccess is a callback called when the task is successfully executed
  122935. * @param onError is a callback called if an error occurs
  122936. */
  122937. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  122938. /**
  122939. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  122940. * This can be used with failed tasks that have the reason for failure fixed.
  122941. */
  122942. reset(): void;
  122943. private onErrorCallback;
  122944. private onDoneCallback;
  122945. }
  122946. /**
  122947. * Define the interface used by progress events raised during assets loading
  122948. */
  122949. export interface IAssetsProgressEvent {
  122950. /**
  122951. * Defines the number of remaining tasks to process
  122952. */
  122953. remainingCount: number;
  122954. /**
  122955. * Defines the total number of tasks
  122956. */
  122957. totalCount: number;
  122958. /**
  122959. * Defines the task that was just processed
  122960. */
  122961. task: AbstractAssetTask;
  122962. }
  122963. /**
  122964. * Class used to share progress information about assets loading
  122965. */
  122966. export class AssetsProgressEvent implements IAssetsProgressEvent {
  122967. /**
  122968. * Defines the number of remaining tasks to process
  122969. */
  122970. remainingCount: number;
  122971. /**
  122972. * Defines the total number of tasks
  122973. */
  122974. totalCount: number;
  122975. /**
  122976. * Defines the task that was just processed
  122977. */
  122978. task: AbstractAssetTask;
  122979. /**
  122980. * Creates a AssetsProgressEvent
  122981. * @param remainingCount defines the number of remaining tasks to process
  122982. * @param totalCount defines the total number of tasks
  122983. * @param task defines the task that was just processed
  122984. */
  122985. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  122986. }
  122987. /**
  122988. * Define a task used by AssetsManager to load meshes
  122989. */
  122990. export class MeshAssetTask extends AbstractAssetTask {
  122991. /**
  122992. * Defines the name of the task
  122993. */
  122994. name: string;
  122995. /**
  122996. * Defines the list of mesh's names you want to load
  122997. */
  122998. meshesNames: any;
  122999. /**
  123000. * Defines the root url to use as a base to load your meshes and associated resources
  123001. */
  123002. rootUrl: string;
  123003. /**
  123004. * Defines the filename of the scene to load from
  123005. */
  123006. sceneFilename: string;
  123007. /**
  123008. * Gets the list of loaded meshes
  123009. */
  123010. loadedMeshes: Array<AbstractMesh>;
  123011. /**
  123012. * Gets the list of loaded particle systems
  123013. */
  123014. loadedParticleSystems: Array<IParticleSystem>;
  123015. /**
  123016. * Gets the list of loaded skeletons
  123017. */
  123018. loadedSkeletons: Array<Skeleton>;
  123019. /**
  123020. * Gets the list of loaded animation groups
  123021. */
  123022. loadedAnimationGroups: Array<AnimationGroup>;
  123023. /**
  123024. * Callback called when the task is successful
  123025. */
  123026. onSuccess: (task: MeshAssetTask) => void;
  123027. /**
  123028. * Callback called when the task is successful
  123029. */
  123030. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  123031. /**
  123032. * Creates a new MeshAssetTask
  123033. * @param name defines the name of the task
  123034. * @param meshesNames defines the list of mesh's names you want to load
  123035. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  123036. * @param sceneFilename defines the filename of the scene to load from
  123037. */
  123038. constructor(
  123039. /**
  123040. * Defines the name of the task
  123041. */
  123042. name: string,
  123043. /**
  123044. * Defines the list of mesh's names you want to load
  123045. */
  123046. meshesNames: any,
  123047. /**
  123048. * Defines the root url to use as a base to load your meshes and associated resources
  123049. */
  123050. rootUrl: string,
  123051. /**
  123052. * Defines the filename of the scene to load from
  123053. */
  123054. sceneFilename: string);
  123055. /**
  123056. * Execute the current task
  123057. * @param scene defines the scene where you want your assets to be loaded
  123058. * @param onSuccess is a callback called when the task is successfully executed
  123059. * @param onError is a callback called if an error occurs
  123060. */
  123061. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123062. }
  123063. /**
  123064. * Define a task used by AssetsManager to load text content
  123065. */
  123066. export class TextFileAssetTask extends AbstractAssetTask {
  123067. /**
  123068. * Defines the name of the task
  123069. */
  123070. name: string;
  123071. /**
  123072. * Defines the location of the file to load
  123073. */
  123074. url: string;
  123075. /**
  123076. * Gets the loaded text string
  123077. */
  123078. text: string;
  123079. /**
  123080. * Callback called when the task is successful
  123081. */
  123082. onSuccess: (task: TextFileAssetTask) => void;
  123083. /**
  123084. * Callback called when the task is successful
  123085. */
  123086. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  123087. /**
  123088. * Creates a new TextFileAssetTask object
  123089. * @param name defines the name of the task
  123090. * @param url defines the location of the file to load
  123091. */
  123092. constructor(
  123093. /**
  123094. * Defines the name of the task
  123095. */
  123096. name: string,
  123097. /**
  123098. * Defines the location of the file to load
  123099. */
  123100. url: string);
  123101. /**
  123102. * Execute the current task
  123103. * @param scene defines the scene where you want your assets to be loaded
  123104. * @param onSuccess is a callback called when the task is successfully executed
  123105. * @param onError is a callback called if an error occurs
  123106. */
  123107. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123108. }
  123109. /**
  123110. * Define a task used by AssetsManager to load binary data
  123111. */
  123112. export class BinaryFileAssetTask extends AbstractAssetTask {
  123113. /**
  123114. * Defines the name of the task
  123115. */
  123116. name: string;
  123117. /**
  123118. * Defines the location of the file to load
  123119. */
  123120. url: string;
  123121. /**
  123122. * Gets the lodaded data (as an array buffer)
  123123. */
  123124. data: ArrayBuffer;
  123125. /**
  123126. * Callback called when the task is successful
  123127. */
  123128. onSuccess: (task: BinaryFileAssetTask) => void;
  123129. /**
  123130. * Callback called when the task is successful
  123131. */
  123132. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  123133. /**
  123134. * Creates a new BinaryFileAssetTask object
  123135. * @param name defines the name of the new task
  123136. * @param url defines the location of the file to load
  123137. */
  123138. constructor(
  123139. /**
  123140. * Defines the name of the task
  123141. */
  123142. name: string,
  123143. /**
  123144. * Defines the location of the file to load
  123145. */
  123146. url: string);
  123147. /**
  123148. * Execute the current task
  123149. * @param scene defines the scene where you want your assets to be loaded
  123150. * @param onSuccess is a callback called when the task is successfully executed
  123151. * @param onError is a callback called if an error occurs
  123152. */
  123153. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123154. }
  123155. /**
  123156. * Define a task used by AssetsManager to load images
  123157. */
  123158. export class ImageAssetTask extends AbstractAssetTask {
  123159. /**
  123160. * Defines the name of the task
  123161. */
  123162. name: string;
  123163. /**
  123164. * Defines the location of the image to load
  123165. */
  123166. url: string;
  123167. /**
  123168. * Gets the loaded images
  123169. */
  123170. image: HTMLImageElement;
  123171. /**
  123172. * Callback called when the task is successful
  123173. */
  123174. onSuccess: (task: ImageAssetTask) => void;
  123175. /**
  123176. * Callback called when the task is successful
  123177. */
  123178. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  123179. /**
  123180. * Creates a new ImageAssetTask
  123181. * @param name defines the name of the task
  123182. * @param url defines the location of the image to load
  123183. */
  123184. constructor(
  123185. /**
  123186. * Defines the name of the task
  123187. */
  123188. name: string,
  123189. /**
  123190. * Defines the location of the image to load
  123191. */
  123192. url: string);
  123193. /**
  123194. * Execute the current task
  123195. * @param scene defines the scene where you want your assets to be loaded
  123196. * @param onSuccess is a callback called when the task is successfully executed
  123197. * @param onError is a callback called if an error occurs
  123198. */
  123199. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123200. }
  123201. /**
  123202. * Defines the interface used by texture loading tasks
  123203. */
  123204. export interface ITextureAssetTask<TEX extends BaseTexture> {
  123205. /**
  123206. * Gets the loaded texture
  123207. */
  123208. texture: TEX;
  123209. }
  123210. /**
  123211. * Define a task used by AssetsManager to load 2D textures
  123212. */
  123213. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  123214. /**
  123215. * Defines the name of the task
  123216. */
  123217. name: string;
  123218. /**
  123219. * Defines the location of the file to load
  123220. */
  123221. url: string;
  123222. /**
  123223. * Defines if mipmap should not be generated (default is false)
  123224. */
  123225. noMipmap?: boolean | undefined;
  123226. /**
  123227. * Defines if texture must be inverted on Y axis (default is false)
  123228. */
  123229. invertY?: boolean | undefined;
  123230. /**
  123231. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  123232. */
  123233. samplingMode: number;
  123234. /**
  123235. * Gets the loaded texture
  123236. */
  123237. texture: Texture;
  123238. /**
  123239. * Callback called when the task is successful
  123240. */
  123241. onSuccess: (task: TextureAssetTask) => void;
  123242. /**
  123243. * Callback called when the task is successful
  123244. */
  123245. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  123246. /**
  123247. * Creates a new TextureAssetTask object
  123248. * @param name defines the name of the task
  123249. * @param url defines the location of the file to load
  123250. * @param noMipmap defines if mipmap should not be generated (default is false)
  123251. * @param invertY defines if texture must be inverted on Y axis (default is false)
  123252. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  123253. */
  123254. constructor(
  123255. /**
  123256. * Defines the name of the task
  123257. */
  123258. name: string,
  123259. /**
  123260. * Defines the location of the file to load
  123261. */
  123262. url: string,
  123263. /**
  123264. * Defines if mipmap should not be generated (default is false)
  123265. */
  123266. noMipmap?: boolean | undefined,
  123267. /**
  123268. * Defines if texture must be inverted on Y axis (default is false)
  123269. */
  123270. invertY?: boolean | undefined,
  123271. /**
  123272. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  123273. */
  123274. samplingMode?: number);
  123275. /**
  123276. * Execute the current task
  123277. * @param scene defines the scene where you want your assets to be loaded
  123278. * @param onSuccess is a callback called when the task is successfully executed
  123279. * @param onError is a callback called if an error occurs
  123280. */
  123281. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123282. }
  123283. /**
  123284. * Define a task used by AssetsManager to load cube textures
  123285. */
  123286. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  123287. /**
  123288. * Defines the name of the task
  123289. */
  123290. name: string;
  123291. /**
  123292. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  123293. */
  123294. url: string;
  123295. /**
  123296. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  123297. */
  123298. extensions?: string[] | undefined;
  123299. /**
  123300. * Defines if mipmaps should not be generated (default is false)
  123301. */
  123302. noMipmap?: boolean | undefined;
  123303. /**
  123304. * Defines the explicit list of files (undefined by default)
  123305. */
  123306. files?: string[] | undefined;
  123307. /**
  123308. * Gets the loaded texture
  123309. */
  123310. texture: CubeTexture;
  123311. /**
  123312. * Callback called when the task is successful
  123313. */
  123314. onSuccess: (task: CubeTextureAssetTask) => void;
  123315. /**
  123316. * Callback called when the task is successful
  123317. */
  123318. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  123319. /**
  123320. * Creates a new CubeTextureAssetTask
  123321. * @param name defines the name of the task
  123322. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  123323. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  123324. * @param noMipmap defines if mipmaps should not be generated (default is false)
  123325. * @param files defines the explicit list of files (undefined by default)
  123326. */
  123327. constructor(
  123328. /**
  123329. * Defines the name of the task
  123330. */
  123331. name: string,
  123332. /**
  123333. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  123334. */
  123335. url: string,
  123336. /**
  123337. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  123338. */
  123339. extensions?: string[] | undefined,
  123340. /**
  123341. * Defines if mipmaps should not be generated (default is false)
  123342. */
  123343. noMipmap?: boolean | undefined,
  123344. /**
  123345. * Defines the explicit list of files (undefined by default)
  123346. */
  123347. files?: string[] | undefined);
  123348. /**
  123349. * Execute the current task
  123350. * @param scene defines the scene where you want your assets to be loaded
  123351. * @param onSuccess is a callback called when the task is successfully executed
  123352. * @param onError is a callback called if an error occurs
  123353. */
  123354. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123355. }
  123356. /**
  123357. * Define a task used by AssetsManager to load HDR cube textures
  123358. */
  123359. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  123360. /**
  123361. * Defines the name of the task
  123362. */
  123363. name: string;
  123364. /**
  123365. * Defines the location of the file to load
  123366. */
  123367. url: string;
  123368. /**
  123369. * Defines the desired size (the more it increases the longer the generation will be)
  123370. */
  123371. size: number;
  123372. /**
  123373. * Defines if mipmaps should not be generated (default is false)
  123374. */
  123375. noMipmap: boolean;
  123376. /**
  123377. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  123378. */
  123379. generateHarmonics: boolean;
  123380. /**
  123381. * 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)
  123382. */
  123383. gammaSpace: boolean;
  123384. /**
  123385. * Internal Use Only
  123386. */
  123387. reserved: boolean;
  123388. /**
  123389. * Gets the loaded texture
  123390. */
  123391. texture: HDRCubeTexture;
  123392. /**
  123393. * Callback called when the task is successful
  123394. */
  123395. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  123396. /**
  123397. * Callback called when the task is successful
  123398. */
  123399. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  123400. /**
  123401. * Creates a new HDRCubeTextureAssetTask object
  123402. * @param name defines the name of the task
  123403. * @param url defines the location of the file to load
  123404. * @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.
  123405. * @param noMipmap defines if mipmaps should not be generated (default is false)
  123406. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  123407. * @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)
  123408. * @param reserved Internal use only
  123409. */
  123410. constructor(
  123411. /**
  123412. * Defines the name of the task
  123413. */
  123414. name: string,
  123415. /**
  123416. * Defines the location of the file to load
  123417. */
  123418. url: string,
  123419. /**
  123420. * Defines the desired size (the more it increases the longer the generation will be)
  123421. */
  123422. size: number,
  123423. /**
  123424. * Defines if mipmaps should not be generated (default is false)
  123425. */
  123426. noMipmap?: boolean,
  123427. /**
  123428. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  123429. */
  123430. generateHarmonics?: boolean,
  123431. /**
  123432. * 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)
  123433. */
  123434. gammaSpace?: boolean,
  123435. /**
  123436. * Internal Use Only
  123437. */
  123438. reserved?: boolean);
  123439. /**
  123440. * Execute the current task
  123441. * @param scene defines the scene where you want your assets to be loaded
  123442. * @param onSuccess is a callback called when the task is successfully executed
  123443. * @param onError is a callback called if an error occurs
  123444. */
  123445. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123446. }
  123447. /**
  123448. * Define a task used by AssetsManager to load Equirectangular cube textures
  123449. */
  123450. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  123451. /**
  123452. * Defines the name of the task
  123453. */
  123454. name: string;
  123455. /**
  123456. * Defines the location of the file to load
  123457. */
  123458. url: string;
  123459. /**
  123460. * Defines the desired size (the more it increases the longer the generation will be)
  123461. */
  123462. size: number;
  123463. /**
  123464. * Defines if mipmaps should not be generated (default is false)
  123465. */
  123466. noMipmap: boolean;
  123467. /**
  123468. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  123469. * but the standard material would require them in Gamma space) (default is true)
  123470. */
  123471. gammaSpace: boolean;
  123472. /**
  123473. * Gets the loaded texture
  123474. */
  123475. texture: EquiRectangularCubeTexture;
  123476. /**
  123477. * Callback called when the task is successful
  123478. */
  123479. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  123480. /**
  123481. * Callback called when the task is successful
  123482. */
  123483. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  123484. /**
  123485. * Creates a new EquiRectangularCubeTextureAssetTask object
  123486. * @param name defines the name of the task
  123487. * @param url defines the location of the file to load
  123488. * @param size defines the desired size (the more it increases the longer the generation will be)
  123489. * If the size is omitted this implies you are using a preprocessed cubemap.
  123490. * @param noMipmap defines if mipmaps should not be generated (default is false)
  123491. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  123492. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  123493. * (default is true)
  123494. */
  123495. constructor(
  123496. /**
  123497. * Defines the name of the task
  123498. */
  123499. name: string,
  123500. /**
  123501. * Defines the location of the file to load
  123502. */
  123503. url: string,
  123504. /**
  123505. * Defines the desired size (the more it increases the longer the generation will be)
  123506. */
  123507. size: number,
  123508. /**
  123509. * Defines if mipmaps should not be generated (default is false)
  123510. */
  123511. noMipmap?: boolean,
  123512. /**
  123513. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  123514. * but the standard material would require them in Gamma space) (default is true)
  123515. */
  123516. gammaSpace?: boolean);
  123517. /**
  123518. * Execute the current task
  123519. * @param scene defines the scene where you want your assets to be loaded
  123520. * @param onSuccess is a callback called when the task is successfully executed
  123521. * @param onError is a callback called if an error occurs
  123522. */
  123523. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123524. }
  123525. /**
  123526. * This class can be used to easily import assets into a scene
  123527. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  123528. */
  123529. export class AssetsManager {
  123530. private _scene;
  123531. private _isLoading;
  123532. protected _tasks: AbstractAssetTask[];
  123533. protected _waitingTasksCount: number;
  123534. protected _totalTasksCount: number;
  123535. /**
  123536. * Callback called when all tasks are processed
  123537. */
  123538. onFinish: (tasks: AbstractAssetTask[]) => void;
  123539. /**
  123540. * Callback called when a task is successful
  123541. */
  123542. onTaskSuccess: (task: AbstractAssetTask) => void;
  123543. /**
  123544. * Callback called when a task had an error
  123545. */
  123546. onTaskError: (task: AbstractAssetTask) => void;
  123547. /**
  123548. * Callback called when a task is done (whatever the result is)
  123549. */
  123550. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  123551. /**
  123552. * Observable called when all tasks are processed
  123553. */
  123554. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  123555. /**
  123556. * Observable called when a task had an error
  123557. */
  123558. onTaskErrorObservable: Observable<AbstractAssetTask>;
  123559. /**
  123560. * Observable called when all tasks were executed
  123561. */
  123562. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  123563. /**
  123564. * Observable called when a task is done (whatever the result is)
  123565. */
  123566. onProgressObservable: Observable<IAssetsProgressEvent>;
  123567. /**
  123568. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  123569. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123570. */
  123571. useDefaultLoadingScreen: boolean;
  123572. /**
  123573. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  123574. * when all assets have been downloaded.
  123575. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  123576. */
  123577. autoHideLoadingUI: boolean;
  123578. /**
  123579. * Creates a new AssetsManager
  123580. * @param scene defines the scene to work on
  123581. */
  123582. constructor(scene: Scene);
  123583. /**
  123584. * Add a MeshAssetTask to the list of active tasks
  123585. * @param taskName defines the name of the new task
  123586. * @param meshesNames defines the name of meshes to load
  123587. * @param rootUrl defines the root url to use to locate files
  123588. * @param sceneFilename defines the filename of the scene file
  123589. * @returns a new MeshAssetTask object
  123590. */
  123591. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  123592. /**
  123593. * Add a TextFileAssetTask to the list of active tasks
  123594. * @param taskName defines the name of the new task
  123595. * @param url defines the url of the file to load
  123596. * @returns a new TextFileAssetTask object
  123597. */
  123598. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  123599. /**
  123600. * Add a BinaryFileAssetTask to the list of active tasks
  123601. * @param taskName defines the name of the new task
  123602. * @param url defines the url of the file to load
  123603. * @returns a new BinaryFileAssetTask object
  123604. */
  123605. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  123606. /**
  123607. * Add a ImageAssetTask to the list of active tasks
  123608. * @param taskName defines the name of the new task
  123609. * @param url defines the url of the file to load
  123610. * @returns a new ImageAssetTask object
  123611. */
  123612. addImageTask(taskName: string, url: string): ImageAssetTask;
  123613. /**
  123614. * Add a TextureAssetTask to the list of active tasks
  123615. * @param taskName defines the name of the new task
  123616. * @param url defines the url of the file to load
  123617. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  123618. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  123619. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  123620. * @returns a new TextureAssetTask object
  123621. */
  123622. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  123623. /**
  123624. * Add a CubeTextureAssetTask to the list of active tasks
  123625. * @param taskName defines the name of the new task
  123626. * @param url defines the url of the file to load
  123627. * @param extensions defines the extension to use to load the cube map (can be null)
  123628. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  123629. * @param files defines the list of files to load (can be null)
  123630. * @returns a new CubeTextureAssetTask object
  123631. */
  123632. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  123633. /**
  123634. *
  123635. * Add a HDRCubeTextureAssetTask to the list of active tasks
  123636. * @param taskName defines the name of the new task
  123637. * @param url defines the url of the file to load
  123638. * @param size defines the size you want for the cubemap (can be null)
  123639. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  123640. * @param generateHarmonics defines if you want to automatically generate (true by default)
  123641. * @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)
  123642. * @param reserved Internal use only
  123643. * @returns a new HDRCubeTextureAssetTask object
  123644. */
  123645. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  123646. /**
  123647. *
  123648. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  123649. * @param taskName defines the name of the new task
  123650. * @param url defines the url of the file to load
  123651. * @param size defines the size you want for the cubemap (can be null)
  123652. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  123653. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  123654. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  123655. * @returns a new EquiRectangularCubeTextureAssetTask object
  123656. */
  123657. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  123658. /**
  123659. * Remove a task from the assets manager.
  123660. * @param task the task to remove
  123661. */
  123662. removeTask(task: AbstractAssetTask): void;
  123663. private _decreaseWaitingTasksCount;
  123664. private _runTask;
  123665. /**
  123666. * Reset the AssetsManager and remove all tasks
  123667. * @return the current instance of the AssetsManager
  123668. */
  123669. reset(): AssetsManager;
  123670. /**
  123671. * Start the loading process
  123672. * @return the current instance of the AssetsManager
  123673. */
  123674. load(): AssetsManager;
  123675. /**
  123676. * Start the loading process as an async operation
  123677. * @return a promise returning the list of failed tasks
  123678. */
  123679. loadAsync(): Promise<void>;
  123680. }
  123681. }
  123682. declare module BABYLON {
  123683. /**
  123684. * Wrapper class for promise with external resolve and reject.
  123685. */
  123686. export class Deferred<T> {
  123687. /**
  123688. * The promise associated with this deferred object.
  123689. */
  123690. readonly promise: Promise<T>;
  123691. private _resolve;
  123692. private _reject;
  123693. /**
  123694. * The resolve method of the promise associated with this deferred object.
  123695. */
  123696. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  123697. /**
  123698. * The reject method of the promise associated with this deferred object.
  123699. */
  123700. readonly reject: (reason?: any) => void;
  123701. /**
  123702. * Constructor for this deferred object.
  123703. */
  123704. constructor();
  123705. }
  123706. }
  123707. declare module BABYLON {
  123708. /**
  123709. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  123710. */
  123711. export class MeshExploder {
  123712. private _centerMesh;
  123713. private _meshes;
  123714. private _meshesOrigins;
  123715. private _toCenterVectors;
  123716. private _scaledDirection;
  123717. private _newPosition;
  123718. private _centerPosition;
  123719. /**
  123720. * Explodes meshes from a center mesh.
  123721. * @param meshes The meshes to explode.
  123722. * @param centerMesh The mesh to be center of explosion.
  123723. */
  123724. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  123725. private _setCenterMesh;
  123726. /**
  123727. * Get class name
  123728. * @returns "MeshExploder"
  123729. */
  123730. getClassName(): string;
  123731. /**
  123732. * "Exploded meshes"
  123733. * @returns Array of meshes with the centerMesh at index 0.
  123734. */
  123735. getMeshes(): Array<Mesh>;
  123736. /**
  123737. * Explodes meshes giving a specific direction
  123738. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  123739. */
  123740. explode(direction?: number): void;
  123741. }
  123742. }
  123743. declare module BABYLON {
  123744. /**
  123745. * Class used to help managing file picking and drag'n'drop
  123746. */
  123747. export class FilesInput {
  123748. /**
  123749. * List of files ready to be loaded
  123750. */
  123751. static readonly FilesToLoad: {
  123752. [key: string]: File;
  123753. };
  123754. /**
  123755. * Callback called when a file is processed
  123756. */
  123757. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  123758. private _engine;
  123759. private _currentScene;
  123760. private _sceneLoadedCallback;
  123761. private _progressCallback;
  123762. private _additionalRenderLoopLogicCallback;
  123763. private _textureLoadingCallback;
  123764. private _startingProcessingFilesCallback;
  123765. private _onReloadCallback;
  123766. private _errorCallback;
  123767. private _elementToMonitor;
  123768. private _sceneFileToLoad;
  123769. private _filesToLoad;
  123770. /**
  123771. * Creates a new FilesInput
  123772. * @param engine defines the rendering engine
  123773. * @param scene defines the hosting scene
  123774. * @param sceneLoadedCallback callback called when scene is loaded
  123775. * @param progressCallback callback called to track progress
  123776. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  123777. * @param textureLoadingCallback callback called when a texture is loading
  123778. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  123779. * @param onReloadCallback callback called when a reload is requested
  123780. * @param errorCallback callback call if an error occurs
  123781. */
  123782. 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);
  123783. private _dragEnterHandler;
  123784. private _dragOverHandler;
  123785. private _dropHandler;
  123786. /**
  123787. * Calls this function to listen to drag'n'drop events on a specific DOM element
  123788. * @param elementToMonitor defines the DOM element to track
  123789. */
  123790. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  123791. /**
  123792. * Release all associated resources
  123793. */
  123794. dispose(): void;
  123795. private renderFunction;
  123796. private drag;
  123797. private drop;
  123798. private _traverseFolder;
  123799. private _processFiles;
  123800. /**
  123801. * Load files from a drop event
  123802. * @param event defines the drop event to use as source
  123803. */
  123804. loadFiles(event: any): void;
  123805. private _processReload;
  123806. /**
  123807. * Reload the current scene from the loaded files
  123808. */
  123809. reload(): void;
  123810. }
  123811. }
  123812. declare module BABYLON {
  123813. /**
  123814. * Defines the root class used to create scene optimization to use with SceneOptimizer
  123815. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123816. */
  123817. export class SceneOptimization {
  123818. /**
  123819. * Defines the priority of this optimization (0 by default which means first in the list)
  123820. */
  123821. priority: number;
  123822. /**
  123823. * Gets a string describing the action executed by the current optimization
  123824. * @returns description string
  123825. */
  123826. getDescription(): string;
  123827. /**
  123828. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123829. * @param scene defines the current scene where to apply this optimization
  123830. * @param optimizer defines the current optimizer
  123831. * @returns true if everything that can be done was applied
  123832. */
  123833. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123834. /**
  123835. * Creates the SceneOptimization object
  123836. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  123837. * @param desc defines the description associated with the optimization
  123838. */
  123839. constructor(
  123840. /**
  123841. * Defines the priority of this optimization (0 by default which means first in the list)
  123842. */
  123843. priority?: number);
  123844. }
  123845. /**
  123846. * Defines an optimization used to reduce the size of render target textures
  123847. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123848. */
  123849. export class TextureOptimization extends SceneOptimization {
  123850. /**
  123851. * Defines the priority of this optimization (0 by default which means first in the list)
  123852. */
  123853. priority: number;
  123854. /**
  123855. * 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
  123856. */
  123857. maximumSize: number;
  123858. /**
  123859. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  123860. */
  123861. step: number;
  123862. /**
  123863. * Gets a string describing the action executed by the current optimization
  123864. * @returns description string
  123865. */
  123866. getDescription(): string;
  123867. /**
  123868. * Creates the TextureOptimization object
  123869. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  123870. * @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
  123871. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  123872. */
  123873. constructor(
  123874. /**
  123875. * Defines the priority of this optimization (0 by default which means first in the list)
  123876. */
  123877. priority?: number,
  123878. /**
  123879. * 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
  123880. */
  123881. maximumSize?: number,
  123882. /**
  123883. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  123884. */
  123885. step?: number);
  123886. /**
  123887. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123888. * @param scene defines the current scene where to apply this optimization
  123889. * @param optimizer defines the current optimizer
  123890. * @returns true if everything that can be done was applied
  123891. */
  123892. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123893. }
  123894. /**
  123895. * Defines an optimization used to increase or decrease the rendering resolution
  123896. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123897. */
  123898. export class HardwareScalingOptimization extends SceneOptimization {
  123899. /**
  123900. * Defines the priority of this optimization (0 by default which means first in the list)
  123901. */
  123902. priority: number;
  123903. /**
  123904. * Defines the maximum scale to use (2 by default)
  123905. */
  123906. maximumScale: number;
  123907. /**
  123908. * Defines the step to use between two passes (0.5 by default)
  123909. */
  123910. step: number;
  123911. private _currentScale;
  123912. private _directionOffset;
  123913. /**
  123914. * Gets a string describing the action executed by the current optimization
  123915. * @return description string
  123916. */
  123917. getDescription(): string;
  123918. /**
  123919. * Creates the HardwareScalingOptimization object
  123920. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  123921. * @param maximumScale defines the maximum scale to use (2 by default)
  123922. * @param step defines the step to use between two passes (0.5 by default)
  123923. */
  123924. constructor(
  123925. /**
  123926. * Defines the priority of this optimization (0 by default which means first in the list)
  123927. */
  123928. priority?: number,
  123929. /**
  123930. * Defines the maximum scale to use (2 by default)
  123931. */
  123932. maximumScale?: number,
  123933. /**
  123934. * Defines the step to use between two passes (0.5 by default)
  123935. */
  123936. step?: number);
  123937. /**
  123938. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123939. * @param scene defines the current scene where to apply this optimization
  123940. * @param optimizer defines the current optimizer
  123941. * @returns true if everything that can be done was applied
  123942. */
  123943. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123944. }
  123945. /**
  123946. * Defines an optimization used to remove shadows
  123947. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123948. */
  123949. export class ShadowsOptimization extends SceneOptimization {
  123950. /**
  123951. * Gets a string describing the action executed by the current optimization
  123952. * @return description string
  123953. */
  123954. getDescription(): string;
  123955. /**
  123956. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123957. * @param scene defines the current scene where to apply this optimization
  123958. * @param optimizer defines the current optimizer
  123959. * @returns true if everything that can be done was applied
  123960. */
  123961. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123962. }
  123963. /**
  123964. * Defines an optimization used to turn post-processes off
  123965. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123966. */
  123967. export class PostProcessesOptimization extends SceneOptimization {
  123968. /**
  123969. * Gets a string describing the action executed by the current optimization
  123970. * @return description string
  123971. */
  123972. getDescription(): string;
  123973. /**
  123974. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123975. * @param scene defines the current scene where to apply this optimization
  123976. * @param optimizer defines the current optimizer
  123977. * @returns true if everything that can be done was applied
  123978. */
  123979. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123980. }
  123981. /**
  123982. * Defines an optimization used to turn lens flares off
  123983. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123984. */
  123985. export class LensFlaresOptimization extends SceneOptimization {
  123986. /**
  123987. * Gets a string describing the action executed by the current optimization
  123988. * @return description string
  123989. */
  123990. getDescription(): string;
  123991. /**
  123992. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123993. * @param scene defines the current scene where to apply this optimization
  123994. * @param optimizer defines the current optimizer
  123995. * @returns true if everything that can be done was applied
  123996. */
  123997. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123998. }
  123999. /**
  124000. * Defines an optimization based on user defined callback.
  124001. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124002. */
  124003. export class CustomOptimization extends SceneOptimization {
  124004. /**
  124005. * Callback called to apply the custom optimization.
  124006. */
  124007. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  124008. /**
  124009. * Callback called to get custom description
  124010. */
  124011. onGetDescription: () => string;
  124012. /**
  124013. * Gets a string describing the action executed by the current optimization
  124014. * @returns description string
  124015. */
  124016. getDescription(): string;
  124017. /**
  124018. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124019. * @param scene defines the current scene where to apply this optimization
  124020. * @param optimizer defines the current optimizer
  124021. * @returns true if everything that can be done was applied
  124022. */
  124023. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124024. }
  124025. /**
  124026. * Defines an optimization used to turn particles off
  124027. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124028. */
  124029. export class ParticlesOptimization extends SceneOptimization {
  124030. /**
  124031. * Gets a string describing the action executed by the current optimization
  124032. * @return description string
  124033. */
  124034. getDescription(): string;
  124035. /**
  124036. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124037. * @param scene defines the current scene where to apply this optimization
  124038. * @param optimizer defines the current optimizer
  124039. * @returns true if everything that can be done was applied
  124040. */
  124041. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124042. }
  124043. /**
  124044. * Defines an optimization used to turn render targets off
  124045. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124046. */
  124047. export class RenderTargetsOptimization extends SceneOptimization {
  124048. /**
  124049. * Gets a string describing the action executed by the current optimization
  124050. * @return description string
  124051. */
  124052. getDescription(): string;
  124053. /**
  124054. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124055. * @param scene defines the current scene where to apply this optimization
  124056. * @param optimizer defines the current optimizer
  124057. * @returns true if everything that can be done was applied
  124058. */
  124059. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  124060. }
  124061. /**
  124062. * Defines an optimization used to merge meshes with compatible materials
  124063. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124064. */
  124065. export class MergeMeshesOptimization extends SceneOptimization {
  124066. private static _UpdateSelectionTree;
  124067. /**
  124068. * Gets or sets a boolean which defines if optimization octree has to be updated
  124069. */
  124070. /**
  124071. * Gets or sets a boolean which defines if optimization octree has to be updated
  124072. */
  124073. static UpdateSelectionTree: boolean;
  124074. /**
  124075. * Gets a string describing the action executed by the current optimization
  124076. * @return description string
  124077. */
  124078. getDescription(): string;
  124079. private _canBeMerged;
  124080. /**
  124081. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  124082. * @param scene defines the current scene where to apply this optimization
  124083. * @param optimizer defines the current optimizer
  124084. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  124085. * @returns true if everything that can be done was applied
  124086. */
  124087. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  124088. }
  124089. /**
  124090. * Defines a list of options used by SceneOptimizer
  124091. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124092. */
  124093. export class SceneOptimizerOptions {
  124094. /**
  124095. * Defines the target frame rate to reach (60 by default)
  124096. */
  124097. targetFrameRate: number;
  124098. /**
  124099. * Defines the interval between two checkes (2000ms by default)
  124100. */
  124101. trackerDuration: number;
  124102. /**
  124103. * Gets the list of optimizations to apply
  124104. */
  124105. optimizations: SceneOptimization[];
  124106. /**
  124107. * Creates a new list of options used by SceneOptimizer
  124108. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  124109. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  124110. */
  124111. constructor(
  124112. /**
  124113. * Defines the target frame rate to reach (60 by default)
  124114. */
  124115. targetFrameRate?: number,
  124116. /**
  124117. * Defines the interval between two checkes (2000ms by default)
  124118. */
  124119. trackerDuration?: number);
  124120. /**
  124121. * Add a new optimization
  124122. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  124123. * @returns the current SceneOptimizerOptions
  124124. */
  124125. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  124126. /**
  124127. * Add a new custom optimization
  124128. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  124129. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  124130. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  124131. * @returns the current SceneOptimizerOptions
  124132. */
  124133. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  124134. /**
  124135. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  124136. * @param targetFrameRate defines the target frame rate (60 by default)
  124137. * @returns a SceneOptimizerOptions object
  124138. */
  124139. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  124140. /**
  124141. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  124142. * @param targetFrameRate defines the target frame rate (60 by default)
  124143. * @returns a SceneOptimizerOptions object
  124144. */
  124145. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  124146. /**
  124147. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  124148. * @param targetFrameRate defines the target frame rate (60 by default)
  124149. * @returns a SceneOptimizerOptions object
  124150. */
  124151. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  124152. }
  124153. /**
  124154. * Class used to run optimizations in order to reach a target frame rate
  124155. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  124156. */
  124157. export class SceneOptimizer implements IDisposable {
  124158. private _isRunning;
  124159. private _options;
  124160. private _scene;
  124161. private _currentPriorityLevel;
  124162. private _targetFrameRate;
  124163. private _trackerDuration;
  124164. private _currentFrameRate;
  124165. private _sceneDisposeObserver;
  124166. private _improvementMode;
  124167. /**
  124168. * Defines an observable called when the optimizer reaches the target frame rate
  124169. */
  124170. onSuccessObservable: Observable<SceneOptimizer>;
  124171. /**
  124172. * Defines an observable called when the optimizer enables an optimization
  124173. */
  124174. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  124175. /**
  124176. * Defines an observable called when the optimizer is not able to reach the target frame rate
  124177. */
  124178. onFailureObservable: Observable<SceneOptimizer>;
  124179. /**
  124180. * Gets a boolean indicating if the optimizer is in improvement mode
  124181. */
  124182. readonly isInImprovementMode: boolean;
  124183. /**
  124184. * Gets the current priority level (0 at start)
  124185. */
  124186. readonly currentPriorityLevel: number;
  124187. /**
  124188. * Gets the current frame rate checked by the SceneOptimizer
  124189. */
  124190. readonly currentFrameRate: number;
  124191. /**
  124192. * Gets or sets the current target frame rate (60 by default)
  124193. */
  124194. /**
  124195. * Gets or sets the current target frame rate (60 by default)
  124196. */
  124197. targetFrameRate: number;
  124198. /**
  124199. * Gets or sets the current interval between two checks (every 2000ms by default)
  124200. */
  124201. /**
  124202. * Gets or sets the current interval between two checks (every 2000ms by default)
  124203. */
  124204. trackerDuration: number;
  124205. /**
  124206. * Gets the list of active optimizations
  124207. */
  124208. readonly optimizations: SceneOptimization[];
  124209. /**
  124210. * Creates a new SceneOptimizer
  124211. * @param scene defines the scene to work on
  124212. * @param options defines the options to use with the SceneOptimizer
  124213. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  124214. * @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)
  124215. */
  124216. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  124217. /**
  124218. * Stops the current optimizer
  124219. */
  124220. stop(): void;
  124221. /**
  124222. * Reset the optimizer to initial step (current priority level = 0)
  124223. */
  124224. reset(): void;
  124225. /**
  124226. * Start the optimizer. By default it will try to reach a specific framerate
  124227. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  124228. */
  124229. start(): void;
  124230. private _checkCurrentState;
  124231. /**
  124232. * Release all resources
  124233. */
  124234. dispose(): void;
  124235. /**
  124236. * Helper function to create a SceneOptimizer with one single line of code
  124237. * @param scene defines the scene to work on
  124238. * @param options defines the options to use with the SceneOptimizer
  124239. * @param onSuccess defines a callback to call on success
  124240. * @param onFailure defines a callback to call on failure
  124241. * @returns the new SceneOptimizer object
  124242. */
  124243. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  124244. }
  124245. }
  124246. declare module BABYLON {
  124247. /**
  124248. * Class used to serialize a scene into a string
  124249. */
  124250. export class SceneSerializer {
  124251. /**
  124252. * Clear cache used by a previous serialization
  124253. */
  124254. static ClearCache(): void;
  124255. /**
  124256. * Serialize a scene into a JSON compatible object
  124257. * @param scene defines the scene to serialize
  124258. * @returns a JSON compatible object
  124259. */
  124260. static Serialize(scene: Scene): any;
  124261. /**
  124262. * Serialize a mesh into a JSON compatible object
  124263. * @param toSerialize defines the mesh to serialize
  124264. * @param withParents defines if parents must be serialized as well
  124265. * @param withChildren defines if children must be serialized as well
  124266. * @returns a JSON compatible object
  124267. */
  124268. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  124269. }
  124270. }
  124271. declare module BABYLON {
  124272. /**
  124273. * Class used to host texture specific utilities
  124274. */
  124275. export class TextureTools {
  124276. /**
  124277. * Uses the GPU to create a copy texture rescaled at a given size
  124278. * @param texture Texture to copy from
  124279. * @param width defines the desired width
  124280. * @param height defines the desired height
  124281. * @param useBilinearMode defines if bilinear mode has to be used
  124282. * @return the generated texture
  124283. */
  124284. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  124285. }
  124286. }
  124287. declare module BABYLON {
  124288. /**
  124289. * This represents the different options available for the video capture.
  124290. */
  124291. export interface VideoRecorderOptions {
  124292. /** Defines the mime type of the video. */
  124293. mimeType: string;
  124294. /** Defines the FPS the video should be recorded at. */
  124295. fps: number;
  124296. /** Defines the chunk size for the recording data. */
  124297. recordChunckSize: number;
  124298. /** The audio tracks to attach to the recording. */
  124299. audioTracks?: MediaStreamTrack[];
  124300. }
  124301. /**
  124302. * This can help with recording videos from BabylonJS.
  124303. * This is based on the available WebRTC functionalities of the browser.
  124304. *
  124305. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  124306. */
  124307. export class VideoRecorder {
  124308. private static readonly _defaultOptions;
  124309. /**
  124310. * Returns whether or not the VideoRecorder is available in your browser.
  124311. * @param engine Defines the Babylon Engine.
  124312. * @returns true if supported otherwise false.
  124313. */
  124314. static IsSupported(engine: Engine): boolean;
  124315. private readonly _options;
  124316. private _canvas;
  124317. private _mediaRecorder;
  124318. private _recordedChunks;
  124319. private _fileName;
  124320. private _resolve;
  124321. private _reject;
  124322. /**
  124323. * True when a recording is already in progress.
  124324. */
  124325. readonly isRecording: boolean;
  124326. /**
  124327. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  124328. * @param engine Defines the BabylonJS Engine you wish to record.
  124329. * @param options Defines options that can be used to customize the capture.
  124330. */
  124331. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  124332. /**
  124333. * Stops the current recording before the default capture timeout passed in the startRecording function.
  124334. */
  124335. stopRecording(): void;
  124336. /**
  124337. * Starts recording the canvas for a max duration specified in parameters.
  124338. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  124339. * If null no automatic download will start and you can rely on the promise to get the data back.
  124340. * @param maxDuration Defines the maximum recording time in seconds.
  124341. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  124342. * @return A promise callback at the end of the recording with the video data in Blob.
  124343. */
  124344. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  124345. /**
  124346. * Releases internal resources used during the recording.
  124347. */
  124348. dispose(): void;
  124349. private _handleDataAvailable;
  124350. private _handleError;
  124351. private _handleStop;
  124352. }
  124353. }
  124354. declare module BABYLON {
  124355. /**
  124356. * Class containing a set of static utilities functions for screenshots
  124357. */
  124358. export class ScreenshotTools {
  124359. /**
  124360. * Captures a screenshot of the current rendering
  124361. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  124362. * @param engine defines the rendering engine
  124363. * @param camera defines the source camera
  124364. * @param size This parameter can be set to a single number or to an object with the
  124365. * following (optional) properties: precision, width, height. If a single number is passed,
  124366. * it will be used for both width and height. If an object is passed, the screenshot size
  124367. * will be derived from the parameters. The precision property is a multiplier allowing
  124368. * rendering at a higher or lower resolution
  124369. * @param successCallback defines the callback receives a single parameter which contains the
  124370. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  124371. * src parameter of an <img> to display it
  124372. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  124373. * Check your browser for supported MIME types
  124374. */
  124375. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  124376. /**
  124377. * Captures a screenshot of the current rendering
  124378. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  124379. * @param engine defines the rendering engine
  124380. * @param camera defines the source camera
  124381. * @param size This parameter can be set to a single number or to an object with the
  124382. * following (optional) properties: precision, width, height. If a single number is passed,
  124383. * it will be used for both width and height. If an object is passed, the screenshot size
  124384. * will be derived from the parameters. The precision property is a multiplier allowing
  124385. * rendering at a higher or lower resolution
  124386. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  124387. * Check your browser for supported MIME types
  124388. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  124389. * to the src parameter of an <img> to display it
  124390. */
  124391. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  124392. /**
  124393. * Generates an image screenshot from the specified camera.
  124394. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  124395. * @param engine The engine to use for rendering
  124396. * @param camera The camera to use for rendering
  124397. * @param size This parameter can be set to a single number or to an object with the
  124398. * following (optional) properties: precision, width, height. If a single number is passed,
  124399. * it will be used for both width and height. If an object is passed, the screenshot size
  124400. * will be derived from the parameters. The precision property is a multiplier allowing
  124401. * rendering at a higher or lower resolution
  124402. * @param successCallback The callback receives a single parameter which contains the
  124403. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  124404. * src parameter of an <img> to display it
  124405. * @param mimeType The MIME type of the screenshot image (default: image/png).
  124406. * Check your browser for supported MIME types
  124407. * @param samples Texture samples (default: 1)
  124408. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  124409. * @param fileName A name for for the downloaded file.
  124410. */
  124411. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  124412. /**
  124413. * Generates an image screenshot from the specified camera.
  124414. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  124415. * @param engine The engine to use for rendering
  124416. * @param camera The camera to use for rendering
  124417. * @param size This parameter can be set to a single number or to an object with the
  124418. * following (optional) properties: precision, width, height. If a single number is passed,
  124419. * it will be used for both width and height. If an object is passed, the screenshot size
  124420. * will be derived from the parameters. The precision property is a multiplier allowing
  124421. * rendering at a higher or lower resolution
  124422. * @param mimeType The MIME type of the screenshot image (default: image/png).
  124423. * Check your browser for supported MIME types
  124424. * @param samples Texture samples (default: 1)
  124425. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  124426. * @param fileName A name for for the downloaded file.
  124427. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  124428. * to the src parameter of an <img> to display it
  124429. */
  124430. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  124431. }
  124432. }
  124433. declare module BABYLON {
  124434. /**
  124435. * A cursor which tracks a point on a path
  124436. */
  124437. export class PathCursor {
  124438. private path;
  124439. /**
  124440. * Stores path cursor callbacks for when an onchange event is triggered
  124441. */
  124442. private _onchange;
  124443. /**
  124444. * The value of the path cursor
  124445. */
  124446. value: number;
  124447. /**
  124448. * The animation array of the path cursor
  124449. */
  124450. animations: Animation[];
  124451. /**
  124452. * Initializes the path cursor
  124453. * @param path The path to track
  124454. */
  124455. constructor(path: Path2);
  124456. /**
  124457. * Gets the cursor point on the path
  124458. * @returns A point on the path cursor at the cursor location
  124459. */
  124460. getPoint(): Vector3;
  124461. /**
  124462. * Moves the cursor ahead by the step amount
  124463. * @param step The amount to move the cursor forward
  124464. * @returns This path cursor
  124465. */
  124466. moveAhead(step?: number): PathCursor;
  124467. /**
  124468. * Moves the cursor behind by the step amount
  124469. * @param step The amount to move the cursor back
  124470. * @returns This path cursor
  124471. */
  124472. moveBack(step?: number): PathCursor;
  124473. /**
  124474. * Moves the cursor by the step amount
  124475. * If the step amount is greater than one, an exception is thrown
  124476. * @param step The amount to move the cursor
  124477. * @returns This path cursor
  124478. */
  124479. move(step: number): PathCursor;
  124480. /**
  124481. * Ensures that the value is limited between zero and one
  124482. * @returns This path cursor
  124483. */
  124484. private ensureLimits;
  124485. /**
  124486. * Runs onchange callbacks on change (used by the animation engine)
  124487. * @returns This path cursor
  124488. */
  124489. private raiseOnChange;
  124490. /**
  124491. * Executes a function on change
  124492. * @param f A path cursor onchange callback
  124493. * @returns This path cursor
  124494. */
  124495. onchange(f: (cursor: PathCursor) => void): PathCursor;
  124496. }
  124497. }
  124498. declare module BABYLON {
  124499. /** @hidden */
  124500. export var blurPixelShader: {
  124501. name: string;
  124502. shader: string;
  124503. };
  124504. }
  124505. declare module BABYLON {
  124506. /** @hidden */
  124507. export var pointCloudVertexDeclaration: {
  124508. name: string;
  124509. shader: string;
  124510. };
  124511. }
  124512. // Mixins
  124513. interface Window {
  124514. mozIndexedDB: IDBFactory;
  124515. webkitIndexedDB: IDBFactory;
  124516. msIndexedDB: IDBFactory;
  124517. webkitURL: typeof URL;
  124518. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  124519. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  124520. WebGLRenderingContext: WebGLRenderingContext;
  124521. MSGesture: MSGesture;
  124522. CANNON: any;
  124523. AudioContext: AudioContext;
  124524. webkitAudioContext: AudioContext;
  124525. PointerEvent: any;
  124526. Math: Math;
  124527. Uint8Array: Uint8ArrayConstructor;
  124528. Float32Array: Float32ArrayConstructor;
  124529. mozURL: typeof URL;
  124530. msURL: typeof URL;
  124531. VRFrameData: any; // WebVR, from specs 1.1
  124532. DracoDecoderModule: any;
  124533. setImmediate(handler: (...args: any[]) => void): number;
  124534. }
  124535. interface HTMLCanvasElement {
  124536. requestPointerLock(): void;
  124537. msRequestPointerLock?(): void;
  124538. mozRequestPointerLock?(): void;
  124539. webkitRequestPointerLock?(): void;
  124540. /** Track wether a record is in progress */
  124541. isRecording: boolean;
  124542. /** Capture Stream method defined by some browsers */
  124543. captureStream(fps?: number): MediaStream;
  124544. }
  124545. interface CanvasRenderingContext2D {
  124546. msImageSmoothingEnabled: boolean;
  124547. }
  124548. interface MouseEvent {
  124549. mozMovementX: number;
  124550. mozMovementY: number;
  124551. webkitMovementX: number;
  124552. webkitMovementY: number;
  124553. msMovementX: number;
  124554. msMovementY: number;
  124555. }
  124556. interface Navigator {
  124557. mozGetVRDevices: (any: any) => any;
  124558. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  124559. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  124560. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  124561. webkitGetGamepads(): Gamepad[];
  124562. msGetGamepads(): Gamepad[];
  124563. webkitGamepads(): Gamepad[];
  124564. }
  124565. interface HTMLVideoElement {
  124566. mozSrcObject: any;
  124567. }
  124568. interface Math {
  124569. fround(x: number): number;
  124570. imul(a: number, b: number): number;
  124571. }
  124572. interface WebGLRenderingContext {
  124573. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  124574. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  124575. vertexAttribDivisor(index: number, divisor: number): void;
  124576. createVertexArray(): any;
  124577. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  124578. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  124579. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  124580. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  124581. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  124582. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  124583. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  124584. // Queries
  124585. createQuery(): WebGLQuery;
  124586. deleteQuery(query: WebGLQuery): void;
  124587. beginQuery(target: number, query: WebGLQuery): void;
  124588. endQuery(target: number): void;
  124589. getQueryParameter(query: WebGLQuery, pname: number): any;
  124590. getQuery(target: number, pname: number): any;
  124591. MAX_SAMPLES: number;
  124592. RGBA8: number;
  124593. READ_FRAMEBUFFER: number;
  124594. DRAW_FRAMEBUFFER: number;
  124595. UNIFORM_BUFFER: number;
  124596. HALF_FLOAT_OES: number;
  124597. RGBA16F: number;
  124598. RGBA32F: number;
  124599. R32F: number;
  124600. RG32F: number;
  124601. RGB32F: number;
  124602. R16F: number;
  124603. RG16F: number;
  124604. RGB16F: number;
  124605. RED: number;
  124606. RG: number;
  124607. R8: number;
  124608. RG8: number;
  124609. UNSIGNED_INT_24_8: number;
  124610. DEPTH24_STENCIL8: number;
  124611. /* Multiple Render Targets */
  124612. drawBuffers(buffers: number[]): void;
  124613. readBuffer(src: number): void;
  124614. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  124615. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  124616. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  124617. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  124618. // Occlusion Query
  124619. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  124620. ANY_SAMPLES_PASSED: number;
  124621. QUERY_RESULT_AVAILABLE: number;
  124622. QUERY_RESULT: number;
  124623. }
  124624. interface WebGLProgram {
  124625. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  124626. }
  124627. interface EXT_disjoint_timer_query {
  124628. QUERY_COUNTER_BITS_EXT: number;
  124629. TIME_ELAPSED_EXT: number;
  124630. TIMESTAMP_EXT: number;
  124631. GPU_DISJOINT_EXT: number;
  124632. QUERY_RESULT_EXT: number;
  124633. QUERY_RESULT_AVAILABLE_EXT: number;
  124634. queryCounterEXT(query: WebGLQuery, target: number): void;
  124635. createQueryEXT(): WebGLQuery;
  124636. beginQueryEXT(target: number, query: WebGLQuery): void;
  124637. endQueryEXT(target: number): void;
  124638. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  124639. deleteQueryEXT(query: WebGLQuery): void;
  124640. }
  124641. interface WebGLUniformLocation {
  124642. _currentState: any;
  124643. }
  124644. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  124645. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  124646. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  124647. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  124648. interface WebGLRenderingContext {
  124649. readonly RASTERIZER_DISCARD: number;
  124650. readonly DEPTH_COMPONENT24: number;
  124651. readonly TEXTURE_3D: number;
  124652. readonly TEXTURE_2D_ARRAY: number;
  124653. readonly TEXTURE_COMPARE_FUNC: number;
  124654. readonly TEXTURE_COMPARE_MODE: number;
  124655. readonly COMPARE_REF_TO_TEXTURE: number;
  124656. readonly TEXTURE_WRAP_R: number;
  124657. readonly HALF_FLOAT: number;
  124658. readonly RGB8: number;
  124659. readonly RED_INTEGER: number;
  124660. readonly RG_INTEGER: number;
  124661. readonly RGB_INTEGER: number;
  124662. readonly RGBA_INTEGER: number;
  124663. readonly R8_SNORM: number;
  124664. readonly RG8_SNORM: number;
  124665. readonly RGB8_SNORM: number;
  124666. readonly RGBA8_SNORM: number;
  124667. readonly R8I: number;
  124668. readonly RG8I: number;
  124669. readonly RGB8I: number;
  124670. readonly RGBA8I: number;
  124671. readonly R8UI: number;
  124672. readonly RG8UI: number;
  124673. readonly RGB8UI: number;
  124674. readonly RGBA8UI: number;
  124675. readonly R16I: number;
  124676. readonly RG16I: number;
  124677. readonly RGB16I: number;
  124678. readonly RGBA16I: number;
  124679. readonly R16UI: number;
  124680. readonly RG16UI: number;
  124681. readonly RGB16UI: number;
  124682. readonly RGBA16UI: number;
  124683. readonly R32I: number;
  124684. readonly RG32I: number;
  124685. readonly RGB32I: number;
  124686. readonly RGBA32I: number;
  124687. readonly R32UI: number;
  124688. readonly RG32UI: number;
  124689. readonly RGB32UI: number;
  124690. readonly RGBA32UI: number;
  124691. readonly RGB10_A2UI: number;
  124692. readonly R11F_G11F_B10F: number;
  124693. readonly RGB9_E5: number;
  124694. readonly RGB10_A2: number;
  124695. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  124696. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  124697. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  124698. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  124699. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  124700. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  124701. 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;
  124702. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  124703. readonly TRANSFORM_FEEDBACK: number;
  124704. readonly INTERLEAVED_ATTRIBS: number;
  124705. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  124706. createTransformFeedback(): WebGLTransformFeedback;
  124707. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  124708. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  124709. beginTransformFeedback(primitiveMode: number): void;
  124710. endTransformFeedback(): void;
  124711. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  124712. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  124713. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  124714. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  124715. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  124716. }
  124717. interface ImageBitmap {
  124718. readonly width: number;
  124719. readonly height: number;
  124720. close(): void;
  124721. }
  124722. interface WebGLQuery extends WebGLObject {
  124723. }
  124724. declare var WebGLQuery: {
  124725. prototype: WebGLQuery;
  124726. new(): WebGLQuery;
  124727. };
  124728. interface WebGLSampler extends WebGLObject {
  124729. }
  124730. declare var WebGLSampler: {
  124731. prototype: WebGLSampler;
  124732. new(): WebGLSampler;
  124733. };
  124734. interface WebGLSync extends WebGLObject {
  124735. }
  124736. declare var WebGLSync: {
  124737. prototype: WebGLSync;
  124738. new(): WebGLSync;
  124739. };
  124740. interface WebGLTransformFeedback extends WebGLObject {
  124741. }
  124742. declare var WebGLTransformFeedback: {
  124743. prototype: WebGLTransformFeedback;
  124744. new(): WebGLTransformFeedback;
  124745. };
  124746. interface WebGLVertexArrayObject extends WebGLObject {
  124747. }
  124748. declare var WebGLVertexArrayObject: {
  124749. prototype: WebGLVertexArrayObject;
  124750. new(): WebGLVertexArrayObject;
  124751. };
  124752. // Type definitions for WebVR API
  124753. // Project: https://w3c.github.io/webvr/
  124754. // Definitions by: six a <https://github.com/lostfictions>
  124755. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  124756. interface VRDisplay extends EventTarget {
  124757. /**
  124758. * Dictionary of capabilities describing the VRDisplay.
  124759. */
  124760. readonly capabilities: VRDisplayCapabilities;
  124761. /**
  124762. * z-depth defining the far plane of the eye view frustum
  124763. * enables mapping of values in the render target depth
  124764. * attachment to scene coordinates. Initially set to 10000.0.
  124765. */
  124766. depthFar: number;
  124767. /**
  124768. * z-depth defining the near plane of the eye view frustum
  124769. * enables mapping of values in the render target depth
  124770. * attachment to scene coordinates. Initially set to 0.01.
  124771. */
  124772. depthNear: number;
  124773. /**
  124774. * An identifier for this distinct VRDisplay. Used as an
  124775. * association point in the Gamepad API.
  124776. */
  124777. readonly displayId: number;
  124778. /**
  124779. * A display name, a user-readable name identifying it.
  124780. */
  124781. readonly displayName: string;
  124782. readonly isConnected: boolean;
  124783. readonly isPresenting: boolean;
  124784. /**
  124785. * If this VRDisplay supports room-scale experiences, the optional
  124786. * stage attribute contains details on the room-scale parameters.
  124787. */
  124788. readonly stageParameters: VRStageParameters | null;
  124789. /**
  124790. * Passing the value returned by `requestAnimationFrame` to
  124791. * `cancelAnimationFrame` will unregister the callback.
  124792. * @param handle Define the hanle of the request to cancel
  124793. */
  124794. cancelAnimationFrame(handle: number): void;
  124795. /**
  124796. * Stops presenting to the VRDisplay.
  124797. * @returns a promise to know when it stopped
  124798. */
  124799. exitPresent(): Promise<void>;
  124800. /**
  124801. * Return the current VREyeParameters for the given eye.
  124802. * @param whichEye Define the eye we want the parameter for
  124803. * @returns the eye parameters
  124804. */
  124805. getEyeParameters(whichEye: string): VREyeParameters;
  124806. /**
  124807. * Populates the passed VRFrameData with the information required to render
  124808. * the current frame.
  124809. * @param frameData Define the data structure to populate
  124810. * @returns true if ok otherwise false
  124811. */
  124812. getFrameData(frameData: VRFrameData): boolean;
  124813. /**
  124814. * Get the layers currently being presented.
  124815. * @returns the list of VR layers
  124816. */
  124817. getLayers(): VRLayer[];
  124818. /**
  124819. * Return a VRPose containing the future predicted pose of the VRDisplay
  124820. * when the current frame will be presented. The value returned will not
  124821. * change until JavaScript has returned control to the browser.
  124822. *
  124823. * The VRPose will contain the position, orientation, velocity,
  124824. * and acceleration of each of these properties.
  124825. * @returns the pose object
  124826. */
  124827. getPose(): VRPose;
  124828. /**
  124829. * Return the current instantaneous pose of the VRDisplay, with no
  124830. * prediction applied.
  124831. * @returns the current instantaneous pose
  124832. */
  124833. getImmediatePose(): VRPose;
  124834. /**
  124835. * The callback passed to `requestAnimationFrame` will be called
  124836. * any time a new frame should be rendered. When the VRDisplay is
  124837. * presenting the callback will be called at the native refresh
  124838. * rate of the HMD. When not presenting this function acts
  124839. * identically to how window.requestAnimationFrame acts. Content should
  124840. * make no assumptions of frame rate or vsync behavior as the HMD runs
  124841. * asynchronously from other displays and at differing refresh rates.
  124842. * @param callback Define the eaction to run next frame
  124843. * @returns the request handle it
  124844. */
  124845. requestAnimationFrame(callback: FrameRequestCallback): number;
  124846. /**
  124847. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  124848. * Repeat calls while already presenting will update the VRLayers being displayed.
  124849. * @param layers Define the list of layer to present
  124850. * @returns a promise to know when the request has been fulfilled
  124851. */
  124852. requestPresent(layers: VRLayer[]): Promise<void>;
  124853. /**
  124854. * Reset the pose for this display, treating its current position and
  124855. * orientation as the "origin/zero" values. VRPose.position,
  124856. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  124857. * updated when calling resetPose(). This should be called in only
  124858. * sitting-space experiences.
  124859. */
  124860. resetPose(): void;
  124861. /**
  124862. * The VRLayer provided to the VRDisplay will be captured and presented
  124863. * in the HMD. Calling this function has the same effect on the source
  124864. * canvas as any other operation that uses its source image, and canvases
  124865. * created without preserveDrawingBuffer set to true will be cleared.
  124866. * @param pose Define the pose to submit
  124867. */
  124868. submitFrame(pose?: VRPose): void;
  124869. }
  124870. declare var VRDisplay: {
  124871. prototype: VRDisplay;
  124872. new(): VRDisplay;
  124873. };
  124874. interface VRLayer {
  124875. leftBounds?: number[] | Float32Array | null;
  124876. rightBounds?: number[] | Float32Array | null;
  124877. source?: HTMLCanvasElement | null;
  124878. }
  124879. interface VRDisplayCapabilities {
  124880. readonly canPresent: boolean;
  124881. readonly hasExternalDisplay: boolean;
  124882. readonly hasOrientation: boolean;
  124883. readonly hasPosition: boolean;
  124884. readonly maxLayers: number;
  124885. }
  124886. interface VREyeParameters {
  124887. /** @deprecated */
  124888. readonly fieldOfView: VRFieldOfView;
  124889. readonly offset: Float32Array;
  124890. readonly renderHeight: number;
  124891. readonly renderWidth: number;
  124892. }
  124893. interface VRFieldOfView {
  124894. readonly downDegrees: number;
  124895. readonly leftDegrees: number;
  124896. readonly rightDegrees: number;
  124897. readonly upDegrees: number;
  124898. }
  124899. interface VRFrameData {
  124900. readonly leftProjectionMatrix: Float32Array;
  124901. readonly leftViewMatrix: Float32Array;
  124902. readonly pose: VRPose;
  124903. readonly rightProjectionMatrix: Float32Array;
  124904. readonly rightViewMatrix: Float32Array;
  124905. readonly timestamp: number;
  124906. }
  124907. interface VRPose {
  124908. readonly angularAcceleration: Float32Array | null;
  124909. readonly angularVelocity: Float32Array | null;
  124910. readonly linearAcceleration: Float32Array | null;
  124911. readonly linearVelocity: Float32Array | null;
  124912. readonly orientation: Float32Array | null;
  124913. readonly position: Float32Array | null;
  124914. readonly timestamp: number;
  124915. }
  124916. interface VRStageParameters {
  124917. sittingToStandingTransform?: Float32Array;
  124918. sizeX?: number;
  124919. sizeY?: number;
  124920. }
  124921. interface Navigator {
  124922. getVRDisplays(): Promise<VRDisplay[]>;
  124923. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  124924. }
  124925. interface Window {
  124926. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  124927. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  124928. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  124929. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  124930. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  124931. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  124932. }
  124933. interface Gamepad {
  124934. readonly displayId: number;
  124935. }
  124936. type XRSessionMode =
  124937. | "inline"
  124938. | "immersive-vr"
  124939. | "immersive-ar";
  124940. type XRReferenceSpaceType =
  124941. | "viewer"
  124942. | "local"
  124943. | "local-floor"
  124944. | "bounded-floor"
  124945. | "unbounded";
  124946. type XREnvironmentBlendMode =
  124947. | "opaque"
  124948. | "additive"
  124949. | "alpha-blend";
  124950. type XRVisibilityState =
  124951. | "visible"
  124952. | "visible-blurred"
  124953. | "hidden";
  124954. type XRHandedness =
  124955. | "none"
  124956. | "left"
  124957. | "right";
  124958. type XRTargetRayMode =
  124959. | "gaze"
  124960. | "tracked-pointer"
  124961. | "screen";
  124962. type XREye =
  124963. | "none"
  124964. | "left"
  124965. | "right";
  124966. interface XRSpace extends EventTarget {
  124967. }
  124968. interface XRRenderState {
  124969. depthNear?: number;
  124970. depthFar?: number;
  124971. inlineVerticalFieldOfView?: number;
  124972. baseLayer?: XRWebGLLayer;
  124973. }
  124974. interface XRInputSource {
  124975. handedness: XRHandedness;
  124976. targetRayMode: XRTargetRayMode;
  124977. targetRaySpace: XRSpace;
  124978. gripSpace: XRSpace | undefined;
  124979. gamepad: Gamepad | undefined;
  124980. profiles: Array<string>;
  124981. }
  124982. interface XRSession {
  124983. addEventListener: Function;
  124984. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  124985. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  124986. requestAnimationFrame: Function;
  124987. end(): Promise<void>;
  124988. renderState: XRRenderState;
  124989. inputSources: Array<XRInputSource>;
  124990. }
  124991. interface XRReferenceSpace extends XRSpace {
  124992. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  124993. onreset: any;
  124994. }
  124995. interface XRFrame {
  124996. session: XRSession;
  124997. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  124998. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  124999. }
  125000. interface XRViewerPose extends XRPose {
  125001. views: Array<XRView>;
  125002. }
  125003. interface XRPose {
  125004. transform: XRRigidTransform;
  125005. emulatedPosition: boolean;
  125006. }
  125007. declare var XRWebGLLayer: {
  125008. prototype: XRWebGLLayer;
  125009. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  125010. };
  125011. interface XRWebGLLayer {
  125012. framebuffer: WebGLFramebuffer;
  125013. framebufferWidth: number;
  125014. framebufferHeight: number;
  125015. getViewport: Function;
  125016. }
  125017. interface XRRigidTransform {
  125018. position: DOMPointReadOnly;
  125019. orientation: DOMPointReadOnly;
  125020. matrix: Float32Array;
  125021. inverse: XRRigidTransform;
  125022. }
  125023. interface XRView {
  125024. eye: XREye;
  125025. projectionMatrix: Float32Array;
  125026. transform: XRRigidTransform;
  125027. }
  125028. interface XRInputSourceChangeEvent {
  125029. session: XRSession;
  125030. removed: Array<XRInputSource>;
  125031. added: Array<XRInputSource>;
  125032. }